public void Initialize() { string projectPath = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName; sh = new Shader(projectPath + "\\Shaders\\SimpleVertexShader.vertexshader", projectPath + "\\Shaders\\SimpleFragmentShader.fragmentshader"); mySound = new SoundPlayer(projectPath + "\\Sounds\\ChillingMusic.wav"); mySound.PlayLooping(); startScreen = new Screen("CALLofDUTY.jpg"); screenTex = startScreen.GetScreenTexture(); screenBufferID = GPU.GenerateBuffer(startScreen.GetScreenSquare()); started = false; float[] skybox = LoadSkybox(projectPath); vertexBufferID = GPU.GenerateBuffer(skybox); hero = new Player(); enemiesList = new List <Enemy>(); enemiesList.Add(new Enemy()); enemiesList.Add(new Enemy()); enemiesList.Add(new Enemy()); enemiesList.Add(new Enemy()); enemiesList.Add(new Enemy()); enemiesList.Add(new Enemy()); bulletsList = new List <Bullet>(); ObstaclesColliders = new List <AABoundingBox>(); //House house = new Model3D(); house.LoadFile(projectPath + "\\ModelFiles\\models\\3DS\\House", 9, "house.obj"); house.transmatrix = glm.translate(new mat4(1), new vec3(20, 0, -10)); AABoundingBox box = new AABoundingBox(house.GetCurrentVertices(), ColliderType.Obstacle); box.SetCenter(new vec3(20, 0, -10)); ObstaclesColliders.Add(box); //jeep jeep = new Model3D(); jeep.LoadFile(projectPath + "\\ModelFiles\\models\\3DS\\jeep", 10, "jeep1.3ds"); jeep.scalematrix = glm.scale(new mat4(1), new vec3(0.3f, 0.3f, 0.3f)); jeep.transmatrix = glm.translate(new mat4(1), new vec3(14, 0, 0)); jeep.rotmatrix = glm.rotate((float)((-90.0f / 180) * Math.PI), new vec3(1, 0, 0)); box = new AABoundingBox(jeep.GetCurrentVertices(), ColliderType.Obstacle); box.Scale(new vec3(0.3f, 0.3f, 0.3f)); box.SetCenter(new vec3(14, 0, 0)); ObstaclesColliders.Add(box); //jeep2 jeep2 = new Model3D(); jeep2.LoadFile(projectPath + "\\ModelFiles\\models\\3DS\\jeep", 10, "jeep1.3ds"); jeep2.scalematrix = glm.scale(new mat4(1), new vec3(0.3f, 0.3f, 0.3f)); jeep2.transmatrix = glm.translate(new mat4(1), new vec3(26, 0, 0)); jeep2.rotmatrix = glm.rotate((float)((-90.0f / 180) * Math.PI), new vec3(1, 0, 0)); box = new AABoundingBox(jeep2.GetCurrentVertices(), ColliderType.Obstacle); box.Scale(new vec3(0.3f, 0.3f, 0.3f)); box.SetCenter(new vec3(26, 0, 0)); ObstaclesColliders.Add(box); //Weapon weaponTex = new Texture(projectPath + "\\Textures\\engineflare1.jpg", 7); Weapon = new Model3D(); Weapon.LoadFile(projectPath + "\\ModelFiles\\models\\3DS\\M4A4", 11, "m4a1.obj"); Weapon.scalematrix = glm.scale(new mat4(1), new vec3(0.1f, 0.1f, 0.1f)); Weapon.transmatrix = glm.translate(new mat4(1), new vec3(hero.camera.GetCameraPosition().x, hero.camera.GetCameraPosition().y - 1.5f, hero.camera.GetCameraPosition().z)); double angle = glm.atan(hero.camera.GetLookDirection().z, hero.camera.GetLookDirection().x); Weapon.rotmatrix = glm.rotate((float)(0.5f * Math.PI), new vec3(0, 1, 0)); Weapon.rotmatrix = glm.rotate(Weapon.rotmatrix, (float)(-angle), new vec3(0, 1, 0)); Gl.glClearColor(0, 0, 0.4f, 1); //hero.camera = new Camera(); //hero.camera.Reset(0, 4, 20, 0, 0, 0, 0, 1, 0); ProjectionMatrix = hero.camera.GetProjectionMatrix(); ViewMatrix = hero.camera.GetViewMatrix(); transID = Gl.glGetUniformLocation(sh.ID, "trans"); projID = Gl.glGetUniformLocation(sh.ID, "projection"); viewID = Gl.glGetUniformLocation(sh.ID, "view"); modelmatrix = glm.scale(new mat4(1), new vec3(1, 1, 1)); sh.UseShader(); DataID = Gl.glGetUniformLocation(sh.ID, "data"); vec2 data = new vec2(5, 50); Gl.glUniform2fv(DataID, 1, data.to_array()); int LightPositionID = Gl.glGetUniformLocation(sh.ID, "LightPosition_worldspace"); vec3 lightPosition = new vec3(100.0f, 55.0f, 48.0f); Gl.glUniform3fv(LightPositionID, 1, lightPosition.to_array()); //setup the ambient light component. AmbientLightID = Gl.glGetUniformLocation(sh.ID, "ambientLight"); vec3 ambientLight = new vec3(1.5f, 1.3f, 1.3f); Gl.glUniform3fv(AmbientLightID, 1, ambientLight.to_array()); //setup the eye position. EyePositionID = Gl.glGetUniformLocation(sh.ID, "EyePosition_worldspace"); Gl.glEnable(Gl.GL_DEPTH_TEST); Gl.glDepthFunc(Gl.GL_LESS); }
public void draw(Model3D m, int matID) { m.Draw(matID); }
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); }