void Start() { grid = transform.Find("Renderer"); layerTexture = grid.Find("LayerTexture").GetComponent <LayerTexture>(); float displayRatio = (float)Display.main.renderingWidth / Display.main.renderingHeight; grid.localScale = new Vector3(displayRatio, 1f, 1f); }
public override void Paint(int layer, float x, float y) { LayerTexture layerTexture = GameManager.ActiveGameManager.LayerManager.Layers[layer].LayerTexture; float xPixelsPerUnit = layerTexture.Size.x / layerTexture.GetComponent <Renderer>().bounds.extents.x; float yPixelPerUnit = layerTexture.Size.y / layerTexture.GetComponent <Renderer>().bounds.extents.y; //get the physical size of the layer panel //Why does x need tex.width/2 added to it, //but y doesnt: the center of the render texture is at 0,1 float xPixel = (layerTexture.Size.x / 2) + (x * xPixelsPerUnit * 0.5f); float yPixel = (y * yPixelPerUnit * 0.5f); //if (emission.GetValue < GameManager.ActiveGameManager.RenderManager.RenderTime) { int drawCount = GameManager.ActiveGameManager.OrbManager.DrawPerFrame; int i = 0; const float pixelCoef = 56; while (i++ < drawCount) { float r = Mathf.Pow(Mathf.Sin(SineCoefficient.GetValue * Theta.GetValue), SineExponent.GetValue) + Mathf.Pow(Mathf.Cos(CosineCoefficient.GetValue * Theta.GetValue), CosineExponent.GetValue) * pixelCoef; int xPos = (int)(xPixel + Mathf.Cos(Theta.GetValue) * Mathf.Clamp(r * XRadius.GetValue, XRadius.Min * pixelCoef, XRadius.Max * pixelCoef)); int yPos = (int)(yPixel + Mathf.Sin(Theta.GetValue) * Mathf.Clamp(r * YRadius.GetValue, YRadius.Min * pixelCoef, YRadius.Max * pixelCoef)); HSL_Color h = new HSL_Color(Mathf.Clamp(Theta.GetValue * Hue.Rate * (Hue.Max - Hue.Min), Hue.Min, Hue.Max), Mathf.Clamp(Theta.GetValue * Saturation.Rate, Saturation.Min, Saturation.Max), Brightness.GetValue); Color col = h.ToRGB(); col.a = Alpha.GetValue; Hue.Update(); Saturation.Update(); Brightness.Update(); Alpha.Update(); Theta.Update(); layerTexture.WriteToTexture(xPos, yPos, col); } } }
public void Start() { canvas = GetComponent <Canvas>(); texture = GetComponentInChildren <LayerTexture>(); display = UnityEngine.Object.FindObjectOfType <VertexDisplay>(); terrainPreviewController = UnityEngine.Object.FindObjectOfType <TerrainPreviewController>(); canvas.enabled = false; display.addMeshAddedDelegate(gameObject => { if (DisplayedObject == null || gameObject.GetComponent <BlockInfo>().Block.Offset == block.Offset) { DisplayedObject = gameObject; } }); texture.addVoxelSelectionDelegate(voxel => { voxelInfoText.text = "Value: " + voxel.Data; }); layerSelection = GameObject.CreatePrimitive(PrimitiveType.Cube); layerSelection.name = "Layer Selection"; layerSelection.transform.parent = display.transform; layerSelection.GetComponent <Renderer>().material = selectionMaterial; layerSelection.SetActive(false); Destroy(layerSelection.GetComponent <BoxCollider>()); NoiseNodeEditor editor = UnityEngine.Object.FindObjectOfType <NoiseNodeEditor>(); editor.registerCanvasDelegate(noiseCanvas => { this.noiseCanvas = noiseCanvas; if (this.Active) { configureComputation(); } }); }