MCPcopy Create free account
hub / github.com/KhronosGroup/OpenCOLLADA / getNormalsCount

Method getNormalsCount

COLLADAFramework/src/COLLADAFWMesh.cpp:172–213  ·  view source on GitHub ↗

----------------------------------

Source from the content-addressed store, hash-verified

170
171 //----------------------------------
172 const size_t Mesh::getNormalsCount() const
173 {
174 // The number of normals in the current mesh.
175 size_t numNormals = 0;
176
177 // We have to go through every mesh primitive.
178 const MeshPrimitiveArray& meshPrimitives = this->getMeshPrimitives ();
179 size_t count = meshPrimitives.getCount ();
180 for ( size_t i=0; i<count; ++i )
181 {
182 // Get the current primitive element.
183 const MeshPrimitive* meshPrimitive = meshPrimitives [ i ];
184
185 // Get the normal indices of the current primitive.
186 const UIntValuesArray& normalIndices = meshPrimitive->getNormalIndices ();
187
188 switch ( meshPrimitive->getPrimitiveType () )
189 {
190 case COLLADAFW::MeshPrimitive::TRIANGLE_FANS:
191 case COLLADAFW::MeshPrimitive::TRIANGLE_STRIPS:
192 {
193 COLLADAFW::MeshPrimitiveWithFaceVertexCount<unsigned int>* trifans = (COLLADAFW::MeshPrimitiveWithFaceVertexCount<unsigned int>*) meshPrimitive;
194 COLLADAFW::MeshPrimitiveWithFaceVertexCount<unsigned int>::VertexCountArray& vertexCountArray = trifans->getGroupedVerticesVertexCountArray ();
195 size_t groupedVtxCount = vertexCountArray.getCount ();
196 for ( size_t groupedVtxIndex=0; groupedVtxIndex<groupedVtxCount; ++groupedVtxIndex )
197 {
198 // Iterate over the indices and write their normal values into the maya file.
199 size_t indexCount = vertexCountArray[groupedVtxIndex]; //normalIndices.getCount();
200 numNormals += (indexCount - 2) * 3;
201 }
202 }
203 break;
204 default:
205 {
206 // Add the normals to the sum of normals
207 numNormals += normalIndices.getCount ();
208 }
209 }
210 }
211
212 return numNormals;
213 }
214
215 //----------------------------------
216 const size_t Mesh::getFacesCount() const

Callers 1

writeNormalsMethod · 0.80

Calls 2

getPrimitiveTypeMethod · 0.80
getCountMethod · 0.45

Tested by

no test coverage detected