示例#1
0
        protected override SolidMeshVertex GetVertex(BinaryReader reader, SolidObjectMaterial material, int stride)
        {
            MostWantedMaterial mwm    = (MostWantedMaterial)material;
            SolidMeshVertex    vertex = new SolidMeshVertex();

            InternalEffectID id = (InternalEffectID)mwm.EffectId;

            switch (id)
            {
            case InternalEffectID.WorldNormalMap:
            case InternalEffectID.WorldReflectShader:
                vertex.Position             = BinaryUtil.ReadVector3(reader);
                vertex.Normal               = BinaryUtil.ReadVector3(reader);
                vertex.Color                = reader.ReadUInt32();
                vertex.TexCoords            = BinaryUtil.ReadVector2(reader);
                reader.BaseStream.Position += 8;     // TODO: What's this additional D3DDECLUSAGE_TEXCOORD element?
                vertex.Tangent              = BinaryUtil.ReadVector3(reader);
                reader.BaseStream.Position += 4;     // skip W component of tangent vector
                break;

            case InternalEffectID.skyshader:
                vertex.Position             = BinaryUtil.ReadVector3(reader);
                vertex.Normal               = BinaryUtil.ReadVector3(reader);
                vertex.Color                = reader.ReadUInt32();
                vertex.TexCoords            = BinaryUtil.ReadVector2(reader);
                reader.BaseStream.Position += 8;     // TODO: What's this additional D3DDECLUSAGE_TEXCOORD element?
                break;

            case InternalEffectID.WorldShader:
            case InternalEffectID.GlossyWindow:
            case InternalEffectID.billboardshader:
            case InternalEffectID.CarShader:
                vertex.Position  = BinaryUtil.ReadVector3(reader);
                vertex.Normal    = BinaryUtil.ReadVector3(reader);
                vertex.Color     = reader.ReadUInt32();
                vertex.TexCoords = BinaryUtil.ReadVector2(reader);
                break;

            default:
                throw new Exception($"Unsupported effect in object {Name}: {id}");
            }

            return(vertex);
        }
示例#2
0
        protected override SolidMeshVertex GetVertex(BinaryReader reader, SolidObjectMaterial material, int stride)
        {
            World15Material wm     = (World15Material)material;
            SolidMeshVertex vertex = new SolidMeshVertex();

            InternalEffectID id = (InternalEffectID)wm.EffectId;

            switch (id)
            {
            case InternalEffectID.WorldShader:
            case InternalEffectID.GLASS_REFLECT:
            case InternalEffectID.WorldZBiasShader:
            case InternalEffectID.Tree:
            case InternalEffectID.WATER:
                vertex.Position  = BinaryUtil.ReadVector3(reader);
                vertex.Normal    = BinaryUtil.ReadNormal(reader, true);
                vertex.TexCoords = BinaryUtil.ReadVector2(reader);
                vertex.Color     = reader.ReadUInt32(); // daytime color
                reader.ReadUInt32();                    // nighttime color
                break;

            case InternalEffectID.WorldPrelitShader:
                vertex.Position = BinaryUtil.ReadVector3(reader);
                vertex.Color    = reader.ReadUInt32(); // daytime color
                reader.ReadUInt32();                   // nighttime color
                vertex.TexCoords = BinaryUtil.ReadVector2(reader);
                break;

            case InternalEffectID.WorldZBiasPrelitShader:
                vertex.Position = BinaryUtil.ReadVector3(reader);
                vertex.Normal   = BinaryUtil.ReadNormal(reader, true);
                vertex.Color    = reader.ReadUInt32(); // daytime color
                reader.ReadUInt32();                   // nighttime color
                vertex.TexCoords = BinaryUtil.ReadVector2(reader);
                break;

            case InternalEffectID.WorldNormalMap:
            case InternalEffectID.GLASS_REFLECTNM:
            case InternalEffectID.WorldRoadShader:
            case InternalEffectID.WorldFEShader:
                vertex.Position  = BinaryUtil.ReadVector3(reader);
                vertex.Normal    = BinaryUtil.ReadNormal(reader, true);
                vertex.TexCoords = BinaryUtil.ReadVector2(reader);
                vertex.Color     = reader.ReadUInt32(); // daytime color
                reader.ReadUInt32();                    // nighttime color
                vertex.Tangent = BinaryUtil.ReadNormal(reader, true);
                break;

            case InternalEffectID.CarShader:
            case InternalEffectID.CARNORMALMAP:
                vertex.Position  = BinaryUtil.ReadNormal(reader, true) * 8;
                vertex.TexCoords = new Vector2(reader.ReadInt16() / 4096f, reader.ReadInt16() / 4096f - 1);
                vertex.Color     = reader.ReadUInt32();
                vertex.Normal    = BinaryUtil.ReadNormal(reader, true);
                vertex.Tangent   = BinaryUtil.ReadNormal(reader, true);
                break;

            default:
                throw new Exception($"Unsupported effect in object {Name}: {id}");
            }

            return(vertex);
        }