Ejemplo n.º 1
0
    void Start()
    {
        Debug.Log("rotation Vector:" + rotationVector.ToString() + "\nAngle: " + angle);

        if (vectorToRotate == null)
        {
            vectorToRotate = new Vector3(0, 0, 0);
        }

        mesh = ((MeshFilter)GameObject.CreatePrimitive(PrimitiveType.Cube).GetComponent("MeshFilter")).mesh;
        if (mesh == null)
        {
            Debug.Log("No Mesh in Cube");
        }
        rigid = new MyRigid(mesh);
        angle = angle / 60;
        q     = new MyQuaternion(rotationVector, angle);

        rigid.rotate(q);

        Debug.Log("Original Vector: " + vectorToRotate);

        Debug.Log("Rotated Point: " + q.rotate(vectorToRotate));

        Graphics.DrawMesh(rigid.getMesh(), Matrix4x4.identity, material, 0);
    }
Ejemplo n.º 2
0
 public void rotate(MyQuaternion q)
 {
     Vector3[] verts   = mesh.vertices;
     Vector3[] rotated = new Vector3[verts.Length];
     for (int i = 0; i < verts.Length; i++)
     {
         rotated[i] = q.rotate(verts[i]);
     }
     mesh.vertices = rotated;
 }