public static BoundingBox CalcBoundingBox(ElevationGrid elevationGrid) { BoundingBox bbox; int xDim, zDim; xDim = elevationGrid._xDimension - 1; zDim = elevationGrid._zDimension - 1; bbox = new BoundingBox(); bbox.Width = xDim * elevationGrid._xSpacing; bbox.Height = elevationGrid.MaxHeight - elevationGrid.MinHeight; bbox.Depth = zDim * elevationGrid._zSpacing; return(bbox); }
public override void CollectGeometry( RenderingContext rc, out GeometryHandle handle, out BoundingBox bbox, out bool Coloring, out bool Texturing) { List <Vertex> geometry; handle = GeometryHandle.Zero; bbox = BoundingBox.Zero; parentShape = GetParent <Shape>(); colorNode = (Color)this.Children.FirstOrDefault(n => n.GetType() == typeof(Color)); colorRGBANode = (ColorRGBA)this.Children.FirstOrDefault(n => n.GetType() == typeof(ColorRGBA)); texCoordinateNode = (TextureCoordinate)this.Children.FirstOrDefault(n => n.GetType() == typeof(TextureCoordinate)); RGBA = colorRGBANode != null; RGB = colorNode != null; coloring = RGBA || RGB; generateColorMap = coloring; texturing = texCoordinateNode != null || parentShape.texturingEnabled; generateTexCoordMap = texturing; Coloring = coloring; Texturing = texturing; if (RGB && !RGBA) { color = X3DTypeConverters.Floats(colorNode.color); } else if (RGBA && !RGB) { color = X3DTypeConverters.Floats(colorRGBANode.color); } _isLoaded = true; //// //// //// if (construct) { float sx = this.xSpacing; float sz = this.zSpacing; IConstructionSet constructionSet; IPerlinNoiseGenerator perlinProvider; Bitmap largePerlinImage; constructionSet = SceneManager.GetCurrentConstructionSet(); perlinProvider = constructionSet.GetPerlinNoiseProvider(); ElevationGrid generated = constructionSet.ElevationBuilder.BuildHeightmapFromGenerator( rc, perlinProvider, out largePerlinImage, 40, 40, 20, 20, 20); // build a rather large height map largePerlinImage.Dispose(); Color genColorNode = (Color)generated.Children.FirstOrDefault(n => n.GetType() == typeof(Color)); this.RGB = coloring = generateColorMap = true; this.height = generated.height; this.color = X3DTypeConverters.Floats(genColorNode.color); this.colorPerVertex = generated.colorPerVertex; this.normalPerVertex = generated.normalPerVertex; this.Children = generated.Children; this.xSpacing = generated.xSpacing; this.zSpacing = generated.zSpacing; this.xDimension = generated.xDimension; this.zDimension = generated.zDimension; } if (!this._isLoaded) { parentShape = GetParent <Shape>(); texturing = parentShape.texturingEnabled; generateTexCoordMap = texturing && texCoordinateNode == null; this._isLoaded = true; } height_mapping(); bbox = BoundingBox.CalcBoundingBox(this); geometry = BuildElevationGeometryQuads(bbox); Buffering.BufferShaderGeometry(geometry, out handle.vbo4, out handle.NumVerticies4); }