private void SendGlobalLightingData() { if (m_settingGlobalLighting) { return; } DirLight dirLight = ActiveDirLight; if (dirLight == null) { return; } var data = new[] { new Tuple <string, object>(GlobalAmbientRed, (float)dirLight.Ambient.R), new Tuple <string, object>(GlobalAmbientBlue, (float)dirLight.Ambient.B), new Tuple <string, object>(GlobalAmbientGreen, (float)dirLight.Ambient.G), new Tuple <string, object>(GlobalSpecularRed, (float)dirLight.Specular.R), new Tuple <string, object>(GlobalSpecularBlue, (float)dirLight.Specular.B), new Tuple <string, object>(GlobalSpecularGreen, (float)dirLight.Specular.G), new Tuple <string, object>(GlobalDiffuseRed, (float)dirLight.Diffuse.R), new Tuple <string, object>(GlobalDiffuseBlue, (float)dirLight.Diffuse.B), new Tuple <string, object>(GlobalDiffuseGreen, (float)dirLight.Diffuse.G), }; Send(data); }
private void RecordGlobalLighting(int i) { DirLight light = ActiveDirLight; if (light != null) { m_globalLightInfos[i] = new LightingInfo(light); } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.F)) { foreach (GameObject item in FindObjectsOfType(typeof(GameObject)) as GameObject[]) { if (item.GetComponent <Renderer>()) { if (item.GetComponent <Renderer>().name != "No Name") { worldObjects.Add(new ColorConvertObject(item, item.GetComponent <Renderer>().material)); } } } Debug.Log("List created"); lerping = true; Light1.GetComponent <Light>().color = Color.white; Light2.GetComponent <Light>().color = Color.white; DirLight.GetComponent <Light>().color = Color.white; RenderSettings.ambientLight = new Color(.62f, .62f, .62f); RenderSettings.skybox = skybox; DynamicGI.UpdateEnvironment(); } if (lerping) { foreach (ColorConvertObject item in worldObjects) { if (item.m_object.GetComponent <Renderer>()) { item.m_object.GetComponent <Renderer>().material.Lerp(item.m_material, whitematerial, Time.deltaTime); } } } if (Input.GetKeyDown(KeyCode.G)) { if (worldObjects != null) { foreach (ColorConvertObject item in worldObjects) { if (item.m_object.GetComponent <Renderer>()) { item.m_object.GetComponent <Renderer>().material = item.m_material; } } } } if (Input.GetKeyDown(KeyCode.O)) { SceneManager.LoadScene("_scenes/OtherSceneTest", LoadSceneMode.Single); Debug.Log("SceneLoad!"); } }
private void SetGlobalDiffuseComponent(DirLight activeDirLight, string address, object data) { if (activeDirLight == null) { return; } Color origColor = activeDirLight.Diffuse; m_settingGlobalLighting = true; m_domNode.As <ITransactionContext>().DoTransaction(() => activeDirLight.Diffuse = ReplaceComponent(origColor, address, data), "OSC Input".Localize("The name of a command")); m_settingGlobalLighting = false; m_designView.ActiveView.Invalidate(); }
private void RecallGlobalLighting(int i) { if (m_globalLightInfos[i] != null) { DirLight light = ActiveDirLight; if (light != null) { //We don't want to set m_settingGlobalLighting to false because the sliders // on OSC display need to be updated in response to the recall button being pressed m_domNode.As <ITransactionContext>().DoTransaction( () => m_globalLightInfos[i].Recall(light), "OSC Input".Localize("The name of a command")); } } }
public override void onAddedToEntity() { _dirLight = entity.scene.findComponentOfType <DirLight>(); _currentLight = _dirLight; }
public void Recall(DirLight light) { light.Ambient = m_ambient; light.Specular = m_specular; light.Diffuse = m_diffuse; }
public LightingInfo(DirLight light) { m_ambient = light.Ambient; m_specular = light.Specular; m_diffuse = light.Diffuse; }
public override void OnAddedToEntity() { _dirLight = Entity.Scene.FindComponentOfType <DirLight>(); _currentLight = _dirLight; }
private void button3_Click(object sender, EventArgs e) { int LightCount = 0; if (cbLight1.Checked) { LightCount++; } if (cbLight2.Checked) { LightCount++; } if (cbLight3.Checked) { LightCount++; } if (cbLight4.Checked) { LightCount++; } if (cbLight5.Checked) { LightCount++; } Light[] Sources = new Light[LightCount]; double c1 = Convert.ToDouble(tb_c1.Text); double c2 = Convert.ToDouble(tb_c2.Text); double c3 = Convert.ToDouble(tb_c3.Text); Vector S = new Vector(Convert.ToDouble(tbSizeX.Text), Convert.ToDouble(tbSizeY.Text), Convert.ToDouble(tbSizeZ.Text)); int i = 0, j; if (cbLight1.Checked) { if (cbPointLight1.Checked) { Sources[i] = new PointLight(ColorToVector(btnAmbient1.BackColor), ColorToVector(btnDiffuse1.BackColor), ColorToVector(btnSpecular1.BackColor), c1, c2, c3, StringToVector(tbLight1.Text) | S); } else { Sources[i] = new DirLight(ColorToVector(btnAmbient1.BackColor), ColorToVector(btnDiffuse1.BackColor), ColorToVector(btnSpecular1.BackColor), StringToNormVector(tbLight1.Text)); } i++; } if (cbLight2.Checked) { if (cbPointLight2.Checked) { Sources[i] = new PointLight(ColorToVector(btnAmbient2.BackColor), ColorToVector(btnDiffuse2.BackColor), ColorToVector(btnSpecular2.BackColor), c1, c2, c3, StringToVector(tbLight2.Text) | S); } else { Sources[i] = new DirLight(ColorToVector(btnAmbient2.BackColor), ColorToVector(btnDiffuse2.BackColor), ColorToVector(btnSpecular2.BackColor), StringToNormVector(tbLight2.Text)); } i++; } if (cbLight3.Checked) { if (cbPointLight3.Checked) { Sources[i] = new PointLight(ColorToVector(btnAmbient3.BackColor), ColorToVector(btnDiffuse3.BackColor), ColorToVector(btnSpecular3.BackColor), c1, c2, c3, StringToVector(tbLight3.Text) | S); } else { Sources[i] = new DirLight(ColorToVector(btnAmbient3.BackColor), ColorToVector(btnDiffuse3.BackColor), ColorToVector(btnSpecular3.BackColor), StringToNormVector(tbLight3.Text)); } i++; } if (cbLight4.Checked) { if (cbPointLight4.Checked) { Sources[i] = new PointLight(ColorToVector(btnAmbient4.BackColor), ColorToVector(btnDiffuse4.BackColor), ColorToVector(btnSpecular4.BackColor), c1, c2, c3, StringToVector(tbLight4.Text) | S); } else { Sources[i] = new DirLight(ColorToVector(btnAmbient4.BackColor), ColorToVector(btnDiffuse4.BackColor), ColorToVector(btnSpecular4.BackColor), StringToNormVector(tbLight4.Text)); } i++; } if (cbLight5.Checked) { if (cbPointLight5.Checked) { Sources[i] = new PointLight(ColorToVector(btnAmbient5.BackColor), ColorToVector(btnDiffuse5.BackColor), ColorToVector(btnSpecular5.BackColor), c1, c2, c3, StringToVector(tbLight5.Text) | S); } else { Sources[i] = new DirLight(ColorToVector(btnAmbient5.BackColor), ColorToVector(btnDiffuse5.BackColor), ColorToVector(btnSpecular5.BackColor), StringToNormVector(tbLight5.Text)); } i++; } L.Ground = new Material(ColorToVector(btnAmbient.BackColor), ColorToVector(btnDiffuse.BackColor), ColorToVector(btnSpecular.BackColor)); float AllTime = 0, t; PerfCounter Counter1 = new PerfCounter(); Counter1.Start(); Convolution[] Convs = new Convolution[3]; Convs[0].Operation = Operation.Plus; Convs[1].Operation = (Operation)cmbOp2.SelectedIndex; Convs[2].Operation = (Operation)cmbOp3.SelectedIndex; Convs[0].Coef = Convert.ToDouble(tbCoef1.Text); Convs[1].Coef = Convert.ToDouble(tbCoef2.Text); Convs[2].Coef = Convert.ToDouble(tbCoef3.Text); L.GenerateHeightmap(Convert.ToInt32(tbSizeX.Text), Convert.ToInt32(tbSizeY.Text), (GenMethod)cmbGenMethod.SelectedIndex, Convs, cbSmoothing.Checked, cbValley.Checked, cbIsland.Checked); t = Counter1.Finish(); lblHeightmapTime.Text = Convert.ToString(t); AllTime += t; L.BuildMesh(new Vector(Convert.ToDouble(tbSizeX.Text), Convert.ToDouble(tbSizeY.Text), Convert.ToDouble(tbSizeZ.Text))); Counter1.Start(); L.BuildLightmap(Sources, 2); t = Counter1.Finish(); lblLightmapTime.Text = Convert.ToString(t); AllTime += t; Counter1.Start(); L.GenerateColormap(Colors, 1); t = Counter1.Finish(); lblTextureTime.Text = Convert.ToString(t); AllTime += t; lblAllTime.Text = Convert.ToString(AllTime); string DirName; /*if (tbDir.Text[0] == '.') * { * DirName = "../../" + tbDir.Text + "/" + tbName.Text; * Directory.CreateDirectory(DirName); * } * else*/ DirName = tbDir.Text + "/" + tbName.Text; Bitmap B1, B2, B3; L.SaveHeightmap(DirName + "/Heightmap.bmp", out B1); L.SaveLightmap(DirName + "/Lightmap.bmp", out B2); L.SaveColormap(DirName + "/Texture.bmp", out B3); //pictureBox1.Image = B1; Bitmap B = new Bitmap(L.SizeX, L.SizeY); for (i = 0; i < B.Width; i++) { for (j = 0; j < B.Height; j++) { byte X = Convert.ToByte(L.Heightmap[i, j] * 255); B.SetPixel(i, j, Color.FromArgb(X, X, X)); } } pictureBox1.Image = B; pictureBox2.Image = B2; pictureBox3.Image = B3; pictureBox1.Refresh(); pictureBox2.Refresh(); pictureBox3.Refresh(); SaveSettings("EditorSettings.ini"); }