public GLScene() { InitializeComponent(); my_UpdateShader = false; my_GenerateGeometries = false; my_Geometries = new List <GLGeometry>(); my_LightCount = 0; my_UpdateLights = false; my_Lights = new List <GLLight>(); //Set a default Light GLLight l1 = new GLLight(LightType.DirectionalLight) { Direction = new Vector3D(-1.0, -2.0, -3.0), Ambient = Color.FromRgb(255, 255, 255), Diffuse = Color.FromRgb(255, 255, 255), Specular = Color.FromRgb(255, 255, 255) }; AddLight(l1); my_Background = Colors.Black; //Set the default camera my_CamStartPos = new Vector3D(0.0, 0.0, 200.0); my_CamStartTarget = new Vector3D(0.0, 0.0, 0.0); my_CamStartUpDir = new Vector3D(0.0, 1.0, 0.0); my_Camera = new TrackballCamera() { Position = my_CamStartPos, TargetPosition = my_CamStartTarget, UpDirection = my_CamStartUpDir }; MousebuttonDown = false; MouseSensitivity = 0.5; SceneIsLoaded = false; }
/// <summary> /// Adds a Light to the scene. /// <para>All the Lights parameters are set on the fragment shader at the next render pass.</para> /// </summary> /// <param name="light">A GLLight or derived class.</param> public void AddLight(GLLight light) { light.Index = my_LightCount; my_Lights.Add(light); my_LightCount++; my_UpdateLights = true; }
private void SetScene() { myScene.Lights.Clear(); GLLight l1 = new GLLight(LightType.DirectionalLight) { Direction = new Vector3D(2.0, 2.0, 2.0), Ambient = Color.FromRgb(150, 150, 150), Diffuse = Color.FromRgb(255, 255, 255), Specular = Color.FromRgb(255, 255, 255) }; myScene.AddLight(l1); GLLight l2 = new GLLight(LightType.PointLight) { Position = new Vector3D(-3.0, 0.0, 1.0), Ambient = Color.FromRgb(150, 150, 150), Diffuse = Color.FromRgb(200, 200, 200), Specular = Color.FromRgb(255, 255, 255), Linear = 0.5, Quadratic = 0, Constant = 0.3 }; myScene.AddLight(l2); GLLight l3 = new GLLight(LightType.SpotLight) { Position = new Vector3D(2.0, 2.0, -2.0), Direction = new Vector3D(-2.0, -2.0, 2.0), Ambient = Color.FromRgb(150, 150, 150), Diffuse = Color.FromRgb(255, 255, 255), Specular = Color.FromRgb(255, 255, 255), CutOff = 8.0, OuterCutOff = 12.0, Linear = 0.09, Quadratic = 0.03, Constant = 0.3 }; myScene.AddLight(l3); //Set the camera position myScene.Camera.Position = new Vector3D(0, 0, -300); myScene.CameraDefaultPosition = myScene.Camera.Position; }