public MyPlanetShapeProvider(Vector3 translation, float radius, MyPlanetGeneratorDefinition definition) { m_radius = radius; m_translation = translation; m_maxHillHeight = definition.HillParams.Max * m_radius; m_minHillHeight = definition.HillParams.Min * m_radius; InnerRadius = radius + m_minHillHeight; OuterRadius = radius + m_maxHillHeight; m_heightmap = new MyHeightCubemap(definition.FolderName, definition.Context); m_mapResolutionMinusOne = m_heightmap.Resolution - 1; m_heightRatio = m_maxHillHeight - m_minHillHeight; m_heightRatioRecip = 1f / m_heightRatio; float faceSize = (float)(radius * Math.PI * .5); m_pixelSize = faceSize / m_heightmap.Resolution; m_pixelSizeRecip = 1f / m_pixelSize; m_pixelSizeRecip2 = .5f / m_pixelSize; // Calculate maximum tolerable curvature deviation when approximating the surface by a line // We use this for LOD1 raycasts so the maximum deviation is 8m(half a LOD1 cell) // Find the angle theta that produces an arc whose secant approximation deviates from the circle at most 8 meters var theta = Math.Acos((radius - 1) / radius); // this produces theta/2 but we use that later anyways // Find the length of this secant segment. var threshold = Math.Sin(theta) * 2 * radius; // Store it's reciprocal because that's all we use m_curvatureThresholdRecip = 1d / threshold; m_pixelSize4 = m_pixelSize * 4; // Used for inflating query boxes m_voxelSize = (float)(2.0 / (radius * Math.PI)); m_mapStepScale = m_pixelSize / m_heightRatio; m_mapStepScaleSquare = m_mapStepScale * m_mapStepScale; if (definition.Detail != null) { m_detail.Init(definition.Detail, faceSize); } Closed = false; }
public MyPlanetShapeProvider(Vector3 translation, float radius, MyPlanetGeneratorDefinition definition, MyHeightCubemap cubemap, MyPlanetTextureMapProvider texProvider) { this.m_radius = radius; this.m_translation = translation; this.m_maxHillHeight = definition.HillParams.Max * this.m_radius; this.m_minHillHeight = definition.HillParams.Min * this.m_radius; this.InnerRadius = radius + this.m_minHillHeight; this.OuterRadius = radius + this.m_maxHillHeight; this.m_heightmap = cubemap; this.m_mapResolutionMinusOne = this.m_heightmap.Resolution - 1; this.m_heightRatio = this.m_maxHillHeight - this.m_minHillHeight; this.m_heightRatioRecip = 1f / this.m_heightRatio; float faceSize = (float)((radius * 3.1415926535897931) * 0.5); this.m_pixelSize = faceSize / ((float)this.m_heightmap.Resolution); this.m_pixelSizeRecip = 1f / this.m_pixelSize; this.m_pixelSizeRecip2 = 0.5f / this.m_pixelSize; double num2 = (Math.Sin(Math.Acos((double)((radius - 1f) / radius))) * 2.0) * radius; this.m_curvatureThresholdRecip = 1.0 / num2; this.m_pixelSize4 = this.m_pixelSize * 4f; this.m_voxelSize = (float)(2.0 / (radius * 3.1415926535897931)); this.m_mapStepScale = this.m_pixelSize / this.m_heightRatio; this.m_mapStepScaleSquare = this.m_mapStepScale * this.m_mapStepScale; if (definition.Detail != null) { this.m_detail.Init(texProvider, definition.Detail, faceSize); } VrPlanetShape.Mapset maps = this.m_heightmap.GetMapset(); VrPlanetShape.DetailMapData detailMapData = new VrPlanetShape.DetailMapData(); if (definition.Detail != null) { detailMapData = this.m_detail.GetDetailMapData(); } this.m_nativeShape = new VrPlanetShape(translation, radius, definition.HillParams.Min, definition.HillParams.Max, maps, detailMapData, true); this.Closed = false; }
public void Close() { m_heightmap = null; Closed = true; }
public void Close() { this.m_heightmap = null; this.Closed = true; }
public MyPlanetShapeProvider(Vector3 translation, float radius, MyPlanetGeneratorDefinition definition) { m_radius = radius; m_translation = translation; m_maxHillHeight = definition.HillParams.Max * m_radius; m_minHillHeight = definition.HillParams.Min * m_radius; InnerRadius = radius + m_minHillHeight; OuterRadius = radius + m_maxHillHeight; m_heightmap = new MyHeightCubemap(definition.FolderName, definition.Context); m_mapResolutionMinusOne = m_heightmap.Resolution - 1; m_heightRatio = m_maxHillHeight - m_minHillHeight; m_heightRatioRecip = 1f / m_heightRatio; float faceSize = (float)(radius * Math.PI * .5); m_pixelSize = faceSize / m_heightmap.Resolution; m_pixelSizeRecip = 1f / m_pixelSize; m_pixelSizeRecip2 = .5f / m_pixelSize; // Calculate maximum toelerable curvature deviation when approximating the surface by a line // We use this for LOD1 raycasts so the maximum deviation is 8m(half a LOD1 cell) // Find the angle theta that produces an arc whose secant aproximation deviates from the circle at most 8 meters var theta = Math.Acos((radius - 1)/radius); // this produces theta/2 but we use that later and I refuce to multiply and divide // Find the length of this secant segment. var threshold = Math.Sin(theta)*2*radius; // Store it's reciprocal because that's all we use m_curvatureThresholdRecip = 1d/threshold; m_pixelSize4 = m_pixelSize * 4; // Used for inflating query boxes m_voxelSize = (float)(2.0 / (radius * Math.PI)); m_mapStepScale = m_pixelSize / m_heightRatio; m_mapStepScaleSquare = m_mapStepScale * m_mapStepScale; if (definition.Detail != null) m_detail.Init(definition.Detail, faceSize); Closed = false; }