So now I think I also have to rotate the normal as well. Do I just rotate it by the same angle as the position?
This is what I do:
Code: Select all
Ogre::ManualObject* tmp = mGraphics.getSceneManager()->createManualObject();
tmp->begin(mMesh->getSubMesh(0)->getMaterialName(), Ogre::RenderOperation::OT_TRIANGLE_LIST);
for( std::size_t v=0; v< mMeshVertices.size(); v++){
Ogre::Vector3 position = Ogre::Vector3(mMeshVertices[v].x, mMeshVertices[v].y, mMeshVertices[v].z);
Ogre::Vector3 normal = Ogre::Vector3(mMeshVertices[v].nx, mMeshVertices[v].ny, mMeshVertices[v].nz);
Ogre::Vector2 tex = Ogre::Vector2(mMeshVertices[v].u, mMeshVertices[v].v);
Ogre::Quaternion quat;
quat.FromAngleAxis( Ogre::Radian(Ogre::Degree(degrees)), Ogre::Vector3(0,0,1) );
//rotate the position!
float scale = 1;
Ogre::Vector3 translatedPos = quat * (position * scale);
position = translatedPos;
Ogre::Vector3 translatedNorm = quat * (normal * scale);
normal = translatedNorm;
tmp->position(position);
tmp->normal(normal);
tmp->textureCoord(tex);
}
for (std::size_t i = 0; i < mMeshIndices.size(); i++) {
tmp->index(mMeshIndices[i]);
}