Ejemplo n.º 1
0
        public static W3dBox Parse(BinaryReader reader)
        {
            var result = new W3dBox
            {
                Version = reader.ReadUInt32()
            };

            var flags = reader.ReadUInt32();

            result.BoxType        = (W3dBoxType)(flags & 0b11);
            result.CollisionTypes = (W3dBoxCollisionTypes)(flags & 0xFF0);

            result.Name   = reader.ReadFixedLengthString(W3dConstants.NameLength * 2);
            result.Color  = W3dRgb.Parse(reader);
            result.Center = reader.ReadVector3();
            result.Extent = reader.ReadVector3();

            return(result);
        }
Ejemplo n.º 2
0
        internal static W3dBox Parse(BinaryReader reader, W3dParseContext context)
        {
            return(ParseChunk(reader, context, header =>
            {
                var result = new W3dBox
                {
                    Version = reader.ReadUInt32()
                };

                var flags = reader.ReadUInt32();

                result.BoxType = (W3dBoxType)(flags & 0b11);
                result.CollisionTypes = (W3dBoxCollisionTypes)(flags & 0xFF0);

                result.Name = reader.ReadFixedLengthString(W3dConstants.NameLength * 2);
                result.Color = W3dRgb.Parse(reader);
                result.Center = reader.ReadVector3();
                result.Extent = reader.ReadVector3();

                return result;
            }));
Ejemplo n.º 3
0
        public static W3dVertexMaterial Parse(BinaryReader reader)
        {
            var rawAttributes = reader.ReadUInt32();

            var result = new W3dVertexMaterial
            {
                Attributes = (W3dVertexMaterialFlags)(rawAttributes & 0xF),

                Stage0Mapping = ConvertStageMapping(rawAttributes, 0x00FF0000, 16),
                Stage1Mapping = ConvertStageMapping(rawAttributes, 0x0000FF00, 8),

                Ambient  = W3dRgb.Parse(reader),
                Diffuse  = W3dRgb.Parse(reader),
                Specular = W3dRgb.Parse(reader),
                Emissive = W3dRgb.Parse(reader),

                Shininess    = reader.ReadSingle(),
                Opacity      = reader.ReadSingle(),
                Translucency = reader.ReadSingle()
            };

            return(result);
        }
Ejemplo n.º 4
0
        internal static W3dVertexMaterialInfo Parse(BinaryReader reader, W3dParseContext context)
        {
            return(ParseChunk(reader, context, header =>
            {
                var rawAttributes = reader.ReadUInt32();

                return new W3dVertexMaterialInfo
                {
                    Attributes = (W3dVertexMaterialFlags)(rawAttributes & 0xF),

                    Stage0Mapping = ConvertStageMapping(rawAttributes, 0x00FF0000, 16),
                    Stage1Mapping = ConvertStageMapping(rawAttributes, 0x0000FF00, 8),

                    Ambient = W3dRgb.Parse(reader),
                    Diffuse = W3dRgb.Parse(reader),
                    Specular = W3dRgb.Parse(reader),
                    Emissive = W3dRgb.Parse(reader),

                    Shininess = reader.ReadSingle(),
                    Opacity = reader.ReadSingle(),
                    Translucency = reader.ReadSingle()
                };
            }));
        }