コード例 #1
0
        private static Face ReadFace(GenericStructure side, IDGenerator generator)
        {
            var id = side.PropertyLong("id");

            if (id == 0)
            {
                id = generator.GetNextFaceID();
            }
            var dispinfo = side.GetChildren("dispinfo").FirstOrDefault();
            var ret      = dispinfo != null?ReadDisplacement(id, dispinfo) : new Face(id);

            // id, plane, material, uaxis, vaxis, rotation, lightmapscale, smoothing_groups
            var uaxis = side.PropertyTextureAxis("uaxis");
            var vaxis = side.PropertyTextureAxis("vaxis");

            ret.Texture.Name     = side["material"];
            ret.Texture.UAxis    = uaxis.Item1;
            ret.Texture.XShift   = uaxis.Item2;
            ret.Texture.XScale   = uaxis.Item3;
            ret.Texture.VAxis    = vaxis.Item1;
            ret.Texture.YShift   = vaxis.Item2;
            ret.Texture.YScale   = vaxis.Item3;
            ret.Texture.Rotation = side.PropertyDecimal("rotation");
            ret.Plane            = side.PropertyPlane("plane");
            //NOTE(SVK) Paste RF data
            ret.Texture.Flags            = (FaceFlags)side.PropertyInteger("flags");
            ret.Texture.Translucency     = (int)side.PropertyDecimal("translucency");
            ret.Texture.Opacity          = side.PropertyDecimal("opacity");
            ret.Texture.PositionRF       = side.PropertyCoordinate("positionrf");
            ret.Texture.TransformAngleRF = side.PropertyMatrix("transformanglerf");

            var verts = side.Children.FirstOrDefault(x => x.Name == "vertex");

            if (verts != null)
            {
                var count = verts.PropertyInteger("count");
                for (var i = 0; i < count; i++)
                {
                    ret.Vertices.Add(new Vertex(verts.PropertyCoordinate("vertex" + i), ret));
                }
            }

            return(ret);
        }
コード例 #2
0
ファイル: VmfProvider.cs プロジェクト: KonstantinUb/sledge
        private static Face ReadFace(GenericStructure side, IDGenerator generator)
        {
            var id = side.PropertyLong("id");
            if (id == 0) id = generator.GetNextFaceID();
            var dispinfo = side.GetChildren("dispinfo").FirstOrDefault();
            var ret = dispinfo != null ? ReadDisplacement(id, dispinfo) : new Face(id);
            // id, plane, material, uaxis, vaxis, rotation, lightmapscale, smoothing_groups
            var uaxis = side.PropertyTextureAxis("uaxis");
            var vaxis = side.PropertyTextureAxis("vaxis");
            ret.Texture.Name = side["material"];
            ret.Texture.UAxis = uaxis.Item1;
            ret.Texture.XShift = uaxis.Item2;
            ret.Texture.XScale = uaxis.Item3;
            ret.Texture.VAxis = vaxis.Item1;
            ret.Texture.YShift = vaxis.Item2;
            ret.Texture.YScale = vaxis.Item3;
            ret.Texture.Rotation = side.PropertyDecimal("rotation");
            ret.Plane = side.PropertyPlane("plane");

            var verts = side.Children.FirstOrDefault(x => x.Name == "vertex");
            if (verts != null)
            {
                var count = verts.PropertyInteger("count");
                for (var i = 0; i < count; i++)
                {
                    ret.Vertices.Add(new Vertex(verts.PropertyCoordinate("vertex"+i), ret));
                }
            }

            return ret;
        }