Esempio n. 1
0
 internal IndexedTriList(SBR block)
 {
     block.VerifyID(TokenID.Indexed_TriList);
     VertexIndices = new VertexIndices(block.ReadSubBlock());
     {
         SBR subBlock = block.ReadSubBlock();
         subBlock.VerifyID(TokenID.Normal_Idxs);
         NormalIndices = new int[subBlock.ReadInt()];
         for (int i = 0; i < NormalIndices.Length; ++i)
         {
             NormalIndices[i] = subBlock.ReadInt();
             subBlock.ReadInt(); // skip the '3' value - its purpose unknown
         }
         subBlock.VerifyEndOfBlock();
     }
     {
         SBR subBlock = block.ReadSubBlock();
         subBlock.VerifyID(TokenID.Flags);
         Flags = new uint[subBlock.ReadInt()];
         for (int i = 0; i < Flags.Length; ++i)
         {
             Flags[i] = subBlock.ReadFlags();
         }
         subBlock.VerifyEndOfBlock();
     }
     block.VerifyEndOfBlock();
 }
Esempio n. 2
0
 public GeometryInfo(SBR block)
 {
     block.VerifyID(TokenID.Geometry_Info);
     FaceNormals         = block.ReadInt();
     TextureLightCmds    = block.ReadInt();
     NodeXTriListIndices = block.ReadInt();
     TriListIndices      = block.ReadInt();
     LineListIndices     = block.ReadInt();
     NodeXTriListIndices = block.ReadInt();
     TriLists            = block.ReadInt();
     LineLists           = block.ReadInt();
     PointLists          = block.ReadInt();
     NodeXTriLists       = block.ReadInt();
     GeometryNodes       = new GeometryNodes(block.ReadSubBlock());
     {
         var subBlock = block.ReadSubBlock();
         subBlock.VerifyID(TokenID.Geometry_Node_Map);
         GeometryNodeMap = new int[subBlock.ReadInt()];
         for (var i = 0; i < GeometryNodeMap.Length; ++i)
         {
             GeometryNodeMap[i] = subBlock.ReadInt();
         }
         subBlock.VerifyEndOfBlock();
     }
     block.VerifyEndOfBlock();
 }
Esempio n. 3
0
 private void ReadTrackItemId(SBR block)
 {
     block.VerifyID(TokenID.TrItemId);
     block.ReadInt();    //don't mind the database id, should be 0 always (TrackDB)
     ItemId = block.ReadInt();
     block.VerifyEndOfBlock();
 }
Esempio n. 4
0
        public PrimaryState(SBR block)
        {
            block.VerifyID(TokenID.Prim_State);

            Name = block.Label;

            Flags       = block.ReadFlags();
            ShaderIndex = block.ReadInt();
            {
                var subBlock = block.ReadSubBlock();
                subBlock.VerifyID(TokenID.Tex_Idxs);
                TextureIndices = new int[subBlock.ReadInt()];
                for (var i = 0; i < TextureIndices.Length; ++i)
                {
                    TextureIndices[i] = subBlock.ReadInt();
                }
                subBlock.VerifyEndOfBlock();
            }
            ZBias            = block.ReadFloat();
            VertexStateIndex = block.ReadInt();
            AlphaTestMode    = block.ReadInt();
            LightConfigIndex = block.ReadInt();
            ZBufferMode      = block.ReadInt();
            block.VerifyEndOfBlock();
        }
Esempio n. 5
0
        internal PatchSet(SBR block)
        {
            block.VerifyID(TokenID.Terrain_PatchSet);
            while (!block.EndOfBlock())
            {
                using (SBR subBlock = block.ReadSubBlock())
                {
                    switch (subBlock.ID)
                    {
                    case TokenID.Terrain_PatchSet_Distance:
                        Distance = subBlock.ReadInt();
                        break;

                    case TokenID.Terrain_PatchSet_NPatches:
                        PatchSize = subBlock.ReadInt();
                        break;

                    case TokenID.Terrain_PatchSet_Patches:
                        Patches = new List <Patch>(PatchSize * PatchSize);
                        for (int i = 0; i < (PatchSize * PatchSize); ++i)
                        {
                            Patches.Add(new Patch(subBlock.ReadSubBlock()));
                        }
                        break;
                    }
                }
            }
        }
Esempio n. 6
0
 public UVOperationCopy(SBR block)
 {
     block.VerifyID(TokenID.UV_OP_Copy);
     TextureAddressMode = block.ReadInt();
     SourceUVIndex      = block.ReadInt();
     block.VerifyEndOfBlock();
 }
