Beispiel #1
0
        public SiFile(string name, GenericReader r)
        {
            Name               = name;
            MeshCount          = r.ReadUInt32();
            LodCount           = r.ReadUInt32();
            CylinderBaseCentre = r.ReadVector3();
            CylinderBaseHeight = r.ReadSingle();
            CylinderBaseRadius = r.ReadSingle();
            SphereCenter       = r.ReadVector3();
            SphereRadius       = r.ReadSingle();
            Unk1               = r.ReadSingle();
            MinBounds          = r.ReadVector3();
            MaxBounds          = r.ReadVector3();
            LodThreshold0      = r.ReadUInt32();
            LodThreshold1      = r.ReadUInt32();
            LodThreshold2      = r.ReadUInt32();
            LodThreshold3      = r.ReadUInt32();
            CenterOfMass       = r.ReadVector3();
            MassOrVolume       = r.ReadSingle();
            InertiaMatrix      = r.ReadRowMajorMatrix3x3();
            InertiaRelated     = r.ReadSingle();
            //
            var meshCount  = (int)(MeshCount * LodCount);
            var meshOffset = r.ReadTArray <uint>(meshCount * 4, meshCount);

            Meshes = new SiMesh[meshCount];
            for (var i = 0; i < meshOffset.Length; i++)
            {
                r.Position = meshOffset[i];
                Meshes[i]  = new SiMesh(r);
            }
        }
Beispiel #2
0
        GameObject InstantiateNiTriShape(SiMesh data, bool visual, bool collidable)
        {
            Assert(visual || collidable);
            var mesh = MeshLodDataToMesh(data.Lod);
            var obj  = new GameObject();

            if (visual)
            {
                obj.AddComponent <MeshFilter>().mesh = mesh;
                var materialProps = MeshLodDataToMaterialProperties(data.Lod);
                var meshRenderer  = obj.AddComponent <MeshRenderer>();
                meshRenderer.material = _materialManager.BuildMaterialFromProperties(materialProps);
                obj.isStatic          = true;
            }
            if (collidable)
            {
                obj.AddComponent <MeshCollider>().sharedMesh = mesh;
                if (KinematicRigidbodies)
                {
                    obj.AddComponent <Rigidbody>().isKinematic = true;
                }
            }
            return(obj);
        }
Beispiel #3
0
        GameObject InstantiateSiObject(SiMesh data)
        {
            var r = InstantiateNiTriShape(data, true, false);

            return(null);
        }
Beispiel #4
0
        GameObject InstantiateRootSiObject(SiMesh data)
        {
            var gameObject = InstantiateSiObject(data);

            return(gameObject);
        }