Polygon Crucher SDK - Documentation
Documentation
Loading...
Searching...
No Matches
Different kind of normals

Detailed Description

Difference between the 3 kinds of normal channels

Normals always need explanations, as there is 3 kind of normals in the SDK:

CPointNormalChannel => Auto generated normal channels on each point (allows normal breaks) => Ignored during optimization CFaceNormalChannel => Auto generated normal channels on each face => Ignored during optimization CSpecNormalChannel => User specified channel => Taken into account during optimization

The 2 first kind of normals are auto-generated, which means it can be autogenerated before optimization, but also after.

To generate normals automatically you may use:

CPointNormalChannel *C3DGeomObject::GetPointNormalChannel(); // It is automatically computed by the SDK using the smooth angle (C3DGeomObject::SetSmoothAngle). CPointNormalChannel contains normal vectors and normal faces.
CFaceNormalChannel *C3DGeomObject::GetFaceNormalChannel(); // It is automatically computed by the SDK. CFaceNormalChannel only contains normals (1 normal by geometric faces)[/code]
CFaceNormalChannel is the channel class dedicated to vertex colors.
Definition FaceNormalChannel.h:22
CPointNormalChannel is the channel class dedicated to vertex colors.
Definition PointNormalChannel.h:61

CSpecNormalChannel is the class through you can optimize some provided normal. This is important to balance if the provided normals have a real interest. If auto generated normals are sufficient, this is better to not provide normals. Normal optimization adds important constraint and reduces the optimization quality, leading to lower optimization ratio.

If normals are important, then you provide them and use CSpecNormalChannel.

// Add a normal channel to your C3DGeomObject *object;
channel = xNew(CSpecNormalChannel);
channelfaces = channel->GetNormalFaceList();
channelfaces->SetFacesFlags(FACE_IS_UNUSED, false);
unsigned int i, j;
for (i=0; i< normalFaceCount; i++)
{
if (myFaceIndexUse[i] == false)
{
channelface.SetFlag(FACE_IS_UNUSED, true);
continue;
}
channelface.SetSize(size2);
int *pts_index = channelface.GetData(size2);
for (j = 0; j < size2; j++)
}
C3DVectorList *channelpoints = channel->GetNormalVectorList();
// Copy normals info
for (i=0; i< normalPointCount; i++)
{
channelnormal = (*channelpoints)[i];
}
// Add channel
object->AddChannel(channel);
@ FACE_IS_UNUSED
This flag is to be used in a dependent channel, meaning that the face should be ignored and does not ...
Definition Face.h:44
The class defines an x, y, z 3D point which can use int, float or double.
Definition 3DPoint.h:27
C3DVectorList is an array of C3DVector. It is used in particular by CPointNormalChannel,...
Definition 3DVectorList.h:45
CNormalFace is a face which indexes refer to an C3DVector stored in a C3DVectorList.
Definition NormalFace.h:20
CNormalFaceList is a CFaceList that contains CNormalFace. It usually belongs to a by CPointNormalChan...
Definition NormalFaceList.h:21
CSpecNormalChannel is the channel class dedicated to user defined or specified normals.
Definition SpecNormalChannel.h:21

Normals and optimization tweaks

To optimize properly normals you must define the normal optimization threshold (radian)

bool SetNormalThreshold(double radianThreshold)
Set the UVW tolerance for all scene optimizer objects.

This threshold define an angle between normals above which optimization consider that there is a normal break. A normal break constraint optimizer which will try to optimize something else.

There is several level of protection for normal optimization. OPTIMIZE_KEEP_NORMALS is the lowest (the one I would use). OPTIMIZE_KEEP_NORMALS|OPTIMIZE_PROTECT_NORMALS is stronger and **OPTIMIZE_KEEP_NORMALS|OPTIMIZE_EXCLUDE_NORMALS **will freeze any points that has a normal break above specified threshold.

Modules

 Smooth angle and normals