Esempio n. 7
0
 public CullablePrims(SBR block)
 {
     block.VerifyID(TokenID.Cullable_Prims);
     NumPrims        = block.ReadInt();
     NumFlatSections = block.ReadInt();
     NumPrimIndices  = block.ReadInt();
     block.VerifyEndOfBlock();
 }
Esempio n. 8
0
 public VertexSet(SBR block)
 {
     block.VerifyID(TokenID.Vertex_Set);
     VertexStateIndex = block.ReadInt();
     StartVertexIndex = block.ReadInt();
     VertexCount      = block.ReadInt();
     block.VerifyEndOfBlock();
 }
Esempio n. 9
0
        }                                                             // :anim_nodes,AnimNodes .

        public Animation(SBR block)
        {
            block.VerifyID(TokenID.Animation);
            FrameCount     = block.ReadInt();
            FrameRate      = block.ReadInt();
            AnimationNodes = new AnimationNodes(block.ReadSubBlock());
            block.VerifyEndOfBlock();
        }
Esempio n. 10
0
 public terrain_uvcalc(SBR block)
 {
     block.VerifyID(TokenID.terrain_uvcalc);
     A = block.ReadInt();
     B = block.ReadInt();
     C = block.ReadInt();
     D = block.ReadInt();
 }
Esempio n. 11
0
 public terrain_texslot(SBR block)
 {
     block.VerifyID(TokenID.terrain_texslot);
     Filename = block.ReadString();
     A        = block.ReadInt();
     B        = block.ReadInt();
     block.Skip();
 }
Esempio n. 12
0
 internal UVCalc(SBR block)
 {
     block.VerifyID(TokenID.Terrain_UVCalc);
     A = block.ReadInt();
     B = block.ReadInt();
     C = block.ReadInt();
     D = (int)block.ReadFloat();
 }
Esempio n. 13
0
 internal TextureSlot(SBR block)
 {
     block.VerifyID(TokenID.Terrain_TexSlot);
     FileName = block.ReadString();
     A        = block.ReadInt();
     B        = block.ReadInt();
     block.Skip();
 }
Esempio n. 14
0
 public UVOperationUniformScale(SBR block)
 {
     block.VerifyID(TokenID.UV_Op_UniformScale);
     TextureAddressMode = block.ReadInt();
     SourceUVIndex      = block.ReadInt();
     UnknownParameter3  = block.ReadFloat();
     block.VerifyEndOfBlock();
     block.TraceInformation(String.Format("{0} was treated as uv_op_copy", block.ID.ToString()));
 }
Esempio n. 15
0
 internal UVOperationUniformScale(SBR block)
 {
     block.VerifyID(TokenID.UV_Op_UniformScale);
     TextureAddressMode = block.ReadInt();
     SourceUVIndex      = block.ReadInt();
     UnknownParameter3  = block.ReadFloat();
     block.VerifyEndOfBlock();
     block.TraceInformation($"{block.ID} was treated as uv_op_copy");
 }
Esempio n. 16
0
        private void ReadCrossingData(SBR block)
        {
            block.VerifyID(TokenID.LevelCrData);
            int data = block.ReadInt();

            block.ReadInt();    // not used and not known
            block.VerifyEndOfBlock();

            Visible = (data & 0x1) == 0;
            Silent  = !Visible || (data & 0x6) == 0x6;
        }
Esempio n. 17
0
 public LightMaterial(SBR block)
 {
     block.VerifyID(TokenID.Light_Material);
     Flags              = block.ReadFlags();
     DiffuseColorIndex  = block.ReadInt();
     AmbientColorIndex  = block.ReadInt();
     SpecularColorIndex = block.ReadInt();
     EmissiveColorIndex = block.ReadInt();
     SpecPower          = block.ReadFloat();
     block.VerifyEndOfBlock();
 }
Esempio n. 18
0
 public GeometryNode(SBR block)
 {
     block.VerifyID(TokenID.Geometry_Node);
     TextureLightCmds      = block.ReadInt();
     NodeXTextureLightCmds = block.ReadInt();
     TriLists      = block.ReadInt();
     LineLists     = block.ReadInt();
     PointLists    = block.ReadInt();
     CullablePrims = new CullablePrims(block.ReadSubBlock());
     block.VerifyEndOfBlock();
 }
Esempio n. 19
0
 public Texture(SBR block)
 {
     block.VerifyID(TokenID.Texture);
     ImageIndex    = block.ReadInt();
     FilterMode    = block.ReadInt();
     MipMapLODBias = block.ReadFloat();
     if (!block.EndOfBlock())
     {
         BorderColor = block.ReadFlags();
     }
     block.VerifyEndOfBlock();
 }
