Polygon Crucher SDK - Documentation
Documentation
Loading...
Searching...
No Matches
PointNormalChannel.h
1//! @file CPointNormalChannel.h
2//! @brief CCPointNormalChannel class for handling one or more normals on an object 3D point
3//!
4//////////////////////////////////////////////////////////////////////
5
6#if !defined(AFX_NORMALPOINTCHANNEL_H__79EB93C4_8866_11D3_A029_8FE73A9B677B__INCLUDED_)
7#define AFX_NORMALPOINTCHANNEL_H__79EB93C4_8866_11D3_A029_8FE73A9B677B__INCLUDED_
8
9#ifdef _MSC_VER
10#pragma once
11#endif // _MSC_VER
12
13#include "Channel.h"
14#include "3DVector.h"
15
16BEGIN_MOOTOOLS_NAMESPACE
17
18class CGeomInfo;
20typedef void (*normalCallback)(CFaceNormalContributionInfo& info, C3DVector& normal);
21
22class DLL_3DFUNCTION CFaceNormalContributionInfo
23{
24protected:
25 const CGeomInfo *geominfo;
26 C3DFaceList *faces;
27 C3DPointList *points;
29 C3DVectorList *unnormalizednormals;
30
31 void InitUnormalizedNormal(NormalSmoothMode mode);
32 normalCallback InitNormalCallback(NormalSmoothMode mode);
33
34 static void NormalAreaWeight(CFaceNormalContributionInfo& info, C3DVector& normal);
35 static void NormalEdgeWeight(CFaceNormalContributionInfo& info, C3DVector& normal);
36 static void NormalAngleWeight(CFaceNormalContributionInfo& info, C3DVector& normal);
37 static void NormalUnweight(CFaceNormalContributionInfo& info, C3DVector& normal);
38
39public:
40 // Initialize before calling GenerateNormal
41 int pointnbr, facenbr;
42 C3DFace *curface;
43 const C3DVector *curfacenormalizednormal;
44 normalCallback callback;
45
46 // Temporary value
47 int offset; // The offset value should be filled or set to -1 when the callback is called. It contains the index of the point number in the face list (get by IsFacePoint)
48 C3DVector tmpnormal, v1, v2;
49 double length;
50
53};
54
55normalCallback InitNormalCallback(NormalSmoothMode mode);
56
57//! @class CPointNormalChannel
58//! @brief CPointNormalChannel is the channel class dedicated to vertex colors.
59//! @details CPointNormalChannel belongs to CDependentChannels and is referenced by the POINT_NORMAL_CHANNEL identifier.
60class DLL_3DFUNCTION CPointNormalChannel : public CChannel
61{
62 DECLARE_SERIAL_XOBJECT(CPointNormalChannel);
63
64public:
65 typedef enum _NormalType
66 {
67 NORMAL_UNDEFINED = 0x00,
68 COMPUTED_NORMAL = 0x01, // Indicate that the normal is generated by computation (used with SPECIFIED_NORMAL or SMOOTH_NORMAL)
69 USER_NORMAL = 0x02, // The normal is user defined
70 SPECIFIED_NORMAL = 0x04, // The normal is computed using the face normal that share the normal index
71 SMOOTH_NORMAL = 0x08, // The normal is computed using all the face that share the normal
72 } NormalType;
73
74public:
75 CPointNormalChannel(ChannelID id = CHANNELID_UNDEFINED); // If id = CHANNELID_UNDEFINED, the id is automatically assigned when adding the channel to object channels. If id != CHANNELID_UNDEFINED, the id might be modified if it already exists in object channels
76
77 C3DVectorList *GetNormalVectorList();
78 CNormalFaceList *GetNormalFaceList();
79
80 bool InitNormals(const CGeomInfo *info, float angle); // Return false if normal does not need to be recomputed or can't be computed
81
82 void PrepareSmoothing(const CGeomInfo *, CSpecNormalChannel *specNormalChannel);
83 C3DVector *GetSmoothNormalByCorner(int facenbr, int cornernbr, unsigned int *normalType = NULL);
84 C3DVector *GetSmoothNormalByIndex(int facenbr, int index, unsigned int *normalType = NULL);
85
86 bool CanBeRecomputed();
87
88 bool SwapCoordinates(unsigned int swapMode);
89 bool MatrixTransform(const C4x4Matrix& refmatrix, POINT_PROPERTIES property = POINT_NONE, bool set = TRUE, int index = 0, int count = -1);
90
91 // Channel update
93 virtual CChannel* Copy(unsigned int copyFlags) const;
94
95protected:
96
97 // Smoothing normal computation
98 float prevangle;
99 NormalSmoothMode prevmode;
100
101 CNormalFaceList *smoothspecfaces; // Can be null when calling GetSmoothNormal calls
102 C3DVectorList *smoothspecnormals; // Can be null when calling GetSmoothNormal calls
103 C3DFaceList *smoothfaces;
104
105 virtual ~CPointNormalChannel();
106};
107
108END_MOOTOOLS_NAMESPACE
109
110#endif // !defined(AFX_NORMALPOINTCHANNEL_H__79EB93C4_8866_11D3_A029_8FE73A9B677B__INCLUDED_)
NormalSmoothMode
Definition 3DType.h:401
@ NORMAL_GLOBAL_MODE
The object used the preferences smoothing mode.
Definition 3DType.h:402
CChannel class definition which is the base class for object channels (UV, normals....
POINT_PROPERTIES
Point flags used by any classes that inherit from CPt (C3DPoint, C3DVector...)
Definition Point.h:19
A 3D face is a list of indexes of C3DPointList object point list.
Definition 3DFace.h:43
C3DFaceList class which implement a list of C3DFace. Each face contains indexes to 3D points stored i...
Definition 3DFaceList.h:249
Definition 3DPointList.h:267
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
A CChannel is the base class for some additional information associated to an object.
Definition Channel.h:93
Definition PointNormalChannel.h:23
CGeomInfo is an helper class oftenly required by different methods.
Definition GeomInfo.h:71
CNormalFaceList is a CFaceList that contains CNormalFace. It usually belongs to a by CPointNormalChan...
Definition NormalFaceList.h:21
CPointNormalChannel is the channel class dedicated to vertex colors.
Definition PointNormalChannel.h:61
CSpecNormalChannel is the channel class dedicated to user defined or specified normals.
Definition SpecNormalChannel.h:21
CXArray is an array of simple data information which does not requires to call a constructor / destru...
Definition XTemplate.h:34