Polygon Crucher SDK - Documentation
Documentation
Loading...
Searching...
No Matches
DependentChannels.h
Go to the documentation of this file.
1//! @file DependentChannels.h
2//! @brief CDependentChannels class definition which handles a CChannel array
3//!
4//////////////////////////////////////////////////////////////////////
5
6#if !defined(AFX_DEPENDENTCHANNELS_H__79EB93C3_8866_11D3_A029_8FE73A9B677B__INCLUDED_)
7#define AFX_DEPENDENTCHANNELS_H__79EB93C3_8866_11D3_A029_8FE73A9B677B__INCLUDED_
8
9#ifdef _MSC_VER
10#pragma once
11#endif // _MSC_VER
12
13#include "Channel.h"
14
15BEGIN_MOOTOOLS_NAMESPACE
16
17typedef CXUIntArray CChannelList;
18
19// As there can be several channels in an object with the same ChannelID,
20// this struct can be used to identify one and only one channel because
21// there are only one ChannelID of a given type...
22class DLL_3DFUNCTION CChannelInfo
23{
24public:
25 ChannelID id;
26 Channel3DType type;
27 unsigned int flags;
28
29 CChannelInfo(CChannel *channel = NULL);
31};
32
33template <> class CHashMethods<CChannelInfo>
34{
35public:
36 static inline unsigned int HashValue(const CChannelInfo& info)
37 {
38 return HashMixValue(info.id) + info.type;
39 }
40
41 static inline bool HashCompare(const CChannelInfo& info1, const CChannelInfo& info2)
42 {
43 if (info1.id != info2.id)
44 return false;
45 if (info1.type != info2.type)
46 return false;
47
48 return true;
49 }
50};
51
52//! @class CDependentChannels
53//! @brief This class contains an array of CChannel information which are associated to the object.
54//! @details Any geometrical object (OBJECT_GEOM) have a CDependentChannels associated to it, which can be retrieved by C3DGeomObject::GetChannels
55class DLL_3DFUNCTION CDependentChannels : protected CXArray<CChannel *, CChannel *>, public CInstanciatedObject
56{
57
58public:
60 virtual ~CDependentChannels(); // Use Delete instead, unless the CDependentChannels is created on the stack (take care that it is referenced once only in this case)
61 static CDependentChannels *Create(); // Allocates and creates an empty set of channel. Use CDependentChannels::Delete to delete it. Same as xNew(CDependentChannels).
62
63 using CXArray<CChannel *, CChannel *>::GetSize;
64 using CXArray::operator[];
65
66 // Channel informations
67 int GetSize() const;
68 int GetChannelsNumber(unsigned int type, bool onlyValid = true);
69 int GetChannels(unsigned int type, CChannelList& list, unsigned int excludedFlags = CHANNEL_IS_INVALID, unsigned int neededFlags = CHANNEL_NONE) const;
70 Channel3DType GetChannelType(int i);
71 int GetChannelIndex(const CChannel *channel) const; // return -1 if channel not find in the CDependentChannels
72
73 CChannel *GetChannelByIndex(int i, unsigned int type = CHANNEL_TYPE_UNDEFINED, bool onlyValid = true);
74 CChannel *GetChannelByID(ChannelID id, Channel3DType type = CHANNEL_TYPE_UNDEFINED); // Specify channel type to be sure the returned channel has the given type.
75 CChannel *GetChannelByIndex(int i, CFaceList *&channelfaces, CPointList *&channelpoints, Channel3DType type = CHANNEL_TYPE_UNDEFINED); // channelfaces / channelpoints set to NULL if no channel exists
76 CChannel *GetChannelByID(ChannelID id, CFaceList *&channelfaces, CPointList *&channelpoints, Channel3DType type); // channelfaces / channelpoints set to NULL if no channel exists
77
78 CUVWChannel *GetUVWChannelByIndex(int i, CUVWFaceList *&uvfaces, CUVWPointList *&uvpoints); // uvfaces / uvpoints set to NULL if no channel exists
79 CUVWChannel *GetUVWChannelByID(ChannelID id, CUVWFaceList *&uvfaces, CUVWPointList *&uvpoints); // uvfaces / uvpoints set to NULL if no channel exists
80
81 CVCChannel *GetVCChannelByIndex(int i, CVCFaceList *&vcfaces, CVCPointList *&vcpoints);
82 CVCChannel *GetVCChannelByID(ChannelID id, CVCFaceList *&vcfaces, CVCPointList *&vcpoints);
83
84 int GetChannelIndex(ChannelID id, Channel3DType type, bool onlyValid = true);
85 ChannelID ModifyChannelIDByID(ChannelID newid, ChannelID currentID, Channel3DType type);
86 ChannelID ModifyChannelIDByIndex(ChannelID newid, int index, Channel3DType type = CHANNEL_TYPE_UNDEFINED, bool onlyValid = true); // Reassign a new channel ID to #index or #index of #type. Return the assign channelID which can be different if provided newid exists.
87
88 CSpecNormalChannel *GetSpecNormalChannel();
90
91 CPointNormalChannel *GetPointNormalChannel(bool createChannelIfNeeded = true);
93 CFaceNormalChannel* GetFaceNormalChannel(bool createChannelIfNeeded = true);
94 CFaceNormalChannel *GetFaceNormalChannel(C3DVectorList*& channelnormals, bool createChannelIfNeeded = true);
95
96 // Channel update
97 bool InvalidateChannels(unsigned int type = ALL_CHANNELS_TYPE); // Invalidate cache for channels that have cache data (ie autogenrated or CSpecNormalChannels), if type specified, only invalidate for the given type
98 int CleanChannels(const CGeomInfo *info, CXUIntArray *newfaceindex, CXUIntArray *newpointindex);
99 bool SwapCoordinates(unsigned int swapMode, unsigned int channelType = ALL_CHANNELS_TYPE);
100 bool MatrixTransform(const C4x4Matrix& matrix, unsigned int channelType = ALL_CHANNELS_TYPE, POINT_PROPERTIES property = POINT_NONE, bool set = true);
101 bool Weld(const CGeomInfo *info, double tolerance, unsigned int channelType = ALL_CHANNELS_TYPE);
102 bool InitBreakFlags(const CGeomInfo *info, unsigned int channelType = ALL_CHANNELS_TYPE, float uvTolerance = 0.0f, int vcTolerance = 0, float normalThreshold = DEG2RADF(DEFAULT_NORMAL_THRESHOLD_VALUE));
103 void FreeExtra();
104
105 // Create, Add, remove channels
106 ChannelID AddChannel(CChannel *channel, ChannelID id = CHANNELID_UNDEFINED); // Add the channel and check the provided id. If duplicated or CHANNELID_UNDEFINED, then a new id is assigned to the channel and returned.
107 CChannel* AddChannel(Channel3DType channelType, ChannelID id = CHANNELID_UNDEFINED); // Create a channel of the given type and add it to the channels. If id is let to CHANNELID_UNDEFINED, then an id is automatically assigned
108 int CopyChannels(const CDependentChannels& srcChannels, unsigned int channelType, unsigned int channelCopyFlags, CXUIntArray *channelIndexMatches = NULL);
109 bool RemoveChannelsByFlag(CHANNEL_PROPERTIES channelFlags, Channel3DType type = CHANNEL_TYPE_UNDEFINED, bool flagIsSet = true, bool deleteChannel = true);
110 bool RemoveChannelByIndex(int i, Channel3DType type = CHANNEL_TYPE_UNDEFINED, bool deleteChannel = true);
111 bool RemoveChannelsByType(unsigned int channelType, bool deleteChannel = true);
112 bool RemoveChannelByID(ChannelID id, Channel3DType type, bool deleteChannel = true);
113 bool RemoveChannel(CChannel *channel, bool deleteChannel = true);
114 void RemoveAll();
115
116 void SetFlag(unsigned int type, CHANNEL_PROPERTIES flag, bool set);
117
118 static ChannelID GetFirstChannelIDByType(Channel3DType channelType); // Return the first default channel ID value, depending on channelType
119
120 // operators
121 CDependentChannels& operator=(CDependentChannels& channel);
122
123 virtual void Serialize(CXArchive& ar);
124
125#ifdef _DEBUG
126 virtual void Dump(unsigned int flags) const;
127 unsigned int MemoryStats() const;
128#endif
129
130 protected:
132
133 void RemoveAt(int index, bool deleteChannel);
134 ChannelID GetNextChannelID(ChannelID baseid, Channel3DType channelType); // Return the next channel id available looking the existing channel, in order to avoid channel conflict.
135};
136
137END_MOOTOOLS_NAMESPACE
138
139#endif // !defined(AFX_DEPENDENTCHANNELS_H__79EB93C3_8866_11D3_A029_8FE73A9B677B__INCLUDED_)
CChannel class definition which is the base class for object channels (UV, normals....
Channel3DType
The channel type which can be used to cast to the appropriate class Bitwise operations can be use to ...
Definition Channel.h:27
POINT_PROPERTIES
Point flags used by any classes that inherit from CPt (C3DPoint, C3DVector...)
Definition Point.h:19
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 DependentChannels.h:23
This class contains an array of CChannel information which are associated to the object.
Definition DependentChannels.h:56
CFaceList is the common base class for a lot of different classes (C3DFaceList, CUVWFaceList....
Definition FaceList.h:179
CFaceNormalChannel is the channel class dedicated to vertex colors.
Definition FaceNormalChannel.h:22
CGeomInfo is an helper class oftenly required by different methods.
Definition GeomInfo.h:71
Definition Hash.h:146
Definition InstanciatedObject.h:16
CNormalFaceList is a CFaceList that contains CNormalFace. It usually belongs to a by CPointNormalChan...
Definition NormalFaceList.h:21
CPointList is the base class for different classes (C3DPointList, CUVWPointList......
Definition PointList.h:50
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
CUVWChannel is the channel class dedicated to UVs.
Definition UVWChannel.h:21
CUVWFaceList is a CFaceList that contains CUVWFace. It usually belongs to a CUVWChannel.
Definition UVWFaceList.h:21
CUVWPointList is an array of CUVWPoint. It usually belongs to a CUVWChannel.
Definition UVWPointList.h:46
CVCChannel is the channel class dedicated to vertex colors.
Definition VCChannel.h:21
CVCFaceList is a CFaceList that contains CVCFace. It usually belongs to a CVCChannel.
Definition VCFaceList.h:21
CVCPointList is an array of CVCPoint. It usually belongs to a CVCChannel.
Definition VCPointList.h:46
Definition XArchive.h:17
CXArray is an array of simple data information which does not requires to call a constructor / destru...
Definition XTemplate.h:34