Guest User

Untitled

a guest
Mar 23rd, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. #include <d3d11.h>
  2. #include <d3dx10.h>
  3. #include <d3dx11.h>
  4. #include"IBehavior.h"
  5.  
  6. namespace NeneLabyrinth
  7. {
  8. namespace Component
  9. {
  10. class Transform :
  11. public IBehavior
  12. {
  13. D3DXMATRIX world;
  14.  
  15. D3DXVECTOR3 position;
  16. D3DXVECTOR3 rotate;
  17. D3DXVECTOR3 scale;
  18. public:
  19.  
  20. __declspec(property(get = GetForward)) D3DXVECTOR3 Forward;
  21. __declspec(property(get = GetRigth)) D3DXVECTOR3 Rigth;
  22. __declspec(property(get = GetUp)) D3DXVECTOR3 Up;
  23.  
  24. PROPERTY_REF(position, Position, D3DXVECTOR3);
  25. PROPERTY_REF(rotate, Rotation, D3DXVECTOR3);
  26. PROPERTY_REF(scale, Scale, D3DXVECTOR3);
  27. PROPERTY_REF(world, World, D3DXMATRIX);
  28.  
  29. D3DXVECTOR3 GetRigth();
  30. D3DXVECTOR3 GetUp();
  31. D3DXVECTOR3 GetForward();
  32.  
  33. Transform();
  34. void Update()override;
  35.  
  36. };
  37.  
  38. D3DXVECTOR3 Transform::GetRigth()
  39. {
  40. return D3DXVECTOR3(world._11, world._12, world._13);
  41. }
  42. D3DXVECTOR3 Transform::GetUp()
  43. {
  44. return D3DXVECTOR3(world._21, world._22, world._33);
  45. }
  46. D3DXVECTOR3 Transform::GetForward()
  47. {
  48. return D3DXVECTOR3(world._31, world._32, world._33);
  49. }
  50.  
  51. Transform::Transform() :
  52. position(0, 0, 0),
  53. rotate(0, 0, 0),
  54. scale(1, 1, 1)
  55. {
  56. }
  57.  
  58. void Transform::Update()
  59. {
  60. D3DXMATRIX matTrans;
  61. D3DXMATRIX matRotate;
  62. D3DXMATRIX matScale;
  63.  
  64. D3DXMatrixIdentity(&world);
  65. D3DXMatrixIdentity(&matTrans);
  66. D3DXMatrixIdentity(&matRotate);
  67. D3DXMatrixIdentity(&matScale);
  68.  
  69. D3DXMatrixTranslation(&matTrans, position.x, position.y, position.z);
  70. D3DXMatrixRotationYawPitchRoll(&matRotate,
  71. D3DXToRadian(rotate.y),
  72. D3DXToRadian(rotate.x),
  73. D3DXToRadian(rotate.z));
  74. D3DXMatrixScaling(&matScale, scale.x, scale.y, scale.z);
  75.  
  76. world = matScale * matRotate * matTrans;
  77. }
  78. }
  79. }
Add Comment
Please, Sign In to add comment