Esempio n. 20
0
 internal void Add(SBR block)
 {
     block.VerifyID(TokenID.TrItemId);
     if (block.ReadInt() == 0)
     {
         TrackDbItems.Add(block.ReadInt());
     }
     else
     {
         RoadDbItems.Add(block.ReadInt());
     }
     block.VerifyEndOfBlock();
 }
Esempio n. 21
0
 public VertexState(SBR block)
 {
     block.VerifyID(TokenID.Vtx_State);
     Flags            = block.ReadFlags();
     MatrixIndex      = block.ReadInt();
     LightMatrixIndex = block.ReadInt();
     LightConfigIndex = block.ReadInt();
     LightFlags       = block.ReadFlags();
     if (!block.EndOfBlock())
     {
         Matrix2 = block.ReadInt();
     }
     block.VerifyEndOfBlock();
 }
Esempio n. 22
0
        public UVOperations(SBR block)
        {
            block.VerifyID(TokenID.UV_Ops);
            var count = Capacity = block.ReadInt();

            while (count-- > 0)
            {
                var subBlock = block.ReadSubBlock();
                switch (subBlock.ID)
                {
                case TokenID.UV_OP_Copy: Add(new UVOperationCopy(subBlock)); break;

                case TokenID.UV_Op_ReflectMapFull: Add(new UVOperationReflectMapFull(subBlock)); break;

                case TokenID.UV_Op_Reflectmap: Add(new UVOperationReflectMap(subBlock)); break;

                case TokenID.UV_Op_UniformScale: this.Add(new UVOperationUniformScale(subBlock)); break;

                case TokenID.UV_Op_NonUniformScale: this.Add(new UVOperationNonUniformScale(subBlock)); break;

                default: throw new System.Exception("Unexpected uv_op: " + subBlock.ID.ToString());
                }
            }
            block.VerifyEndOfBlock();
        }
Esempio n. 23
0
 public LinearKey(SBR block)
 {
     block.VerifyID(TokenID.Linear_Key);
     Frame    = block.ReadInt();
     position = new Vector3(block.ReadFloat(), block.ReadFloat(), -block.ReadFloat());
     block.VerifyEndOfBlock();
 }
Esempio n. 24
0
 public SlerpRotation(SBR block)
 {
     block.VerifyID(TokenID.Slerp_Rot);
     Frame      = block.ReadInt();
     quaternion = new Quaternion(block.ReadFloat(), block.ReadFloat(), -block.ReadFloat(), block.ReadFloat());
     block.VerifyEndOfBlock();
 }
Esempio n. 25
0
        internal UVOperations(SBR block)
        {
            block.VerifyID(TokenID.UV_Ops);
            int count = Capacity = block.ReadInt();

            while (count-- > 0)
            {
                SBR subBlock = block.ReadSubBlock();
                switch (subBlock.ID)
                {
                case TokenID.UV_OP_Copy: Add(new UVOperationCopy(subBlock)); break;

                case TokenID.UV_Op_ReflectMapFull: Add(new UVOperationReflectMapFull(subBlock)); break;

                case TokenID.UV_Op_Reflectmap: Add(new UVOperationReflectMap(subBlock)); break;

                case TokenID.UV_Op_UniformScale: Add(new UVOperationUniformScale(subBlock)); break;

                case TokenID.UV_Op_NonUniformScale: Add(new UVOperationNonUniformScale(subBlock)); break;

                default: throw new InvalidDataException($"Unexpected uv_op: {subBlock.ID}");
                }
            }
            block.VerifyEndOfBlock();
        }
Esempio n. 26
0
        internal Samples(SBR block)
        {
            block.VerifyID(TokenID.Terrain_Samples);
            while (!block.EndOfBlock())
            {
                using (SBR subBlock = block.ReadSubBlock())
                {
                    switch (subBlock.ID)
                    {
                    case TokenID.Terrain_NSamples:
                        SampleCount = subBlock.ReadInt();
                        break;

                    case TokenID.Terrain_Sample_Rotation:
                        SampleRotation = subBlock.ReadFloat();
                        break;

                    case TokenID.Terrain_Sample_Floor:
                        SampleFloor = subBlock.ReadFloat();
                        break;

                    case TokenID.Terrain_Sample_Scale:
                        SampleScale = subBlock.ReadFloat();
                        break;

                    case TokenID.Terrain_Sample_Size:
                        SampleSize = subBlock.ReadFloat();
                        break;

                    case TokenID.Terrain_Sample_YBuffer:
                        SampleBufferY = subBlock.ReadString();
                        break;

                    case TokenID.Terrain_Sample_EBuffer:
                        SampleBufferE = subBlock.ReadString();
                        break;

                    case TokenID.Terrain_Sample_NBuffer:
                        SampleBufferN = subBlock.ReadString();
                        break;

                    case TokenID.Terrain_Sample_AsBuffer:
                        subBlock.Skip();     // TODO parse this
                        break;

                    case TokenID.Terrain_Sample_FBuffer:
                        subBlock.Skip();     // TODO parse this
                        break;

                    case (TokenID)282:      // TODO figure out what this is and handle it
                        subBlock.Skip();
                        break;

                    default:
                        throw new InvalidDataException("Unknown token " + subBlock.ID.ToString());
                    }
                }
            }
        }
