// initialize public void Init() { sGraph = new scenegraph(this.screen); wood = new Texture("../../assets/wood.jpg"); // load stuff mesh = new Mesh("../../assets/teapot.obj"); floor = new Mesh("../../assets/floor.obj"); floor.texture = wood; floor.modelAxis = new Vector3(0, 1, 0); floor.worldAxis = new Vector3(0, 1, 0); floor.modelRotate = 0.0f; floor.modelRSpeed = 0.0f; mesh.texture = wood; mesh.location = Matrix4.CreateScale(0.75f) * Matrix4.CreateTranslation(0, 0, 0); sGraph.addChild(floor); // initialize stopwatch timer = new Stopwatch(); timer.Reset(); timer.Start(); // create the render target target = new RenderTarget(screen.width, screen.height); quad = new ScreenQuad(); shader = new Shader("../../shaders/vs.glsl", "../../shaders/fs.glsl"); postproc = new Shader("../../shaders/vs_post.glsl", "../../shaders/fs_post.glsl"); int lightID = GL.GetUniformLocation(shader.programID, "lightPos"); light1 = new light(shader, new Vector3(0, 2, 0), new Vector3(10, 10, 10)); GL.UseProgram(shader.programID); GL.Uniform3(lightID, new Vector3(1, 1, 1)); }
bool useRenderTarget = true; // post-processing // initialize public void Init() { // load texture wood = new Texture("../../assets/wood.jpg"); // load lights List <Light> ls = new List <Light>(); ls.Add(new Light(new Vector4(0, 2, 0, 1), new Vector3(8.0f, 8.0f, 8.0f), Vector3.Zero, Key.Number0)); ls.Add(new Light(new Vector4(1, 1, 1, 1), new Vector3(8.0f, 8.0f, 8.0f), new Vector3(-1.0f, -1.0f, -1.0f), Key.Number1, 12.5f, 15.0f)); ls.Add(new Light(new Vector4(1, 1, -1, 1), new Vector3(8.0f, 0.0f, 0.0f), new Vector3(-1.0f, -1.0f, 1.0f), Key.Number2, 12.5f, 15.0f)); ls.Add(new Light(new Vector4(-1, 1, 1, 1), new Vector3(0.0f, 8.0f, 0.0f), new Vector3(1.0f, -1.0f, -1.0f), Key.Number3, 12.5f, 15.0f)); ls.Add(new Light(new Vector4(-1, 1, -1, 1), new Vector3(0.0f, 0.0f, 8.0f), new Vector3(1.0f, -1.0f, 1.0f), Key.Number4, 12.5f, 15.0f)); lights = ls.ToArray(); // load turret teapot and floor turret = new Mesh("../../assets/teapot.obj", wood, lights); floor = new Mesh("../../assets/floor.obj", wood, lights); // the floor is base of the world, with the turret as its first child world.Add(floor); floor.children.Add(turret); // initialize stopwatch timer = new Stopwatch(); timer.Reset(); timer.Start(); // create shaders shader = new Shader("../../shaders/vs.glsl", "../../shaders/fs.glsl", BuildULightArray()); postproc = new Shader("../../shaders/vs_post.glsl", "../../shaders/fs_post.glsl", BuildULightArray()); // create the render target target = new RenderTarget(screen.width, screen.height); quad = new ScreenQuad(); }
// initialize public void Init() { // create shaders shader = new Shader("../../shaders/vs.glsl", "../../shaders/fs.glsl"); postproc = new Shader("../../shaders/vs_post.glsl", "../../shaders/fs_post.glsl"); // load a texture wood = new Texture("../../assets/wood.jpg"); silver = new Texture("../../assets/silver3.jpg"); dark = new Texture("../../assets/dark4.jpg"); // load car and flag flag = new Mesh("../../assets/teapot.obj", car, shader, dark); car = new Mesh("../../assets/db8.obj", floor, shader, silver); floor = new Mesh("../../assets/floor.obj", null, shader, wood); // initialize stopwatch timer = new Stopwatch(); timer.Reset(); timer.Start(); // create the render target target = new RenderTarget(screen.width, screen.height); quad = new ScreenQuad(); //set the light Light light1 = new Light(GL.GetUniformLocation(shader.programID, "lightPos"), shader); light1.setLight(3, 3, 3); //set the ambient light color int ambientID = GL.GetUniformLocation(shader.programID, "ambientColor"); GL.UseProgram(shader.programID); GL.Uniform3(ambientID, 0.5f, 0.4f, 0.3f); }
public scenegraph(Surface display) { //Assign target rTarget = new RenderTarget(display.width, display.height); postQuad = new ScreenQuad(); //Begin init of render tree renderTree = new List <Mesh>(); //Assign shaders shader = new Shader("../../shaders/vs.glsl", "../../shaders/fs.glsl"); postShader = new Shader("../../shaders/vs_post.glsl", "../../shaders/fs_post.glsl"); }