Ejemplo n.º 1
0
 public static Matrix ToMatrix(this TV_3DMATRIX matrix)
 {
     return(new Matrix
     {
         M11 = matrix.m11, M12 = matrix.m12, M13 = matrix.m13, M14 = matrix.m14,
         M21 = matrix.m21, M22 = matrix.m22, M23 = matrix.m23, M24 = matrix.m24,
         M31 = matrix.m31, M32 = matrix.m32, M33 = matrix.m33, M34 = matrix.m34,
         M41 = matrix.m41, M42 = matrix.m42, M43 = matrix.m43, M44 = matrix.m44
     });
 }
Ejemplo n.º 2
0
        public void RotateZ(float angle)
        {
            TV_3DVECTOR position = Physics.GetBodyPosition(PhysicsId);
            TV_3DMATRIX mat      = new TV_3DMATRIX();
            TV_3DMATRIX modyMat  = Physics.GetBodyMatrix(PhysicsId);

            MathLibrary.TVMatrixRotationZ(ref mat, angle);
            MathLibrary.TVMatrixMultiply(ref mat, modyMat, mat);
            Physics.SetBodyMatrix(PhysicsId, mat);
            Physics.SetBodyPosition(PhysicsId, position.x, position.y, position.z);
        }
Ejemplo n.º 3
0
        public void RotateZAroundPoint(TV_3DVECTOR point, float angle)
        {
            TVMesh node = Scene.CreateMeshBuilder();

            node.SetPosition(point.x, point.y, point.z);
            mesh.AttachTo(CONST_TV_NODETYPE.TV_NODETYPE_MESH, node.GetIndex(), -1);
            TV_3DVECTOR nodePos = node.GetPosition();
            TV_3DMATRIX mat     = new TV_3DMATRIX();
            TV_3DMATRIX modyMat = node.GetMatrix();

            MathLibrary.TVMatrixRotationZ(ref mat, angle);
            node.SetRotationMatrix(mat);
            mesh.AttachTo(CONST_TV_NODETYPE.TV_NODETYPE_NONE, -1, -1);
            node.Destroy();
            mat = mesh.GetMatrix();
            Physics.SetBodyMatrix(PhysicsId, mat);
        }
Ejemplo n.º 4
0
 // 1 - X, 2 - Y, 3 - Z
 private void RotateObject(int axis, MouseEventArgs e)
 {
     if (selectedObject != null)
     {
         VECTOR3D position = selectedObject.Position;
         TV_3DMATRIX mat = new TV_3DMATRIX();
         TV_3DMATRIX modyMat = selectedObject.GetMesh().GetMatrix();
         var rotation = Settings.RotationValue;
         if (e.Button == MouseButtons.Right)
             rotation = -rotation;
         if (axis == 1)
             core.MathLibrary.TVMatrixRotationX(ref mat, rotation);
         else if (axis == 2)
             core.MathLibrary.TVMatrixRotationY(ref mat, rotation);
         else if (axis == 3)
             core.MathLibrary.TVMatrixRotationZ(ref mat, rotation);
         else return;
         core.MathLibrary.TVMatrixMultiply(ref mat, modyMat, mat);
         selectedObject.GetMesh().SetMatrix(mat);
         selectedObject.Position = position;
         selectedObject.Rotation = new VECTOR3D(selectedObject.GetMesh().GetRotation());
         UpdateSelectedObject(selectedObject);
     }
 }
Ejemplo n.º 5
0
 public void RotateZAroundPoint(TV_3DVECTOR point, float angle)
 {
     TVMesh node = Scene.CreateMeshBuilder();
     node.SetPosition(point.x, point.y, point.z);
     mesh.AttachTo(CONST_TV_NODETYPE.TV_NODETYPE_MESH, node.GetIndex(), -1);
     TV_3DVECTOR nodePos = node.GetPosition();
     TV_3DMATRIX mat = new TV_3DMATRIX();
     TV_3DMATRIX modyMat = node.GetMatrix();
     MathLibrary.TVMatrixRotationZ(ref mat, angle);
     node.SetRotationMatrix(mat);
     mesh.AttachTo(CONST_TV_NODETYPE.TV_NODETYPE_NONE, -1, -1);
     node.Destroy();
     mat = mesh.GetMatrix();
     Physics.SetBodyMatrix(PhysicsId, mat);
 }
Ejemplo n.º 6
0
 public void RotateZ(float angle)
 {
     TV_3DVECTOR position = Physics.GetBodyPosition(PhysicsId);
     TV_3DMATRIX mat = new TV_3DMATRIX();
     TV_3DMATRIX modyMat = Physics.GetBodyMatrix(PhysicsId);
     MathLibrary.TVMatrixRotationZ(ref mat, angle);
     MathLibrary.TVMatrixMultiply(ref mat, modyMat, mat);
     Physics.SetBodyMatrix(PhysicsId, mat);
     Physics.SetBodyPosition(PhysicsId, position.x, position.y, position.z);
 }