Return a vertex normal of the array * @param vertexIndex Index of a given vertex of the array * @return The normal vector of the vertex */
| 168 | * @return The normal vector of the vertex |
| 169 | */ |
| 170 | Vector3 TriangleVertexArray::getVertexNormal(uint32 vertexIndex) const { |
| 171 | |
| 172 | assert(vertexIndex < mNbVertices); |
| 173 | |
| 174 | const uchar* vertexNormalPointerChar = mVerticesNormalsStart + vertexIndex * mVerticesNormalsStride; |
| 175 | const void* vertexNormalPointer = static_cast<const void*>(vertexNormalPointerChar); |
| 176 | |
| 177 | // Get the normals from the array |
| 178 | if (mVertexNormaldDataType == TriangleVertexArray::NormalDataType::NORMAL_FLOAT_TYPE) { |
| 179 | const float* normal = static_cast<const float*>(vertexNormalPointer); |
| 180 | return Vector3(decimal(normal[0]), decimal(normal[1]), decimal(normal[2])); |
| 181 | } |
| 182 | else if (mVertexNormaldDataType == TriangleVertexArray::NormalDataType::NORMAL_DOUBLE_TYPE) { |
| 183 | const double* normal = static_cast<const double*>(vertexNormalPointer); |
| 184 | return Vector3(decimal(normal[0]), decimal(normal[1]), decimal(normal[2])); |
| 185 | } |
| 186 | else { |
| 187 | assert(false); |
| 188 | } |
| 189 | |
| 190 | return Vector3::zero(); |
| 191 | } |