// 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)); }
// initialize public void Init() { screen.Print("Move: UP, DOWN, LEFT, RIGHT", 10, 10, 10); // load teapot mesh = new Mesh("../../assets/teapot.obj"); floor = new Mesh("../../assets/floor.obj"); eye = new Mesh("../../assets/eyeball.obj"); moon = new Mesh("../../assets/moon.obj"); earth = new Mesh("../../assets/earth.obj"); jet = new Mesh("../../assets/jet.obj"); // initialize stopwatch timer = new Stopwatch(); timer.Reset(); timer.Start(); // create shaders shader = new Shader("../../shaders/vs.glsl", "../../shaders/fs.glsl"); // load a texture wood = new Texture("../../assets/wood.jpg"); eyeR = new Texture("../../assets/ref1.jpg"); crater = new Texture("../../assets/crater.jpg"); land = new Texture("../../assets/land.jpg"); stars = new Texture("../../assets/stars.jpg"); jetp = new Texture("../../assets/jetp.png"); //add light int lightID = GL.GetUniformLocation(shader.programID, "lightPos"); GL.UseProgram(shader.programID); GL.Uniform3(lightID, 0f, 10f, 0.0f); //add camera position Tc = Matrix4.CreateTranslation(new Vector3(0, -25.5f, 0)) * Matrix4.CreateFromAxisAngle(new Vector3(1, 0, 0), PI / 2); Vector4 c = Tc * (new Vector4(0f, 0f, 0f, 1f)); int cameraID = GL.GetUniformLocation(shader.programID, "cPos"); GL.UseProgram(shader.programID); GL.Uniform4(cameraID, c); //create scenegraph meshes = new scenegraph(floor, Matrix4.CreateScale(6.0f) * Matrix4.CreateFromAxisAngle(new Vector3(0, 1, 0), 0), stars, shader); meshes.addNode(mesh, Matrix4.CreateScale(0.5f) * Matrix4.CreateFromAxisAngle(new Vector3(0, 1, 0), 0), wood, shader); meshes.getChildren()[0].addNode(mesh, Matrix4.CreateScale(0.5f) * Matrix4.CreateTranslation(new Vector3(5, 0, 0)) * Matrix4.CreateFromAxisAngle(new Vector3(0, 1, 0), 0), wood, shader); meshes.getChildren()[0].getChildren()[0].addNode(mesh, Matrix4.CreateScale(0.25f) * Matrix4.CreateTranslation(new Vector3(8, 0, 0)) * Matrix4.CreateFromAxisAngle(new Vector3(0, 1, 0), 0), wood, shader); }