Esempio n. 27
0
        internal Terrain(SBR block)
        {
            block.VerifyID(TokenID.Terrain);
            while (!block.EndOfBlock())
            {
                using (SBR subBlock = block.ReadSubBlock())
                {
                    switch (subBlock.ID)
                    {
                    case TokenID.Terrain_ErrThreshold_Scale:
                        ErrorThresholdScale = subBlock.ReadFloat();
                        break;

                    case TokenID.Terrain_Water_Height_Offset:
                        WaterLevelOffset = new WaterLevelOffset(subBlock);
                        break;

                    case TokenID.Terrain_AlwaysSelect_MaxDist:
                        AlwaysSelectMaxDistance = subBlock.ReadFloat();
                        break;

                    case TokenID.Terrain_Samples:
                        Samples = new Samples(subBlock);
                        break;

                    case TokenID.Terrain_Shaders:
                        Shaders = new Shader[subBlock.ReadInt()];
                        for (int i = 0; i < Shaders.Length; ++i)
                        {
                            using (SBR terrain_shadersBlock = subBlock.ReadSubBlock())
                                Shaders[i] = new Shader(terrain_shadersBlock);
                        }
                        if (!subBlock.EndOfBlock())
                        {
                            subBlock.Skip();
                        }
                        break;

                    case TokenID.Terrain_Patches:
                        using (SBR patch_sets_Block = subBlock.ReadSubBlock())
                        {
                            Patchsets = new PatchSet[patch_sets_Block.ReadInt()];
                            for (int i = 0; i < Patchsets.Length; ++i)
                            {
                                using (SBR terrain_patchsetBlock = patch_sets_Block.ReadSubBlock())
                                    Patchsets[i] = new PatchSet(terrain_patchsetBlock);
                            }
                            if (!subBlock.EndOfBlock())
                            {
                                subBlock.Skip();
                            }
                        }
                        break;
                    }
                }
            }
        }
Esempio n. 28
0
        public SubObjectHeader(SBR block)
        {
            block.VerifyID(TokenID.Sub_Object_Header);

            Flags                        = block.ReadFlags();
            SortVectorIndex              = block.ReadInt();
            VolumeIndex                  = block.ReadInt();
            SourceVertexFormatFlags      = block.ReadFlags();
            DestinationVertexFormatFlags = block.ReadFlags();
            GeometryInfo                 = new GeometryInfo(block.ReadSubBlock());

            if (!block.EndOfBlock())
            {
                var subBlock = block.ReadSubBlock();
                subBlock.VerifyID(TokenID.SubObject_Shaders);
                SubObjectShaders = new int[subBlock.ReadInt()];
                for (var i = 0; i < SubObjectShaders.Length; ++i)
                {
                    SubObjectShaders[i] = subBlock.ReadInt();
                }
                subBlock.VerifyEndOfBlock();
            }

            if (!block.EndOfBlock())
            {
                var subBlock = block.ReadSubBlock();
                subBlock.VerifyID(TokenID.SubObject_Light_Cfgs);
                SubObjectLightConfigs = new int[subBlock.ReadInt()];
                for (var i = 0; i < SubObjectLightConfigs.Length; ++i)
                {
                    SubObjectLightConfigs[i] = subBlock.ReadInt();
                }
                subBlock.VerifyEndOfBlock();
            }

            if (!block.EndOfBlock())
            {
                SubObjectID = block.ReadInt();
            }

            block.VerifyEndOfBlock();
        }
Esempio n. 29
0
        public SubObjects(SBR block)
        {
            block.VerifyID(TokenID.Sub_Objects);
            var count = Capacity = block.ReadInt();

            while (count-- > 0)
            {
                Add(new SubObject(block.ReadSubBlock()));
            }
            block.VerifyEndOfBlock();
        }
Esempio n. 30
0
        public DistanceLevels(SBR block)
        {
            block.VerifyID(TokenID.Distance_Levels);
            var count = Capacity = block.ReadInt();

            while (count-- > 0)
            {
                Add(new DistanceLevel(block.ReadSubBlock()));
            }
            block.VerifyEndOfBlock();
        }