Exemplo n.º 1
0
        private static U3DPhysxMesh GeneratePhysxConvexMeshCollider(int id, MeshCollider mesh_col)
        {
            U3DPhysxMesh mesh = new U3DPhysxMesh();

            mesh.id   = id;
            mesh.type = ColliderType.MESH;

            mesh.vertex_count = mesh_col.sharedMesh.vertexCount;
            for (int i = 0; i < mesh_col.sharedMesh.vertexCount; ++i)
            {
                killer.proto.Vector3 new_vertice = new killer.proto.Vector3();
                //consider scale
                new_vertice.x = mesh_col.sharedMesh.vertices[i].x * mesh_col.transform.localScale.x;
                new_vertice.y = mesh_col.sharedMesh.vertices[i].y * mesh_col.transform.localScale.y;
                new_vertice.z = mesh_col.sharedMesh.vertices[i].z * mesh_col.transform.localScale.z;

                mesh.vertices.Add(new_vertice);
            }

            //BUG:这里还差一个rotate

            Debug.Log("Mesh ID: " + mesh.id);
            Debug.Log("Mesh Vertex num: " + mesh.vertex_count);

            return(mesh);
        }
Exemplo n.º 2
0
        private static U3DPhysxMesh GeneratePhysxConvexMeshCollider(int id, MeshCollider mesh_col)
        {
            U3DPhysxMesh mesh = new U3DPhysxMesh();

            mesh.id   = id;
            mesh.type = ColliderType.MESH;

            mesh.vertex_count = mesh_col.sharedMesh.vertexCount;
            for (int i = 0; i < mesh_col.sharedMesh.vertexCount; ++i)
            {
                Position new_vertice = new Position();
                new_vertice.x = mesh_col.sharedMesh.vertices[i].x;
                new_vertice.y = mesh_col.sharedMesh.vertices[i].y;
                new_vertice.z = mesh_col.sharedMesh.vertices[i].z;

                mesh.vertices.Add(new_vertice);
            }

            Debug.Log("Mesh ID: " + mesh.id);
            Debug.Log("Mesh Vertex num: " + mesh.vertex_count);

            return(mesh);
        }