Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h> // Header File For Windows
- #include <gl.h> // Header File For The OpenGL32 Library
- #include <glu.h> // Header File For The GLu32 Library
- #include <glaux.h> // Header File For The Glaux Library
- #include <cmath>
- #include "GLTexture.h"
- #include "Model_3DS.h"
- #include <texture.h>
- #include "Building.h"
- #include "wall.h"
- #include "camera.h"
- #include "FootballField.h"
- #include "Ground.h"
- #include "Mall.h"
- //#include "Sound.h"
- FootballField Store(400, 125, 250);
- FootballField Store2(60, 18, 30);
- FootballField Build1(275, 175, 500);
- FootballField Build2(275, 170, 500);
- FootballField Build3(600, 150, 300);
- FootballField Build4(350, 175, 550);
- FootballField Build5(800, 150, 200);
- FootballField Build5Floor2(800, 150, 200);
- FootballField Build6(275, 170, 500);
- FootballField KShop1(800, 325, 250);
- FootballField KShop2(400, 325, 250);
- FootballField KShop3(800, 325, 250);
- FootballField KShop4(380, 325, 250);
- FootballField KShop5(400, 325, 250);
- FootballField KShop6(380, 325, 250);
- FootballField KShop7(380, 325, 250);
- FootballField KShopWall(400, 20, 250);
- FootballField Floor2(380, 50, 75);
- //first WIDTH second IS LENGTH THIRD HIEGHT 845is height of the second floor
- Mall MyMall(3720, 2500, 1350);
- wall MallWall;
- wall MallWall2;
- Mall GunStore(500, 300, 320);
- Mall BedStore(850, 600, 320);
- wall ModelToMall;
- wall GroundRoad;
- wall WallToStore;
- int HondaBlack;
- Model_3DS Mosc;
- FootballField ii(20, 20, 50);
- Camera camera;
- HDC hDC = NULL; // Private GDI Device Context
- HGLRC hRC = NULL; // Permanent Rendering Cntext
- HWND hWnd = NULL; // Holds Our Window Handle
- HINSTANCE hInstance; // Holds The Instance Of The Application
- bool keys[256]; // Array Used For The Keyboard Routine
- bool active = TRUE; // Window Active Flag Set To TRUE By Default
- bool fullscreen = FALSE; // Fullscreen Flag Set To Fullscreen Mode By Default
- LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // Declaration For WndProc
- GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize The GL Window
- {
- if (height == 0) // Prevent A Divide By Zero By
- {
- height = 1; // Making Height Equal One
- }
- glViewport(0, 0, width, height); // Reset The Current Viewport
- glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
- glLoadIdentity(); // Reset The Projection Matrix
- // Calculate The Aspect Ratio Of The Window
- gluPerspective(45.0f, (GLfloat)width / (GLfloat)height, 0.1f, 7500.0f);
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glLoadIdentity(); // Reset The Modelview Matrix
- }
- Model_3DS Model1, Model2, Model3, Model4, Model5, Model13, Laptop, Model6, Model12, Model11, Model7, Model8,
- Model10, M16, AWP, Sword, PP19, M4, glock, Honda, Honda1, Honda2, RPG, Pistol, Ch1,Conne,Bed1,Bed2,sofa1,Beroo, Sport1,Sport2,Sport3;
- int elevatorH = 0, back, front, left, right, top, down;
- int MallFace2, Store1, SideStore, Window;
- int Build1Tex, SideOfBuild1, WallBack, Build2Tex;
- int SideOfBuild2, Store2Tex, SideOfStore2;
- int Build3Tex, SideOfBuild3, BackOfBuild3;
- int SideOfMall, Floor2Tex;
- int RoadTex, Cone, Shop1, Shop2, Shop3, Shop4, SecondFloor;
- int Raod2, Road3, Build5Floor2Tex;
- int Build4Tex, SideOfBuild4, Build5Tex;
- bool EnableSound = true;
- int WallSide, KshopWall, Kshop1, Kshop2, Kshop3, Kshop4, Kshop5, Kshop6, Kshop7, Kshop8; float DeafultX = 0;
- float xx = 0, yy = 5, zz = 0, xxx = 0, yyy = 0, zzz = 0, teta = 90, mousexx = 0, mouseyy = 0, mouseSensitivity = 0.009;
- float mousexxDiff = 0, mousexxCurrent = 0, mousexxPrev = 0, speed = 1.8;
- int mouseX = 0, mouseY = 0; bool isClicked = false, isRClicked = false;
- //INIT initialize = INIT();
- //Sound sound;
- int Build6Tex, Build6Side, Baloor;
- void CameraKeyBoard()
- {
- if (keys['P']) {
- if (EnableSound) {
- //sound.Stop();
- EnableSound = false;
- }
- else
- {
- //sound.Play();
- EnableSound = true;
- }
- }
- /*if (keys['W']) {
- camera.MoveForward(2);
- }
- if (keys['D'])
- camera.MoveRight(2);
- if (keys['A'])
- camera.MoveRight(-2);
- if (keys['S'])
- camera.MoveForward(-2);*/
- if (keys['E'])
- camera.RotateY(-1);
- if (keys['Q'])
- camera.RotateY(1);
- if (keys['U'])
- camera.RotateX(1);
- if (keys['O'])
- camera.RotateX(-1);
- }
- int InitGL(GLvoid) // All Setup For OpenGL Goes Here
- {
- glShadeModel(GL_SMOOTH); // Enable Smooth Shading
- glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
- glClearDepth(1.0f); // Depth Buffer Setup
- glEnable(GL_DEPTH_TEST); // Enables Depth Testing
- glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
- glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
- //initialize.InitOpenAL();
- //sound = Sound("cello.wav");
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_TEXTURE_2D);
- Shop1 = LoadTexture("Shop1.bmp");
- Shop2 = LoadTexture("Shop2.bmp");
- Shop3 = LoadTexture("Shop3.bmp");
- Shop4 = LoadTexture("Shop4.bmp");
- Cone = LoadTexture("Cone.bmp");
- SecondFloor = LoadTexture("SecondFloor.bmp");
- Build1Tex = LoadTexture("21.bmp");
- SideOfBuild1 = LoadTexture("SideOfBuild1.bmp");
- WallBack = LoadTexture("WallBack.bmp");
- Build2Tex = LoadTexture("FreeBuild.bmp");
- SideOfBuild2 = LoadTexture("SideOfBuild2.bmp");
- Store2Tex = LoadTexture("Store2.bmp");
- SideOfStore2 = LoadTexture("SideOfStore2.bmp");
- Build3Tex = LoadTexture("Build3.bmp");
- SideOfBuild3 = LoadTexture("SideOfBuild3.bmp");
- BackOfBuild3 = LoadTexture("BackOfBuild3.bmp");
- Build4Tex = LoadTexture("Build4.bmp");
- SideOfBuild4 = LoadTexture("SideOfBuild.bmp");
- Build5Tex = LoadTexture("Build6.bmp");
- Build5Floor2Tex = LoadTexture("Build5Floor2.bmp");
- SideOfMall = LoadTexture("SideOfMall1.bmp");
- Build6Tex = LoadTexture("SideOfBuild4.bmp");
- Build6Side = LoadTexture("Cone.bmp");
- Baloor = LoadTexture("Baloor.bmp");
- ////////////////////////////////////////////////
- Kshop1 = LoadTexture("resturant.bmp");
- Kshop2 = LoadTexture("Shop2.bmp");
- Kshop3 = LoadTexture("dress.bmp");
- Kshop4 = LoadTexture("shoos.bmp");
- Kshop5 = LoadTexture("Shop1.bmp");
- Kshop6 = LoadTexture("shoos3.bmp");
- Kshop7 = LoadTexture("resturant1.bmp");
- KshopWall = LoadTexture("Cone.bmp");
- WallSide = LoadTexture("Cone.bmp");
- Floor2Tex = LoadTexture("Floor2.bmp");
- back = LoadTexture("back.bmp");
- left = LoadTexture("left.bmp");
- right = LoadTexture("right.bmp");
- top = LoadTexture("top.bmp");
- down = LoadTexture("down.bmp");
- RoadTex = LoadTexture("Road.bmp");
- front = LoadTexture("front.bmp");
- Store1 = LoadTexture("Store1.bmp");
- SideStore = LoadTexture("SideStore.bmp");
- Window = LoadTexture("Window.bmp");
- Cone = LoadTexture("Cone.bmp");
- Raod2 = LoadTexture("Road2.bmp");
- Road3 = LoadTexture("Road3.bmp");
- HondaBlack = LoadTexture("Honda7.bmp");
- Store.Ws.SetTexture(Store1);
- Store.We.SetTexture(SideStore);
- Store.Ww.SetTexture(SideStore);
- Store.Wn.SetTexture(Baloor);
- Store2.Ws.SetTexture(Store2Tex);
- Store2.We.SetTexture(SideOfStore2);
- Store2.Ww.SetTexture(SideOfStore2);
- Store2.Wn.SetTexture(WallBack);
- Build1.Ws.SetTexture(Build1Tex);
- Build1.We.SetTexture(SideOfBuild1);
- Build1.Ww.SetTexture(SideOfBuild1);
- Build1.Wn.SetTexture(WallBack);
- Build2.Wn.SetTexture(WallBack);
- Build2.Ws.SetTexture(Build2Tex);
- Build2.We.SetTexture(SideOfBuild2);
- Build2.Ww.SetTexture(SideOfBuild2);
- Build3.Ws.SetTexture(Build3Tex);
- Build3.Ww.SetTexture(SideOfBuild3);
- Build3.We.SetTexture(SideOfBuild3);
- Build3.Wn.SetTexture(BackOfBuild3);
- Build4.Ws.SetTexture(Build4Tex);
- Build4.We.SetTexture(SideOfBuild4);
- Build4.Ww.SetTexture(SideOfBuild4);
- Build5.Ws.SetTexture(Build5Tex);
- Build5.We.SetTexture(SideOfMall);
- Build5.Ww.SetTexture(SideOfMall);
- Build5Floor2.Ws.SetTexture(Build5Floor2Tex);
- Build5Floor2.We.SetTexture(SideOfMall);
- Build5Floor2.Ww.SetTexture(SideOfMall);
- Build6.Ws.SetTexture(Build6Tex);
- Build6.We.SetTexture(Build6Side);
- Build6.Ww.SetTexture(Build6Side);
- Floor2.Ws.SetTexture(Floor2Tex);
- KShop1.Ws.SetTexture(Kshop1);
- KShop1.We.SetTexture(WallSide);
- KShop1.Ww.SetTexture(WallSide);
- KShop1.Wn.SetTexture(Kshop1);
- KShop2.Ws.SetTexture(Kshop2);
- KShop2.We.SetTexture(WallSide);
- KShop2.Ww.SetTexture(WallSide);
- KShop2.Wn.SetTexture(Kshop2);
- KShop3.Ws.SetTexture(Kshop3);
- KShop3.We.SetTexture(WallSide);
- KShop3.Ww.SetTexture(WallSide);
- KShop3.Wn.SetTexture(Kshop3);
- KShop4.Ws.SetTexture(Kshop4);
- KShop4.We.SetTexture(WallSide);
- KShop4.Ww.SetTexture(WallSide);
- KShop4.Wn.SetTexture(Kshop4);
- KShop5.Ws.SetTexture(Kshop5);
- KShop5.We.SetTexture(WallSide);
- KShop5.Ww.SetTexture(WallSide);
- KShop5.Wn.SetTexture(Kshop5);
- KShop6.Ws.SetTexture(Kshop6);
- KShop6.We.SetTexture(Kshop6);
- KShop6.Ww.SetTexture(Kshop6);
- KShop6.Wn.SetTexture(Kshop6);
- KShop7.Ws.SetTexture(Kshop7);
- KShop7.We.SetTexture(Kshop7);
- KShop7.Ww.SetTexture(Kshop7);
- KShop7.Wn.SetTexture(Kshop7);
- KShopWall.Ws.SetTexture(KshopWall);
- KShopWall.We.SetTexture(KshopWall);
- KShopWall.Ww.SetTexture(KshopWall);
- KShopWall.Wn.SetTexture(KshopWall);
- Bed1.Load("Bed1.3ds");
- Bed1.Materials[0].tex.Load("Bed1.bmp");
- Bed1.Materials[1].tex.Load("Bed1.bmp");
- Bed1.Materials[2].tex.Load("Bed2.bmp");
- Bed1.Materials[3].tex.Load("Bed2.bmp");
- Bed1.Materials[4].tex.Load("Bed3.bmp");
- Bed1.Materials[5].tex.Load("Bed2.bmp");
- Bed2.Load("Bed2.3ds");
- Bed2.Materials[0].tex.Load("Bed21.bmp");
- Bed2.Materials[1].tex.Load("Bed21.bmp");
- Bed2.Materials[2].tex.Load("wood.bmp");
- Bed2.Materials[3].tex.Load("Doo.bmp");
- sofa1.Load("sofa.3ds");
- sofa1.Materials[0].tex.Load("sofa3.bmp");
- sofa1.Materials[1].tex.Load("Mall_craq.bmp");
- sofa1.Materials[2].tex.Load("sofa3.bmp");
- sofa1.Materials[3].tex.Load("wood.bmp");
- Beroo.Load("Beroo.3ds");
- Beroo.Materials[0].tex.Load("Wood.bmp");
- Beroo.Materials[1].tex.Load("Bed2.bmp");
- Beroo.Materials[2].tex.Load("Bed2.bmp");
- Beroo.Materials[3].tex.Load("Bed2.bmp");
- Mosc.Load("Es46.3ds");
- Mosc.Materials[0].tex.Load("Glasss.bmp");//koba || glass
- Mosc.Materials[1].tex.Load("Doolab.bmp"); //k7le
- Mosc.Materials[2].tex.Load("Doolab.bmp"); //door //k7le
- Mosc.Materials[3].tex.Load("Mall_whites.bmp"); //mskat al bab //white
- Mosc.Materials[4].tex.Load("yellow.bmp"); //soor fo6 //k7le
- Mosc.Materials[5].tex.Load("Mall_whites.bmp"); //l 3'laf //withe
- Mosc.Materials[6].tex.Load("SideOfBuild1.bmp"); // mn joa //k7le
- Mosc.Materials[7].tex.Load("Baloor.bmp"); //windows //bne
- Mosc.Materials[8].tex.Load("Doolab.bmp"); // cover of windows //k7le || aswd
- Mosc.Materials[9].tex.Load("Road2.bmp"); //ground // fde
- Mosc.Materials[10].tex.Load("Cone.bmp"); // قاعدة الجامع مثل الرصيف
- Sport1.Load("Sport.3ds");
- Sport1.Materials[0].tex.Load("Wood.bmp");
- Sport1.Materials[1].tex.Load("Bed2.bmp");
- Sport1.Materials[2].tex.Load("Honda2.bmp");
- Sport1.Materials[3].tex.Load("Bed2.bmp");
- Sport1.Materials[4].tex.Load("Honda7.bmp");
- Sport1.Materials[5].tex.Load("Honda7.bmp");
- Sport1.Materials[6].tex.Load("Honda7.bmp");
- Sport1.Materials[7].tex.Load("Honda7.bmp");
- Sport2.Load("Sport2.3ds");
- Sport2.Materials[0].tex.Load("Wood.bmp");
- Sport2.Materials[1].tex.Load("Bed2.bmp");
- Sport2.Materials[2].tex.Load("Bed2.bmp");
- Sport2.Materials[3].tex.Load("Bed2.bmp");
- Sport3.Load("Sport3.3ds");
- Sport3.Materials[0].tex.Load("Wood.bmp");
- Sport3.Materials[1].tex.Load("Bed2.bmp");
- Sport3.Materials[2].tex.Load("Bed2.bmp");
- Sport3.Materials[3].tex.Load("Bed2.bmp");
- Sport3.Materials[4].tex.Load("Honda2.bmp");
- Sport3.Materials[5].tex.Load("Honda2.bmp");
- Sport3.Materials[6].tex.Load("Honda2.bmp");
- Sport3.Materials[7].tex.Load("Honda2.bmp");
- Model1.Load("ModelPark.3ds");
- Model1.Materials[0].tex.Load("1.bmp");
- Model1.Materials[1].tex.Load("7.bmp");
- Model1.Materials[2].tex.Load("2.bmp");
- Model1.Materials[3].tex.Load("4.bmp");
- Model1.Materials[4].tex.Load("5.bmp");
- Model1.Materials[5].tex.Load("6.bmp");
- Model1.Materials[6].tex.Load("7.bmp");
- Model1.Materials[7].tex.Load("5.bmp");
- Model1.Materials[10].tex.Load("3.bmp");
- Model3.Load("D:\\Residence.3ds");
- ///nto2
- Model3.Materials[6].tex.LoadBMP("Wood.bmp");
- Model3.Materials[2].tex.LoadBMP("Doolab.bmp");
- ///mrb3at
- Model3.Materials[1].tex.LoadBMP("Wood.bmp");
- ////nto2
- Model3.Materials[3].tex.LoadBMP("3.bmp");
- ///shbak
- Model3.Materials[4].tex.LoadBMP("Wood.bmp");
- /*الدار */
- Model3.Materials[5].tex.LoadBMP("Doolab.bmp");
- Model3.Materials[8].tex.LoadBMP("SideOfBuild1.bmp");
- Model3.Materials[9].tex.LoadBMP("Car.bmp");
- Model3.Materials[10].tex.LoadBMP("Grass.bmp");
- Model3.Materials[11].tex.LoadBMP("SideOfMall1.bmp");
- Model3.Materials[12].tex.LoadBMP("Wood.bmp"); //windows right side
- Model3.Materials[13].tex.LoadBMP("SideOfBuild.bmp"); //all windows and door
- Model10.Load("D:\\Residence.3ds");
- ///nto2
- Model10.Materials[6].tex.LoadBMP("Wood.bmp");
- Model10.Materials[2].tex.LoadBMP("Doolab.bmp");
- ////mrb3at
- Model10.Materials[1].tex.LoadBMP("Wood.bmp");
- ////nto2
- Model10.Materials[3].tex.LoadBMP("5.bmp");
- ///shbak
- Model10.Materials[4].tex.LoadBMP("Doo.bmp");
- ////الدار
- Model10.Materials[5].tex.LoadBMP("Car.bmp");
- Model10.Materials[8].tex.LoadBMP("SideOfBuild1.bmp");
- Model10.Materials[9].tex.LoadBMP("Mall_grey.bmp");
- Model10.Materials[10].tex.LoadBMP("SideOfBuild.bmp");
- Model10.Materials[11].tex.LoadBMP("Mall_grey.bmp");
- Model10.Materials[12].tex.LoadBMP("Mall_grey.bmp"); //windows right side
- Model10.Materials[13].tex.LoadBMP("SecondFloor.bmp"); //all windows and door
- Model6.Load("D:\\Naf.3ds");
- Model6.Materials[0].tex.Load("7.bmp");
- Model6.Materials[1].tex.Load("1.bmp");
- Model6.Materials[2].tex.Load("1.bmp");
- Model6.Materials[3].tex.Load("1.bmp");
- Model6.Materials[4].tex.Load("1.bmp");
- Model7.Load("Chers.3ds");
- Model7.Materials[0].tex.Load("Wood.bmp");
- Model7.Materials[1].tex.Load("Wood.bmp");
- Model8.Load("golf_iv1.3ds");
- Model8.Materials[0].tex.Load("Doo.bmp");
- Model8.Materials[1].tex.Load("Doo.bmp");
- Model8.Materials[2].tex.Load("Car.bmp");
- Model8.Materials[3].tex.Load("Car.bmp");
- Model8.Materials[6].tex.Load("Baloor.bmp");
- Model8.Materials[7].tex.Load("Baloor.bmp");
- Model8.Materials[11].tex.Load("down.bmp");
- Model8.Materials[12].tex.Load("Doolab.bmp");
- Model8.Materials[13].tex.Load("Doolab.bmp");
- Model8.Materials[14].tex.Load("Jn6.bmp");
- Model8.Materials[15].tex.Load("Jn6.bmp");
- Model8.Materials[4].tex.Load("down.bmp");
- Model8.Materials[5].tex.Load("down.bmp");
- Model11.Load("Tabble.3ds");
- ///balck
- Model11.Materials[0].tex.Load("Doolab.bmp");
- Model11.Materials[1].tex.Load("Doolab.bmp");
- ///mn t7t kaml red
- Model11.Materials[2].tex.Load("Mall_red.bmp");
- ///white
- Model11.Materials[3].tex.Load("Mall_whites.bmp");
- ///red
- Model11.Materials[4].tex.Load("Mall_red.bmp");
- ///gray
- Model11.Materials[5].tex.Load("Mall_red.bmp");
- Model11.Materials[6].tex.Load("Mall_red.bmp");
- Model11.Materials[7].tex.Load("Mall_red.bmp");
- Model11.Materials[8].tex.Load("Mall_red.bmp");
- Model11.Materials[9].tex.Load("Mall_red.bmp");
- Model11.Materials[10].tex.Load("Mall_red.bmp");
- Model11.Materials[11].tex.Load("Mall_red.bmp");
- Model11.Materials[12].tex.Load("Mall_red.bmp");
- M16.Load("M16.3ds");
- M16.Materials[0].tex.Load("GFX.bmp");
- AWP.Load("AWP.3ds");
- AWP.Materials[0].tex.Load("AWP.bmp");
- AWP.Materials[1].tex.Load("AWP1.bmp");
- Sword.Load("Sword.3ds");
- Sword.Materials[0].tex.Load("MetalBare.bmp");
- Sword.Materials[1].tex.Load("Viking-sword.bmp");
- Sword.Materials[2].tex.Load("CHROMIC.bmp");
- PP19.Load("PP19.3ds");
- PP19.Materials[0].tex.Load("PP19.bmp");
- PP19.Materials[1].tex.Load("PP191.bmp");
- M4.Load("M4.3ds");
- M4.Materials[0].tex.Load("AWP.bmp");
- glock.Load("glock.3ds");
- glock.Materials[0].tex.Load("9mm.bmp");
- glock.Materials[1].tex.Load("glock.bmp");
- RPG.Load("RPG.3ds");
- RPG.Materials[0].tex.Load("RPG.bmp");
- Honda.Load("Honda.3ds");
- Honda.Materials[0].tex.Load("Honda1.bmp");
- Honda.Materials[1].tex.Load("down.bmp");
- Honda.Materials[2].tex.Load("Honda1.bmp");
- Honda.Materials[3].tex.Load("Honda1.bmp");
- Honda.Materials[4].tex.Load("Honda2.bmp");
- Honda.Materials[5].tex.Load("Honda1.bmp");
- Honda.Materials[6].tex.Load("Honda1.bmp");
- Honda.Materials[7].tex.Load("Honda1.bmp");
- Honda.Materials[8].tex.Load("Honda1.bmp");
- Honda.Materials[9].tex.Load("Honda6.bmp");
- Honda.Materials[10].tex.Load("Honda2.bmp");
- Honda.Materials[11].tex.Load("Honda1.bmp");
- Honda.Materials[12].tex.Load("Honda1.bmp");
- Honda.Materials[13].tex.Load("Honda3.bmp");
- Honda.Materials[14].tex.Load("Honda3.bmp");
- Honda.Materials[15].tex.Load("Honda3.bmp");
- Honda.Materials[16].tex.Load("Honda1.bmp");
- Honda.Materials[17].tex.Load("Honda1.bmp");
- Honda.Materials[18].tex.Load("Honda3.bmp");
- Honda.Materials[19].tex.Load("Honda3.bmp");
- Honda.Materials[20].tex.Load("Honda3.bmp");
- Honda.Materials[21].tex.Load("Honda3.bmp");
- Honda.Materials[22].tex.Load("Honda3.bmp");
- Honda.Materials[23].tex.Load("Honda3.bmp");
- Honda.Materials[24].tex.Load("Honda3.bmp");
- Honda.Materials[25].tex.Load("Honda2.bmp");
- Honda.Materials[26].tex.Load("Honda2.bmp");
- Honda.Materials[27].tex.Load("Honda3.bmp");
- Honda.Materials[28].tex.Load("Honda3.bmp");
- Honda.Materials[29].tex.Load("Honda3.bmp");
- Honda.Materials[30].tex.Load("Honda3.bmp");
- Honda.Materials[31].tex.Load("Honda7.bmp");
- Honda.Materials[32].tex.Load("Honda7.bmp");
- Honda.Materials[33].tex.Load("Honda7.bmp");
- Honda.Materials[34].tex.Load("Honda7.bmp");
- Honda.Materials[35].tex.Load("Honda7.bmp");
- Honda.Materials[36].tex.Load("Honda2.bmp");
- Honda.Materials[37].tex.Load("Honda8.bmp");
- Honda.Materials[38].tex.Load("Honda2.bmp");
- Honda.Materials[39].tex.Load("Honda2.bmp");
- Honda1.Load("Honda.3ds");
- Honda1.Materials[0].tex.Load("Honda6.bmp");
- Honda1.Materials[1].tex.Load("down.bmp");
- Honda1.Materials[2].tex.Load("Honda6.bmp");
- Honda1.Materials[3].tex.Load("Honda6.bmp");
- Honda1.Materials[4].tex.Load("Honda2.bmp");
- Honda1.Materials[5].tex.Load("Honda6.bmp");
- Honda1.Materials[6].tex.Load("Honda6.bmp");
- Honda1.Materials[7].tex.Load("Honda6.bmp");
- Honda1.Materials[8].tex.Load("Honda6.bmp");
- Honda1.Materials[9].tex.Load("Honda6.bmp");
- Honda1.Materials[10].tex.Load("Honda2.bmp");
- Honda1.Materials[11].tex.Load("Honda6.bmp");
- Honda1.Materials[12].tex.Load("Honda6.bmp");
- Honda1.Materials[13].tex.Load("Honda3.bmp");
- Honda1.Materials[14].tex.Load("Honda3.bmp");
- Honda1.Materials[15].tex.Load("Honda3.bmp");
- Honda1.Materials[16].tex.Load("Honda6.bmp");
- Honda1.Materials[17].tex.Load("Honda6.bmp");
- Honda1.Materials[18].tex.Load("Honda3.bmp");
- Honda1.Materials[19].tex.Load("Honda3.bmp");
- Honda1.Materials[20].tex.Load("Honda3.bmp");
- Honda1.Materials[21].tex.Load("Honda3.bmp");
- Honda1.Materials[22].tex.Load("Honda3.bmp");
- Honda1.Materials[23].tex.Load("Honda3.bmp");
- Honda1.Materials[24].tex.Load("Honda3.bmp");
- Honda1.Materials[25].tex.Load("Honda2.bmp");
- Honda1.Materials[26].tex.Load("Honda2.bmp");
- Honda1.Materials[27].tex.Load("Honda3.bmp");
- Honda1.Materials[28].tex.Load("Honda3.bmp");
- Honda1.Materials[29].tex.Load("Honda3.bmp");
- Honda1.Materials[30].tex.Load("Honda3.bmp");
- Honda1.Materials[31].tex.Load("Honda7.bmp");
- Honda1.Materials[32].tex.Load("Honda7.bmp");
- Honda1.Materials[33].tex.Load("Honda7.bmp");
- Honda1.Materials[34].tex.Load("Honda7.bmp");
- Honda1.Materials[35].tex.Load("Honda7.bmp");
- Honda1.Materials[36].tex.Load("Honda2.bmp");
- Honda1.Materials[37].tex.Load("Honda8.bmp");
- Honda1.Materials[38].tex.Load("Honda2.bmp");
- Honda1.Materials[39].tex.Load("Honda2.bmp");
- Honda2.Load("Honda.3ds");
- Honda2.Materials[0].tex.Load("Honda9.bmp");
- Honda2.Materials[1].tex.Load("down.bmp");
- Honda2.Materials[2].tex.Load("Honda9.bmp");
- Honda2.Materials[3].tex.Load("Honda9.bmp");
- Honda2.Materials[4].tex.Load("Honda2.bmp");
- Honda2.Materials[5].tex.Load("Honda6.bmp");
- Honda2.Materials[6].tex.Load("Honda9.bmp");
- Honda2.Materials[7].tex.Load("Honda9.bmp");
- Honda2.Materials[8].tex.Load("Honda9.bmp");
- Honda2.Materials[9].tex.Load("Honda9.bmp");
- Honda2.Materials[10].tex.Load("Honda2.bmp");
- Honda2.Materials[11].tex.Load("Honda9.bmp");
- Honda2.Materials[12].tex.Load("Honda9.bmp");
- Honda2.Materials[13].tex.Load("Honda3.bmp");
- Honda2.Materials[14].tex.Load("Honda3.bmp");
- Honda2.Materials[15].tex.Load("Honda3.bmp");
- Honda2.Materials[16].tex.Load("Honda9.bmp");
- Honda2.Materials[17].tex.Load("Honda9.bmp");
- Honda2.Materials[18].tex.Load("Honda3.bmp");
- Honda2.Materials[19].tex.Load("Honda3.bmp");
- Honda2.Materials[20].tex.Load("Honda3.bmp");
- Honda2.Materials[21].tex.Load("Honda3.bmp");
- Honda2.Materials[22].tex.Load("Honda3.bmp");
- Honda2.Materials[23].tex.Load("Honda3.bmp");
- Honda2.Materials[24].tex.Load("Honda3.bmp");
- Honda2.Materials[25].tex.Load("Honda2.bmp");
- Honda2.Materials[26].tex.Load("Honda2.bmp");
- Honda2.Materials[27].tex.Load("Honda3.bmp");
- Honda2.Materials[28].tex.Load("Honda3.bmp");
- Honda2.Materials[29].tex.Load("Honda3.bmp");
- Honda2.Materials[30].tex.Load("Honda3.bmp");
- Honda2.Materials[31].tex.Load("Honda7.bmp");
- Honda2.Materials[32].tex.Load("Honda7.bmp");
- Honda2.Materials[33].tex.Load("Honda7.bmp");
- Honda2.Materials[34].tex.Load("Honda7.bmp");
- Honda2.Materials[35].tex.Load("Honda7.bmp");
- Honda2.Materials[36].tex.Load("Honda2.bmp");
- Honda2.Materials[37].tex.Load("Honda8.bmp");
- Honda2.Materials[38].tex.Load("Honda2.bmp");
- Honda2.Materials[39].tex.Load("Honda2.bmp");
- Laptop.Load("Laptop.3ds");
- Laptop.Materials[0].tex.Load("Honda6.bmp");
- Laptop.Materials[1].tex.Load("down.bmp");
- Model13.Load("Counter.3ds");
- Model13.Materials[0].tex.Load("Honda2.bmp");
- Model13.Materials[1].tex.Load("st-2.bmp");
- Model13.Materials[2].tex.Load("st-2.bmp");
- Model13.Materials[3].tex.Load("st-1.bmp");
- Model13.Materials[4].tex.Load("st-1.bmp");
- Model13.Materials[5].tex.Load("Honda2.bmp");
- Model13.Materials[6].tex.Load("Honda2.bmp");
- Model13.Materials[7].tex.Load("Honda2.bmp");
- Model13.Materials[8].tex.Load("Honda2.bmp");
- Model13.Materials[9].tex.Load("Honda2.bmp");
- Model13.Materials[10].tex.Load("Honda2.bmp");
- Model13.Materials[11].tex.Load("Honda2.bmp");
- Model13.Materials[12].tex.Load("Honda2.bmp");
- camera.Position.x = 5;
- camera.Position.y = 120;
- camera.Position.z = 1000;
- return TRUE; // Initialization Went OK
- }
- float radian(float h)
- {
- return h*3.14 - 180;
- }
- void KeyBoardWithMouse()
- {
- mousexx = mouseSensitivity * (mouseX - 500);
- mouseyy = mouseSensitivity * -1 * (mouseY - 300);
- mousexxPrev = mousexxCurrent;
- mousexxCurrent = mousexx;
- mousexxDiff = mousexxCurrent - mousexxPrev;
- xxx = xx + cos(radian(teta));
- zzz = zz - sin(radian(teta));
- yyy = yy;
- gluLookAt(xx, yy, zz, xxx, yyy, zzz, 0, 1, 0);
- teta = mouseX >= 990 ? teta - 5 : mouseX <= 10 ? teta + 5 : teta - mousexxDiff;
- if (keys['W']) zz -= sin(radian(teta))*speed, xx += cos(radian(teta))*speed;
- if (keys['S']) zz += sin(radian(teta))*speed, xx -= cos(radian(teta))*speed;
- if (keys['A']) xx -= sin(radian(teta))*(speed - 0.3), zz -= cos(radian(teta))*(speed - 0.3);
- if (keys['D']) xx += sin(radian(teta))*(speed - 0.3), zz += cos(radian(teta))*(speed - 0.3);
- if (keys[VK_UP]) yy += 0.8;
- if (keys[VK_DOWN]) yy -= 0.8;
- if (keys['1']) { float cach = 10; if (yy < cach) { yy -= 2; elevatorH -= 2; } }
- if (keys['2']) { float cach = 550; if (yy < cach) { yy += 2; elevatorH += 2; } }
- }
- void skybox()
- {
- glBindTexture(GL_TEXTURE_2D, back);
- glBegin(GL_QUADS);
- glTexCoord2d(0, 0);
- glVertex3d(-500, -500, -500);
- glTexCoord2d(1, 0);
- glVertex3d(500, -500, -500);
- glTexCoord2d(1, 1);
- glVertex3d(500, 500, -500);
- glTexCoord2d(0, 1);
- glVertex3d(-500, 500, -500);
- glEnd();
- glBindTexture(GL_TEXTURE_2D, front);
- glBegin(GL_QUADS);
- glTexCoord2d(1, 0);
- glVertex3d(-500, -500, 500);
- glTexCoord2d(0, 0);
- glVertex3d(500, -500, 500);
- glTexCoord2d(0, 1);
- glVertex3d(500, 500, 500);
- glTexCoord2d(1, 1);
- glVertex3d(-500, 500, 500);
- glEnd();
- glBindTexture(GL_TEXTURE_2D, left);
- glBegin(GL_QUADS);
- glTexCoord2d(0, 0);
- glVertex3d(-500, -500, 500);
- glTexCoord2d(1, 0);
- glVertex3d(-500, -500, -500);
- glTexCoord2d(1, 1);
- glVertex3d(-500, 500, -500);
- glTexCoord2d(0, 1);
- glVertex3d(-500, 500, 500);
- glEnd();
- glBindTexture(GL_TEXTURE_2D, right);
- glBegin(GL_QUADS);
- glTexCoord2d(1, 0);
- glVertex3d(500, -500, 500);
- glTexCoord2d(0, 0);
- glVertex3d(500, -500, -500);
- glTexCoord2d(0, 1);
- glVertex3d(500, 500, -500);
- glTexCoord2d(1, 1);
- glVertex3d(500, 500, 500);
- glEnd();
- glBindTexture(GL_TEXTURE_2D, top);
- glBegin(GL_QUADS);
- glTexCoord2d(0, 1);
- glVertex3d(-500, 500, -500);
- glTexCoord2d(0, 0);
- glVertex3d(500, 500, -500);
- glTexCoord2d(1, 0);
- glVertex3d(500, 500, 500);
- glTexCoord2d(1, 1);
- glVertex3d(-500, 500, 500);
- glEnd();
- //glBindTexture(GL_TEXTURE_2D, down);
- //glBegin(GL_QUADS);
- ////glColor3f(1, 0, 0);
- //glTexCoord2d(0, 0);
- //glVertex3d(-500, 0, 500);
- //glTexCoord2d(0, 1);
- //glVertex3d(-500, 0, -500);
- //glTexCoord2d(1, 1);
- //glVertex3d(500, 0, -500);
- //glTexCoord2d(0, 0);
- //glVertex3d(500, 0, 500);
- //glEnd();
- //glBindTexture(GL_TEXTURE_2D, RoadTex);
- //glBegin(GL_QUADS);
- ////glColor3f(1, 0, 0);
- //glTexCoord2d(0, 0);
- //glVertex3d(-500, -0.5, 500);
- //glTexCoord2d(0, 1);
- //glVertex3d(-500, -0.5, -500);
- //glTexCoord2d(1, 1);
- //glVertex3d(500, -0.5, -500);
- //glTexCoord2d(0, 0);
- //glVertex3d(500, -0.5, 500);
- //glEnd();
- }
- void Connne(float x, float y, float z, float h, float r, int texture)
- {
- glBindTexture(GL_TEXTURE_2D, texture);
- for (float i = 0; i < 2 * 3.14; i += 0.3)
- {
- glNormal3d(sin(i), atan(r / h), cos(i));
- float xx = r*cos(i);
- float zz = r*sin(i);
- float xxx = r*cos(i + 0.3);
- float zzz = r*sin(i + 0.3);
- glBegin(GL_QUADS);
- glTexCoord2d(0, 0);
- glVertex3f(x + xx, y, z - zz);
- glTexCoord2d(1, 0);
- glVertex3f(x + xxx, y, z - zzz);
- glTexCoord2d(1, 2);
- glVertex3f(x + xxx, y + h, z - zzz);
- glTexCoord2d(0, 2);
- glVertex3f(x + xx, y + h, z - zz);
- glEnd();
- }
- }
- bool Cam = false;
- double eyeX, eyeY = 5, eyeZ;
- double lllX, lllY, lllZ;
- double angle = 0;
- void ThirdCamera() {
- if (Cam == false) {
- gluLookAt(eyeX, eyeY, eyeZ, lllX, lllY, lllZ, 0, 1, 0);
- }
- if (keys['D']) eyeZ -= 0.005; eyeY = 0.3*fabs(cos(angle));
- if (keys['A']) eyeZ += 0.005; eyeY = 0.3*fabs(cos(angle));
- if (keys['W']) eyeX -= 0.005; eyeY = 0.3*fabs(cos(angle));;
- if (keys['S']) eyeX += 0.005; eyeY = 0.3*fabs(cos(angle));
- if (keys['Z']) lllX -= 0.01*cos(0.1); lllZ -= 0.01*sin(0.1);
- if (keys['X']) lllX += 0.01*cos(0.1); lllZ += 0.01*sin(0.1);
- }
- bool checkNearDoor(float leftX, float rightX, float doorZ) {
- float vision = 200;
- if (camera.Position.x >= leftX && camera.Position.x <= rightX && abs(camera.Position.z - doorZ) <= vision)
- return true;
- else
- return false;
- }
- void Ligth() {
- // (0 , 30) (0,170) (0 30)
- //glTranslated(0, -400, );
- glColor3f(0, 0, 0);
- glBegin(GL_POLYGON);
- glTexCoord2d(0, 0);
- glVertex3f(0, -155, 155);
- glTexCoord2d(0, 1);
- glVertex3f(20, -155, 155);
- glTexCoord2d(1, 1);
- glVertex3f(0, -155, 0);
- glTexCoord2d(1, 0);
- glVertex3f(20, -155, 0);
- glEnd();
- glBegin(GL_POLYGON);
- glBindTexture(GL_TEXTURE_2D, HondaBlack);
- glTexCoord2d(0, 0);
- glVertex3f(30, -155, 155);
- glTexCoord2d(0, 0);
- glVertex3f(-10, -155, 155);
- glTexCoord2d(0, 0);
- glVertex3f(30, -155, 130);
- glTexCoord2d(0, 0);
- glVertex3f(-10, -155, 130);
- glEnd();
- /**/
- glColor3f(0, 0, 0);
- //glScaled(1.4, 1, 1.4);
- //glTranslated(0, 155, 0);
- //ii.Draw();
- //ii.Ws.SetTexture(HondaBlack);
- }
- void Ligth3d() {
- // (0 , 30) (0,170) (0 30)
- glTranslated(400, 0, 1500);
- glColor3f(0.2, 0.2, 0.2);
- glBegin(GL_POLYGON);
- glVertex3f(0, 0, 20);
- glVertex3f(20, 0, 0);
- glVertex3f(0, 155, 0);
- glVertex3f(20, 155, 20);
- glEnd();
- glBegin(GL_POLYGON);
- glVertex3f(0, 0, 20);
- glVertex3f(0, 0, 0);
- glVertex3f(0, 155, 20);
- glVertex3f(0, 155, 0);
- glEnd();
- glBegin(GL_POLYGON);
- glVertex3f(20, 0, 20);
- glVertex3f(20, 0, 0);
- glVertex3f(20, 155, 20);
- glVertex3f(20, 155, 0);
- glEnd();
- glBegin(GL_POLYGON);
- glVertex3f(0, 0, 20);
- glVertex3f(20, 0, 20);
- glVertex3f(0, 155, 0);
- glVertex3f(20, 155, 0);
- glEnd();
- /**/
- glColor3f(0, 0, 0);
- glScaled(1.4, 1, 1.4);
- glTranslated(0, 155, 0);
- ii.Draw();
- }
- int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing
- {
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glLoadIdentity();
- KeyBoardWithMouse();
- //camera.Render();
- //CameraKeyBoard();
- //Ccamera();
- if (keys['B']) ThirdCamera();
- glPushMatrix();
- glScaled(7, 7, 7);
- skybox();
- glPopMatrix();
- glPushMatrix();
- glScaled(7, 7, 7);
- skybox();
- glPopMatrix();
- glPushMatrix();
- glTranslated(1065, 430, -650);
- KShop1.Draw();
- glPopMatrix();
- glPushMatrix();
- glTranslated(1065, 430, 830);
- KShop3.Draw();
- glPopMatrix();
- //first to the door of the mall second raise to up last more to the right
- glPushMatrix();
- glRotated(90, 0, 1, 0);
- glTranslated(-70, 425, 1885);
- KShop5.Draw();
- glPopMatrix();
- glPushMatrix();
- glRotated(90, 0, 1, 0);
- glTranslated(-855, 425, 1865);
- KShop2.Draw();
- glPopMatrix();
- //first left and right of the door second up and down third go front to the door
- glPushMatrix();
- glRotated(90, 0, 1, 0);
- glTranslated(-455, 425, 2135);
- KShopWall.Draw();
- glPopMatrix();
- //the side of the door
- glPushMatrix();
- glRotated(90, 0, 1, 0);
- glTranslated(-70, 425, 1085);
- KShop4.Draw();
- glPopMatrix();
- glPushMatrix();
- glRotated(90, 0, 1, 0);
- glTranslated(-835, 425, 1065);
- KShop6.Draw();
- glPopMatrix();
- glPushMatrix();
- glRotated(90, 0, 1, 0);
- glTranslated(-450, 425, 1065);
- KShop7.Draw();
- glPopMatrix();
- glPushMatrix();
- glRotated(90, 1, 0, 0);
- MallWall.SetPosition(1600, -600, -405);
- MallWall.SetDimntion(1800, 1150);
- MallWall.Draw();
- glPopMatrix();
- glPushMatrix();
- glRotated(90, 1, 0, 0);
- MallWall2.SetPosition(1600,-600, -20);
- MallWall2.SetDimntion(1800, 1150);
- MallWall2.Draw();
- glPopMatrix();
- glPushMatrix();
- //first go back and front second height third positive to right
- glTranslated(2270, 5, -660);
- glScaled(0.5, 0.5, 0.5);
- glRotated(-90, 0, 1, 0);
- MyMall.Draw();
- glPopMatrix();
- /*glPushMatrix();
- glTranslated(90, 112.6, -75);
- glScaled(0.5, 0.5, 0.5);
- Floor2.Draw();
- glPopMatrix();*/
- glPushMatrix();
- glTranslated(2200, 10, 400);
- glRotatef(-90, 0, 1, 0);
- glScaled(35, 35, 35);
- Model12.pos.x = 0;
- Model12.pos.y = 0;
- Model12.pos.z = 0;//درج
- Model12.Draw();
- glPopMatrix();
- glPushMatrix();
- glTranslated(2000, 10, -420);
- glScaled(0.07, 0.07, 0.07);
- Model13.pos.x = 0;
- Model13.pos.y = 0;
- Model13.pos.z = 0;
- Model13.Draw();
- glPopMatrix();
- //////////////////////////////////
- glPushMatrix();
- glTranslated(2000, 70, 1100);
- glScaled(2.5, 2.5, 2.5);
- Sport1.pos.x = 0;
- Sport1.pos.y = 0;
- Sport1.pos.z = 0;
- Sport1.Draw();
- glPopMatrix();
- ///////////////////////////////////////
- //////////////////////////////////
- glPushMatrix();
- glTranslated(2200, 70, 1100);
- glScaled(2.5, 2.5, 2.5);
- glRotatef(180, 0, 1, 0);
- Sport2.pos.x = 0;
- Sport2.pos.y = 0;
- Sport2.pos.z = 0;
- Sport2.Draw();
- glPopMatrix();
- ///////////////////////////////////////
- //////////////////////////////////
- glPushMatrix();
- glTranslated(2200, 40, 900);
- glScaled(40, 40, 40);
- Sport3.pos.x = 0;
- Sport3.pos.y = 0;
- Sport3.pos.z = 0;
- Sport3.Draw();
- glPopMatrix();
- ///////////////////////////////////////
- glPushMatrix();
- glTranslated(1050, 0, -640);
- GunStore.Draw();
- glPopMatrix();
- ///////////////////////////
- glPushMatrix();
- glTranslated(1905, 0, 1120);
- glRotatef(180, 0, 1, 0);
- BedStore.Draw();
- glPopMatrix();
- ///////////////////////////////
- glPushMatrix();
- glTranslated(-240, 0, 0);
- Store.Draw();
- glPopMatrix();
- ////glPushMatrix();
- ////glTranslated(-290, 0, 0);
- ////glRotated(90, 0, 1, 0); ///////////////////////////////////////////////////////////
- ////Store2.Draw();
- ////glPopMatrix();
- //
- glPushMatrix();
- glTranslated(1117, 45, -405);
- glScaled(80, 80, 80);
- Laptop.pos.x = 0;
- Laptop.pos.y = 0;
- Laptop.pos.z = 0;
- Laptop.Draw();
- glPopMatrix();
- glPushMatrix();
- glTranslated(1150, 0, -405);
- glScaled(1.4, 1.4, 1.4);
- Model11.pos.x = 0;
- Model11.pos.y = 0;
- Model11.pos.z = 0;
- Model11.Draw();
- glPopMatrix();
- ///////////////////////////
- glPushMatrix();
- glTranslated(1680, 32, 1060);
- glScaled(1.8, 1.8, 1.8);
- glRotatef(180, 0, 1, 0);
- Bed1.pos.x = 0;
- Bed1.pos.y = 0;
- Bed1.pos.z = 0;
- Bed1.Draw();
- glPopMatrix();
- ////////////////////////////////
- //////////////////////////////
- glPushMatrix();
- glTranslated(1100, 15, 820);
- glScaled(0.07, 0.07, 0.07);
- glRotatef(90, 0, 1, 0);
- Bed2.pos.x = 0;
- Bed2.pos.y = 0;
- Bed2.pos.z = 0;
- Bed2.Draw();
- glPopMatrix();
- ////////////////////
- ////////////////////////
- glPushMatrix();
- glTranslated(1850, 15, 720);
- glScaled(0.09, 0.09, 0.09);
- glRotatef(-90, 0, 1, 0);
- sofa1.pos.x = 0;
- sofa1.pos.y = 0;
- sofa1.pos.z = 0;
- sofa1.Draw();
- glPopMatrix();
- ////////////////////////////
- glPushMatrix();
- glTranslated(1520, 100, 890);
- glScaled(0.6, 0.6, 0.6);
- glRotatef(180, 0, 1, 0);
- Beroo.pos.x = 0;
- Beroo.pos.y = 0;
- Beroo.pos.z = 0;
- Beroo.Draw();
- glPopMatrix();
- ///////////////////////////////////
- glPushMatrix();
- glTranslated(0, 3, 650);
- glScaled(30, 30, 30);
- Model3.pos.x = 0;
- Model3.pos.y = 0;
- Model3.pos.z = 0;
- Model3.Draw();
- glPopMatrix();
- glPushMatrix();
- glTranslated(-450, 3, 1300);
- glScaled(30, 30, 30);
- Model10.pos.x = 0;
- Model10.pos.y = 0;
- Model10.pos.z = 0;
- Model10.Draw();
- glPopMatrix();
- glPushMatrix();
- glTranslated(-600, 3, 500);
- glRotated(90, 0, 1, 0);
- glScaled(2, 2, 2);
- Model7.pos.x = 0;
- Model7.pos.y = 0;
- Model7.pos.z = 0;
- Model7.Draw();
- glPopMatrix();
- glPushMatrix();
- glTranslated(1530, 60, -560);
- glScalef(0.8, 0.8, 0.8);
- M16.pos.x = 0;
- M16.pos.y = 60;
- M16.pos.z = 0;
- M16.Draw();
- glPopMatrix();
- glPushMatrix();
- glTranslated(1530, 60, -420);
- glScalef(0.8, 0.8, 0.8);
- M16.pos.x = 0;
- M16.pos.y = 60;
- M16.pos.z = 0;
- M16.Draw();
- glPopMatrix();
- glPushMatrix();
- glTranslated(1070, 40, -630);
- glScalef(2, 2, 2);
- AWP.pos.x = 0;
- AWP.pos.y = 40;
- AWP.pos.z = 0;
- AWP.Draw();
- glPopMatrix();
- glPushMatrix();
- glTranslated(1070, 40, -510);
- glScalef(2, 2, 2);
- AWP.pos.x = 0;
- AWP.pos.y = 40;
- AWP.pos.z = 0;
- AWP.Draw();
- glPopMatrix();
- glPushMatrix();
- glTranslated(1300, 30, -600);
- glScaled(0.3, 0.3, 0.3);
- Sword.pos.x = 0;
- Sword.pos.y = 30;
- Sword.pos.z = 0;
- Sword.Draw();
- glPopMatrix();
- glPushMatrix();
- glTranslated(1520, 20, -500);
- glScaled(2.5, 2.5, 2.5);
- PP19.pos.x = 0;
- PP19.pos.y = 20;
- PP19.pos.z = 0;
- PP19.Draw();
- glPopMatrix();
- glPushMatrix();
- glTranslated(1070, 35, -500);
- glScaled(1.5, 1.5, 1.5);
- M4.pos.x = 0;
- M4.pos.y = 35;
- M4.pos.z = 0;
- M4.Draw();
- glPopMatrix();
- glPushMatrix();
- glTranslated(1520, 140, -600);
- glScaled(0.05, 0.05, 0.05);
- glock.pos.x = 0;
- glock.pos.y = 140;
- glock.pos.z = 0;
- glock.Draw();
- glPopMatrix();
- glPushMatrix();
- glTranslated(1520, 140, -500);
- glScaled(0.05, 0.05, 0.05);
- glock.pos.x = 0;
- glock.pos.y = 140;
- glock.pos.z = 0;
- glock.Draw();
- glPopMatrix();
- glPushMatrix();
- glTranslated(1520, 140, -400);
- glScaled(0.05, 0.05, 0.05);
- glock.pos.x = 0;
- glock.pos.y = 140;
- glock.pos.z = 0;
- glock.Draw();
- glPopMatrix();
- glPushMatrix();
- glTranslated(1130, 150, -620);
- glScaled(0.05, 0.05, 0.05);
- RPG.pos.x = 0;
- RPG.pos.y = 50;
- RPG.pos.z = 0;
- RPG.Draw();
- glPopMatrix();
- glPushMatrix();
- glTranslated(1240, 150, -620);
- glScaled(0.05, 0.05, 0.05);
- RPG.pos.x = 0;
- RPG.pos.y = 50;
- RPG.pos.z = 0;
- RPG.Draw();
- glPopMatrix();
- glPushMatrix();
- glTranslated(1350, 150, -620);
- glScaled(0.05, 0.05, 0.05);
- RPG.pos.x = 0;
- RPG.pos.y = 50;
- RPG.pos.z = 0;
- RPG.Draw();
- glPopMatrix();
- glPushMatrix();
- glTranslated(1450, 150, -620);
- glScaled(0.05, 0.05, 0.05);
- RPG.pos.x = 0;
- RPG.pos.y = 50;
- RPG.pos.z = 0;
- RPG.Draw();
- glPopMatrix();
- glPushMatrix();
- glTranslated(2000, 45, -400);
- glScaled(0.2, 0.2, 0.2);
- Ch1.pos.x = -65;
- Ch1.pos.y = 45;
- Ch1.pos.z = 0;
- Ch1.Draw();
- glPopMatrix();
- Connne(700, 15, 140, 300, 30, 1);
- Connne(700, 15, 380, 300, 30, 1);
- bool open = checkNearDoor(700, 155, 170);
- if (open) {
- if (DeafultX < 300) {
- DeafultX += 50;
- }
- }
- else // closed
- {
- if (DeafultX > 0)
- DeafultX -= 50;
- }
- glPushMatrix();
- glTranslated(1200, 30, 170); // translation for updating the door postion (Opening).
- glBegin(GL_QUADS);
- glColor3d(1, 0.3, 0.3);
- glVertex3d(-2, 5, 2);
- glVertex3d(-6, 5, 35);
- glVertex3d(-6, -70, 35);
- glVertex3d(-2, -70, 2);
- glEnd();
- glPopMatrix();
- glPushMatrix();
- glTranslated(1200, 30, 190); // translation for updating the door postion (Opening).
- glBegin(GL_QUADS);
- glColor3d(1, 0, 0.3);
- glVertex3d(-2, 5, 2);
- glVertex3d(-6, 5, 35);
- glVertex3d(-6, -70, 35);
- glVertex3d(-2, -70, 2);
- glEnd();
- glPopMatrix();
- glPushMatrix();
- glTranslated(-900, 5, 600);
- glScaled(2, 2, 2);
- Model8.pos.x = 0;
- Model8.pos.y = 0;
- Model8.pos.z = 0;
- Model8.Draw();
- glPopMatrix();
- glPushMatrix();
- glTranslated(-920, 30, 250);
- glScaled(50, 50, 50);
- Honda.pos.x = 0;
- Honda.pos.y = 0;
- Honda.pos.z = 0;
- Honda.Draw();
- glPopMatrix();
- glPushMatrix();
- glTranslated(-920, 40, 800);
- glScaled(50, 50, 50);
- Honda1.pos.x = 0;
- Honda1.pos.y = 0;
- Honda1.pos.z = 0;
- Honda1.Draw();
- glPopMatrix();
- glPushMatrix();
- glTranslated(100, 32, 1250);
- glScaled(50, 50, 50);
- Honda2.pos.x = 0;
- Honda2.pos.y = 0;
- Honda2.pos.z = 0;
- Honda2.Draw();
- glPopMatrix();
- glPushMatrix();
- glTranslated(-10, 32, 1250);
- glScaled(50, 50, 50);
- Honda1.pos.x = 0;
- Honda1.pos.y = 0;
- Honda1.pos.z = 0;
- Honda1.Draw();
- glPopMatrix();
- glPushMatrix();
- glTranslated(200, 125, 1100);
- glScaled(3, 3, 3);
- Model6.pos.x = 0;
- Model6.pos.y = 0;
- Model6.pos.z = 0;
- Model6.Draw();
- glPopMatrix();
- glPushMatrix();
- glTranslated(185, 0, 125);
- glScaled(5, 5, 5);
- Model5.pos.x = 0;
- Model5.pos.y = 0;
- Model5.pos.z = 0;
- Model5.Draw();
- glPopMatrix();
- glPushMatrix();
- glTranslated(185, 0, -80);
- glScaled(5, 5, 5);
- Model5.pos.x = 0;
- Model5.pos.y = 0;
- Model5.pos.z = 0;
- Model5.Draw();
- glPopMatrix();
- glPushMatrix();
- glTranslated(0, 0, -400);
- Build1.Draw();
- glPopMatrix();
- glTranslated(-240, 0, -400);
- Build2.Draw();
- glTranslated(-625, 0, 0);
- Build3.Draw();
- glPushMatrix();
- glRotated(90, 0, 1, 0);
- glTranslated(-500, 0, -375);
- Build4.Draw();
- glPopMatrix();
- glPushMatrix();
- glRotated(90, 0, 1, 0);
- glTranslated(-1400, 0, -375);
- Build5.Draw();
- glPopMatrix();
- glPushMatrix();
- glRotated(90, 0, 1, 0);
- glTranslated(-1400, 210, -375);
- Build5Floor2.Draw();
- glPopMatrix();
- //glPushMatrix();
- //glRotated(180, 0, 1, 0);
- //glTranslated(0, 0, 1400);
- //Build6.Draw();
- //glPopMatrix();
- glPushMatrix();
- glRotated(90, 0, 1, 0);
- glRotated(90, 1, 0, 0);
- GroundRoad.SetPosition(-300, 0, -0.5);
- GroundRoad.SetDimntion(2500, 6000);
- GroundRoad.SetTexture(Raod2);
- GroundRoad.Draw();
- glPopMatrix();
- glPushMatrix();
- glRotated(90, 1, 0, 0);
- GroundRoad.SetPosition(-95, 0, -0.5);
- GroundRoad.SetDimntion(2500, 205);
- GroundRoad.SetTexture(Road3);
- GroundRoad.Draw();
- glPopMatrix();
- glPushMatrix();
- glTranslated(250, 3, 500);
- glScaled(0.2, 0.2, 0.2);
- Model1.pos.x = 0;
- Model1.pos.y = 0;
- Model1.pos.z = 0;
- Model1.Draw();
- glPopMatrix();
- glPushMatrix();
- glTranslated(1300, 615, 2000);
- glScaled(35, 35, 35);
- Mosc.pos.x = 0;
- Mosc.pos.y = 0;
- Mosc.pos.z = 0;
- Mosc.Draw();
- glPopMatrix();
- glPushMatrix();
- glTranslatef(370, 0, 0);
- Ligth3d();
- Ligth();
- glPopMatrix();
- glFlush();
- Sleep(1);
- return TRUE;
- }
- GLvoid KillGLWindow(GLvoid) // Properly Kill The Window
- {
- if (fullscreen) // Are We In Fullscreen Mode?
- {
- ChangeDisplaySettings(NULL, 0); // If So Switch Back To The Desktop
- ShowCursor(TRUE); // Show Mouse Pointer
- }
- if (hRC) // Do We Have A Rendering Context?
- {
- if (!wglMakeCurrent(NULL, NULL)) // Are We Able To Release The DC And RC Contexts?
- {
- MessageBox(NULL, "Release Of DC And RC Failed.", "SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION);
- }
- if (!wglDeleteContext(hRC)) // Are We Able To Delete The RC?
- {
- MessageBox(NULL, "Release Rendering Context Failed.", "SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION);
- }
- hRC = NULL; // Set RC To NULL
- }
- if (hDC && !ReleaseDC(hWnd, hDC)) // Are We Able To Release The DC
- {
- MessageBox(NULL, "Release Device Context Failed.", "SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION);
- hDC = NULL; // Set DC To NULL
- }
- if (hWnd && !DestroyWindow(hWnd)) // Are We Able To Destroy The Window?
- {
- MessageBox(NULL, "Could Not Release hWnd.", "SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION);
- hWnd = NULL; // Set hWnd To NULL
- }
- if (!UnregisterClass("OpenGL", hInstance)) // Are We Able To Unregister Class
- {
- MessageBox(NULL, "Could Not Unregister Class.", "SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION);
- hInstance = NULL; // Set hInstance To NULL
- }
- }
- /* This Code Creates Our OpenGL Window. Parameters Are: *
- * title - Title To Appear At The Top Of The Window *
- * width - Width Of The GL Window Or Fullscreen Mode *
- * height - Height Of The GL Window Or Fullscreen Mode *
- * bits - Number Of Bits To Use For Color (8/16/24/32) *
- * fullscreenflag - Use Fullscreen Mode (TRUE) Or Windowed Mode (FALSE) */
- BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag)
- {
- GLuint PixelFormat; // Holds The Results After Searching For A Match
- WNDCLASS wc; // Windows Class Structure
- DWORD dwExStyle; // Window Extended Style
- DWORD dwStyle; // Window Style
- RECT WindowRect; // Grabs Rectangle Upper Left / Lower Right Values
- WindowRect.left = (long)0; // Set Left Value To 0
- WindowRect.right = (long)width; // Set Right Value To Requested Width
- WindowRect.top = (long)0; // Set Top Value To 0
- WindowRect.bottom = (long)height; // Set Bottom Value To Requested Height
- fullscreen = fullscreenflag; // Set The Global Fullscreen Flag
- hInstance = GetModuleHandle(NULL); // Grab An Instance For Our Window
- wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // Redraw On Size, And Own DC For Window.
- wc.lpfnWndProc = (WNDPROC)WndProc; // WndProc Handles Messages
- wc.cbClsExtra = 0; // No Extra Window Data
- wc.cbWndExtra = 0; // No Extra Window Data
- wc.hInstance = hInstance; // Set The Instance
- wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); // Load The Default Icon
- wc.hCursor = LoadCursor(NULL, IDC_ARROW); // Load The Arrow Pointer
- wc.hbrBackground = NULL; // No Background Required For GL
- wc.lpszMenuName = NULL; // We Don't Want A Menu
- wc.lpszClassName = "OpenGL"; // Set The Class Name
- if (!RegisterClass(&wc)) // Attempt To Register The Window Class
- {
- MessageBox(NULL, "Failed To Register The Window Class.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
- return FALSE; // Return FALSE
- }
- if (fullscreen) // Attempt Fullscreen Mode?
- {
- DEVMODE dmScreenSettings; // Device Mode
- memset(&dmScreenSettings, 0, sizeof(dmScreenSettings)); // Makes Sure Memory's Cleared
- dmScreenSettings.dmSize = sizeof(dmScreenSettings); // Size Of The Devmode Structure
- dmScreenSettings.dmPelsWidth = width; // Selected Screen Width
- dmScreenSettings.dmPelsHeight = height; // Selected Screen Height
- dmScreenSettings.dmBitsPerPel = bits; // Selected Bits Per Pixel
- dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
- // Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.
- if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
- {
- // If The Mode Fails, Offer Two Options. Quit Or Use Windowed Mode.
- if (MessageBox(NULL, "The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?", "GL template", MB_YESNO | MB_ICONEXCLAMATION) == IDYES)
- {
- fullscreen = FALSE; // Windowed Mode Selected. Fullscreen = FALSE
- }
- else
- {
- // Pop Up A Message Box Letting User Know The Program Is Closing.
- MessageBox(NULL, "Program Will Now Close.", "ERROR", MB_OK | MB_ICONSTOP);
- return FALSE; // Return FALSE
- }
- }
- }
- if (fullscreen) // Are We Still In Fullscreen Mode?
- {
- dwExStyle = WS_EX_APPWINDOW; // Window Extended Style
- dwStyle = WS_POPUP; // Windows Style
- ShowCursor(FALSE); // Hide Mouse Pointer
- }
- else
- {
- dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; // Window Extended Style
- dwStyle = WS_OVERLAPPEDWINDOW; // Windows Style
- }
- AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle); // Adjust Window To True Requested Size
- // Create The Window
- if (!(hWnd = CreateWindowEx(dwExStyle, // Extended Style For The Window
- "OpenGL", // Class Name
- title, // Window Title
- dwStyle | // Defined Window Style
- WS_CLIPSIBLINGS | // Required Window Style
- WS_CLIPCHILDREN, // Required Window Style
- 0, 0, // Window Position
- WindowRect.right - WindowRect.left, // Calculate Window Width
- WindowRect.bottom - WindowRect.top, // Calculate Window Height
- NULL, // No Parent Window
- NULL, // No Menu
- hInstance, // Instance
- NULL))) // Dont Pass Anything To WM_CREATE
- {
- KillGLWindow(); // Reset The Display
- MessageBox(NULL, "Window Creation Error.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
- return FALSE; // Return FALSE
- }
- static PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be
- {
- sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
- 1, // Version Number
- PFD_DRAW_TO_WINDOW | // Format Must Support Window
- PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
- PFD_DOUBLEBUFFER, // Must Support Double Buffering
- PFD_TYPE_RGBA, // Request An RGBA Format
- bits, // Select Our Color Depth
- 0, 0, 0, 0, 0, 0, // Color Bits Ignored
- 0, // No Alpha Buffer
- 0, // Shift Bit Ignored
- 0, // No Accumulation Buffer
- 0, 0, 0, 0, // Accumulation Bits Ignored
- 16, // 16Bit Z-Buffer (Depth Buffer)
- 0, // No Stencil Buffer
- 0, // No Auxiliary Buffer
- PFD_MAIN_PLANE, // Main Drawing Layer
- 0, // Reserved
- 0, 0, 0 // Layer Masks Ignored
- };
- if (!(hDC = GetDC(hWnd))) // Did We Get A Device Context?
- {
- KillGLWindow(); // Reset The Display
- MessageBox(NULL, "Can't Create A GL Device Context.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
- return FALSE; // Return FALSE
- }
- if (!(PixelFormat = ChoosePixelFormat(hDC, &pfd))) // Did Windows Find A Matching Pixel Format?
- {
- KillGLWindow(); // Reset The Display
- MessageBox(NULL, "Can't Find A Suitable PixelFormat.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
- return FALSE; // Return FALSE
- }
- if (!SetPixelFormat(hDC, PixelFormat, &pfd)) // Are We Able To Set The Pixel Format?
- {
- KillGLWindow(); // Reset The Display
- MessageBox(NULL, "Can't Set The PixelFormat.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
- return FALSE; // Return FALSE
- }
- if (!(hRC = wglCreateContext(hDC))) // Are We Able To Get A Rendering Context?
- {
- KillGLWindow(); // Reset The Display
- MessageBox(NULL, "Can't Create A GL Rendering Context.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
- return FALSE; // Return FALSE
- }
- if (!wglMakeCurrent(hDC, hRC)) // Try To Activate The Rendering Context
- {
- KillGLWindow(); // Reset The Display
- MessageBox(NULL, "Can't Activate The GL Rendering Context.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
- return FALSE; // Return FALSE
- }
- ShowWindow(hWnd, SW_SHOW); // Show The Window
- SetForegroundWindow(hWnd); // Slightly Higher Priority
- SetFocus(hWnd); // Sets Keyboard Focus To The Window
- ReSizeGLScene(width, height); // Set Up Our Perspective GL Screen
- if (!InitGL()) // Initialize Our Newly Created GL Window
- {
- KillGLWindow(); // Reset The Display
- MessageBox(NULL, "Initialization Failed.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
- return FALSE; // Return FALSE
- }
- return TRUE; // Success
- }
- LRESULT CALLBACK WndProc(HWND hWnd, // Handle For This Window
- UINT uMsg, // Message For This Window
- WPARAM wParam, // Additional Message Information
- LPARAM lParam) // Additional Message Information
- {
- switch (uMsg) // Check For Windows Messages
- {
- case WM_MOUSEMOVE: { mouseX = (int)LOWORD(lParam); mouseY = (int)HIWORD(lParam); isClicked = (LOWORD(wParam) & MK_LBUTTON) ? true : false; isRClicked = (LOWORD(wParam) & MK_RBUTTON) ? true : false; break; }
- case WM_LBUTTONUP: isClicked = false; break;
- case WM_RBUTTONUP: isRClicked = false; break;
- case WM_LBUTTONDOWN: isClicked = true; break;
- case WM_RBUTTONDOWN: isRClicked = true; break;
- case WM_ACTIVATE: // Watch For Window Activate Message
- {
- if (!HIWORD(wParam)) // Check Minimization State
- {
- active = TRUE; // Program Is Active
- }
- else
- {
- active = FALSE; // Program Is No Longer Active
- }
- return 0; // Return To The Message Loop
- }
- case WM_SYSCOMMAND: // Intercept System Commands
- {
- switch (wParam) // Check System Calls
- {
- case SC_SCREENSAVE: // Screensaver Trying To Start?
- case SC_MONITORPOWER: // Monitor Trying To Enter Powersave?
- return 0; // Prevent From Happening
- }
- break; // Exit
- }
- case WM_CLOSE: // Did We Receive A Close Message?
- {
- PostQuitMessage(0); // Send A Quit Message
- return 0; // Jump Back
- }
- case WM_KEYDOWN: // Is A Key Being Held Down?
- {
- keys[wParam] = TRUE; // If So, Mark It As TRUE
- return 0; // Jump Back
- }
- case WM_KEYUP: // Has A Key Been Released?
- {
- keys[wParam] = FALSE; // If So, Mark It As FALSE
- return 0; // Jump Back
- }
- case WM_SIZE: // Resize The OpenGL Window
- {
- ReSizeGLScene(LOWORD(lParam), HIWORD(lParam)); // LoWord=Width, HiWord=Height
- return 0; // Jump Back
- }
- }
- // Pass All Unhandled Messages To DefWindowProc
- return DefWindowProc(hWnd, uMsg, wParam, lParam);
- }
- int WINAPI WinMain(HINSTANCE hInstance, // Instance
- HINSTANCE hPrevInstance, // Previous Instance
- LPSTR lpCmdLine, // Command Line Parameters
- int nCmdShow) // Window Show State
- {
- MSG msg; // Windows Message Structure
- BOOL done = FALSE; // Bool Variable To Exit Loop
- // Ask The User Which Screen Mode They Prefer
- //if (MessageBox(NULL,"Would You Like To Run In Fullscreen Mode?", "Start FullScreen?",MB_YESNO|MB_ICONQUESTION)==IDNO)
- {
- fullscreen = FALSE; // Windowed Mode
- }
- // Create Our OpenGL Window
- if (!CreateGLWindow("OpenGL template", 640, 480, 16, fullscreen))
- {
- return 0; // Quit If Window Was Not Created
- }
- while (!done) // Loop That Runs While done=FALSE
- {
- if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) // Is There A Message Waiting?
- {
- if (msg.message == WM_QUIT) // Have We Received A Quit Message?
- {
- done = TRUE; // If So done=TRUE
- }
- else // If Not, Deal With Window Messages
- {
- TranslateMessage(&msg); // Translate The Message
- DispatchMessage(&msg); // Dispatch The Message
- }
- }
- else // If There Are No Messages
- {
- // Draw The Scene. Watch For ESC Key And Quit Messages From DrawGLScene()
- if (active) // Program Active?
- {
- if (keys[VK_ESCAPE]) // Was ESC Pressed?
- {
- done = TRUE; // ESC Signalled A Quit
- }
- else // Not Time To Quit, Update Screen
- {
- DrawGLScene(); // Draw The Scene
- SwapBuffers(hDC); // Swap Buffers (Double Buffering)
- }
- }
- if (keys[VK_F1]) // Is F1 Being Pressed?
- {
- keys[VK_F1] = FALSE; // If So Make Key FALSE
- KillGLWindow(); // Kill Our Current Window
- fullscreen = !fullscreen; // Toggle Fullscreen / Windowed Mode
- // Recreate Our OpenGL Window
- if (!CreateGLWindow("OpenGL template", 640, 480, 16, fullscreen))
- {
- return 0; // Quit If Window Was Not Created
- }
- }
- }
- }
- // Shutdown
- KillGLWindow(); // Kill The Window
- return (msg.wParam); // Exit The Program
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement