Return a vertex of the array * @param vertexIndex Index of a given vertex of the array * @return The vertex coordinates */
| 141 | * @return The vertex coordinates |
| 142 | */ |
| 143 | Vector3 TriangleVertexArray::getVertex(uint32 vertexIndex) const { |
| 144 | |
| 145 | assert(vertexIndex < mNbVertices); |
| 146 | |
| 147 | const uchar* vertexPointerChar = mVerticesStart + vertexIndex * mVerticesStride; |
| 148 | const void* vertexPointer = static_cast<const void*>(vertexPointerChar); |
| 149 | |
| 150 | // Get the vertices components of the triangle |
| 151 | if (mVertexDataType == TriangleVertexArray::VertexDataType::VERTEX_FLOAT_TYPE) { |
| 152 | |
| 153 | const float* vertices = static_cast<const float*>(vertexPointer); |
| 154 | return Vector3(decimal(vertices[0]), decimal(vertices[1]), decimal(vertices[2])); |
| 155 | } |
| 156 | else if (mVertexDataType == TriangleVertexArray::VertexDataType::VERTEX_DOUBLE_TYPE) { |
| 157 | const double* vertices = static_cast<const double*>(vertexPointer); |
| 158 | return Vector3(decimal(vertices[0]), decimal(vertices[1]), decimal(vertices[2])); |
| 159 | } |
| 160 | else { |
| 161 | assert(false); |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | // Return a vertex normal of the array |
| 166 | /** |