Ejemplo n.º 1
0
        public void Read()
        {
            foreach (var subChunk in SubData.Chunks)
            {
                switch (subChunk.Name)
                {
                case "MOPY":
                    MOPY = new MOPY(subChunk);
                    break;

                case "MOVI":
                    MOVI = new MOVI(subChunk);
                    break;

                case "MOVT":
                    MOVT = new MOVT(subChunk);
                    break;

                case "MONR":
                    MONR = new MONR(subChunk);
                    break;

                case "MODR":
                    MODR = new MODR(subChunk);
                    break;

                case "MLIQ":
                    MLIQ = new MLIQ(subChunk);
                    break;
                }
            }

            Generate();
        }
Ejemplo n.º 2
0
        public Mesh GenerateLiquid(MODF.MODFEntry wmoDefinition = null)
        {
            if (MLIQ == null)
            {
                return(null);
            }

            var vertices = new List <Vector3>((int)(MLIQ.Height * MLIQ.Width) * 4);
            var indices  = new List <uint>((int)((MLIQ.Height * MLIQ.Width) * 3));

            var relPos = MLIQ.Position;

            for (var y = 0; y < MLIQ.Height; y++)
            {
                for (var x = 0; x < MLIQ.Width; x++)
                {
                    if (!MLIQ.ShouldRender(x, y))
                    {
                        continue;
                    }

                    var vo = (uint)vertices.Count;

                    vertices.AddRange(new[] {
                        relPos - new Vector3(x * Constants.UnitSize, y * Constants.UnitSize, MLIQ.HeightMap[x, y]),
                        relPos - new Vector3((x + 1) * Constants.UnitSize, y * Constants.UnitSize, MLIQ.HeightMap[x + 1, y]),
                        relPos - new Vector3(x * Constants.UnitSize, (y + 1) * Constants.UnitSize, MLIQ.HeightMap[x, y + 1]),
                        relPos - new Vector3((x + 1) * Constants.UnitSize, (y + 1) * Constants.UnitSize, MLIQ.HeightMap[x + 1, y + 1])
                    });

                    indices.AddRange(new uint[] {
                        vo, vo + 2, vo + 1,
                        vo + 2, vo + 3, vo + 1
                    });
                }
            }

            var mesh = new Mesh
            {
                Type     = MeshType.Liquid,
                Indices  = indices.ToArray(),
                Vertices = vertices.ToArray(),
            };

            if (wmoDefinition != null)
            {
                return(mesh.Transform(Transformation.GetWMOTransform(wmoDefinition.Position, wmoDefinition.Rotation)));
            }
            return(mesh);
        }