Here's a screenshot:
http://zith.cisko.org/screen2.gif
So it still rotates around the same point as before, while i want it to rotate around its own pivot-point / axis. The speed of the rotation also increases every frame, making the object spin faster and faster and i really can't figure out why..
I made a frame-class pretty much like the one you showed me.
// This is the headerclass CFrame{private: D3DXMATRIX m_mLocal; D3DXVECTOR3 m_vPosition; D3DXVECTOR3 m_vVelocity; D3DXVECTOR3 m_vOrientation; LPDIRECT3DDEVICE8 m_D3DDevice; D3DXMATRIX mtxRot; CMesh *m_Mesh;public: CFrame(LPDIRECT3DDEVICE8 lpD3DDevice, CMesh *Mesh); ~CFrame(); //All your set and get functions for position, velocity, etc void Rotate(D3DXVECTOR3 axis, long Speed); void Update(); HRESULT Render();};// This is the cpp fileCFrame::CFrame(LPDIRECT3DDEVICE8 lpD3DDevice, CMesh *Mesh){ m_vOrientation = D3DXVECTOR3(0.00000001,0.00000001,0.00000001); m_vVelocity = D3DXVECTOR3(0,0,0); m_vPosition = D3DXVECTOR3(0,0,0); D3DXMatrixIdentity(&m_mLocal); m_D3DDevice = lpD3DDevice; m_Mesh = Mesh;}HRESULT CFrame::Render(){ HRESULT hr; m_D3DDevice->SetTransform(D3DTS_WORLD, &m_mLocal); hr = m_Mesh->Render(); return hr;}void CFrame::Rotate(D3DXVECTOR3 axis, long speed){ m_vOrientation += axis * (float)speed) / 10000.0f; D3DXMatrixRotationYawPitchRoll(&mtxRot, m_vOrientation.x, m_vOrientation.y, m_vOrientation.z); D3DXMatrixMultiply(&m_mLocal, &mtxRot, &m_mLocal);}
As you can see, i'm using 0.00000001x0.00000001x0.00000001 as the orientation-vector. If i use a bigger value, the rotation will be much faster. If i use 0, there is no rotation.
The mesh-class have changed quite a lot so i'll post that too.
// This is the header (some old parts might still be in it)class CMesh{public: CMesh(LPDIRECT3DDEVICE8 lpD3DDevice, LPSTR Filename); ~CMesh(); HRESULT Render();private: LPD3DXMESH m_Mesh; D3DMATERIAL8 *m_Materials; LPDIRECT3DTEXTURE8 *m_Textures; DWORD m_NumMaterials; LPD3DXBUFFER m_MaterialsBuffer; LPDIRECT3DDEVICE8 m_D3DDevice;};// This is the cpp-file, pretty much init-stuff, the only function that is left except for the constructor and the deconstructor is Render()CMesh::CMesh(LPDIRECT3DDEVICE8 lpD3DDevice, LPSTR Filename){ HRESULT hr; m_D3DDevice = lpD3DDevice; Log.Log("Loading Model ",Filename); if(FAILED(D3DXLoadMeshFromX(Filename, D3DXMESH_SYSTEMMEM, m_D3DDevice, NULL, &m_MaterialsBuffer, &m_NumMaterials, &m_Mesh))) { Log.Log("Could not load model ",Filename); } D3DXMATERIAL *d3dxMaterials = (D3DXMATERIAL*)m_MaterialsBuffer->GetBufferPointer(); m_Materials = new D3DMATERIAL8[m_NumMaterials]; m_Textures = new LPDIRECT3DTEXTURE8[m_NumMaterials]; for(DWORD i = 0; i < m_NumMaterials; i++) { m_Materials[i] = d3dxMaterials[i].MatD3D; m_Materials[i].Ambient = m_Materials[i].Diffuse; hr = D3DXCreateTextureFromFile(m_D3DDevice, d3dxMaterials[i].pTextureFilename, &m_Textures[i]); if(hr==D3DERR_NOTAVAILABLE) { m_Textures[i] = NULL; Log.Log(" Error, Not Avavible"); } else if(hr==D3DERR_OUTOFVIDEOMEMORY) { m_Textures[i] = NULL; Log.Log(" Error, Out of videomemory"); } else if(hr==D3DERR_INVALIDCALL) { m_Textures[i] = NULL; Log.Log(" Error, Invalid Call"); } else if(hr==D3DXERR_INVALIDDATA) { m_Textures[i] = NULL; Log.Log(" Error, Couldn't find texture", d3dxMaterials[i].pTextureFilename); } else if(hr==E_OUTOFMEMORY) { m_Textures[i] = NULL; Log.Log(" Error, Out of memory"); } } m_MaterialsBuffer->Release(); Log.Log("Model Loaded");}CMesh::~CMesh(){ if(m_Materials != NULL) delete[] m_Materials; if(m_Textures != NULL) { for(DWORD i = 0; i < m_NumMaterials; i++) { if(m_Textures[i]) m_Textures[i]->Release(); } delete[] m_Textures; } if(m_Mesh != NULL) m_Mesh->Release();}HRESULT CMesh::Render(){ HRESULT r = E_FAIL; for (int i = 0; i < m_NumMaterials; i++) { //m_Materials.Update();<br></font><br> m_D3DDevice->SetMaterial(&m_Materials[<font color="purple">i</font>]);<br> m_D3DDevice->SetTexture(0, m_Textures[<font color="purple">i</font>]);<br> r = m_Mesh->DrawSubset(i);<br> }<br><br> <font color="gray">// Reset the vertexshader here when (if) i will use one<br></font><br> <font color="blue">return</font> r;<br>}<br><br><br> </pre></DIV><!–ENDSCRIPT–><br><br><br><SPAN CLASS=editedby>[edited by - ZitherMan on May 13, 2003 11:58:56 AM]</SPAN><br><br><SPAN CLASS=editedby>[edited by - ZitherMan on May 16, 2003 10:56:44 AM]</SPAN>