Exemple #1
0
 public override void Awake()
 {
     base.Awake();
     if (boneIds != null && bones == null)
     {
         bones = new Transform[boneIds.Length];
         bindPoses = new Matrix[boneIds.Length];
         for (int i = 0; i < boneIds.Length; i++)
         {
             bones[i] = transform.parent.FindChild("//" + boneIds[i]);
             if (bones[i] == null)
             {
                 Debug.LogError(string.Format("The bone {0} did not exist for the renderer {1}.", boneIds[i], this));
             }
         }
     }
     animation = GetComponentInParents<Animation>();
     // Get a local mesh copy that we can molest
     mesh = (Mesh)sharedMesh.Clone();
 }
Exemple #2
0
 private static void CloneTo(Mesh from, Mesh to)
 {
     if (from._vertices.HasElements())
     {
         to._vertices = (Microsoft.Xna.Framework.Vector3[])from._vertices.Clone();
     }
     if (from._normals.HasElements())
     {
         to._normals = (Microsoft.Xna.Framework.Vector3[])from._normals.Clone();
     }
     if (from._uv.HasElements())
     {
         to._uv = (Microsoft.Xna.Framework.Vector2[])from._uv.Clone();
     }
     if (from._uv2.HasElements())
     {
         to._uv2 = (Microsoft.Xna.Framework.Vector2[])from._uv2.Clone();
     }
     if (from.tangents.HasElements())
     {
         to.tangents = (Vector4[])from.tangents.Clone();
     }
     if (from.triangles.HasElements())
     {
         to.triangles = (short[])from.triangles.Clone();
     }
     if (from.triangleSets.HasElements())
     {
         to.triangleSets = (short[][])from.triangleSets.Clone();
     }
     to.bounds = from.bounds;
     // Note that these are not actually cloned as they will not be changed
     to.boneWeights = from.boneWeights;
     to.bindPoses = from.bindPoses;
 }
Exemple #3
0
 internal override UnityObject Clone()
 {
     Mesh clone = new Mesh();
     CloneTo(this, clone);
     return clone;
 }