I can't understand why, but i've a problem with my method. The direction change at every Update() ! The code for my render is this:
void GameObject::Update(){ D3DXMatrixScaling(&m_mat_scale, transform.scale.x, transform.scale.y, transform.scale.z); D3DXMatrixRotationYawPitchRoll( &m_Rotation, transform.yaw, transform.pitch, transform.roll ); D3DXVec3TransformNormal( &transform.direction, &transform.direction, &m_Rotation ); D3DXVec3Normalize(&transform.direction, &transform.direction); D3DXMatrixTranslation(&m_mat_position, transform.position.x, transform.position.y, transform.position.z); NinjaEngineDevice::get_ist()->m_d3d_device->SetTransform(D3DTS_WORLD, &( m_Rotation * m_mat_position * m_mat_scale)); for(m_itr = m_GameComponents.begin(); m_itr != m_GameComponents.end(); m_itr++) { /*(*m_itr).second->Update();*/ (*m_itr)->Update(); }}
and my code for GetDirection()
D3DXVECTOR3 GameObject::GetDirection(){ D3DXMATRIX mxRotation; D3DXMatrixRotationYawPitchRoll( &mxRotation, transform.yaw, transform.pitch, transform.roll ); D3DXVec3TransformNormal( &transform.direction, &transform.direction, &mxRotation ); D3DXVec3Normalize(&transform.direction, &transform.direction); return transform.direction;}
So
transform.direction is different from previous frame! I don't rotate or translate my gameobject, so i can't understand why with the same Roll, Pitch and Yaw i've different results!
Any idea? Thanks a lot.