Advertisement
Guest User

Untitled

a guest
Oct 30th, 2014
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. void Bullet::UpdatePosition()
  2. {
  3.     D3DXVECTOR3 rotationVector(0.0f, 1.0f, 0.0f);
  4.  
  5.     // rotation
  6.     D3DXMATRIX rotateX;
  7.     D3DXMATRIX rotateY;
  8.     D3DXMATRIX rotateZ;
  9.     D3DXMatrixRotationX(&rotateX, myModel->rotation.x);
  10.     D3DXMatrixRotationY(&rotateY, myModel->rotation.y);
  11.     D3DXMatrixRotationZ(&rotateZ, myModel->rotation.z);
  12.     D3DXMATRIX rotationMatrix = rotateX*rotateY*rotateZ;
  13.     D3DXVECTOR4 outputVec;
  14.  
  15.     D3DXVec3Transform(&outputVec, &rotationVector, &rotationMatrix);
  16.     rotationVector.x = outputVec.x;
  17.     rotationVector.y = outputVec.y;
  18.     rotationVector.z = outputVec.z;
  19.  
  20.     myModel->position += (speed/200.0f*rotationVector*System::time);
  21.     currentDistance = sqrt(pow(myModel->position.x - originPos.x, 2) + pow(myModel->position.y - originPos.y, 2));
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement