Exemplo n.º 1
0
        // Methods
        public override void Load(Stream fileStream)
        {
            // Header
            var reader = new GensReader(fileStream, true);

            Header = new GensHeader(reader);

            // Root Node
            uint lightType = reader.ReadUInt32();

            if (lightType < 0 || lightType > 1)
            {
                throw new InvalidDataException(
                          $"Cannot read light - unknown light type! ({lightType})");
            }

            // Data
            LightType = (LightTypes)lightType;

            Position = reader.ReadVector3();
            Color    = reader.ReadVector3();

            if (LightType == LightTypes.Omni)
            {
                UnknownTotal1 = reader.ReadUInt32();
                UnknownTotal2 = reader.ReadUInt32();
                UnknownTotal3 = reader.ReadUInt32();

                OmniInnerRange = reader.ReadSingle();
                OmniOuterRange = reader.ReadSingle();
            }
        }
        // Methods
        public override void Load(Stream fileStream)
        {
            // Header
            var reader = new GensReader(fileStream, true);

            Header = new GensHeader(reader);

            // Root Node
            uint instanceInfoCount         = reader.ReadUInt32();
            uint instanceInfoOffsetsOffset = reader.ReadUInt32();

            uint terrainModelCount         = reader.ReadUInt32();
            uint terrainModelOffsetsOffset = reader.ReadUInt32();

            // Instance Infos
            InstanceInfos = new InstanceInfoEntry[instanceInfoCount];
            reader.JumpTo(instanceInfoOffsetsOffset, false);

            for (uint i = 0; i < instanceInfoCount; ++i)
            {
                var  instanceInfo       = new InstanceInfoEntry();
                uint instanceInfoOffset = reader.ReadUInt32();
                long curPos             = reader.BaseStream.Position;
                reader.JumpTo(instanceInfoOffset, false);

                uint fileNameCount         = reader.ReadUInt32();
                uint fileNameOffsetsOffset = reader.ReadUInt32();
                uint boundingSphereOffset  = reader.ReadUInt32();
                reader.JumpTo(fileNameOffsetsOffset, false);

                // File Names
                instanceInfo.FileNames = new string[fileNameCount];
                for (uint i2 = 0; i2 < fileNameCount; ++i2)
                {
                    instanceInfo.FileNames[i2] = reader.GetString();
                }

                // Bounding Sphere
                reader.JumpTo(boundingSphereOffset, false);
                instanceInfo.BoundingSphereCenter = reader.ReadVector3();
                instanceInfo.BoundingSphereRadius = reader.ReadSingle();

                InstanceInfos[i]           = instanceInfo;
                reader.BaseStream.Position = curPos;
            }

            // Terrain Models
            TerrainModels = new string[terrainModelCount];
            reader.JumpTo(terrainModelOffsetsOffset, false);

            for (uint i = 0; i < terrainModelCount; ++i)
            {
                TerrainModels[i] = reader.GetString();
            }
        }
Exemplo n.º 3
0
        // Methods
        public override void Load(Stream fileStream)
        {
            // Header
            var reader = new GensReader(fileStream);

            Header = new GensHeader(reader);

            // Root Node
            uint groupCount         = reader.ReadUInt32();
            uint groupOffsetsOffset = reader.ReadUInt32();

            GroupEntries = new TerrainGroupEntry[groupCount];

            // Group Offsets
            var groupOffsets = new uint[groupCount];

            reader.JumpTo(groupOffsetsOffset, false);

            for (uint i = 0; i < groupCount; ++i)
            {
                groupOffsets[i] = reader.ReadUInt32();
            }

            // Groups
            for (uint i = 0; i < groupCount; ++i)
            {
                var group = new TerrainGroupEntry();
                reader.JumpTo(groupOffsets[i], false);

                // Entry
                uint centerPosOffset = reader.ReadUInt32();
                uint fileNameOffset  = reader.ReadUInt32();
                group.UncompressedGroupSize = reader.ReadUInt32();
                uint sphereCount         = reader.ReadUInt32();
                uint sphereOffsetsOffset = reader.ReadUInt32();
                group.SubsetID = reader.ReadUInt32();

                // Center position
                reader.JumpTo(centerPosOffset, false);
                group.CenterPosition = reader.ReadVector3();
                group.CenterRadius   = reader.ReadSingle();

                // FileName
                reader.JumpTo(fileNameOffset, false);
                group.FileName = reader.ReadNullTerminatedString();

                // Sphere Offsets
                var sphereOffsets = new uint[sphereCount];
                reader.JumpTo(sphereOffsetsOffset, false);

                for (uint i2 = 0; i2 < sphereCount; ++i2)
                {
                    sphereOffsets[i2] = reader.ReadUInt32();
                }

                // Spheres
                var spheres = new TerrainSphere[sphereCount];
                for (uint i2 = 0; i2 < sphereCount; ++i2)
                {
                    reader.JumpTo(sphereOffsets[i2], false);
                    spheres[i2] = new TerrainSphere()
                    {
                        Center       = reader.ReadVector3(),
                        CenterRadius = reader.ReadSingle()
                    };
                }

                group.Spheres   = spheres;
                GroupEntries[i] = group;
            }
        }