1 /* 2 Copyright (c) 2008-2009 NetAllied Systems GmbH 3 4 This file is part of COLLADAFramework. 5 6 Licensed under the MIT Open Source License, 7 for details please see LICENSE file or the website 8 http://www.opensource.org/licenses/mit-license.php 9 */ 10 11 #ifndef __COLLADAFW_MESHPRIMITIVEWITHFACEVERTEXCOUNT_H__ 12 #define __COLLADAFW_MESHPRIMITIVEWITHFACEVERTEXCOUNT_H__ 13 14 #include "COLLADAFWPrerequisites.h" 15 #include "COLLADAFWMeshPrimitive.h" 16 17 namespace COLLADAFW 18 { 19 20 /** 21 Geometric primitives, which assemble values from the inputs into vertex attribute data. 22 Can be any combination of any primitive types in any order. 23 24 To describe geometric primitives that are formed from the vertex data, the <mesh> element may 25 contain zero or more of the primitive elements <lines>, <linestrips>, <polygons>, <polylist>, 26 <triangles>, <trifans>, and <tristrips>. 27 The <vertices> element under <mesh> is used to describe mesh-vertices. Polygons, triangles, and 28 so forth index mesh-vertices, not positions directly. Mesh-vertices must have at least one 29 <input> (unshared) element with a semantic attribute whose value is POSITION. 30 For texture coordinates, COLLADA's right-handed coordinate system applies; therefore, an ST 31 texture coordinate of [0,0] maps to the lower-left texel of a texture image, when loaded in a 32 professional 2-D texture viewer/editor. 33 */ 34 template<class VertexCountType> 35 class MeshPrimitiveWithFaceVertexCount : public MeshPrimitive 36 { 37 38 public: 39 typedef ArrayPrimitiveType<VertexCountType> VertexCountArray; 40 41 private: 42 /** 43 * Contains a list of integers, each specifying the number of vertices for one 44 * - polygon face 45 * - hole 46 * - tristrip or trifan 47 * element. 48 */ 49 VertexCountArray mGroupedVerticesVertexCountArray; 50 51 protected: 52 53 /** 54 * Constructor. 55 */ MeshPrimitiveWithFaceVertexCount(const UniqueId & uniqueId,PrimitiveType primitiveType)56 MeshPrimitiveWithFaceVertexCount ( const UniqueId& uniqueId, PrimitiveType primitiveType ) 57 : MeshPrimitive ( uniqueId, primitiveType ) 58 , mGroupedVerticesVertexCountArray(VertexCountArray::OWNER) 59 {} 60 61 public: 62 63 /** 64 * Destructor. 65 */ ~MeshPrimitiveWithFaceVertexCount()66 virtual ~MeshPrimitiveWithFaceVertexCount() {} 67 68 /** 69 * Contains a list of integers, each specifying the number of vertices for one polygon face. 70 */ getGroupedVerticesVertexCountArray()71 VertexCountArray& getGroupedVerticesVertexCountArray () { return mGroupedVerticesVertexCountArray; } 72 73 /** 74 * Contains a list of integers, each specifying the number of vertices for one polygon face. 75 */ getGroupedVerticesVertexCountArray()76 const VertexCountArray& getGroupedVerticesVertexCountArray () const { return mGroupedVerticesVertexCountArray; } 77 78 /** 79 * Contains a list of integers, each specifying the number of vertices for one polygon face. 80 */ setGroupedVerticesVertexCountArray(const VertexCountArray & FaceVertexCountArray)81 void setGroupedVerticesVertexCountArray ( const VertexCountArray& FaceVertexCountArray ) { mGroupedVerticesVertexCountArray = FaceVertexCountArray; } 82 83 /* 84 * Returns the vertex count of the face on the specified index position. 85 */ getGroupedVerticesVertexCount(const size_t faceIndex)86 const int getGroupedVerticesVertexCount ( const size_t faceIndex ) const 87 { 88 if ( faceIndex >= mGroupedVerticesVertexCountArray.getCount () ) 89 { 90 std::cerr << "Face index out of range: " << faceIndex << std::endl; 91 COLLADABU_ASSERT ( "Face index out of range: " + faceIndex ); 92 return -1; 93 } 94 95 return mGroupedVerticesVertexCountArray [ faceIndex ]; 96 } 97 98 }; 99 100 101 } 102 103 #endif // __COLLADAFW_MESHPRIMITIVEWITHFACEVERTEXCOUNT_H__ 104