private void CheckRadioButtonsAndDrawNewPicture() { PaintingManager.SetLightColor(lightSourceColorPictureBox.BackColor); if (ConstantObjectRadioButton.Checked) { PaintingManager.SetBaseObject(constantObjectColorPictureBox.BackColor); } else { PaintingManager.SetBaseObject(textureObjectPictureBox.Image as Bitmap); } if (constantNormalVectorRadioButton.Checked) { PaintingManager.SetNormalVector(new Vector3(0, 0, 1)); } else { PaintingManager.SetNormalVector(textureVectorPictureBox.Image as Bitmap); } if (noDisorderRadioButton.Checked) { PaintingManager.SetDisorder(new Vector3(0, 0, 0)); } else { PaintingManager.SetDisorder(textureDisoderPictureBox.Image as Bitmap, fDisorderTextbox.Text); } if (constantLightSourceVectorRadioButton.Checked) { timer.Stop(); PaintingManager.SetLightVector(new Vector3(0, 0, 1), true); } else { if (!int.TryParse(radiusLightSourceVectorTextBox.Text, out int radius)) { return; } PaintingManager.SetLightVector(new Vector3(radius, 0, 0), false); timer.Start(); } PaintingManager.SetLights(redLightToolStripMenuItem.Checked, greenLightToolStripMenuItem.Checked, blueLightToolStripMenuItem.Checked); this.DrawNewPicture(); }
private void timer_Tick(object sender, EventArgs e) { if (!int.TryParse(radiusLightSourceVectorTextBox.Text, out int radius)) { return; } if (lightX >= radius + screenMiddle.X - lightMove) { lightX = screenMiddle.X - radius + lightMove; } else { lightX += lightMove; } int z = (int)Math.Sqrt(radius * radius - Math.Pow(screenMiddle.X - lightX, 2)); Vector3 vector = new Vector3(lightX - screenMiddle.X, 0, z); PaintingManager.SetLightVector(vector, false); this.DrawNewPicture(); }