FCDocument/FCDGeometryMesh.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2005-2007 Feeling Software Inc.
00003     Portions of the code are:
00004     Copyright (C) 2005-2007 Sony Computer Entertainment America
00005     
00006     MIT License: http://www.opensource.org/licenses/mit-license.php
00007 */
00008 /*
00009     Based on the FS Import classes:
00010     Copyright (C) 2005-2006 Feeling Software Inc
00011     Copyright (C) 2005-2006 Autodesk Media Entertainment
00012     MIT License: http://www.opensource.org/licenses/mit-license.php
00013 */
00014 
00020 #ifndef _FCD_GEOMETRY_MESH_H_
00021 #define _FCD_GEOMETRY_MESH_H_
00022 
00023 #ifndef __FCD_OBJECT_H_
00024 #include "FCDocument/FCDObject.h"
00025 #endif // __FCD_OBJECT_H_
00026 #ifndef _FU_PARAMETER_H_
00027 #include "FUtils/FUParameter.h"
00028 #endif // _FU_PARAMETER_H_
00029 #ifndef _FU_DAE_ENUM_H_
00030 #include "FUtils/FUDaeEnum.h"
00031 #endif // _FU_DAE_ENUM_H_
00032 
00033 class FCDocument;
00034 class FCDGeometry;
00035 class FCDGeometryPolygons;
00036 class FCDGeometrySource;
00037 
00038 typedef fm::pvector<FCDGeometrySource> FCDGeometrySourceList; 
00039 typedef fm::pvector<const FCDGeometrySource> FCDGeometrySourceConstList; 
00040 typedef fm::pvector<FCDGeometryPolygons> FCDGeometryPolygonsList; 
00056 class FCOLLADA_EXPORT FCDGeometryMesh : public FCDObject
00057 {
00058 private:
00059     DeclareObjectType(FCDObject);
00060 
00061     FCDGeometry* parent;
00062     DeclareParameterContainer(FCDGeometrySource, sources, FC("Data Sources"));
00063     DeclareParameterContainer(FCDGeometryPolygons, polygons, FC("Polygons Sets"));
00064 
00065     DeclareParameterTrackList(FCDGeometrySource, vertexSources, FC("Vertex Sources"));
00066     size_t faceCount, holeCount;
00067     size_t faceVertexCount;
00068 
00069     bool isConvex; //determines if the mesh is defined as a <convex_mesh>
00070     bool convexify; //determines if the mesh needs to be turned into a convex mesh
00071     DeclareParameter(fm::string, FUParameterQualifiers::SIMPLE, convexHullOf, FC("Convex Hull of"));
00072 
00073 public:
00077     FCDGeometryMesh(FCDocument* document, FCDGeometry* parent);
00078 
00080     virtual ~FCDGeometryMesh();
00081 
00087     bool Link();
00088 
00091     FCDGeometry* GetParent() { return parent; }
00092     const FCDGeometry* GetParent() const { return parent; } 
00096     inline size_t GetFaceCount() const { return faceCount; }
00097 
00101     inline size_t GetHoleCount() const { return holeCount; }
00102 
00106     inline size_t GetFaceVertexCount() const { return faceVertexCount; }
00107 
00110     inline bool IsConvex() const { return isConvex; }
00111 
00114     inline void SetConvex(bool _isConvex) { isConvex = _isConvex; SetDirtyFlag(); }
00115 
00118     inline bool GetConvexify() const { return convexify; }
00119 
00124     inline void SetConvexify(bool _convexify) { convexify = _convexify; SetDirtyFlag();}
00125 
00128     const fm::string& GetConvexHullOf() const {return convexHullOf;}
00129 
00133     inline FCDGeometryMesh* FindConvexHullOfMesh() { return const_cast<FCDGeometryMesh*>(const_cast<const FCDGeometryMesh*>(this)->FindConvexHullOfMesh()); }
00134     const FCDGeometryMesh* FindConvexHullOfMesh() const; 
00138     void SetConvexHullOf(FCDGeometry* _geom);
00139 
00143     void SetConvexHullOf(const fm::string& id){ convexHullOf = id; }
00144 
00148     const fm::string& GetDaeId() const;
00149 
00155     inline size_t GetPolygonsCount() const { return polygons.size(); }
00156 
00164     inline FCDGeometryPolygons* GetPolygons(size_t index) { FUAssert(index < GetPolygonsCount(), return NULL); return polygons.at(index); }
00165     inline const FCDGeometryPolygons* GetPolygons(size_t index) const { FUAssert(index < GetPolygonsCount(), return NULL); return polygons.at(index); } 
00172     FCDGeometryPolygons* AddPolygons();
00173 
00176     bool IsTriangles() const;
00177 
00183     void FindPolygonsByMaterial(const fstring& semantic, FCDGeometryPolygonsList& sets);
00184 
00189     DEPRECATED(3.05A, GetVertexSourceCount and GetVertexSource(index)) void GetVertexSources() const {}
00190 
00195     inline size_t GetVertexSourceCount() const { return vertexSources.size(); }
00196 
00202     inline FCDGeometrySource* GetVertexSource(size_t index) { FUAssert(index < GetVertexSourceCount(), return NULL); return vertexSources.at(index); }
00203     inline const FCDGeometrySource* GetVertexSource(size_t index) const { FUAssert(index < GetVertexSourceCount(), return NULL); return vertexSources.at(index); } 
00211     FCDGeometrySource* AddVertexSource(FUDaeGeometryInput::Semantic type = FUDaeGeometryInput::UNKNOWN);
00212 
00215     void AddVertexSource(FCDGeometrySource* source);
00216 
00220     void RemoveVertexSource(FCDGeometrySource* source);
00221 
00225     inline bool IsVertexSource(const FCDGeometrySource* source) const { return vertexSources.contains(const_cast<FCDGeometrySource*>(source)); }
00226 
00230     FCDGeometrySource* FindSourceById(const fm::string& id) { return const_cast<FCDGeometrySource*>(const_cast<const FCDGeometryMesh*>(this)->FindSourceById(id)); }
00231     const FCDGeometrySource* FindSourceById(const fm::string& id) const; 
00237     FCDGeometrySource* FindSourceByType(FUDaeGeometryInput::Semantic type) { return const_cast<FCDGeometrySource*>(const_cast<const FCDGeometryMesh*>(this)->FindSourceByType(type)); }
00238     const FCDGeometrySource* FindSourceByType(FUDaeGeometryInput::Semantic type) const; 
00244     FCDGeometrySource* FindSourceByName(const fstring& name) { return const_cast<FCDGeometrySource*>(const_cast<const FCDGeometryMesh*>(this)->FindSourceByName(name)); }
00245     const FCDGeometrySource* FindSourceByName(const fstring& name) const; 
00251     void FindSourcesByType(FUDaeGeometryInput::Semantic type, FCDGeometrySourceList& sources) { FindSourcesByType(type, *(FCDGeometrySourceConstList*) &sources); }
00252     void FindSourcesByType(FUDaeGeometryInput::Semantic type, FCDGeometrySourceConstList& sources) const; 
00259     FCDGeometrySource* GetPositionSource() { return FindSourceByType(FUDaeGeometryInput::POSITION); }
00260     const FCDGeometrySource* GetPositionSource() const { return FindSourceByType(FUDaeGeometryInput::POSITION); } 
00265     DEPRECATED(3.05A, GetSourceCount and GetSource(index)) void GetSources() const {}
00266 
00269     inline size_t GetSourceCount() const { return sources.size(); }
00270 
00275     inline FCDGeometrySource* GetSource(size_t index) { FUAssert(index < GetSourceCount(), return NULL); return sources.at(index); }
00276     inline const FCDGeometrySource* GetSource(size_t index) const { FUAssert(index < GetSourceCount(), return NULL); return sources.at(index); } 
00283     FCDGeometrySource* AddSource(FUDaeGeometryInput::Semantic type = FUDaeGeometryInput::UNKNOWN);
00284 
00290     FCDGeometryMesh* Clone(FCDGeometryMesh* clone = NULL) const;
00291 
00295     void Recalculate();
00296 };
00297 
00298 #endif // _FCD_GEOMETRY_MESH_H_

Generated on Thu Feb 14 16:58:34 2008 for FCollada by  doxygen 1.4.6-NO