------------------------------
| 298 | |
| 299 | //------------------------------ |
| 300 | bool MeshWriter::writeVerticesForMultipleObjects(size_t firstTriangleIndex, CountType trianglesCount, const COLLADABU::Math::Matrix4& worldMatrix) |
| 301 | { |
| 302 | if ( mMeshPositions.getType() == COLLADAFW::FloatOrDoubleArray::DATA_TYPE_FLOAT ) |
| 303 | { |
| 304 | MeshAccessor::TriangleType triangle = mMeshAccessor.getTriangle(firstTriangleIndex); |
| 305 | const COLLADAFW::FloatArray* floatArray = mMeshPositions.getFloatValues(); |
| 306 | if ( getApplyTransformationsToMeshes() && multiplyMeshes ) |
| 307 | { |
| 308 | // apply the world matrix to the vertices |
| 309 | float wm[3][4]; |
| 310 | wm[0][0] = (float)worldMatrix.getElement(0,0); |
| 311 | wm[0][1] = (float)worldMatrix.getElement(0,1); |
| 312 | wm[0][2] = (float)worldMatrix.getElement(0,2); |
| 313 | wm[0][3] = (float)worldMatrix.getElement(0,3); |
| 314 | wm[1][0] = (float)worldMatrix.getElement(1,0); |
| 315 | wm[1][1] = (float)worldMatrix.getElement(1,1); |
| 316 | wm[1][2] = (float)worldMatrix.getElement(1,2); |
| 317 | wm[1][3] = (float)worldMatrix.getElement(1,3); |
| 318 | wm[2][0] = (float)worldMatrix.getElement(2,0); |
| 319 | wm[2][1] = (float)worldMatrix.getElement(2,1); |
| 320 | wm[2][2] = (float)worldMatrix.getElement(2,2); |
| 321 | wm[2][3] = (float)worldMatrix.getElement(2,3); |
| 322 | |
| 323 | for ( IndexType i = 0; ; ++i) |
| 324 | { |
| 325 | // apply transformation |
| 326 | transformAndWriteVertex( *floatArray, wm, 3*triangle.indices[0]); |
| 327 | transformAndWriteVertex( *floatArray, wm, 3*triangle.indices[1]); |
| 328 | transformAndWriteVertex( *floatArray, wm, 3*triangle.indices[2]); |
| 329 | |
| 330 | mMaterialIds[i] = triangle.materialId; |
| 331 | if ( i >= trianglesCount - 1) |
| 332 | break; |
| 333 | triangle = mMeshAccessor.getNextTriangle(); |
| 334 | } |
| 335 | } |
| 336 | else |
| 337 | { |
| 338 | for ( IndexType i = 0; ; ++i) |
| 339 | { |
| 340 | // we can write the vertices directly to the mBuffer |
| 341 | mBuffer.copyToBuffer(floatArray->getData() + 3*triangle.indices[0], 3); |
| 342 | mBuffer.copyToBuffer(floatArray->getData() + 3*triangle.indices[1], 3); |
| 343 | mBuffer.copyToBuffer(floatArray->getData() + 3*triangle.indices[2], 3); |
| 344 | mMaterialIds[i] = triangle.materialId; |
| 345 | if ( i >= trianglesCount - 1) |
| 346 | break; |
| 347 | triangle = mMeshAccessor.getNextTriangle(); |
| 348 | } |
| 349 | } |
| 350 | } |
| 351 | else if ( mMeshPositions.getType() == COLLADAFW::FloatOrDoubleArray::DATA_TYPE_DOUBLE ) |
| 352 | { |
| 353 | // we need to cast the values from double to float |
| 354 | const COLLADAFW::DoubleArray* doubleArray = mMeshPositions.getDoubleValues(); |
| 355 | |
| 356 | MeshAccessor::TriangleType triangle = mMeshAccessor.getTriangle(firstTriangleIndex); |
| 357 |
nothing calls this directly
no test coverage detected