Polygon Crucher SDK - Documentation
Documentation
Loading...
Searching...
No Matches
GeomInfo.h
Go to the documentation of this file.
1//! @file GeomInfo.h
2//! CGeomInfo class definition. An helper class to provide additional information to methods that needs it.
3//!
4//////////////////////////////////////////////////////////////////////
5
6#if !defined(AFX_GEOMINFO_H__6A7ECAE5_4687_11D3_A382_F9580C633921__INCLUDED_)
7#define AFX_GEOMINFO_H__6A7ECAE5_4687_11D3_A382_F9580C633921__INCLUDED_
8
9#ifdef _MSC_VER
10#pragma once
11#endif // _MSC_VER
12
13#include "Channel.h"
14#include "3DMaterial.h"
15
16BEGIN_MOOTOOLS_NAMESPACE
17
18class CFaceList;
19class CPointList;
20
21typedef enum _GeomInfoDeleteInfo
22{
23 GEOMINFO_DELETE_NONE = 0x00,
24 GEOMINFO_DELETE_SRC = 0x01,
25 GEOMINFO_DELETE_DST = 0x02,
27
28//! @class CGeomInfo
29//! @brief CGeomInfo is an helper class oftenly required by different methods.
30//! @details For example, CFaceList or CPointList are not linked together. Moreover, CFaceList knows nothing about its owner, which is often a C3DGeomObject.
31//! So CGeomInfo is a way to provide that additional information when it is needed.\n
32//! You can construct a CGeomInfo on the stack using the appropriate C3DGeomObject or C3DSceneNode.\n
33//! Most of the time this is the CGeomInfo main usage.
34//!
35//! But depending on the method called, CGeomInfo can also get the operation result.\n
36//! This is the case for C3DFaceList::Triangulate method which does not modify the provided face list, but generates a new list.\n
37//! The result can be retrieved using CGeomInfo::GetDst3DPointList.\n
38//! Depending on how is initialized to the CGeomInfo you can also get additional results.
39//!
40//! @code{.cpp}
41//! {
42//! CGeomInfo info(faces, points);
43//! faces->Triangulate(&info); // Only generates a triangulated face list
44//! C3DFaceList *trifaces = info.GetDst3DFaceList(false); // info is still a trifaces owner. trifaces will be deleted when info destroyed, unless trifaces->AddRef() is called, or info.GetDst3DFaceList(true) is called
45//! } // trifaces destroyed with CGeomInfo after this line
46//! @endcode
47//!
48//! This code shows how to generate a triangulated object from an object.
49//!
50//! @code{.cpp}
51//! CGeomInfo info(object);
52//! faces->Triangulate(&info); // triangulates anything that belong to the object (faces, channel faces...)
53//! C3DPointList *points = object->GetPointList(); // Points remain the same
54//! points->AddRef(); // points belong to object and will be shared with triobject created below. If reference not increased, the point list will be destroyed when calling object->Delete()
55//! C3DFaceList *trifaces = info.GetDst3DFaceList(true);
56//! CDependentChannels *trichannels = info.GetDstChannels(true);
57//! C3DGeomObject *triobject = xNewParams(C3DGeomObject, points, trifaces, trichannels); // Create the triangular object
58//! object->Delete(); // Don't need original object anymore.
59//! @endcode
60//!
61//! If a list is created by a method, it belongs to the CGeomInfo unless you retrieve it using on of the provided method with detach = true.\n
62//! Saying that, this simply means, that things are destroyed automatically if not required by the caller.
63//!
64//! @code{.cpp}
65//! {
66//! CGeomInfo info(object);
67//! faces->Triangulate(&info); // triangulates anything that belong to the object (faces, channel faces...)
68//! } // If you did nothing with triangulation, anything provided to CGeomInfo is keep safe and anything created by triangulation process is delete here.
69//! @endcode
70class DLL_3DFUNCTION CGeomInfo
71{
72 //! @enum GeomFlags
73 //! These flags can be used to inform if the provided list must be deleted by the CGeomInfo when using SetPointList, SetFaceList or SetChannels\n
74 //! Default constructors never delete provided information.
75 typedef enum GeomFlags
76 {
77 GEOMINFO_NONE = 0x00,
78 GEOMINFO_DELETE_SRC_POINTS = 0x01,
79 GEOMINFO_DELETE_DST_POINTS = 0x02,
80 GEOMINFO_DELETE_SRC_FACES = 0x04,
81 GEOMINFO_DELETE_DST_FACES = 0x08,
82 GEOMINFO_DELETE_SRC_CHANNELS = 0x10,
83 GEOMINFO_DELETE_DST_CHANNELS = 0x20,
84 } GeomFlags;
85
86protected:
87 unsigned int flags;
88 mutable C3DScene *scene;
89 mutable C3DSceneNode *node;
90 mutable C3DBaseObject *object;
91 mutable CPointList *points, *dstpoints;
92 mutable CFaceList *faces, *dstfaces;
93 mutable CDependentChannels *channels, *dstchannels;
94
95public:
96 CGeomInfo();
97 CGeomInfo(C3DSceneNode *node, C3DBaseObject *object = NULL); //!< If object = NULL, node->GetBaseObject is used. scene = object scene if any, or node scene otherwise (which are the same most of the time)
98 CGeomInfo(C3DBaseObject *object);
99 CGeomInfo(CFaceList *faces, CPointList *points); //!< Can be use with a generic CFaceList / CPointList and GetSrcFaceList / GetSrcPointList only
100 virtual ~CGeomInfo();
101
102 void Init(C3DSceneNode *node = NULL, C3DBaseObject *object = NULL);
103
104 void SetFaceList(CFaceList *faces, CFaceList *dstfaces = NULL, unsigned int deleteInfoGeomFlags = GEOMINFO_DELETE_NONE);
105 void SetPointList(CPointList *points, CPointList *dstpoints = NULL, unsigned int deleteInfoGeomFlags = GEOMINFO_DELETE_NONE);
106
107 CPointList *GetSrcPointList(bool detach = false) const; //!< Return the source point list, which has been set by the constructor. detach = true means that CGeomInfo does not own the list anymore.
108 CFaceList *GetSrcFaceList(bool detach = false) const; //!< Return the source face list, which has been set by the constructor. detach = true means that CGeomInfo does not own the list anymore.
109
110 C3DPointList *GetSrc3DPointList(bool detach = false) const; //!< Return the source 3D point list, which has been set by the constructor
111 C3DFaceList *GetSrc3DFaceList(bool detach = false) const;
112 C3DPointList *GetDst3DPointList(bool detach = false) const; //!< When using SetPointList with source and destination points
113 C3DFaceList *GetDst3DFaceList(bool detach = false) const; //!< When using SetFaceList with source and destination faces
114
115 void SetScene(C3DScene *scene);
116 C3DScene *GetScene() const { return scene; }
117
118 C3DBaseObject *GetBaseObject() const { return object; }
119 C3DGeomObject *GetGeomObject() const; //!< Return NULL if not a geomobject
120 C3DSceneNode* GetNode() const { return node; }
121
122 // Materials
123 ChannelID GetMaterialUVWChannelID(C3DScene* scene, MaterialID id, MapType type, bool front = true) const; //!< Get channel ID (if any, CHANNELID_UNDEFINED otherwise) for the provided material which belong to scene (useful if object or node does not belong to any scene, or if material belong to a different scene)
124 ChannelID GetMaterialUVWChannelID(MaterialID id, MapType type, bool front = true) const; //!< Get the channel ID (if any, CHANNELID_UNDEFINED otherwise) for the provided material which belong to object's scene (or node's scene) that was used to initialized the CGeomInfo
125
126 CDependentChannels *GetSrcChannels(bool detach = false) const;
127 CUVWChannel *GetSrcUVWChannelByIndex(unsigned int index, CUVWFaceList*& faces, CUVWPointList*& uvpoints) const; //!< Internally call CDependentChannels::GetUVWChannelByIndex. Return NULL if no UVW index exists in source channel.
128 CUVWChannel* GetSrcUVWChannelByID(ChannelID chnid, CUVWFaceList*& faces, CUVWPointList*& uvpoints) const; //!< Internally call CDependentChannels::GetUVWChannelByID. Return NULL if no UVW ID exists in source channel.
129 CVCChannel* GetSrcVCChannelByIndex(unsigned int index, CVCFaceList*& faces, CVCPointList*& uvpoints) const; //!< Internally call CDependentChannels::GetVCChannelByIndex. Return NULL if no VC index exists in source channel.
130 CVCChannel* GetSrcVCChannelByID(ChannelID chnid, CVCFaceList*& faces, CVCPointList*& points) const; //!< Internally call CDependentChannels::GetVCChannelByID. Return NULL if no VC ID exists in source channel.
131 CPointNormalChannel* GetSrcPointNormalChannel(CNormalFaceList*& faces, C3DVectorList*& points, bool createIfNeeded = false) const; //!< Return the point normal channel and optionally create it if it does not exists in source channel.
132 CFaceNormalChannel* GetSrcFaceNormalChannel(C3DVectorList*& points, bool createIfNeeded = false) const; //!< Return the face normal channel and optionally create it if it does not exists in source channel.
133 CSpecNormalChannel* GetSrcSpecNormalChannel(CNormalFaceList*& faces, C3DVectorList*& points) const; //!< Return the specified normals channels in source channel.
134 int GetChannelSize() const; //!< Return the number of channels in source channels.
135 int GetChannelNumber(Channel3DType type = ALL_CHANNELS_TYPE, bool onlyValid = true) const; //!< Return the number of channels of the given type in source channels (cf. CDependentChannels::GetChannelsNumber).
136
137 //!< CGeomInfo methods to simplify a source and destination channels access
138 void SetChannels(CDependentChannels* srcchannels, CDependentChannels* dstchannels = NULL, unsigned int deleteInfoGeomFlags = GEOMINFO_DELETE_NONE); //!< You may provide the source channels and corresponding destination channels. For example, in the triangulation case, C3DGeomObject::Triangulate will only process these channels.
139 CDependentChannels *GetDstChannels(bool detach = false) const;
140 void GetChannelFaceList(int i, CFaceList *&srcfaces, CFaceList *&dstfaces) const; //!< Get the #i source and destination face list
141 void GetChannelPointList(int i, CPointList *&srcpts, CPointList *&dstpts) const; //!< Get the #i source and destination point list
142};
143
144END_MOOTOOLS_NAMESPACE
145
146#endif // !defined(AFX_GEOMINFO_H__6A7ECAE5_4687_11D3_A382_F9580C633921__INCLUDED_)
The files handles materials definition.
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
MapType
This enum allows to know the kind of texture map.
Definition MaterialMap.h:26
This is the base class for any kind of object.
Definition 3DBaseObject.h:106
C3DFaceList class which implement a list of C3DFace. Each face contains indexes to 3D points stored i...
Definition 3DFaceList.h:249
This is the base class for any object containing geometry (curve, polygonal object,...
Definition 3DGeomObject.h:49
Definition 3DPointList.h:267
The class allows to get access to the scene graph, node hierarchy, material.
Definition 3DScene.h:306
A node matches one element that is part of the C3DScene graph. It references a C3DBaseObject and has ...
Definition 3DSceneNode.h:64
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
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
CSpecNormalChannel * GetSrcSpecNormalChannel(CNormalFaceList *&faces, C3DVectorList *&points) const
Return the specified normals channels in source channel.
ChannelID GetMaterialUVWChannelID(C3DScene *scene, MaterialID id, MapType type, bool front=true) const
Get channel ID (if any, CHANNELID_UNDEFINED otherwise) for the provided material which belong to scen...
CGeomInfo(C3DSceneNode *node, C3DBaseObject *object=NULL)
If object = NULL, node->GetBaseObject is used. scene = object scene if any, or node scene otherwise (...
int GetChannelSize() const
Return the number of channels in source channels.
int GetChannelNumber(Channel3DType type=ALL_CHANNELS_TYPE, bool onlyValid=true) const
Return the number of channels of the given type in source channels (cf. CDependentChannels::GetChanne...
CPointList * GetSrcPointList(bool detach=false) const
Return the source point list, which has been set by the constructor. detach = true means that CGeomIn...
C3DGeomObject * GetGeomObject() const
Return NULL if not a geomobject.
CGeomInfo(CFaceList *faces, CPointList *points)
Can be use with a generic CFaceList / CPointList and GetSrcFaceList / GetSrcPointList only.
CFaceList * GetSrcFaceList(bool detach=false) const
Return the source face list, which has been set by the constructor. detach = true means that CGeomInf...
CUVWChannel * GetSrcUVWChannelByIndex(unsigned int index, CUVWFaceList *&faces, CUVWPointList *&uvpoints) const
Internally call CDependentChannels::GetUVWChannelByIndex. Return NULL if no UVW index exists in sourc...
C3DPointList * GetDst3DPointList(bool detach=false) const
When using SetPointList with source and destination points.
CPointNormalChannel * GetSrcPointNormalChannel(CNormalFaceList *&faces, C3DVectorList *&points, bool createIfNeeded=false) const
Return the point normal channel and optionally create it if it does not exists in source channel.
C3DFaceList * GetDst3DFaceList(bool detach=false) const
When using SetFaceList with source and destination faces.
C3DPointList * GetSrc3DPointList(bool detach=false) const
Return the source 3D point list, which has been set by the constructor.
void SetChannels(CDependentChannels *srcchannels, CDependentChannels *dstchannels=NULL, unsigned int deleteInfoGeomFlags=GEOMINFO_DELETE_NONE)
You may provide the source channels and corresponding destination channels. For example,...
void GetChannelFaceList(int i, CFaceList *&srcfaces, CFaceList *&dstfaces) const
Get the #i source and destination face list.
void GetChannelPointList(int i, CPointList *&srcpts, CPointList *&dstpts) const
Get the #i source and destination point list.
CFaceNormalChannel * GetSrcFaceNormalChannel(C3DVectorList *&points, bool createIfNeeded=false) const
Return the face normal channel and optionally create it if it does not exists in source channel.
CUVWChannel * GetSrcUVWChannelByID(ChannelID chnid, CUVWFaceList *&faces, CUVWPointList *&uvpoints) const
Internally call CDependentChannels::GetUVWChannelByID. Return NULL if no UVW ID exists in source chan...
CVCChannel * GetSrcVCChannelByID(ChannelID chnid, CVCFaceList *&faces, CVCPointList *&points) const
Internally call CDependentChannels::GetVCChannelByID. Return NULL if no VC ID exists in source channe...
CVCChannel * GetSrcVCChannelByIndex(unsigned int index, CVCFaceList *&faces, CVCPointList *&uvpoints) const
Internally call CDependentChannels::GetVCChannelByIndex. Return NULL if no VC index exists in source ...
ChannelID GetMaterialUVWChannelID(MaterialID id, MapType type, bool front=true) const
Get the channel ID (if any, CHANNELID_UNDEFINED otherwise) for the provided material which belong to ...
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