public void Update(float deltaTime) { cam.UpdateViewMatrix(); ProjectionMatrix = cam.GetProjectionMatrix(); ViewMatrix = cam.GetViewMatrix(); m.UpdateExportedAnimation(); }
public void Update(float deltaTime) { cam.UpdateViewMatrix(); Gl.glUniform3fv(camposID, 1, cam.GetCameraPosition().to_array()); ProjectionMatrix = cam.GetProjectionMatrix(); ViewMatrix = cam.GetViewMatrix(); m.UpdateExportedAnimation(); enemy2.UpdateExportedAnimation(); }
public void Update(float deltaTime) { cam.UpdateViewMatrix(); ProjectionMatrix = cam.GetProjectionMatrix(); ViewMatrix = cam.GetViewMatrix(); zombie.UpdateAnimation(); Blade.UpdateAnimation(); for (int i = 0; i < bullets.Count; i++) { bullets[i].Update(); if (bullets[i].shouldBeDestroyed()) { bullets.RemoveAt(i); } } }
public void Initialize() { string projectPath = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName; Shader3D = new Shader(projectPath + "\\Shaders\\SimpleVertexShader.vertexshader", projectPath + "\\Shaders\\SimpleFragmentShader.fragmentshader"); WaterShader = new Shader(projectPath + "\\Shaders\\WaterVertexShader.vertexshader", projectPath + "\\Shaders\\WaterFragmentShader.fragmentshader"); //SkyBox BackTexture = new Texture(projectPath + "\\Textures\\back.jpg", 3, false); BottomTexture = new Texture(projectPath + "\\Textures\\bottom.jpg", 4, false); FrontTexture = new Texture(projectPath + "\\Textures\\front.jpg", 5, false); LeftTexture = new Texture(projectPath + "\\Textures\\left.jpg", 6, false); RightTexture = new Texture(projectPath + "\\Textures\\right.jpg", 7, false); TopTexture = new Texture(projectPath + "\\Textures\\top.jpg", 8, false); Gl.glClearColor(0, 0, 0.4f, 1); float[] SkyboxVertices = { // front -1, -1, 1, 1, 0, 1, 0, 0, //0 -1, 1, 1, 1, 0, 1, 0, 1, //1 1, -1, 1, 1, 0, 1, 1, 0, //2 1, -1, 1, 1, 0, 1, 1, 0, //3 1, 1, 1, 1, 0, 1, 1, 1, //4 -1, 1, 1, 1, 0, 1, 0, 1, //5 // back -1, 1, -1, 1, 0, 1, 0, 1, //6 -1, -1, -1, 1, 0, 1, 0, 0, //7 1, -1, -1, 1, 0, 1, 1, 0, //8 1, -1, -1, 1, 0, 1, 1, 0, //9 -1, 1, -1, 1, 0, 1, 0, 1, //10 1, 1, -1, 1, 0, 1, 1, 1, //11 // top -1, 1, 1, 1, 0, 1, 0, 0, //12 1, 1, 1, 1, 0, 1, 1, 0, //13 -1, 1, -1, 1, 0, 1, 0, 1, //14 1, 1, 1, 1, 0, 1, 1, 0, //15 -1, 1, -1, 1, 0, 1, 0, 1, //16 1, 1, -1, 1, 0, 1, 1, 1, //17 // bottom -1, -1, 1, 1, 0, 1, 0, 0, //18 1, -1, 1, 1, 0, 1, 1, 0, //19 -1, -1, -1, 1, 0, 1, 0, 1, //20 1, -1, 1, 1, 0, 1, 1, 0, //21 -1, -1, -1, 1, 0, 1, 0, 1, //22 1, -1, -1, 1, 0, 1, 1, 1, //23 // right 1, -1, 1, 1, 0, 1, 0, 0, //24 1, 1, 1, 1, 0, 1, 0, 1, //25 1, 1, -1, 1, 0, 1, 1, 1, //26 1, 1, -1, 1, 0, 1, 1, 1, //27 1, -1, 1, 1, 0, 1, 0, 0, //28 1, -1, -1, 1, 0, 1, 1, 0, //29 // left -1, -1, 1, 1, 0, 1, 1, 0, //30 -1, -1, -1, 1, 0, 1, 0, 0, //31 -1, 1, -1, 1, 0, 1, 0, 1, //32 -1, 1, -1, 1, 0, 1, 0, 1, //33 -1, -1, 1, 1, 0, 1, 1, 0, //34 -1, 1, 1, 1, 0, 1, 1, 1, //35 }; //Terrain TerrainImage = (Bitmap)Bitmap.FromFile("heightMap.jpg"); heights = new float[TerrainImage.Width, TerrainImage.Height]; TerrainVertices = new List <float>(); float h_size = TerrainImage.Height; float w_size = TerrainImage.Width; Color pixel; int x, y; for (x = 0; x < TerrainImage.Width; x++) { for (y = 0; y < TerrainImage.Height; y++) { pixel = TerrainImage.GetPixel(x, y); //get pixel di btrg3 el height"color" bta3 el pixel heights[x, y] = pixel.R; //bakhod el R component, kan momken akhod g,b bs msh fr2a 3shan hya grey scale } } for (int i = 0; i < TerrainImage.Width - 1; i++) // blef 3la TerrainImage, btl3 el pixel wl neighbours { // kda el list di feha vertices(x,y,z) w uv for (int j = 0; j < TerrainImage.Height - 1; j++) { TerrainVertices.Add(i); TerrainVertices.Add(heights[i, j] / 4); TerrainVertices.Add(j); TerrainVertices.Add(0); TerrainVertices.Add(1); TerrainVertices.Add(i + 1); TerrainVertices.Add(heights[i + 1, j] / 4); TerrainVertices.Add(j); TerrainVertices.Add(1); TerrainVertices.Add(1); TerrainVertices.Add(i); TerrainVertices.Add(heights[i, j + 1] / 4); TerrainVertices.Add(j); TerrainVertices.Add(0); TerrainVertices.Add(0); TerrainVertices.Add(i + 1); TerrainVertices.Add(heights[i + 1, j + 1] / 4); TerrainVertices.Add(j + 1); TerrainVertices.Add(1); TerrainVertices.Add(0); ////////////////////////////repeted SkyboxVertices 3shan arsm square m7taga six vertices msh 4 bs TerrainVertices.Add(i); TerrainVertices.Add(heights[i, j] / 4); TerrainVertices.Add(j); TerrainVertices.Add(0); TerrainVertices.Add(0); TerrainVertices.Add(i + 1); TerrainVertices.Add(heights[i, j] / 4); TerrainVertices.Add(j); TerrainVertices.Add(1); TerrainVertices.Add(1); } } scaleMatrix = glm.scale(new mat4(1), new vec3(50, 50, 50)); //grass GrassTexture = new Texture(projectPath + "\\Textures\\grass.jpg", 10, false); GrassVertices = new List <float>(); for (int i = 0; i < TerrainImage.Width - 1; i++) // blef 3la TerrainImage, btl3 el pixel wl neighbours { // kda el list di feha vertices(x,y,z) w uv for (int j = 0; j < TerrainImage.Height - 1; j++) { GrassVertices.Add(i); GrassVertices.Add(heights[i, j] / 4); GrassVertices.Add(j); GrassVertices.Add(0); GrassVertices.Add(1); GrassVertices.Add(i + 1); GrassVertices.Add(heights[i + 1, j] / 4); GrassVertices.Add(j); GrassVertices.Add(1); GrassVertices.Add(1); GrassVertices.Add(i); GrassVertices.Add(heights[i, j + 1] / 4); GrassVertices.Add(j); GrassVertices.Add(0); GrassVertices.Add(0); GrassVertices.Add(i + 1); GrassVertices.Add(heights[i + 1, j + 1] / 4); GrassVertices.Add(j + 1); GrassVertices.Add(1); GrassVertices.Add(0); GrassVertices.Add(i); GrassVertices.Add(heights[i, j] / 4); GrassVertices.Add(j); GrassVertices.Add(0); GrassVertices.Add(0); GrassVertices.Add(i + 1); GrassVertices.Add(heights[i, j] / 4); GrassVertices.Add(j); GrassVertices.Add(1); GrassVertices.Add(1); j += 8; } i += 8; } //Tree tree = new Model3D(); tree.LoadFile(projectPath + "\\ModelFiles\\static\\tree", 11, "Tree.obj"); TreeVertices = new List <float>(); for (int i = 0; i < TerrainImage.Width / 4; i++) { for (int j = 0; j < TerrainImage.Height / 4; j++) { TreeVertices.Add(i); TreeVertices.Add(heights[i, j] / 4); TreeVertices.Add(j); TreeVertices.Add(i + 1); TreeVertices.Add(heights[i + 1, j] / 4); TreeVertices.Add(j); TreeVertices.Add(i); TreeVertices.Add(heights[i, j + 1] / 4); TreeVertices.Add(j); } } //Water List <float> WaterVertices = new List <float>(); for (int i = 0; i < TerrainImage.Width / 4; i++) // blef 3la TerrainImage, btl3 el pixel wl neighbours { // kda el list di feha vertices(x,y,z) w uv for (int j = 0; j < TerrainImage.Height / 4; j++) { WaterVertices.Add(i); WaterVertices.Add(heights[i, j] / 4); WaterVertices.Add(j); WaterVertices.Add(0); WaterVertices.Add(1); WaterVertices.Add(i + 1); WaterVertices.Add(heights[i + 1, j] / 4); WaterVertices.Add(j); WaterVertices.Add(1); WaterVertices.Add(1); WaterVertices.Add(i); WaterVertices.Add(heights[i, j + 1] / 4); WaterVertices.Add(j); WaterVertices.Add(0); WaterVertices.Add(0); WaterVertices.Add(i + 1); WaterVertices.Add(heights[i + 1, j + 1] / 4); WaterVertices.Add(j + 1); WaterVertices.Add(1); WaterVertices.Add(0); WaterVertices.Add(i); WaterVertices.Add(heights[i, j] / 4); WaterVertices.Add(j); WaterVertices.Add(0); WaterVertices.Add(0); WaterVertices.Add(i + 1); WaterVertices.Add(heights[i, j] / 4); WaterVertices.Add(j); WaterVertices.Add(1); WaterVertices.Add(1); } } WaterTexture = new Texture(projectPath + "\\Textures\\water.PNG", 2); WaterTimeID = Gl.glGetUniformLocation(Shader3D.ID, "t"); //ground //ground = new Ground(256, 256, 0, 8); //Camera camera = new Camera(); camera.Reset(0, 5, 5, 0, 0, 0, 0, 1, 0); ProjectionMatrix = camera.GetProjectionMatrix(); ViewMatrix = camera.GetViewMatrix(); //Transformations and Shader Configurations transID = Gl.glGetUniformLocation(Shader3D.ID, "model"); projID = Gl.glGetUniformLocation(Shader3D.ID, "projection"); viewID = Gl.glGetUniformLocation(Shader3D.ID, "view"); DataID = Gl.glGetUniformLocation(Shader3D.ID, "data"); vec2 data = new vec2(100, 50); Gl.glUniform2fv(DataID, 1, data.to_array()); //Light int LightPositionID = Gl.glGetUniformLocation(Shader3D.ID, "LightPosition_worldspace"); vec3 lightPosition = new vec3(1.0f, 20f, 4.0f); Gl.glUniform3fv(LightPositionID, 1, lightPosition.to_array()); //setup the ambient light component. AmbientLightID = Gl.glGetUniformLocation(Shader3D.ID, "ambientLight"); vec3 ambientLight = new vec3(0.2f, 0.18f, 0.01f); Gl.glUniform3fv(AmbientLightID, 1, ambientLight.to_array()); //setup the eye position. EyePositionID = Gl.glGetUniformLocation(Shader3D.ID, "EyePosition_worldspace"); SkyboxBufferID = GPU.GenerateBuffer(SkyboxVertices); TerrainBufferID = GPU.GenerateBuffer(TerrainVertices.ToArray()); GrassBufferID = GPU.GenerateBuffer(GrassVertices.ToArray()); WaterBufferID = GPU.GenerateBuffer(WaterVertices.ToArray()); Gl.glEnable(Gl.GL_DEPTH_TEST); Gl.glDepthFunc(Gl.GL_LESS); }
public void Draw() { Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); Shader3D.UseShader(); /*WaterShader.UseShader();*/ //water motion /*if (reverse) * t -= 0.0002f; * else * t += 0.0002f; * if (t > 0.2f) * reverse = true; * if (t < 0) * reverse = false; * Gl.glUniform1f(WaterTimeID, t);*/ Gl.glUniformMatrix4fv(projID, 1, Gl.GL_FALSE, camera.GetProjectionMatrix().to_array()); Gl.glUniformMatrix4fv(viewID, 1, Gl.GL_FALSE, camera.GetViewMatrix().to_array()); Gl.glUniformMatrix4fv(transID, 1, Gl.GL_FALSE, scaleMatrix.to_array()); //SKYBOX START GPU.BindBuffer(SkyboxBufferID); Gl.glEnableVertexAttribArray(0); Gl.glVertexAttribPointer(0, 3, Gl.GL_FLOAT, Gl.GL_FALSE, 8 * sizeof(float), IntPtr.Zero); Gl.glEnableVertexAttribArray(1); Gl.glVertexAttribPointer(1, 3, Gl.GL_FLOAT, Gl.GL_FALSE, 8 * sizeof(float), (IntPtr)(3 * sizeof(float))); Gl.glEnableVertexAttribArray(2); Gl.glVertexAttribPointer(2, 2, Gl.GL_FLOAT, Gl.GL_FALSE, 8 * sizeof(float), (IntPtr)(6 * sizeof(float))); FrontTexture.Bind(); Gl.glDrawArrays(Gl.GL_TRIANGLES, 0, 6); BottomTexture.Bind(); Gl.glDrawArrays(Gl.GL_TRIANGLES, 18, 6); BackTexture.Bind(); Gl.glDrawArrays(Gl.GL_TRIANGLES, 6, 6); LeftTexture.Bind(); Gl.glDrawArrays(Gl.GL_TRIANGLES, 30, 6); RightTexture.Bind(); Gl.glDrawArrays(Gl.GL_TRIANGLES, 24, 6); TopTexture.Bind(); Gl.glDrawArrays(Gl.GL_TRIANGLES, 12, 6); //SKYBOX END //WATER START mat4 WaterModel = MathHelper.MultiplyMatrices(new List <mat4>() { glm.translate(new mat4(1), new vec3(-30, -65, -100)), glm.scale(new mat4(1), new vec3(2.5f, 0.6f, 0.6f)) }); Gl.glUniformMatrix4fv(transID, 1, Gl.GL_FALSE, WaterModel.to_array()); GPU.BindBuffer(WaterBufferID); Gl.glEnableVertexAttribArray(0); Gl.glVertexAttribPointer(0, 3, Gl.GL_FLOAT, Gl.GL_FALSE, 5 * sizeof(float), IntPtr.Zero); Gl.glEnableVertexAttribArray(2); Gl.glVertexAttribPointer(2, 2, Gl.GL_FLOAT, Gl.GL_FALSE, 5 * sizeof(float), (IntPtr)(3 * sizeof(float))); WaterTexture.Bind(); Gl.glEnable(Gl.GL_BLEND); Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA); Gl.glDrawArrays(Gl.GL_TRIANGLE_STRIP, 0, TerrainImage.Height / 4 * TerrainImage.Width / 4); Gl.glDisable(Gl.GL_BLEND); /*WaterTexture.Bind(); * Gl.glEnable(Gl.GL_BLEND); * Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA); * ground.Draw(transID); * Gl.glDisable(Gl.GL_BLEND);*/ //WATER END //TREE START for (int i = 0; i < 4500 - 3; i += 100) { //tree.scalematrix = glm.scale(new mat4(1), new vec3(2f, 2.5f, 2f)); tree.transmatrix = glm.translate(new mat4(1), new vec3(TreeVertices[i], -1 * TreeVertices[i + 1], TreeVertices[i + 2])); tree.Draw(transID); } //TREE END //GRASS START mat4 GrassModel = MathHelper.MultiplyMatrices(new List <mat4>() { glm.translate(new mat4(1), new vec3(-30, -65, -100)), glm.scale(new mat4(1), new vec3(1.5f, .3f, .3f)) }); Gl.glUniformMatrix4fv(transID, 1, Gl.GL_FALSE, GrassModel.to_array()); GPU.BindBuffer(GrassBufferID); Gl.glEnableVertexAttribArray(0); Gl.glVertexAttribPointer(0, 3, Gl.GL_FLOAT, Gl.GL_FALSE, 5 * sizeof(float), IntPtr.Zero); Gl.glEnableVertexAttribArray(2); Gl.glVertexAttribPointer(2, 2, Gl.GL_FLOAT, Gl.GL_FALSE, 5 * sizeof(float), (IntPtr)(3 * sizeof(float))); GrassTexture.Bind(); for (int i = 0; i < GrassVertices.Count;) { Gl.glDrawArrays(Gl.GL_TRIANGLES, i, 5); i += 5; } //GRASS END //TERRAIN START mat4 model = MathHelper.MultiplyMatrices(new List <mat4>() { glm.translate(new mat4(1), new vec3(-30, -65, -100)), glm.scale(new mat4(1), new vec3(0.9f, 0.6f, 0.6f)) }); //b3ml tranformations 3l terrain Gl.glUniformMatrix4fv(transID, 1, Gl.GL_FALSE, model.to_array()); GPU.BindBuffer(TerrainBufferID); Gl.glEnableVertexAttribArray(0); Gl.glVertexAttribPointer(0, 3, Gl.GL_FLOAT, Gl.GL_FALSE, 5 * sizeof(float), IntPtr.Zero); Gl.glEnableVertexAttribArray(2); Gl.glVertexAttribPointer(2, 2, Gl.GL_FLOAT, Gl.GL_FALSE, 5 * sizeof(float), (IntPtr)(3 * sizeof(float))); BottomTexture.Bind(); Gl.glDrawArrays(Gl.GL_TRIANGLE_STRIP, 0, TerrainImage.Height * TerrainImage.Width); Gl.glEnable(Gl.GL_BLEND); Gl.glBlendFunc(Gl.GL_SOURCE0_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA); //TERRAIN END Gl.glDisableVertexAttribArray(0); Gl.glDisableVertexAttribArray(1); }
public void Initialize() { string projectPath = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName; sh = new Shader(projectPath + "\\Shaders\\SimpleVertexShader.vertexshader", projectPath + "\\Shaders\\SimpleFragmentShader.fragmentshader"); //tex1 = new Texture(projectPath + "\\Textures\\grass_mix_d.jpg", 2); tex1 = new Texture(projectPath + "\\Textures\\ground_cracks2v_d.jpg", 2); tex = new Texture(projectPath + "\\Textures\\crate.jpg", 3); textri2 = new Texture(projectPath + "\\Textures\\crate.jpg", 4); //m = new md2LOL(projectPath + "\\ModelFiles\\animated\\md2LOL\\fiora.md2"); //bytl3 ghreb!!!!!!!!!! m = new md2LOL(projectPath + "\\ModelFiles\\zombie.md2"); m.StartAnimation(animType_LOL.STAND); m.rotationMatrix = glm.rotate((float)((-90.0f / 180) * Math.PI), new vec3(1, 0, 0)); m.scaleMatrix = glm.scale(new mat4(1), new vec3(0.8f, 0.8f, 0.8f)); m.TranslationMatrix = glm.translate(new mat4(1), new vec3(15, 1, 20)); // enemy2 = new md2LOL(projectPath + "\\ModelFiles\\animated\\md2LOL\\zombie1.md2"); enemy2 = new md2LOL(projectPath + "\\ModelFiles\\zombie.md2"); enemy2.StartAnimation(animType_LOL.STAND); enemy2.rotationMatrix = glm.rotate((float)((-90.0f / 180) * Math.PI), new vec3(1, 0, 0)); enemy2.scaleMatrix = glm.scale(new mat4(1), new vec3(0.8f, 0.8f, 0.8f)); enemy2.TranslationMatrix = glm.translate(new mat4(1), new vec3(30, 1, 20)); //building PROBLEM HERE building = new Model3D(); building.LoadFile(projectPath + "\\ModelFiles\\static\\building", 5, "Building 02.obj"); building.scalematrix = glm.scale(new mat4(1), new vec3(20, 20, 30)); building.transmatrix = glm.translate(new mat4(1), new vec3(200, 40, -300)); //tree tree = new Model3D(); tree.LoadFile(projectPath + "\\ModelFiles\\static\\tree", 6, "Tree.obj"); tree.scalematrix = glm.scale(new mat4(1), new vec3(5f, 10f, 5f)); tree.transmatrix = glm.translate(new mat4(1), new vec3(-70, 10, 1)); //spider spider = new Model3D(); spider.LoadFile(projectPath + "\\ModelFiles\\static\\spider", 7, "spider.obj"); spider.scalematrix = glm.scale(new mat4(1), new vec3(0.099f, 0.099f, 0.099f)); spider.transmatrix = glm.translate(new mat4(1), new vec3(-70, 2, 1)); //jeep jeep = new Model3D(); jeep.LoadFile(projectPath + "\\ModelFiles\\static\\car", 8, "dpv.obj"); jeep.scalematrix = glm.scale(new mat4(1), new vec3(0.1f, 0.1f, 0.1f)); jeep.transmatrix = glm.translate(new mat4(1), new vec3(-50, 5, 1)); jeep.rotmatrix = glm.rotate((float)((1 / 180) * Math.PI), new vec3(1, 0, 0)); //house house = new Model3D(); house.LoadFile(projectPath + "\\ModelFiles\\static\\house", 9, "house.obj"); house.scalematrix = glm.scale(new mat4(1), new vec3(9, 9, 9)); house.transmatrix = glm.translate(new mat4(1), new vec3(-60, 10, -45)); // skybox Downtex = new Texture(projectPath + "\\Textures\\nottingham_dn.jpg", 2); //ground Uptex = new Texture(projectPath + "\\Textures\\nottingham_up.jpg", 3); //up Fronttex = new Texture(projectPath + "\\Textures\\nottingham_ft.jpg", 4); //front Righttex = new Texture(projectPath + "\\Textures\\nottingham_rt.jpg", 5); //right Backtex = new Texture(projectPath + "\\Textures\\nottingham_bk.jpg", 6); ///back Lefttex = new Texture(projectPath + "\\Textures\\nottingham_lf.jpg", 7); //left //define normal for each vertex float[] ground = { -10.0f, 0.0f, 10.0f, 0, 0, 1, 0, 1, 0, 1, 0, 10.0f, 0.0f, -10.0f, 0, 0, 1, 1, 0, 0, 1, 0, -10.0f, 0.0f, -10.0f, 0, 0, 1, 0, 0, 0, 1, 0, 10.0f, 0.0f, 10.0f, 0, 0, 1, 1, 1, 0, 1, 0, -10.0f, 0.0f, 10.0f, 0, 0, 1, 0, 1, 0, 1, 0, 10.0f, 0.0f, -10.0f, 0, 0, 1, 1, 0, 0, 1, 0, }; vertexBufferID = GPU.GenerateBuffer(ground); //skybox Gl.glClearColor(1.0f, 1.0f, 1.0f, 1); float[] myCube = { //ground -10.0f, -1.0f,-10.0f, //0 1, 0, 0, 0, 1, 0, -10.0f, -1.0f,10.0f, //1 1, 0, 0, 0, 1, 0, 10.0f, -1.0f,10.0f,//2 1, 0, 0, 0, 1, 0, 10.0f, -1.0f,-10.0f,//3 1, 0, 0, 0, 1, 0, //roof -10.0f, 9.0f,-10.0f,//4 1, 0, 0, 0, 1, 0, -10.0f, 9.0f,10.0f,//10 1, 0, 0, 0, 1, 0, 10.0f, 9.0f,10.0f,//6 1, 0, 0, 0, 1, 0, 10.0f, 9.0f,-10.0f,//7 1, 0, 0, 0, 1, 0, //back -10.0f, -1.0f,-10.0f, //8 1, 0, 0, 0, 1, 0, -10.0f, 9.0f,-10.0f,//10 1, 0, 0, 0, 1, 0, //normal 10.0f, 9.0f,-10.0f,//9 1, 0, 0, 0, 1, 0, 10.0f, -1.0f,-10.0f,//11 1, 0, 0, 0, 1, 0, //right 10.0f, -1.0f,-10.0f,//12 1, 0, 0, 0, 1, 0, 10.0f, 9.0f,-10.0f,//14 1, 0, 0, 0, 1, 0, 10.0f, 9.0f,10.0f,//13 1, 0, 0, 0, 1, 0, 10.0f, -1.0f,10.0f,//110 1, 0, 0, 0, 1, 0, //front -10.0f, -1.0f,10.0f, //8 1, 0, 0, 0, 1, 0, 10.0f, -1.0f,10.0f,//11 1, 0, 0, 0, 1, 0, 10.0f, 9.0f,10.0f,//10 1, 0, 0, 0, 1, 0, -10.0f, 9.0f,10.0f,//9 1, 0, 0, 0, 1, 0, //left -10.0f, -1.0f,-10.0f, //20 1, 0, 0, 0, 1, 0, -10.0f, -1.0f,10.0f,//23 1, 0, 0, 0, 1, 0, -10.0f, 9.0f,10.0f,//21 1, 0, 0, 0, 1, 0, -10.0f, 9.0f,-10.0f,//22 1, 0, 0, 0, 1, 0, }; float[] CubeCoord = { //down 1, 0, 0, 0, 0, 1, 1, 1, /////22222 up 0, 0, 1, 0, 1, 1, 0, 1, /////333333 BACK 0, 1, 0, 0, 1, 0, 1, 1, /////444444 right 0, 1, 0, 0, 1, 0, 1, 1, /////555555 front 1, 1, 0, 1, 0, 0, 1, 0, /////66666 left 1, 1, 0, 1, 0, 0, 1, 0, }; SkyboxBufferID = GPU.GenerateBuffer(myCube); cubeCoordID = GPU.GenerateBuffer(CubeCoord); //triangle float[] TrianleCoord = { 0, 0, 1, 1, 0, 1, }; float[] triangle = { -1.0f, -1.0f, 0.0f, 0, 0, 0, 1.0f, -1.0f, 0.0f, 0, 0, 0, 0.0f, 1.0f, 0.0f, 0, 0, 0, }; vertexBufferID2 = GPU.GenerateBuffer(triangle); TriangleCoordID = GPU.GenerateBuffer(TrianleCoord); //2nd triangle //triangle float[] TrianleCoord2 = { 0, 0, 1, 1, 0, 1, }; float[] triangle2 = { -1.0f, -1.0f, 0.0f, 0, 0, 0, 1.0f, -1.0f, 0.0f, 0, 0, 0, 0.0f, 1.0f, 0.0f, 0, 0, 0, }; vertexBuffer2ID2 = GPU.GenerateBuffer(triangle2); TriangleCoord2ID = GPU.GenerateBuffer(TrianleCoord2); Gl.glClearColor(0, 0, 0.4f, 1); cam = new Camera(); cam.Reset(0, 34, 100, 0, 0, 0, 0, 1, 0); ProjectionMatrix = cam.GetProjectionMatrix(); ViewMatrix = cam.GetViewMatrix(); transID = Gl.glGetUniformLocation(sh.ID, "trans"); //7ala m7l l model kman fl vertex shader projID = Gl.glGetUniformLocation(sh.ID, "projection"); viewID = Gl.glGetUniformLocation(sh.ID, "view"); //modelID = Gl.glGetUniformLocation(sh.ID, "model"); modelmatrix = glm.scale(new mat4(1), new vec3(50, 50, 50)) * glm.translate(new mat4(1), new vec3(1, 1, 1)); //here! zombies // modelmatrix2 = glm.scale(new mat4(1), new vec3(15,15,15)) * glm.translate(new mat4(1), new vec3(80, 100, -100)); //wooden triangle1 sh.UseShader(); //get location of specular and attenuation then send their values //get location of light position and send its value //setup the ambient light component. //setup the eye position. camposID = Gl.glGetUniformLocation(sh.ID, "campos"); Gl.glEnable(Gl.GL_DEPTH_TEST); Gl.glDepthFunc(Gl.GL_LESS); }
public void Initialize() { string projectPath = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName; sh = new Shader(projectPath + "\\Shaders\\SimpleVertexShader.vertexshader", projectPath + "\\Shaders\\SimpleFragmentShader.fragmentshader"); d = new Texture(projectPath + "\\Textures\\skybox\\bottom.jpg", 1, true); u = new Texture(projectPath + "\\Textures\\skybox\\top.jpg", 2, true); l = new Texture(projectPath + "\\Textures\\skybox\\left.jpg", 3, true); r = new Texture(projectPath + "\\Textures\\skybox\\right.jpg", 4, true); f = new Texture(projectPath + "\\Textures\\skybox\\front.jpg", 5, true); b = new Texture(projectPath + "\\Textures\\skybox\\back.jpg", 6, true); groundTexture = new Texture(projectPath + "\\Textures\\ground.jpg", 7, true); shoot = new Texture(projectPath + "\\Textures\\gunshot.png", 8, true); cam = new Camera(); cam.Reset(0, 34, 55, 0, 0, 0, 0, 1, 0); float[] square = { -1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, -1, 0, -1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, -1, 0, -1, 1, 0, 0, 0, 1, 1, 0, -1, 1, 0, 0, 1, 1 }; skyboxBuffer_ID = GPU.GenerateBuffer(square); up = MathHelper.MultiplyMatrices(new List <mat4> { glm.rotate(3.1412f, new vec3(1, 0, 0)), glm.translate(new mat4(1), new vec3(0, 1, 0)) }); down = glm.translate(new mat4(1), new vec3(0, -1, 0)); // Dclare Matrices For transformation edges front = MathHelper.MultiplyMatrices(new List <mat4> { glm.rotate(90.0f / 180.0f * 3.1412f, new vec3(1, 0, 0)), glm.translate(new mat4(1), new vec3(0, 0, -1)) }); left = MathHelper.MultiplyMatrices(new List <mat4> { glm.rotate(90.0f / 180.0f * 3.1412f, new vec3(1, 0, 0)), glm.rotate(90.0f / 180.0f * 3.1412f, new vec3(0, 1, 0)), glm.translate(new mat4(1), new vec3(-1, 0, 0)) }); back = MathHelper.MultiplyMatrices(new List <mat4> { glm.rotate(90.0f / 180.0f * 3.1412f, new vec3(1, 0, 0)), glm.rotate(3.1412f, new vec3(0, 1, 0)), glm.translate(new mat4(1), new vec3(0, 0, 1)) }); right = MathHelper.MultiplyMatrices(new List <mat4> { glm.rotate(90.0f / 180.0f * 3.1412f, new vec3(1, 0, 0)), glm.rotate(-90.0f / 180.0f * 3.1412f, new vec3(0, 1, 0)), glm.translate(new mat4(1), new vec3(1, 0, 0)) }); ground = MathHelper.MultiplyMatrices(new List <mat4> { glm.scale(new mat4(1), new vec3(6000, 6000, 6000)), glm.translate(new mat4(1), new vec3(0, -45, 0)) }); building = new Model3D(); building.LoadFile(projectPath + "\\ModelFiles\\static\\building", 1, "Building 02.obj"); building.scalematrix = glm.scale(new mat4(1), new vec3(30, 30, 30)); building.transmatrix = glm.translate(new mat4(1), new vec3(1, 1, 1)); car = new Model3D(); car.LoadFile(projectPath + "\\ModelFiles\\static\\car", 3, "dpv.obj"); car.scalematrix = glm.scale(new mat4(1), new vec3(0.15f, 0.25f, 0.15f)); car.transmatrix = glm.translate(new mat4(1), new vec3(-150, -45.0f, 0.5f)); car.rotmatrix = glm.rotate(3.1412f, new vec3(0, 1, 0)); tree = new Model3D(); tree.LoadFile(projectPath + "\\ModelFiles\\static\\tree", 2, "Tree.obj"); tree.scalematrix = glm.scale(new mat4(1), new vec3(50, 50, 50)); tree.transmatrix = glm.translate(new mat4(1), new vec3(-240, -45.0f, 0.5f)); tree.rotmatrix = glm.rotate(3.1412f, new vec3(0, 1, 0)); Blade = new md2(projectPath + "\\ModelFiles\\animated\\md2\\blade\\Blade.md2"); Blade.StartAnimation(animType.STAND); Blade.rotationMatrix = glm.rotate((float)((-90.0f / 180) * Math.PI), new vec3(1, 0, 0)); Blade.scaleMatrix = glm.scale(new mat4(1), new vec3(0.8f, 0.8f, 0.8f)); Blade.TranslationMatrix = glm.translate(new mat4(1), new vec3(20, 19, -20)); zombie = new md2LOL(projectPath + "\\ModelFiles\\animated\\md2LOL\\zombie.md2"); zombie.StartAnimation(animType_LOL.STAND); zombie.rotationMatrix = glm.rotate((float)((-90.0f / 180) * Math.PI), new vec3(1, 0, 0)); zombie.scaleMatrix = glm.scale(new mat4(1), new vec3(0.8f, 0.8f, 0.8f)); spider = new Model3D(); spider.LoadFile(projectPath + "\\ModelFiles\\static\\spider", 4, "spider.obj"); spider.transmatrix = glm.translate(new mat4(1), new vec3(240, 0.0f, 0)); spider.rotmatrix = glm.rotate((float)((-90.0f / 180) * Math.PI), new vec3(0, 1, 0)); HandsWGun = new Model3D(); HandsWGun.LoadFile(projectPath + "\\ModelFiles\\hands with gun", 8, "gun.obj"); HandsWGun.scalematrix = glm.scale(new mat4(1), new vec3(0.2f, 0.2f, 0.2f)); bulletModel = new Model3D(); bulletModel.LoadFile(projectPath + "\\ModelFiles\\static\\bullet", 8, "bullet.obj"); sh.UseShader(); Gl.glClearColor(0, 0, 0.4f, 1); ProjectionMatrix = cam.GetProjectionMatrix(); ViewMatrix = cam.GetViewMatrix(); modelID = Gl.glGetUniformLocation(sh.ID, "model"); projID = Gl.glGetUniformLocation(sh.ID, "projection"); viewID = Gl.glGetUniformLocation(sh.ID, "view"); sh.UseShader(); c = timer; }
public void Update() { //update view and projection matrix cam.UpdateViewMatrix(); ViewMatrix = cam.GetViewMatrix(); ProjectionMatrix = cam.GetProjectionMatrix(); //Keyframes if (GraphicsForm.runAnimation == true) { int startKeyFrame = GraphicsForm.startFrame; int endKeyFrame = GraphicsForm.endFrame;// startKeyFrame + 1; time = startKeyFrame; interpolatedList = new List <float>(); time += speed; time %= endKeyFrame; float alpha = (time - startKeyFrame) / (endKeyFrame - startKeyFrame); //to fill the main keyframes list just one time if (initialzeList == 1) { foreach (KeyFrame keyFrame in GraphicsForm.vertexKeyFramesDict.Values) { tempKeyFrameList = new List <float>(); foreach (List <float> l in keyFrame.verticesDict.Values) { tempKeyFrameList.AddRange(l); } int numOfFrames = keyFrame.numOfInterpolatedFrames; Tuple <int, List <float> > t = new Tuple <int, List <float> >(numOfFrames, tempKeyFrameList); mainKeyFrameList.Add(t); } initialzeList = 0; } //to fill the interpolated list with the start, interpolated, end frames for (int i = startKeyFrame; i < endKeyFrame; i++) { //ba7ot al start bta3e ele howa(0,0,0...) interpolatedList.AddRange(mainKeyFrameList[i].Item2); int count = mainKeyFrameList[i].Item2.Count; //Item1: num of required interpolated frames for (int j = 0; j < mainKeyFrameList[i + 1].Item1; j++) { int indx = 0; for (; indx < mainKeyFrameList[i + 1].Item2.Count; indx++) { float interpolatedValue = (alpha * (mainKeyFrameList[i + 1].Item2[indx] - mainKeyFrameList[i].Item2[indx])) + mainKeyFrameList[i].Item2[indx]; interpolatedList.Add(interpolatedValue); } time += speed; time %= endKeyFrame; alpha = (time - startKeyFrame) / (endKeyFrame - startKeyFrame); } } interpolatedList.AddRange(mainKeyFrameList[endKeyFrame].Item2); } }
public void Initialize() { string projectPath = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName; sh = new Shader(projectPath + "\\Shaders\\SimpleVertexShader.vertexshader", projectPath + "\\Shaders\\SimpleFragmentShader.fragmentshader"); Gl.glClearColor(0.6f, 0.6f, 0.6f, 1); float[] backGroundVertices = { //plane -2.0f, 0.0f, 2.0f, 1.0f, 1.0f, 1.0f, //color w -2.0f, 0.0f, -2.0f, 1.0f, 1.0f, 1.0f, //color w 2.0f, 0.0f, -2.0f, 1.0f, 1.0f, 1.0f, //color w 2.0f, 0.0f, 2.0f, 1.0f, 1.0f, 1.0f, //color w //Axis //x -2.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, //R 2.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, //R //y 0.0f, -2.0f, 0.0f, 0.0f, 1.0f, 0.0f, //G 0.0f, 2.0f, 0.0f, 0.0f, 1.0f, 0.0f, //G //z 0.0f, 0.0f, 2.0f, 0.0f, 0.0f, 1.0f, //B 0.0f, 0.0f, -2.0f, 0.0f, 0.0f, 1.0f, //B }; sh.UseShader(); planeBufferID = GPU.GenerateBuffer(backGroundVertices); vertexID = GPU.GenerateBuffer(verts.ToArray()); transID = Gl.glGetUniformLocation(sh.ID, "trans"); projID = Gl.glGetUniformLocation(sh.ID, "projection"); viewID = Gl.glGetUniformLocation(sh.ID, "view"); DataID = Gl.glGetUniformLocation(sh.ID, "data"); EyePositionID = Gl.glGetUniformLocation(sh.ID, "EyePosition_worldspace"); AmbientLightID = Gl.glGetUniformLocation(sh.ID, "ambientLight"); DiffuseLightID = Gl.glGetUniformLocation(sh.ID, "diffuseLight"); SpecularLightID = Gl.glGetUniformLocation(sh.ID, "specularLight"); LightPosID = Gl.glGetUniformLocation(sh.ID, "LightPosition_worldspace"); checkTextureID = Gl.glGetUniformLocation(sh.ID, "checkTextureOut"); checkLightID = Gl.glGetUniformLocation(sh.ID, "checkLightOut"); cam = new Camera(); cam.Reset(0, 2, 5, 0, 0, 0, 0, 1, 0); ProjectionMatrix = cam.GetProjectionMatrix(); ViewMatrix = cam.GetViewMatrix(); // Model matrix: apply transformations to the model List <mat4> transformations = new List <mat4>(); transformations.Add(glm.scale(new mat4(1), new vec3(1, 2, 1))); transformations.Add(glm.rotate(-30.0f / 180 * 3.14f, new vec3(0, 1, 0))); ModelMatrix = MathHelper.MultiplyMatrices(transformations); }
protected void ShowCore(FrameEventArgs e) { // workspace viewport GL.Viewport((int)(0.25 * Width), 0, (int)(0.75 * Width), Height); GL.Enable(EnableCap.DepthTest); // TODO: fix depth test so that it doesn't hide objects behind alpha-fragments // clearing viewport GL.Enable(EnableCap.ScissorTest); GL.Scissor((int)(0.25 * Width), 0, (int)(0.75 * Width), Height); GL.ClearColor(0.2f, 0.3f, 0.3f, 1.0f); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit); GL.Disable(EnableCap.ScissorTest); // attaching shader _shader.Use(); // set view and projection matrices; // these matrices come pre-transposed, so there's no need to transpose them again (see VertexShader file) _shader.SetMatrix4("view", _camera.GetViewMatrix(), false); _shader.SetMatrix4("projection", _camera.GetProjectionMatrix(), false); // set general properties _shader.SetVector3("viewPos", _camera.Position); // set directional light properties _shader.SetVector3("dirLight[0].direction", new Vector3(1.0f, 0.0f, 0.0f)); _shader.SetVector3("dirLight[1].direction", new Vector3(0.0f, -1.0f, 0.0f)); _shader.SetVector3("dirLight[2].direction", new Vector3(0.0f, 0.0f, -1.0f)); for (int i = 0; i < 3; i++) { _shader.SetVector3($"dirLight[{i}].ambient", new Vector3(0.05f, 0.05f, 0.05f)); _shader.SetVector3($"dirLight[{i}].diffuse", new Vector3(0.75f, 0.75f, 0.75f)); _shader.SetVector3($"dirLight[{i}].specular", new Vector3(0.5f, 0.5f, 0.5f)); } // setup line shader lineShader.Use(); lineShader.SetMatrix4("view", _camera.GetViewMatrix(), false); lineShader.SetMatrix4("projection", _camera.GetProjectionMatrix(), false); lineShader.SetVector3("color", Vector3.One); Matrix4 model; if (ManipLoaded) { // obstacles & colliders if (obstacles.Contains(null)) { for (int i = 0; i < obstacles.Length; i++) { obstacles[i] = new Entity(lineShader, GL_Convert(Manager.Obstacles[i].Data, Vector4.One)); switch (Manager.Obstacles[i].Collider.Shape) { case ColliderShape.Box: boundings[i] = new Entity(lineShader, GL_Convert(Manager.Obstacles[i].Collider.Data, new Vector4(Vector3.UnitY, 1.0f)), new uint[] { 0, 1, 2, 3, 0, 4, 5, 1, 5, 6, 2, 6, 7, 3, 7, 4 }); break; case ColliderShape.Sphere: boundings[i] = new Entity(lineShader, GL_Convert(Manager.Obstacles[i].Collider.Data, new Vector4(Vector3.UnitY, 1.0f))); lon[i] = new Entity(lineShader, GL_Convert(Manager.Obstacles[i].Collider.Data, new Vector4(Vector3.UnitY, 1.0f)), ((Sphere)Manager.Obstacles[i].Collider).indicesLongitude); break; } } } else { float dt; if (forward) { dt = (float)e.Time; if (time > 1) { forward = false; } } else { dt = -(float)e.Time; if (time < -1) { forward = true; } } time += dt; model = Matrix4.Identity * Matrix4.CreateTranslation(time, 0, 0); for (int i = 0; i < obstacles.Length; i++) { Manager.Obstacles[i].Move(Vector3.UnitX, dt); obstacles[i].Display(model, () => { GL.DrawArrays(PrimitiveType.Points, 0, Manager.Obstacles[i].Data.Length); }); if (Dispatcher.WorkspaceBuffer.ObstBuffer[i].ShowBounding) { boundings[i].Display(model, Manager.Obstacles[i].Collider.Draw); lon[i].Display(model, ((Sphere)Manager.Obstacles[i].Collider).DrawLongitudes); } } } for (int j = 0; j < Manager.Manipulators.Length; j++) { Manipulator manip = Manager.Manipulators[j]; // goal if (goal[j] == null) { if (manip.States["Goal"]) { List <Vector3> MainAttr = new List <Vector3> { manip.GoodAttractors[0].Center }; MainAttr.AddRange(manip.GoodAttractors[0].Area); goal[j] = new Entity(lineShader, GL_Convert(MainAttr.ToArray(), new Vector4(1.0f, 1.0f, 0.0f, 1.0f))); } } else { model = Matrix4.Identity; goal[j].Display(model, () => { GL.PointSize(5); GL.DrawArrays(PrimitiveType.Points, 0, 1); GL.PointSize(1); GL.DrawArrays(PrimitiveType.Points, 1, manip.GoodAttractors[0].Area.Length); }); } // path if (manip.States["Path"] && manip.Path != null) { int count = manip.Path.Count; path[j] = new Entity(lineShader, GL_Convert(manip.Path.ToArray(), new Vector4(Vector3.UnitX, 1.0f))); model = Matrix4.Identity; path[j].Display(model, () => { GL.DrawArrays(PrimitiveType.LineStrip, 0, count); }); } // random tree if (manip.Tree != null) { // block the manager thread while updating tree Dispatcher.ThreadHandle.Reset(); // add all elements from addition buffer to the hash set var add = new List <Logic.PathPlanning.Tree.Node>(manip.Tree.AddBuffer); tree[j].UnionWith(add); manip.Tree.AddBuffer.Clear(); // delete all elements contained in deletion buffer from the hash set var del = new List <Logic.PathPlanning.Tree.Node>(manip.Tree.DelBuffer); tree[j].ExceptWith(del); manip.Tree.DelBuffer.Clear(); // unblock the manager thread to continue calculations Dispatcher.ThreadHandle.Set(); } if (Dispatcher.WorkspaceBuffer.JointBuffer[j].ShowTree) { model = Matrix4.Identity; foreach (var node in tree[j]) { if (node.Entity == null) { node.Entity = CreateTreeBranch(node.p, node.Parent.p); } node.Entity.Display(model, () => { GL.DrawArrays(PrimitiveType.LineStrip, 0, 2); }); } } // draw manipulator configuration if its model is loaded properly if (ManipLoaded) { manip.Draw(_shader); } } } // workspace grid model = Matrix4.Identity; grid.Display(model, () => { GL.DrawArrays(PrimitiveType.LineStrip, 0, 2); GL.DrawArrays(PrimitiveType.LineStrip, 2, 2); }); for (int i = 1; i < 11; i++) { model = Matrix4.CreateTranslation(Vector3.UnitZ * i); grid.Display(model, () => { GL.DrawArrays(PrimitiveType.LineStrip, 0, 2); }); model = Matrix4.CreateTranslation(Vector3.UnitZ * -i); grid.Display(model, () => { GL.DrawArrays(PrimitiveType.LineStrip, 0, 2); }); model = Matrix4.CreateTranslation(Vector3.UnitX * i); grid.Display(model, () => { GL.DrawArrays(PrimitiveType.LineStrip, 2, 2); }); model = Matrix4.CreateTranslation(Vector3.UnitX * -i); grid.Display(model, () => { GL.DrawArrays(PrimitiveType.LineStrip, 2, 2); }); } model = Matrix4.Identity; gridFloor.Display(model, () => { // the workspace grid rendering is done lastly, because it's common to render all transparent objects at last // // the blending function is determined as follows: // Color = SourceColor * SourceFactor + DestColor * DestFactor, // where // SourceColor - color of the currently rendering fragment, // SourceFactor - its factor, // DestColor - color of the already rendered fragment (the one in the color buffer), // DestFactor - its factor. // // so, to render transparent floor, we take SourceFactor as source's alpha (floor's alpha) and DestFactor as the remainder of the source's alpha // (the visible amount of the opaque object behind the floor) GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha); GL.DrawElements(BeginMode.Triangles, 7, DrawElementsType.UnsignedInt, 0); GL.Disable(EnableCap.Blend); }); //ImGui.ShowDemoWindow(); base.OnRenderFrame(e); }
public void Initialize() { string projectPath = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName; sh = new Shader(projectPath + "\\Shaders\\SimpleVertexShader.vertexshader", projectPath + "\\Shaders\\SimpleFragmentShader.fragmentshader"); tex = new Texture(projectPath + "\\Textures\\crate.jpg", 0); down = new Texture(projectPath + "\\Textures\\down.jpg", 1); right = new Texture(projectPath + "\\Textures\\right.jpg", 2); left = new Texture(projectPath + "\\Textures\\left.jpg", 3); up = new Texture(projectPath + "\\Textures\\up.jpg", 4); front = new Texture(projectPath + "\\Textures\\front.jpg", 5); back = new Texture(projectPath + "\\Textures\\back.jpg", 6); tex1 = new Texture(projectPath + "\\Textures\\Ground.jpg", 2); m = new md2LOL(projectPath + "\\ModelFiles\\zombie.md2"); m.StartAnimation(animType_LOL.RUN); m.rotationMatrix = glm.rotate((float)((-90.0f / 180) * Math.PI), new vec3(1, 0, 0)); m.scaleMatrix = glm.scale(new mat4(1), new vec3(0.0093f, 0.0093f, 0.0093f)); m.TranslationMatrix = glm.translate(new mat4(1), new vec3(0, -2, 5)); ////define normal for each vertex m2 = new md2LOL(projectPath + "\\ModelFiles\\wolf.md2"); m2.StartAnimation(animType_LOL.ATTACK1); m2.rotationMatrix = glm.rotate((float)((-90.0f / 180) * Math.PI), new vec3(1, 0, 0)); m2.scaleMatrix = glm.scale(new mat4(1), new vec3(0.008f, 0.008f, 0.008f)); m2.TranslationMatrix = glm.translate(new mat4(1), new vec3(-2, -2, 5)); Gl.glClearColor(0, 0, 0, 1); float ground = 1; float[] skybox = { -ground, -ground, -ground, 0, 0, ground, -ground, -ground, 1, 0, ground, ground, -ground, 1, 1, -ground, -ground, -ground, 0, 0, -ground, ground, -ground, 0, 1, ground, ground, -ground, 1, 1 }; float[] verts = { -1.0f, -1.0f, 0.0f, 0, 0, 1.0f, -1.0f, 0.0f, 1, 0, 0.0f, 1.0f, 0.0f, 0.5f, 1 }; vertexBufferID = GPU.GenerateBuffer(skybox); vertexBufferID2 = GPU.GenerateBuffer(verts); scaleMat = glm.scale(new mat4(1), new vec3(200f, 200f, 200f)); cam = new Camera(); ProjectionMatrix = cam.GetProjectionMatrix(); ViewMatrix = cam.GetViewMatrix(); transID = Gl.glGetUniformLocation(sh.ID, "model"); projID = Gl.glGetUniformLocation(sh.ID, "projection"); viewID = Gl.glGetUniformLocation(sh.ID, "view"); leftmatrix = MathHelper.MultiplyMatrices(new List <mat4>() { glm.rotate(90.0f / 180.0f * 3.1412f, new vec3(0, 1, 0)), glm.translate(new mat4(1), new vec3(0, 0, 0)), scaleMat }); rightmatrix = MathHelper.MultiplyMatrices(new List <mat4>() { glm.rotate(270f / 180.0f * 3.1412f, new vec3(0, 1, 0)), glm.translate(new mat4(1), new vec3(0, 0, 0)), scaleMat }); upmatrix = MathHelper.MultiplyMatrices(new List <mat4>() { glm.rotate(90 / 180.0f * 3.1412f, new vec3(1, 0, 0)), glm.translate(new mat4(1), new vec3(0, 0, 0)), scaleMat }); backmatrix = MathHelper.MultiplyMatrices(new List <mat4>() { glm.rotate(180f / 180f * 3.1412f, new vec3(0, 1, 0)), glm.translate(new mat4(1), new vec3(0, 0, 0)), scaleMat }); groundmatrix = MathHelper.MultiplyMatrices(new List <mat4>() { glm.rotate(90f / 180.0f * 3.1412f, new vec3(1, 0, 0)), glm.translate(new mat4(1), new vec3(0, -2, 0)), scaleMat }); //Gl.glClearColor(0, 0, 0.4f, 1); //cam = new Camera(); cam.Reset(0, -1.75f, 0, 0, 0, 0, 0, 0, 0); ProjectionMatrix = cam.GetProjectionMatrix(); ViewMatrix = cam.GetViewMatrix(); modelmatrix = glm.scale(new mat4(1), new vec3(50, 50, 50)); tree = new Model3D(); tree.LoadFile(projectPath + "\\ModelFiles\\tree", 6, "Tree.obj"); tree.scalematrix = glm.scale(new mat4(1), new vec3(0.1f, 0.1f, 0.1f)); tree.transmatrix = glm.translate(new mat4(1), new vec3(0.6f, -2, 0.4f)); //tree2 = new Model3D(); //tree2.LoadFile(projectPath + "\\ModelFiles\\Tree1", 6, "Tree1.obj"); //tree2.scalematrix = glm.scale(new mat4(1), new vec3(30, 30, 30)); treee3 = new Model3D(); treee3.LoadFile(projectPath + "\\ModelFiles\\Wolf Rigged and Game Ready", 6, "Wolf.fbx"); treee3.scalematrix = glm.scale(new mat4(1), new vec3(0.1f, 0.1f, 0.1f)); treee3.transmatrix = glm.translate(new mat4(1), new vec3(-0.6f, -2, 0.4f)); treee3.rotmatrix = glm.rotate((float)((-180.0f / 180) * Math.PI), new vec3(1, 0, 0)); //car = new Model3D(); //car.LoadFile(projectPath + "\\ModelFiles\\car", 6, "dpv.obj"); //car.scalematrix = glm.scale(new mat4(1), new vec3(15, 1, 15)); cottage = new Model3D(); cottage.LoadFile(projectPath + "\\ModelFiles\\House", 6, "house.obj"); cottage.scalematrix = glm.scale(new mat4(1), new vec3(0.1f, 0.1f, 0.1f)); cottage.transmatrix = glm.translate(new mat4(1), new vec3(-0.6f, -2f, 0.4f)); jeep = new Model3D(); jeep.LoadFile(projectPath + "\\ModelFiles\\jeep", 9, "jeep1.3ds"); jeep.scalematrix = glm.scale(new mat4(1), new vec3(0.05f, 0.05f, 0.05f)); jeep.transmatrix = glm.translate(new mat4(1), new vec3(1f, -2f, 1f)); jeep.rotmatrix = glm.rotate((float)((-90.0f / 180) * Math.PI), new vec3(1, 0, 0)); //jeep2 = new Model3D(); //jeep2.LoadFile(projectPath + "\\ModelFiles\\jeep", 10, "jeep1.3ds"); //jeep2.scalematrix = glm.scale(new mat4(1), new vec3(5, 5, 5)); //jeep2.transmatrix = glm.translate(new mat4(1), new vec3(-80, 1, 180)); //jeep2.rotmatrix = glm.rotate((float)((-90.0f / 180) * Math.PI), new vec3(1, 0, 0)); //get location of specular and attenuation then send their values //get location of light position and send its value //setup the ambient light component. //setup the eye position. Gl.glEnable(Gl.GL_DEPTH_TEST); Gl.glDepthFunc(Gl.GL_LESS); }