Exemplo n.º 1
0
        private static Mesh RemoveRotation(Mesh mesh, Matrix4x4 targetRotationMatrix, bool merge)
        {
            Mesh[]            meshes           = MeshUtils.Separate(mesh);
            CombineInstance[] combineInstances = new CombineInstance[meshes.Length];
            for (int i = 0; i < meshes.Length; ++i)
            {
                CombineInstance removeRotation = new CombineInstance();
                removeRotation.mesh         = meshes[i];
                removeRotation.subMeshIndex = 0;
                removeRotation.transform    = targetRotationMatrix;
                combineInstances[i]         = removeRotation;
            }

            //got final mesh without rotation
            mesh = new Mesh();
            mesh.CombineMeshes(combineInstances, merge);
            mesh.RecalculateBounds();
            return(mesh);
        }
Exemplo n.º 2
0
        private static List <Mesh> GetColliderMeshes(GameObject obj)
        {
            List <Mesh> meshes = new List <Mesh>();

            Collider[] allColliders = obj.GetComponents <Collider>();

            if (allColliders.Length == 0)
            {
                MeshFilter f = obj.GetComponent <MeshFilter>();
                if (f != null)
                {
                    //UNCOMMENT TO INCLUDE OBJECT MESH TO COLLIDER
                    //meshes.AddRange(Separate(f.sharedMesh));
                }
            }
            else
            {
                for (int i = 0; i < allColliders.Length; ++i)
                {
                    MeshCollider meshCollider = allColliders[i] as MeshCollider;
                    if (meshCollider != null)
                    {
                        meshes.AddRange(MeshUtils.Separate(meshCollider.sharedMesh));
                    }
                    else
                    {
                        //Use object's mesh if there is no meshcollider
                        MeshFilter f = obj.GetComponent <MeshFilter>();
                        if (f != null)
                        {
                            meshes.AddRange(MeshUtils.Separate(f.sharedMesh));
                        }
                    }
                }
            }

            return(meshes);
        }
Exemplo n.º 3
0
 public void ToCenterOffMass()
 {
     transform.position = MeshUtils.CenterOfMass(m_origin.Target.gameObject);
 }
Exemplo n.º 4
0
 public void ToBoundsCenter()
 {
     transform.position = MeshUtils.BoundsCenter(m_origin.Target.gameObject);
 }
Exemplo n.º 5
0
 public static void SaveMesh()
 {
     GameObject[] selectedObjects = Selection.gameObjects;
     MeshUtils.SaveMesh(selectedObjects, "Battlehub/");
 }