/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { TerrainDisplayConfig.Initialize(); LogUtil.SetupConsoleLogging(); NativeMethods.StormLibFolder = TerrainDisplayConfig.LibDir; NativeMethods.InitAPI(); var defaultTileId = TileIdentifier.DefaultTileIdentifier; var useExtractedData = TerrainDisplayConfig.UseExtractedData; if (useExtractedData) { TerrainManager = new ExtractedTerrainManager(TerrainDisplayConfig.MapDir, defaultTileId); } else { TerrainManager = new MpqTerrainManager(defaultTileId); } TerrainManager.LoadTile(defaultTileId); AvatarPosition = new Vector3(TerrainConstants.CenterPoint - (defaultTileId.TileX + 1) * TerrainConstants.TileSize, TerrainConstants.CenterPoint - (defaultTileId.TileY) * TerrainConstants.TileSize, 100.0f); PositionUtil.TransformWoWCoordsToXNACoords(ref AvatarPosition); //new RecastRunner(TerrainManager).Start(); using (var game = new Game1(AvatarPosition.ToXna())) { game.Run(); } }
protected override bool BuildPolyVerticiesAndIndicies() { List <Vector3> vertices; List <int> indices; _manager.GetMeshVerticesAndIndices(out vertices, out indices); if (vertices.Count == 0 || indices.Count == 0) { return(false); } _cachedPolyVertices = new VertexPositionNormalColored[vertices.Count]; for (var i = 0; i < vertices.Count; i++) { _cachedPolyVertices[i] = new VertexPositionNormalColored(vertices[i].ToXna(), MeshPolyColor, Vector3.Up.ToXna()); PositionUtil.TransformWoWCoordsToXNACoords(ref _cachedPolyVertices[i]); } _cachedPolyIndices = new int[indices.Count]; for (int i = 0; i < indices.Count; i++) { _cachedPolyIndices[i] = indices[i]; } RenderPolyCached = true; return(true); }
private void BuildVerticiesAndIndicies() { // Cycle through each ADT var tempVertices = new List <VertexPositionNormalColored>(); var tempIndicies = new List <int>(); var offset = 0; foreach (var adt in _manager.MapTiles) { // Handle the ADTs for (var v = 0; v < adt.TerrainVertices.Count; v++) { var vertex = adt.TerrainVertices[v]; var vertexPosNmlCol = new VertexPositionNormalColored(vertex.ToXna(), TerrainColor, Microsoft.Xna.Framework.Vector3.Down); tempVertices.Add(vertexPosNmlCol); } for (var i = 0; i < adt.Indices.Count; i++) { tempIndicies.Add(adt.Indices[i] + offset); } offset = tempVertices.Count; //if (!DrawLiquids) continue; for (var v = 0; v < adt.LiquidVertices.Count; v++) { var vertex = adt.LiquidVertices[v]; var vertexPosNmlCol = new VertexPositionNormalColored(vertex.ToXna(), WaterColor, Microsoft.Xna.Framework.Vector3.Down); tempVertices.Add(vertexPosNmlCol); } for (var i = 0; i < adt.LiquidIndices.Count; i++) { tempIndicies.Add(adt.LiquidIndices[i] + offset); } offset = tempVertices.Count; } _cachedIndices = tempIndicies.ToArray(); _cachedVertices = tempVertices.ToArray(); _renderCached = true; for (var i = 0; i < _cachedVertices.Length; i++) { PositionUtil.TransformWoWCoordsToXNACoords(ref _cachedVertices[i]); } }
private void BuildVerticiesAndIndicies() { var tileId = TileIdentifier.DefaultTileIdentifier; var tempVertices = new List <VertexPositionNormalColored>(); var tempIndices = new List <int>(); var offset = 0; var baseXPos = TerrainConstants.CenterPoint - (tileId.TileX + 1) * TerrainConstants.TileSize; var baseYPos = TerrainConstants.CenterPoint - (tileId.TileY + 1) * TerrainConstants.TileSize; var baseZPos = -100.0f; // The Bottom-Righthand corner of a Tile in WoW coords var baseAxisVec = new Vector3(baseXPos, baseYPos, baseZPos); //var baseAxisVec = new Vector3(0.0f); // The Top-Lefthand corner of a Tile in WoW coords var endAxisVec = baseAxisVec + new Vector3(TerrainConstants.TileSize * 2); PositionUtil.TransformWoWCoordsToXNACoords(ref baseAxisVec); PositionUtil.TransformWoWCoordsToXNACoords(ref endAxisVec); // The WoW X-axis drawn in XNA coords tempVertices.Add(new VertexPositionNormalColored(baseAxisVec, Color.Red, Vector3.Up)); tempIndices.Add(0); tempVertices.Add(new VertexPositionNormalColored(new Vector3(baseAxisVec.X, baseAxisVec.Y, endAxisVec.Z), Color.Red, Vector3.Up)); tempIndices.Add(1); tempIndices.Add(0); // The WoW Y-axis drawn in XNA coords tempVertices.Add(new VertexPositionNormalColored(baseAxisVec, Color.White, Vector3.Up)); tempIndices.Add(2); tempVertices.Add(new VertexPositionNormalColored(new Vector3(endAxisVec.X, baseAxisVec.Y, baseAxisVec.Z), Color.White, Vector3.Up)); tempIndices.Add(3); tempIndices.Add(2); // The WoW Z-axis tempVertices.Add(new VertexPositionNormalColored(baseAxisVec, Color.Blue, Vector3.Up)); tempIndices.Add(4); tempVertices.Add(new VertexPositionNormalColored(new Vector3(baseAxisVec.X, endAxisVec.Y, baseAxisVec.Z), Color.Blue, Vector3.Up)); tempIndices.Add(5); tempIndices.Add(4); _cachedIndices = tempIndices.ToArray(); _cachedVertices = tempVertices.ToArray(); _renderCached = true; }
protected override void BuildVerticiesAndIndicies() { _cachedVertices = new VertexPositionNormalColored[_manager.Vertices.Count]; _cachedIndices = new int[_manager.Indices.Count]; for (var i = 0; i < _manager.Vertices.Count; i++) { var position = _manager.Vertices[i]; PositionUtil.TransformWoWCoordsToXNACoords(ref position); _cachedVertices[i] = new VertexPositionNormalColored(position.ToXna(), SelectedTriangleColor, Vector3.Up); } for (var i = 0; i < _manager.Indices.Count; i++) { _cachedIndices[i] = _manager.Indices[i]; } }
protected override void BuildVerticiesAndIndicies() { // Cycle through each M2 var tempVertices = _manager.RenderVertices; var tempIndicies = _manager.RenderIndices; _cachedVertices = new VertexPositionNormalColored[tempVertices.Count]; for (var i = 0; i < tempVertices.Count; i++) { var vec = tempVertices[i]; PositionUtil.TransformWoWCoordsToXNACoords(ref vec); _cachedVertices[i] = new VertexPositionNormalColored(vec.ToXna(), M2Color, Microsoft.Xna.Framework.Vector3.Down); } _cachedIndices = new int[tempIndicies.Count]; for (var i = 0; i < tempIndicies.Count; i++) { _cachedIndices[i] = tempIndicies[i]; } _renderCached = true; }
public void GetRecastTriangleMesh(out Vector3[] vertices, out int[] indices) { var vecList = new List <Vector3>(); var indexList = new List <int>(); List <Vector3> renderVertices; int offset; // Get the ADT triangles foreach (var tile in _adtManager.MapTiles) { offset = vecList.Count; renderVertices = tile.TerrainVertices; if (renderVertices != null) { for (int i = 0; i < renderVertices.Count; i++) { var vertex = renderVertices[i]; PositionUtil.TransformWoWCoordsToXNACoords(ref vertex); vecList.Add(vertex); } foreach (var index in tile.Indices) { indexList.Add(index + offset); } } offset = vecList.Count; renderVertices = tile.TerrainVertices; if (renderVertices == null) { continue; } for (int i = 0; i < renderVertices.Count; i++) { var vertex = renderVertices[i]; PositionUtil.TransformWoWCoordsToXNACoords(ref vertex); vecList.Add(vertex); } foreach (var index in tile.Indices) { indexList.Add(index + offset); } } // Get the WMO triangles offset = vecList.Count; renderVertices = _wmoManager.WmoVertices; var renderIndices = _wmoManager.WmoIndices; if (renderVertices != null) { for (int i = 0; i < renderVertices.Count; i++) { var vertex = renderVertices[i]; PositionUtil.TransformWoWCoordsToXNACoords(ref vertex); vecList.Add(vertex); } } if (renderIndices != null) { foreach (var index in renderIndices) { indexList.Add(index + offset); } } // Get the M2 triangles offset = vecList.Count; renderVertices = _m2Manager.RenderVertices; renderIndices = _m2Manager.RenderIndices; if (renderVertices != null) { for (int i = 0; i < renderVertices.Count; i++) { var vertex = renderVertices[i]; PositionUtil.TransformWoWCoordsToXNACoords(ref vertex); vecList.Add(vertex); } } if (renderIndices != null) { foreach (var index in renderIndices) { indexList.Add(index + offset); } } vertices = vecList.ToArray(); indices = indexList.ToArray(); }
protected override void BuildVerticiesAndIndicies() { var vertCount = _manager.WmoVertices.Count + _manager.WmoM2Vertices.Count + _manager.WmoLiquidVertices.Count; _cachedVertices = new VertexPositionNormalColored[vertCount]; var idxCount = _manager.WmoIndices.Count + _manager.WmoM2Indices.Count + _manager.WmoLiquidIndices.Count; _cachedIndices = new int[idxCount]; var vertices = _manager.WmoVertices; var indices = _manager.WmoIndices; for (var i = 0; i < vertices.Count; i++) { var vec = vertices[i]; PositionUtil.TransformWoWCoordsToXNACoords(ref vec); _cachedVertices[i] = new VertexPositionNormalColored(vec.ToXna(), WMOColor, Vector3.Down); } for (var i = 0; i < indices.Count; i++) { _cachedIndices[i] = indices[i]; } // Add the M2 stuff var vecOffset = vertices.Count; vertices = _manager.WmoM2Vertices; for (var i = 0; i < vertices.Count; i++) { var vec = vertices[i]; PositionUtil.TransformWoWCoordsToXNACoords(ref vec); _cachedVertices[i + vecOffset] = new VertexPositionNormalColored(vec.ToXna(), WMOModelColor, Vector3.Down); } var idxOffset = indices.Count; indices = _manager.WmoM2Indices; for (var i = 0; i < indices.Count; i++) { _cachedIndices[i + idxOffset] = indices[i] + vecOffset; } // Add the Liquid stuff vecOffset += vertices.Count; vertices = _manager.WmoLiquidVertices; for (var i = 0; i < vertices.Count; i++) { var vec = vertices[i]; PositionUtil.TransformWoWCoordsToXNACoords(ref vec); _cachedVertices[i + vecOffset] = new VertexPositionNormalColored(vec.ToXna(), WMOWaterColor, Vector3.Down); } idxOffset += indices.Count; indices = _manager.WmoLiquidIndices; for (var i = 0; i < indices.Count; i++) { _cachedIndices[i + idxOffset] = indices[i] + vecOffset; } _renderCached = true; }