public void Initialize() { health = 1.0f; damage = 0.001f; dead = false; speed = 0.01f; mAngleX = 0; float x = RandomNumber(-50, 50); float z = RandomNumber(-50, 50); mPosition = new vec3(x, 0, z); mDirection = new vec3(0, 0, 0) - mPosition; mDirection = glm.normalize(mDirection); float scale_value = 0.05f; vec3 scale_vec = new vec3(scale_value); model.rotationMatrix = glm.rotate((float)((-0.5f) * Math.PI), new vec3(1, 0, 0)); model.scaleMatrix = glm.scale(new mat4(1), scale_vec); model.TranslationMatrix = glm.translate(new mat4(1), mPosition); state = EnemyStat.IDLE; model.AnimationSpeed = 0.003f; model.StartAnimation(animType_LOL.STAND); collider = new AABoundingBox(model.GetCurrentVertices(model.animSt), ColliderType.Enemy); collider.Scale(scale_vec); collider.Scale(1.1f, 3.0f, 0); collider.SetCenter(mPosition); healthBar = new HealthBar(mPosition, health, HealthType.Enemy); }
public void Initialize() { health = 1.0f; dead = false; speed = 0.5f; mPosition = new vec3(0, 0, 0); float scale_value = 0.05f; vec3 scale_vec = new vec3(scale_value); model.rotationMatrix = glm.rotate((float)((-1.0f) * Math.PI), new vec3(0, 1, 1)); model.scaleMatrix = glm.scale(new mat4(1), scale_vec); model.TranslationMatrix = glm.translate(new mat4(1), mPosition); camera = new Camera(); camera.Reset(mPosition.x, mPosition.y + 2.25f, mPosition.z, 0, 0, 0, 0, 1, 0); fireRate = 0.25f; nextFire = 0.0f; now = DateTime.Now; //model.AnimationSpeed = 0.001f; //model.StartAnimation(animType_LOL.STAND); collider = new AABoundingBox(model.GetCurrentVertices(model.animSt), ColliderType.Player); collider.Scale(scale_vec); collider.SetCenter(mPosition); healthBar = new HealthBar(mPosition, health, HealthType.Player); }
public bool CheckCollision(AABoundingBox box, vec3 offset) { vec3 newCenter = center + offset; vec3 distance = new vec3(Math.Abs(newCenter.x - box.center.x), Math.Abs(newCenter.y - box.center.y), Math.Abs(newCenter.z - box.center.z)); vec3 length = this.halfSize + box.halfSize; if ((distance.x <= length.x) && (distance.y <= length.y) && (distance.z <= length.z)) { return(true); } return(false); }
public void Initialize(vec3 pos, vec3 dir) { damage = 0.25f; speed = 0.1f; maxDistance = 100.0f; mPosition = pos; mDirection = dir; mDirection = glm.normalize(mDirection); float scale_value = 0.005f; vec3 scale_vec = new vec3(scale_value); double angle = glm.atan(mDirection.z, mDirection.x); model.rotmatrix = glm.rotate((float)(-angle), new vec3(0, 1, 0)); model.scalematrix = glm.scale(new mat4(1), scale_vec); model.transmatrix = glm.translate(new mat4(1), mPosition); collider = new AABoundingBox(model.GetCurrentVertices(), ColliderType.Bullet); collider.Scale(scale_vec); collider.SetCenter(mPosition); }
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); }