FCDocument/FCDGeometryPolygons.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2005-2006 Feeling Software Inc.
00003     MIT License: http://www.opensource.org/licenses/mit-license.php
00004 */
00005 /*
00006     Based on the FS Import classes:
00007     Copyright (C) 2005-2006 Feeling Software Inc
00008     Copyright (C) 2005-2006 Autodesk Media Entertainment
00009     MIT License: http://www.opensource.org/licenses/mit-license.php
00010 */
00011 
00017 #ifndef _FCD_GEOMETRY_POLYGONS_H_
00018 #define _FCD_GEOMETRY_POLYGONS_H_
00019 
00020 #include "FCDocument/FCDObject.h"
00021 #include "FUtils/FUDaeEnum.h"
00022 
00023 class FCDocument;
00024 class FRMeshPolygons;
00025 class FCDMaterial;
00026 class FCDGeometryMesh;
00027 class FCDGeometrySource;
00028 
00044 class FCDGeometryPolygonsInput
00045 {
00046 public:
00048     FCDGeometryPolygonsInput();
00049 
00051     FUDaeGeometryInput::Semantic semantic; 
00052 
00055     uint32 idx; 
00056 
00060     bool ownsIdx;
00061 
00064     UInt32List indices;
00065 
00068     FCDGeometrySource* source;
00069 
00073     int32 set;
00074 };
00075 
00077 typedef vector<FCDGeometryPolygonsInput*> FCDGeometryPolygonsInputList;
00078 
00089 class FCOLLADA_EXPORT FCDGeometryPolygons : public FCDObject
00090 {
00091 private:
00092     DeclareObjectType;
00093     FCDGeometryPolygonsInputList inputs;
00094     FCDGeometryPolygonsInputList idxOwners;
00095     UInt32List faceVertexCounts;
00096     FCDGeometryMesh* parent;
00097     size_t faceVertexCount;
00098     UInt32List holeFaces;
00099 
00100     // Buffered statistics
00101     size_t faceOffset;
00102     size_t faceVertexOffset;
00103     size_t holeOffset;
00104 
00105     // Material for this set of polygons
00106     fstring materialSemantic;
00107 
00108 public:
00113     FCDGeometryPolygons(FCDocument* document, FCDGeometryMesh* parent);
00114 
00117     virtual ~FCDGeometryPolygons();
00118 
00121     inline FCDGeometryMesh* GetParent() { return parent; }
00122     inline const FCDGeometryMesh* GetParent() const { return parent; } 
00133     inline const UInt32List& GetFaceVertexCounts() const { return faceVertexCounts; }
00134 
00137     inline size_t GetHoleCount() const { return holeFaces.size(); }
00138 
00141     inline size_t GetFaceCount() const { return faceVertexCounts.size() - GetHoleCount(); }
00142 
00146     inline size_t GetFaceOffset() const { return faceOffset; }
00147 
00152     inline size_t GetFaceVertexCount() const { return faceVertexCount; }
00153 
00158     size_t GetFaceVertexCount(size_t index) const;
00159 
00164     inline size_t GetFaceVertexOffset() const { return faceVertexOffset; }
00165 
00168     inline size_t GetHoleOffset() const { return holeOffset; }
00169 
00175     size_t GetFaceVertexOffset(size_t index) const;
00176 
00180     inline void SetFaceOffset(size_t offset) { faceOffset = offset; }
00181 
00185     inline void SetFaceVertexOffset(size_t offset) { faceVertexOffset = offset; }
00186 
00190     inline void SetHoleOffset(size_t offset) { holeOffset = offset; }
00191 
00197     void AddFace(uint32 degree);
00198 
00202     void RemoveFace(size_t index);
00203 
00207     inline FCDGeometryPolygonsInputList& GetInputs() { return inputs; }
00208     inline const FCDGeometryPolygonsInputList& GetInputs() const { return inputs; } 
00212     inline size_t GetInputCount() const { return inputs.size(); }
00213 
00218     inline FCDGeometryPolygonsInput* GetInput(size_t index) { FUAssert(index < GetInputCount(), return NULL); return inputs.at(index); }
00219     inline const FCDGeometryPolygonsInput* GetInput(size_t index) const { FUAssert(index < GetInputCount(), return NULL); return inputs.at(index); } 
00228     FCDGeometryPolygonsInput* AddInput(FCDGeometrySource* source, uint32 offset);
00229 
00234     void ReleaseInput(FCDGeometryPolygonsInput* input);
00235 
00241     inline const UInt32List& GetHoleFaces() const { return holeFaces; }
00242 
00250     size_t GetHoleCountBefore(size_t index) const;
00251 
00255     size_t GetHoleCount(size_t index) const;
00256 
00261     FCDGeometryPolygonsInput* FindInput(FUDaeGeometryInput::Semantic semantic);
00262     const FCDGeometryPolygonsInput* FindInput(FUDaeGeometryInput::Semantic semantic) const; 
00268     FCDGeometryPolygonsInput* FindInput(FCDGeometrySource* source);
00269     const FCDGeometryPolygonsInput* FindInput(const FCDGeometrySource* source) const; 
00275     FCDGeometryPolygonsInput* FindInput(const string& sourceId);
00276 
00281     void FindInputs(FUDaeGeometryInput::Semantic semantic, FCDGeometryPolygonsInputList& inputs);
00282 
00288     UInt32List* FindIndicesForIdx(uint32 idx);
00289     const UInt32List* FindIndicesForIdx(uint32 idx) const; 
00295     UInt32List* FindIndices(FCDGeometrySource* source);
00296     const UInt32List* FindIndices(const FCDGeometrySource* source) const; 
00302     UInt32List* FindIndices(FCDGeometryPolygonsInput* input);
00303     const UInt32List* FindIndices(const FCDGeometryPolygonsInput* input) const; 
00309     inline const fstring& GetMaterialSemantic() const { return materialSemantic; }
00310 
00315     inline void SetMaterialSemantic(const fchar* semantic) { materialSemantic = semantic; }
00316     inline void SetMaterialSemantic(const fstring& semantic) { materialSemantic = semantic; } 
00320     void Triangulate();
00321 
00323     void Recalculate();
00324 
00330     FUStatus LoadFromXML(xmlNode* polygonNode);
00331 
00336     xmlNode* WriteToXML(xmlNode* parentNode) const;
00337 
00343     FCDGeometryPolygons* Clone(FCDGeometryMesh* cloneParent);
00344 
00345 private:
00346     // Performs operations needed before tessellation
00347     bool InitTessellation(xmlNode* itNode, 
00348         uint32* localFaceVertexCount, UInt32List& allIndices, 
00349         const char* content, xmlNode*& holeNode, uint32 idxCount, 
00350         bool* failed);
00351 };
00352 
00353 #endif // _FCD_GEOMETRY_POLYGONS_H_

Generated on Fri May 12 16:44:38 2006 for FCollada by  doxygen 1.4.6-NO