Exemplo n.º 1
0
 public void Init(Vector4 A_)
 {
     center = A_;
     cube   = new HyperCubeMesh(A_);
     A      = new Vector4();
     UpdateRotation(cube);
     A = B;
 }
Exemplo n.º 2
0
 void Awake()
 {
     // box = this.GetComponent<Transform>();
     cube = new HyperCubeMesh(center);
     #region Faces
     faces = new int[] { 4, 0, 8, 12,
                         6, 2, 10, 14,
                         5, 1, 9, 13,
                         7, 3, 11, 15,
                         2, 0, 8, 10,
                         6, 4, 12, 14,
                         3, 1, 9, 11,
                         7, 5, 13, 15,
                         2, 0, 4, 6,
                         10, 8, 12, 14,
                         3, 1, 5, 7,
                         11, 9, 13, 15,
                         1, 0, 8, 9,
                         5, 4, 12, 13,
                         3, 2, 10, 11,
                         7, 6, 14, 15,
                         1, 0, 4, 5,
                         9, 8, 12, 13,
                         3, 2, 6, 7,
                         11, 10, 14, 15,
                         1, 0, 2, 3,
                         9, 8, 10, 11,
                         5, 4, 6, 7,
                         13, 12, 14, 15 };
     vertices = new Vector3[16];
     for (int i = 0; i < 16; i++)
     {
         vertices[i] = cube.get3dver(i);
     }
     Mesh tmp = new Mesh();
     updatevertices(tmp);
     #endregion
     mesh = new Mesh();
     for (int i = 0; i < 16; i++)
     {
         vertices[i] = cube.get3dver(i);
     }
     mesh.vertices = vertices;
     mesh.SetIndices(faces, MeshTopology.Quads, 0);
     mesh.RecalculateBounds();
     mesh.Optimize();
     mesh.SetTriangles(mesh.GetTriangles(0), 0);
     GetComponent <MeshFilter>().mesh         = mesh;
     GetComponent <MeshCollider>().sharedMesh = mesh;
     A_ = new Vector3();
     B_ = new Vector3();
     isTriggerPressed = false;
     A        = new Vector4();
     B        = new Vector4();
     radius   = 1.0f;
     children = new GameObject[8];
 }
Exemplo n.º 3
0
 void UpdateRotation(HyperCubeMesh cube)
 {
     for (int i = 0; i < 16; i++)
     {
         float[] src = new float[4];
         src[0] = cube.srcVertices[i].x;
         src[1] = cube.srcVertices[i].y;
         src[2] = cube.srcVertices[i].z;
         src[3] = cube.srcVertices[i].w;
         float[] dst = new float[4];
         manager.GetComponent <Manager>().trackball.transform(src, dst);
         cube.updatepoint4(dst, i);
     }
 }
Exemplo n.º 4
0
 public void Renew()
 {
     hypermesh = new HyperCubeMesh(center);
     vertices  = new Vector3[8];
     for (int i = 0; i < 8; i++)
     {
         vertices[i] = hypermesh.get3dver(hyperface[i + faceindex * 8]);
     }
     mesh.vertices = vertices;
     mesh.SetIndices(faces, MeshTopology.Quads, 0);
     mesh.RecalculateBounds();
     mesh.Optimize();
     UpdateRotation(hypermesh);
 }
Exemplo n.º 5
0
        // Use this for initialization

        void Awake()
        {
            faceindex        = 0;
            _A               = new Vector3();
            _B               = new Vector3();
            isTriggerPressed = false;
            A         = new Vector4();
            B         = new Vector4();
            center    = new Vector4();
            radius    = 1.0f;           //Setup the radius of the sphere collider
            hypermesh = new HyperCubeMesh(center);
            vertices  = new Vector3[8];
            hyperface = new int[] { 1, 3, 5, 7, 9, 11, 13, 15,
                                    0, 2, 4, 6, 8, 10, 12, 14,
                                    2, 3, 6, 7, 10, 11, 14, 15,
                                    0, 1, 4, 5, 8, 9, 12, 13,
                                    4, 5, 6, 7, 12, 13, 14, 15,
                                    0, 1, 2, 3, 8, 9, 10, 11,
                                    8, 9, 10, 11, 12, 13, 14, 15,
                                    0, 1, 2, 3, 4, 5, 6, 7 };
            for (int i = 0; i < 8; i++)
            {
                vertices[i] = hypermesh.get3dver(hyperface[i + faceindex * 8]);
            }

            mesh  = new Mesh();
            faces = new int[24] {
                2, 0, 4, 6,
                3, 1, 5, 7,
                1, 0, 4, 5,
                3, 2, 6, 7,
                1, 0, 2, 3,
                5, 4, 6, 7
            };
            mesh.vertices = vertices;
            mesh.SetIndices(faces, MeshTopology.Quads, 0);
            mesh.RecalculateBounds();
            mesh.Optimize();
            GetComponent <MeshFilter>().mesh = mesh;
        }
Exemplo n.º 6
0
        public void UpdateRotation(HyperCubeMesh cube)
        {
            center_ = new Vector4();
            for (int i = 0; i < 16; i++)
            {
                float[] src = new float[4];
                src[0] = cube.srcVertices[i].x;
                src[1] = cube.srcVertices[i].y;
                src[2] = cube.srcVertices[i].z;
                src[3] = cube.srcVertices[i].w;
                float[] dst = new float[4];

                manager.GetComponent <Manager>().trackball.transform(src, dst);
                center_.x += dst[0];
                center_.y += dst[1];
                center_.z += dst[2];
                center_.w += dst[3];
                cube.updatepoint4(dst, i);
            }
            center_ = center_ / 16f;
            updatevertices(mesh);
        }