public void GetData(object[] obj) { foreach (object o in obj) { if (o is QuadTree) terrain = (QuadTree)o; if (o is Camera.Camera) camera = (Camera.Camera)o; } }
public void InitializeTerrin(QuadTree Qtree, Camera.Camera camera, Terrain terrain, Texture2D HeightMap, Vector3 WaterPos, ContentManager Content, GraphicsDevice graphicsDevice) { Camera.Camera.DefaultCamera = camera; float quadFrontTreeDetail = float.Parse(System.Configuration.ConfigurationManager.AppSettings[WindowsGame2.Properties.Resources.ChildFrontTestThreshold], CultureInfo.GetCultureInfo("en-us")); float quadFarTreeDetail = float.Parse(System.Configuration.ConfigurationManager.AppSettings[WindowsGame2.Properties.Resources.ChildFarTestThreshold], CultureInfo.GetCultureInfo("en-us")); float vertexDetail = float.Parse(System.Configuration.ConfigurationManager.AppSettings[WindowsGame2.Properties.Resources.VertexTestThreshold], CultureInfo.GetCultureInfo("en-us")); float nodeRelevance = float.Parse(System.Configuration.ConfigurationManager.AppSettings[WindowsGame2.Properties.Resources.ChildRelevanceThreshold], CultureInfo.GetCultureInfo("en-us")); for (int i = 0; i < terrain.QuadTrees.Count; i++) { terrain.QuadTrees[i].NodeRelevance = nodeRelevance; terrain.QuadTrees[i].QuadTreeDetailAtFront = quadFrontTreeDetail; terrain.QuadTrees[i].QuadTreeDetailAtFar = quadFarTreeDetail; terrain.QuadTrees[i].VertexDetail = vertexDetail; LoadGround(terrain.QuadTrees[i], HeightMap, Content); } Qtree.effect = Content.Load<Effect>("Effects//Terrain"); Qtree._effect = Content.Load<Effect>("shaders//LPPMainEffect"); terrain.Initialize(); terrain.Load(graphicsDevice); Qtree.WaterHeight = WaterPos.Y; }
private void InitializeTerrain() { //create terrain object this.terrain = new Terrain.Terrain(); //set the depth of the tree byte treeDepth = 8; //set the scale of the terrain float scale = 0.39f; //set the size of the terrain part represented by the root quad tree node. int landSize = (int)(32768 * scale); //create a new quadtree with the specified depth, land size and at location (0,0) Qtree = new QuadTree(treeDepth, landSize, scale, new Vector2(-landSize / 2, -landSize / 2)); this.terrain.QuadTrees.Add(Qtree); }
public QuadNode(QuadNode parent, NodeChild position) { //array for neighbors at each sides this._neighbors = new QuadNode[4]; //array for all the nine vertices of the current node this._vertices = new TerrainVertex[QuadNode.VerticesNumber]; //the interpolated position difference with the real position this._realToInterpolatedVertexHeight = new float[QuadNode.SidesNumber]; this._parent = parent; this._position = position; if (parent == null) this._depth = 0; else { this._depth = Convert.ToByte(parent.Depth + 1); this._parentTree = parent._parentTree; } }
private void LoadHeightData(QuadTree tree, Texture2D heightMap) { Color[] heightMapColors = new Color[heightMap.Width * heightMap.Height]; heightMap.GetData(heightMapColors); tree.HeightData = new float[heightMap.Width, heightMap.Height]; for (int x = 0; x < heightMap.Width; x++) for (int y = 0; y < heightMap.Height; y++) { // Get color value (0 - 255) float amt = heightMapColors[y * heightMap.Width + x].R; // Scale to (0 - 1) amt /= 255.0f; // Multiply by max height to get final height tree.HeightData[x, y] = amt * BasicWorld.THeight; } }
public void TerrainTextures(QuadTree Qtree, Texture2D[] TexturesMap, Texture2D[] Textures, int[] textureTiling, ContentManager Content) { //TexturesMaps for (int i = 0; i < TexturesMap.Length; i++) Qtree.TexturesMaps[i] = TexturesMap[i]; //Textures for (int i = 0; i < Textures.Length; i++) Qtree.Textures[i] = Textures[i]; //Tiling for (int i = 0; i < Textures.Length; i++) Qtree.textureTiling[i] = textureTiling[i]; //Detail Texture Qtree.DetailTexture = Content.Load<Texture2D>("textures//Terrain//noise_texture"); }
public void LoadGround(QuadTree tree, Texture2D HeightMap, ContentManager Content) { string heightMapTextureName = System.Configuration.ConfigurationManager.AppSettings[WindowsGame2.Properties.Resources.HeightGrayScaleImage]; using (Texture2D heightMap = HeightMap) { LoadHeightData(tree, heightMap); } }