Beispiel #1
0
        public static MqFace Parse(MqChunk chunk)
        {
            var rt = new MqFace
            {
                baseChunk = chunk,
            };

            foreach (var i in chunk.Attributes)
            {
                switch (i.Name.ToLower())
                {
                case "v":
                    rt.Vertices = i.Arguments.Select(int.Parse).ToArray();

                    break;

                case "m":
                    rt.Material = int.Parse(i.Arguments.First());

                    break;

                case "uv":
                    rt.UV = i.Arguments.Select(float.Parse).Buffer(2).Select(_ => _.ToArray()).ToArray();

                    break;

                case "col":
                    rt.VertexColor = i.Arguments.Select(uint.Parse).Select(_ => new MqVertexColor((byte)(_ & 0xFF), (byte)((_ >> 8) & 0xFF), (byte)((_ >> 16) & 0xFF), (byte)((_ >> 24) & 0xFF))).ToArray();

                    break;
                }
            }

            return(rt);
        }
Beispiel #2
0
        public static MqFace Parse(MqChunk chunk)
        {
            var rt = new MqFace
            {
                baseChunk = chunk,
            };

            foreach (var i in chunk.Attributes)
                switch (i.Name.ToLower())
                {
                    case "v":
                        rt.Vertices = i.Arguments.Select(int.Parse).ToArray();

                        break;
                    case "m":
                        rt.Material = int.Parse(i.Arguments.First());

                        break;
                    case "uv":
                        rt.UV = i.Arguments.Select(float.Parse).Buffer(2).Select(_ => _.ToArray()).ToArray();

                        break;
                    case "col":
                        rt.VertexColor = i.Arguments.Select(uint.Parse).Select(_ => new MqVertexColor((byte)(_ & 0xFF), (byte)((_ >> 8) & 0xFF), (byte)((_ >> 16) & 0xFF), (byte)((_ >> 24) & 0xFF))).ToArray();

                        break;
                }

            return rt;
        }