コード例 #1
0
 public void ResetMorph(GameObject gao)
 {
     // First, reset vertex buffer
     if (Settings.s.platform == Settings.Platform.N64)
     {
         foreach (GeometricObjectElementVisualList.GeometricElementListEntry entry in elementsVisual.Value.elements)
         {
             if (entry.element.Value is GeometricObjectElementTriangles)
             {
                 GeometricObjectElementTriangles el = entry.element.Value as GeometricObjectElementTriangles;
                 el.ResetVertexBuffer();
             }
         }
     }
     for (int i = 0; i < num_elementsVisual; i++)
     {
         ROMStruct entry1 = elementsVisual.Value.elements[i].element.Value;
         if (entry1 != null && entry1 is GeometricObjectElementTriangles)
         {
             GeometricObjectElementTriangles tris1 = entry1 as GeometricObjectElementTriangles;
             MeshFilter[] mfs = gao.GetComponentsInChildren <MeshFilter>();
             MeshFilter   mf  = mfs.FirstOrDefault(m => m.name == "ElementTriangles @ " + tris1.Offset);
             if (mf != null)
             {
                 tris1.ResetMorph(mf.sharedMesh, this);
                 //mf.mesh.RecalculateNormals();
             }
         }
     }
 }
コード例 #2
0
        public GameObject GetGameObject(Type type, CollideType collideType = CollideType.None)
        {
            GameObject gao = new GameObject("GeometricObject @ " + Offset);

            if (type == Type.Visual)
            {
                gao.layer = LayerMask.NameToLayer("Visual");
            }
            else
            {
                gao.layer = LayerMask.NameToLayer("Collide");
            }
            gao.name = gao.name + " - S0:" + scaleFactor
                       + " - S1:" + factor_1
                       + " - U0:" + string.Format("{0:X4}", unk0)
                       + " - U1:" + string.Format("{0:X4}", unk1)
                       + " - U2:" + string.Format("{0:X4}", hasVertexColors)
                       + " - U3:" + string.Format("{0:X4}", lookAtMode);
            MapLoader l = MapLoader.Loader;

            if (type == Type.Visual)
            {
                if (elementsVisual.Value != null)
                {
                    // First, reset vertex buffer
                    if (Settings.s.platform == Settings.Platform.N64)
                    {
                        foreach (GeometricObjectElementVisualList.GeometricElementListEntry entry in elementsVisual.Value.elements)
                        {
                            if (entry.element.Value is GeometricObjectElementTriangles)
                            {
                                GeometricObjectElementTriangles el = entry.element.Value as GeometricObjectElementTriangles;
                                el.ResetVertexBuffer();
                            }
                        }
                    }
                    //gao.transform.position = new Vector3(UnityEngine.Random.Range(-100f, 100f), UnityEngine.Random.Range(-100f, 100f), UnityEngine.Random.Range(-100f, 100f));
                    foreach (GeometricObjectElementVisualList.GeometricElementListEntry entry in elementsVisual.Value.elements)
                    {
                        /*if (entry.element.Value == null) {
                         *      l.print("Visual element null: " + entry.element.type);
                         * }*/
                        if (entry.element.Value != null)
                        {
                            GameObject child = null;
                            if (entry.element.Value is GeometricObjectElementTriangles)
                            {
                                GeometricObjectElementTriangles el = entry.element.Value as GeometricObjectElementTriangles;
                                child = el.GetGameObject(type, this);
                            }
                            else if (entry.element.Value is GeometricObjectElementSprites)
                            {
                                GeometricObjectElementSprites el = entry.element.Value as GeometricObjectElementSprites;
                                child = el.GetGameObject(type, this);
                            }
                            if (child != null)
                            {
                                child.transform.SetParent(gao.transform);
                                child.transform.localPosition = Vector3.zero;
                            }
                        }
                    }
                }
                if (lookAtMode != 0)
                {
                    BillboardBehaviour billboard = gao.AddComponent <BillboardBehaviour>();
                    billboard.mode = (BillboardBehaviour.LookAtMode)lookAtMode;
                }
            }
            else
            {
                if (elementsCollide.Value != null)
                {
                    foreach (GeometricObjectElementCollideList.GeometricElementListEntry entry in elementsCollide.Value.elements)
                    {
                        if (entry.element.Value == null)
                        {
                            l.print("Collide element null: " + entry.element.type);
                        }
                        if (entry.element.Value != null)
                        {
                            GameObject child = null;
                            if (entry.element.Value is GeometricObjectElementCollideTriangles)
                            {
                                GeometricObjectElementCollideTriangles el = entry.element.Value as GeometricObjectElementCollideTriangles;
                                child = el.GetGameObject(type, this, collideType: collideType);
                            }
                            else if (entry.element.Value is GeometricObjectElementCollideSpheres)
                            {
                                GeometricObjectElementCollideSpheres el = entry.element.Value as GeometricObjectElementCollideSpheres;
                                child = el.GetGameObject(type, this, collideType: collideType);
                            }
                            else if (entry.element.Value is GeometricObjectElementCollideAlignedBoxes)
                            {
                                GeometricObjectElementCollideAlignedBoxes el = entry.element.Value as GeometricObjectElementCollideAlignedBoxes;
                                child = el.GetGameObject(type, this, collideType: collideType);
                            }
                            if (child != null)
                            {
                                child.transform.SetParent(gao.transform);
                                child.transform.localPosition = Vector3.zero;
                            }
                        }
                    }
                }
            }
            return(gao);
        }