All-
So I've been slowly collecting various game objects (think: mailboxes) to add to my R+D meshes, but of course I've come into a problem on the last step.
I'm trying to use the matrix I saved with each game object to transform the vertices of the given model to the correct coordinates, but I don't know how to do this unfortunately.
I'm basically adapting the transformVertices function that comes with wowmapper to accept the GO's matrix, but it's still not working correctly (the final vertices are definitely not the correct coords, by any means). Anyone have any ideas on what I'm doing wrong?
Code:
static void transformVerticesGO( float matrix[4][4], float scale, Vertices_t *vertices ) {
static const float map_offset = 17066.0f + (2/3.0f);
static const glm::vec3 map_pos( map_offset, 0, map_offset );
static const glm::vec3 pos( matrix[3][0], matrix[3][1], matrix[3][2] );
// create rotation matrix
glm::mat4 rot_mtx = glm::mat4(matrix[0][0], matrix[0][1], matrix[0][2], matrix[0][3], \
matrix[1][0], matrix[1][1], matrix[1][2], matrix[1][3], \
matrix[2][0], matrix[2][1], matrix[2][2], matrix[2][3], \
matrix[3][0], matrix[3][1], matrix[3][2], matrix[3][3]);
// transform vertices
for ( Vertices_t::iterator vertex = vertices->begin(); vertex != vertices->end(); ++vertex ){
glm::vec4 v4( *vertex, 0 );
v4 = scale * rot_mtx * v4;
*vertex = glm::vec3( v4 );
*vertex += pos - map_pos;
}
}
Thanks in advance!
~ Tanaris