-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
1081 lines (799 loc) · 24.7 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//Add Clickable object to the objects collection of the Miscfunct
#include <GL/glut.h>
#include <GL/glfw.h>
#include <stdlib.h>
#include <math.h>
#include "CZA/Vector3.cpp"
#include "CZA/CZAIL.h"
#include <string.h>
#include "CZA/Motion.h"
#include "CZA/Camera.cpp"
#include "CZA/Camera2.cpp"
#include "CZA/SkyBox.h"
#include "CZA/ObjectManager.h"
#include "CZA/Water.h"
#include "CZA/Terrain.h"
#include "CZA/md2model.cpp"
#include "CZA/guy.h"
#include "CZA/staticobject.h"
#include "CZA/font.h"
#include "CZA/misc.h"
#include "CZA/grass.h"
#include "CZA/fog.h"
#include "CZA/TextruedSquare.h"
#include "CZA/bullet.h"
#include "CZA/FPSCamera.cpp"
#include "CZA/Model_3DS.cpp"
//#include "3ds.cpp"
//#include "loader.h"
//#include "3dsloader.cpp"
//#include "Object.h"
#include <vector>
#define BULLETMAX 30
#define WORLDSIZE 512
#define SELF 991128
using namespace std;
Vector3 position;
Vector3 size;
Vector3 g0vec(-999,-999,-999);
float g0ang;
//CLoad3DS g_Load3ds; // This is 3DS class. This should go in a good model class.
//Model_3DS m;
vector<Model_3DS> models3ds;
SkyBox SkyBox1;
Grid Grid1;
Ball Ball1;
Cube Cube1;
ObjectManager OManage;
Loader3ds spaceship, bus,maxtest;//, house;
//Water Lake;
//Water Lake2;
Terrain Land1;
FPSCamera Cam; //Camera for scene
Misc Miscfunct;
Bullet* bulletList[BULLETMAX];
TexturedSquare Crosshair;
MD2Model* _model;
MD2Model* fighter;
MD2Model* testmodel;
MD2Model* van;
MD2Model* sonic;
MD2Model* Archv;
vector<Guy*> _guys;
vector<StaticObject*> _trees;
vector<Water*> _water;
Guy* CameraGuy;
//vector<GrassObject*> _grass;
fog myfog;
GrassObject* grass;
FontClass Font;
int WINDOWWIDTH = 640;
int WINDOWHEIGHT = 480;
//C3dsLoader obj3dsLoader;
int mode = 0;
int mousex = 0;
int mousey = 0;
int pickx = 0;
int picky = 0;
char s[30];
int grassmode = 0;
static int slices = 16;
static int stacks = 16;
GLuint landDL;
GLuint treeDL;
int frame = 0;
int timebase = glutGet(GLUT_ELAPSED_TIME);
int time1 = glutGet(GLUT_ELAPSED_TIME);
/* GLUT callback Handlers */
bool runonce = false;
static void
resize(int width, int height)
{
const float ar = (float) width / (float) height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-ar, ar, -1.0, 1.0, 2.0, 10000.0);//change the last numer to stay on screen.
glMatrixMode(GL_MODELVIEW);
glLoadIdentity() ;
runonce = false;
}
static void SetDefaultMousePosition(){
glutWarpPointer(WINDOWWIDTH / 2, WINDOWHEIGHT / 2);
Cam.ResetLast();
}
void processMouse(int button, int state, int x, int y) {
//specialKey = glutGetModifiers();
if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
{
mousex = x;
mousey = y;
mode = 1;
//Create Bullets
for (int i = 0; i < BULLETMAX; i++){
if (!bulletList[i]->Active()){
//This is so collision dectection can not let your own bullets hit you right after initial firing.
bulletList[i]->setUserGenerated(true);
bulletList[i]->SetPosition(Cam);
bulletList[i]->setActive(true);
break;
}
}
}
}
int ztran = -6;
float lx = 0;
float ly = 1;
int ttl = -100;
string inttostring(int val){
char test[10];
itoa(val, test, 10);
string str = test;
const char * str1 = str.c_str();
return str;//MessageBox(NULL, str1, "Error", MB_OK);
}
static int
handle_collisions(){
int jki = 0;
OManage.handleCollisions(jki);
return jki;
}
static void
render_skybox(){
glPushMatrix();
glDisable(GL_DEPTH_TEST);
SkyBox1.RenderSkyBox(Cam.GetPosition());
//SkyBox1.RenderSkyBox();
glEnable(GL_DEPTH_TEST);
glColor3f(1,1,1);
}
static void
render_land(){
(&Land1)->Render();
}
static void
render_guys(){
glDepthFunc(GL_LEQUAL);
for(unsigned int i = 0; i < _guys.size(); i++) {
if(!_guys[i]->Active())
continue;
if (i==0){
glPushMatrix();
g0vec = Vector3(_guys[i]->GetCurrentx(),_guys[i]->GetCurrenty(),_guys[i]->GetCurrentz());
g0ang = 90 - _guys[i]->walkAngle() * 180 / PI; //rad to deg
//Cam.SetPosition(_guys[i]->GetCurrentx(),_guys[i]->GetCurrenty(),_guys[i]->GetCurrentz());
//Cam.orientMe(90 - _guys[i]->angle * 180 / PI);
//Cam.orientMe(_guys[i]->angle);
//_guys[i]->DrawBoundingBox();
glPopMatrix();
}
_guys[i]->draw();
_guys[i]->Refresh();
_guys[i]->advance(0.01);
//_guys[i]->DrawBoundingBox();
}
glDepthFunc(GL_LESS);
}
static void
render_bullets(){
glPushMatrix();
for(unsigned int i = 0; i < BULLETMAX; i++) {
if (bulletList[i]->Active()){
bulletList[i]->Render();
bulletList[i]->Update(1);
}
}
glPopMatrix();
}
static void
render_trees(){
glPushMatrix();
for(unsigned int i = 0; i < _trees.size(); i++) {
_trees[i]->Render();
//_trees[i]->DrawBoundingBox();
}
glPopMatrix();
}
static void
render_grass(){
glPushMatrix();
if (grassmode == 1)
grass->Render();
glPopMatrix();
}
static void
render_testitems(){
glPushMatrix();
glDisable(GL_CULL_FACE);
//Vector3 camloc = Cam.GetPosition();
//glColor3f(1,1,0);
//glTranslatef(0,4.7f,0);
//CameraGuy->draw(&Cam);
//CameraGuy->Refresh(); Bad Attempt at 3rd person Need a real 3rd Person Cam
//CameraGuy->advance(0.01);
//glColor3f(1,1,1);
//MotionPath Test
//MP.draw();
//Fighter
glDepthFunc(GL_LEQUAL);
fighter->draw();
fighter->Refresh();
fighter->advance(0.01);
fighter->DrawBoundingBox();
//van->draw();
// van->Refresh();
//van->advance(0.01);
//van->DrawBoundingBox();
sonic->draw();
sonic->Refresh();
sonic->advance(0.001);
sonic->DrawBoundingBox();
for (int i=0;i<models3ds.size();i++){
models3ds.at(i).Render();
//m.Render();
}
glPushMatrix();
for(unsigned int i = 0; i < _water.size(); i++) {
_water[i]->Render();
}
glPopMatrix();
//Lake.Render();
//spaceship.Render();
//g_Load3ds.Render();
// house.Render();
glDepthFunc(GL_LESS);
//myfog.Render();
Crosshair.Render(WINDOWWIDTH, WINDOWHEIGHT);
glEnable(GL_CULL_FACE);
glPopMatrix();
//(&maxtest)->SetPosition(Vector3(0 , ly, 0));
//(&maxtest)->Render();
//(&maxtest)->DrawBoundingBox();
}
static void
render_world(){
render_skybox();
render_land();
render_trees();
render_guys();
render_grass();
render_testitems();
render_bullets();
}
static void
renderOnscreenText(int collisions){
//Font.glPrint( 30, WINDOWHEIGHT - 50, "This is my Text test!!!", 1, 0.0, 1.0, 0.0, 0.5 );
Font.glPrint( 30, WINDOWHEIGHT - 50, (char*)(s), 1, 0.0, 1.0, 0.0, 0.5 );
Font.glPrint( 30, WINDOWHEIGHT - 75, (char*)(inttostring(collisions).c_str()), 1, 0.0, 1.0, 0.0, 0.5 );
char clx[30];
char clz[30];
sprintf(clx,"lx:%4.2f",Cam.lx);
sprintf(clz,"ly:%4.2f",Cam.lz);
Font.glPrint( 30, WINDOWHEIGHT - 100, (char*)(clx), 1, 0.0, 1.0, 0.0, 0.5 );
Font.glPrint( 30, WINDOWHEIGHT - 125, (char*)(clz), 1, 0.0, 1.0, 0.0, 0.5 );
char cx[30];
char cz[30];
sprintf(cx,"x:%4.2f",Cam.x);
sprintf(cz,"z:%4.2f",Cam.z);
Font.glPrint( 30, WINDOWHEIGHT - 150, (char*)(cx), 1, 0.0, 1.0, 0.0, 0.5 );
Font.glPrint( 30, WINDOWHEIGHT - 175, (char*)(cz), 1, 0.0, 1.0, 0.0, 0.5 );
char cx1[30];
char cz1[30];
sprintf(cx1,"TSCALE:%4.2f",Land1.terrainScale());
sprintf(cz1,"angle:%4.2f",Cam.angle*100.0f);
Font.glPrint( 30, WINDOWHEIGHT - 200, (char*)(cx1), 1, 0.0, 1.0, 0.0, 0.5 );
Font.glPrint( 30, WINDOWHEIGHT - 225, (char*)(cz1), 1, 0.0, 1.0, 0.0, 0.5 );
}
static void
startpicking(){
if (mode == 1)
Miscfunct.StartPicking(mousex,mousey, pickx,picky, WINDOWHEIGHT);
}
static void
stoppicking(){
if (mode == 1)
Miscfunct.StopPicking(pickx, picky, mode);
else
glutSwapBuffers();
}
static void
initdisplay_const(){
const double t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
const double a = t*90.0;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if (runonce == false){
runonce = true;
Cam.moveMeFlat(0);
}else{
if (Cam.mode == 1){//follow mode
if (g0vec.x != -999){
//Cam.SetPosition(g0vec.x - (Land1.width_starting()/2),g0vec.y,g0vec.z - (Land1.length_starting()/2));
Cam.SetPosition(g0vec.x,g0vec.y,g0vec.z);
//Cam.orientMe((180+g0ang)/100.0f);
}
}
}
}
static void
reset_lx_ly(){
if (lx >= 10)
lx = 0;
if (ly >= 10)
ly = 0;
}
static void
update_lx_ly(){
lx += 0.01f;
ly += 0.01f;
}
double savedTime = 0;
double updateTimer = 0;
//const double updateInterval = 1.0/60.0;
const double updateInterval = 1000.0/65.0;
static bool framerate_correct(){
/*if (time1 - timebase > 1000) {
sprintf(s,"FPS:%4.2f",frame*1000.0/(time1-timebase));
timebase = time1;
frame = 0;
}*/
//double currentTime = glfwGetTime();
double currentTime = glutGet(GLUT_ELAPSED_TIME);
double elapseTime = currentTime - savedTime;
savedTime = currentTime;
updateTimer += elapseTime;
if(updateTimer >= updateInterval){
//update(updateInterval); //update game logic /keyframe animation
updateTimer = 0;
return true;
}
return false;
}
static void
display(void)
{
if (framerate_correct()){
frame++;
time1=glutGet(GLUT_ELAPSED_TIME);
if (time1 - timebase > 1000) {
sprintf(s,"FPS:%4.2f",frame*1000.0/(time1-timebase));
timebase = time1;
frame = 0;
}
initdisplay_const();
startpicking();
reset_lx_ly();
render_world();
int jki = 0;
jki = handle_collisions();
renderOnscreenText(jki);
glPopMatrix();
update_lx_ly();
stoppicking();
glFlush();
}
}
static void pressKey(int key, int x, int y) {
switch (key) {
case GLUT_KEY_F1:
//case 's' :
Cam.SetPosition(55,0,55);
break;
case GLUT_KEY_LEFT:
//case 's' :
/*Cam.angle -= 0.01f;
if (Cam.mode == 0){
Cam.orientMe(Cam.angle);
}else{
Cam.CirclePoint(Cam.angle);
}*/
Cam.Strafe(-1);
break;
case GLUT_KEY_RIGHT:
//case 'f' :
/*Cam.angle +=0.01f;
if (Cam.mode == 0){
Cam.orientMe(Cam.angle);
}else{
Cam.CirclePoint(Cam.angle);
}*/
Cam.Strafe(1);
break;
case GLUT_KEY_UP:
//case 'e' :
Cam.moveMeFlat(1);break;
case GLUT_KEY_DOWN:
//case 'd' :
Cam.moveMeFlat(-1);break;
case 99 :
Cam.moveVert(1);break;
case 118 :
Cam.moveVert(-1);break;
case 27 :
//case 'q':
exit(0);
break;
}
glutPostRedisplay();
}
static void releaseKey(int key, int x, int y) {
switch (key) {
//case GLUT_KEY_LEFT :
//case GLUT_KEY_RIGHT :
// deltaAngle = 0.0f;break;
//case GLUT_KEY_UP :
//case GLUT_KEY_DOWN :
// deltaMove = 0;break;
}
}
static void
key(unsigned char key, int x, int y)
{
switch (key)
{
//case GLUT_KEY_LEFT:
case 's' :
/*Cam.angle -= 0.01f;
if (Cam.mode == 0){
Cam.orientMe(Cam.angle);
}else{
Cam.CirclePoint(Cam.angle);
}*/
Cam.Strafe(-1);
break;
//case GLUT_KEY_RIGHT:
case 'f' :
/*Cam.angle +=0.01f;
if (Cam.mode == 0){
Cam.orientMe(Cam.angle);
}else{
Cam.CirclePoint(Cam.angle);
}*/
Cam.Strafe(1);
break;
//case GLUT_KEY_UP:
case 'e' :
Cam.moveMeFlat(1);break;
//case GLUT_KEY_DOWN:
case 'd' :
Cam.moveMeFlat(-1);break;
case 'c' :
Cam.moveVert(1);break;
case 'v' :
Cam.moveVert(-1);break;
case 27 :
case 'q':
exit(0);
break;
case 'w':
ztran += 1;
break;
case 'k':
ztran -=1;
break;
case '+':
slices++;
stacks++;
break;
case '-':
if (slices>3 && stacks>3)
{
slices--;
stacks--;
}
break;
case '1':
if (Cam.mode == 1)
Cam.mode = 0;
else
Cam.mode = 1;
break;
case '2':
if (grassmode == 1)
grassmode = 0;
else
grassmode = 1;
break;
}
glutPostRedisplay();
}
static void
idle(void)
{
/* frame++;
time1=glutGet(GLUT_ELAPSED_TIME);
if (time1 - timebase > 1000) {
sprintf(s,"FPS:%4.2f",frame*1000.0/(time1-timebase));
timebase = time1;
frame = 0;
}*/
glutPostRedisplay();
}
void mouseMove(int x, int y) {
Cam.CursorChange(x,y);
if (x >= (WINDOWWIDTH-10) || x <= (10+0))// || y >= (WINDOWHEIGHT - 10) ||y <= (0 + 10))
SetDefaultMousePosition();
//SetDefaultMousePosition();
}
const GLfloat light_ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f };
const GLfloat light_diffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat light_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat light_position[] = { 2.0f, 5.0f, 5.0f, 0.0f };
const GLfloat mat_ambient[] = { 0.7f, 0.7f, 0.7f, 1.0f };
const GLfloat mat_diffuse[] = { 0.8f, 0.8f, 0.8f, 1.0f };
const GLfloat mat_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat high_shininess[] = { 100.0f };
//This needs to moved to the guy class.
const float TERRAIN_WIDTH = 512.0f;
struct mapobj{
char let;
int x;
int y;
};
void init(){
//testing scales
//float ra = 1;//randomFloat();
//float radius0 = 0.4f * ra + 0.25f;
//float tscale = radius0 / 2.5;
glEnable( GL_TEXTURE_2D );
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0F, 0.0F, ztran);
//load spaceship 3ds model
Font.initFont();
//spaceship.Load3DS ("models\\Castle\\Castle.3ds");
//spaceship.LoadTexture("models\\Castle\\castlewa.bmp");
//spaceship.SetScale(5);
//g_Load3ds.Import3DS("models\\Castle\\Castle.3ds");
//g_Load3ds.init("models\\Castle\\\0");
//g_Load3ds.Import3DS("models\\spaceship\\spaceship.3ds");
//g_Load3ds.init("models\\spaceship\\");
//CLoad3DS g_Load3ds; // This is 3DS class. This should go in a good model class.
//t3DModel g_3DModel;
//spaceship.Load3DS ("models\\spaceship\\spaceship.3ds");
//spaceship.LoadTexture("models\\spaceship\\spaceshiptexture.bmp");
/*house.Load3DS ("models\\house\\cabin.3DS");
house.LoadTexture("models\\house\\house.jpg");*/
//maxtest.Load3DS("models\\cube\\Camaro_2006.3DS");
//Land1.LoadTextures("images\\heightmap512.bmp", "images\\green.bmp",10);
//models3ds.push_back(m);
//m.scale = 14;
/*
Model_3DS m;
//m.Load("models\\hogwarts\\Hogwarts.3ds");
m.Load("models\\deathstar\\Death_Star.3ds");
//m.Load("models\\Castle\\Castle.3DS");
m.lit = false;
m.pos.x = Land1.width() / 2;
m.pos.y += 0.1f;
m.pos.z = Land1.length() / 2;
m.scale = .2;
*/
//Load the model GUY
_model = MD2Model::load("models\\misc\\blockybalboa.md2");
if (_model != NULL) {
_model->setAnimation("run");
}
fighter = MD2Model::load("models\\Fighter\\fighter.md2");
if (fighter != NULL) {
fighter->setAnimation("run");
fighter->Rotate(-90);
fighter->Rotx(true);
fighter->SetScale(0.05f);
fighter->SetPosition(Vector3(0,1.5f,0));
fighter->UseMotionPath = true;
fighter->SetupMotionPath(5);
fighter->path->set(0,0,15.0f,0);
fighter->path->set(1,-20,15.0f,-20);
fighter->path->set(2,20,15.0f,-20);
fighter->path->set(3,20,15.0f,20);
fighter->path->set(4,-20,15.0f,20);
//OManage.AddToManager(*fighter);
}
testmodel = MD2Model::load("models\\banana\\banana.md2");
if (testmodel != NULL) {
testmodel->setAnimation("run");
testmodel->Rotate(-90);
testmodel->Roty(true);
testmodel->SetPosition(Vector3(-5,0,0)); //puts tree on surface instead of under
}
sonic = MD2Model::load("models\\sonic\\ClassicSonic\\PLAY.md2");
if (sonic != NULL) {
sonic->setAnimation("run");
sonic->Rotate(-90);
sonic->Rotx(true);
sonic->SetScale(0.05f);
sonic->SetPosition(Vector3(15,1,10)); //puts tree on surface instead of under
}
van = MD2Model::load("models\\van\\van.md2");
if (van != NULL) {
van->setAnimation("run");
van->Rotate(-90);
van->Rotx(true);
van->SetScale(0.05f);
van->SetPosition(Vector3(-15,1,10)); //puts tree on surface instead of under
}
Archv = MD2Model::load("models\\Archvile\\Archvile.md2");
if (Archv != NULL) {
Archv->setAnimation("run");
Archv->Rotate(-90);
Archv->Rotx(true);
Archv->SetScale(0.05f);
Archv->SetPosition(Vector3(-15,1,10)); //puts tree on surface instead of under
}
vector<mapobj> mapobjs;
//Load in file for processing.
int cmx = 0;
int cmy = 0;
int cmwid = 0;
int cmlen = 0;
string line;
ifstream myfile ("Map3.txt");
if (myfile.is_open())
{
while ( myfile.good() )
{
getline (myfile,line);
for (int i = 0;i<line.size();i++){
if (cmx == 0 && cmy == 0){
cmwid = line.size();
break;
}
char c = line.at(i);
if (c != ' ' && c != 'X'){
mapobj maptemp;
maptemp.let = c;
maptemp.x = cmx;
maptemp.y = cmy;
mapobjs.push_back(maptemp);
}
cmx += 1;
}
//cout << line << endl;
cmx = 0;
cmy += 1;
}
cmlen = cmy;
myfile.close();
}
Land1 = Terrain(cmlen,cmwid);
//Land1 = Terrain(WORLDSIZE,WORLDSIZE);
Cam = FPSCamera(&Land1); //Camera for scene
Land1.LoadTextures("images\\heightmap.bmp", "images\\green.bmp",0, "images\\mountain_texture.jpg");
Cam.setUseTerrainHeight(false);
//Lake.LoadTexture("images\\alpha.jpg","images\\reflection.jpg");
//Lake.SetPosition(Vector3(5,0,5));
Water::LoadTexture("images\\alpha.jpg","images\\reflection.jpg");
for (int i = 0; i < mapobjs.size();i++){
mapobj m1 = mapobjs.at(i);
if (m1.let == 'T'){
_trees.push_back(StaticObject::makeObject(0, testmodel, &Land1, m1.x, m1.y));
}else if (m1.let == 'W'){
Water* wtemp;
wtemp = new Water(&Land1);
wtemp->SetPosition(Vector3(m1.x,0,m1.y));
_water.push_back(wtemp);
}else if (m1.let == 'Q'){
Water* wtemp;
wtemp = new Water(&Land1);
wtemp->SetPosition(Vector3(m1.x,0,m1.y));
_water.push_back(wtemp);
_trees.push_back(StaticObject::makeObject(0, testmodel, &Land1, m1.x, m1.y));
}
}
Model_3DS m;
//m.Load("models\\hogwarts\\Hogwarts.3ds");
//m.Load("models\\deathstar\\Death_Star.3ds");
m.Load("models\\Castle\\Castle.3DS");
//m.Load("models\\peachtree\\ganyedes_s Peach tree.3ds");
m.lit = false;
m.pos.x = Land1.width() / 2;
m.pos.y += 0.1f;
m.pos.z = Land1.length() / 2;
m.scale = 7.0f;
//models3ds.push_back(m);
CameraGuy = new Guy(_model, &Land1, TERRAIN_WIDTH / (Land1.width() - 1));
//Make the guys
_guys = Guy::makeGuys(10, _model, &Land1); //Create the guys
//create banana trees objects
//_trees = StaticObject::makeObjects(0, testmodel, &Land1); //Create the trees
grass = new GrassObject(&Land1, (Land1.terrainScale()));
grass->LoadGrassTexture("images\\grassPackjjjj.jpg","images\\grassmap60.jpg","images\\grassPackmask.jpg",true);
//bus.Load3DS ("models\\cars\\masterchief2.3ds");
//obj3dsLoader.Init_3ds("models\\spaceship\\spaceship.3ds");
//Init Bullets
for (int i=0 ; i < BULLETMAX; i++){
bulletList[i] = new Bullet(&Land1);
}
//add to manager
for(unsigned int i = 0; i < _trees.size(); i++) {
OManage.AddToManager(*_trees[i]);
}
//water
for(unsigned int i = 0; i < _water.size(); i++) {
//OManage.AddToManager(*_water[i]);
//need to maek sure water is not colliding with other water and also need to utilize the hight portions since a flyer should not be affected.
}
//add to manager
for(unsigned int i = 0; i < _guys.size(); i++) {
OManage.AddToManager(*_guys[i]);
}
for(unsigned int i = 0; i < BULLETMAX; i++) {
OManage.AddToManager(*bulletList[i]);
}
Crosshair.LoadTexture("images\\Crosshair.tga");
//OManage.AddToManager(Cam);
//OManage.AddToManager(Ball1);
//OManage.AddToManager(Ball1);
//OManage.AddToManager(Cube1);
//OManage.AddToManager(spaceship);
//OManage.AddToManager(bus);
//OManage.Is_Collision(Vector3(0,0,0));
SkyBox1.LoadSkyBoxTexture("skybox\\out_up.bmp",SKYUP, true, false);
SkyBox1.LoadSkyBoxTexture("skybox\\out_down.bmp",SKYDOWN, true, false);
SkyBox1.LoadSkyBoxTexture("skybox\\out_east.bmp",SKYRIGHT, true, false);
SkyBox1.LoadSkyBoxTexture("skybox\\out_west.bmp",SKYLEFT, true, false);
SkyBox1.LoadSkyBoxTexture("skybox\\out_north.bmp",SKYBACK, true, false);
SkyBox1.LoadSkyBoxTexture("skybox\\out_south.bmp",SKYFRONT, true, false);
/*SkyBox1.LoadSkyBoxTexture("skybox\\side1.png",SKYUP, true, false);
SkyBox1.LoadSkyBoxTexture("skybox\\side6.png",SKYDOWN, true, false);
SkyBox1.LoadSkyBoxTexture("skybox\\side5.png",SKYRIGHT, true, false);
SkyBox1.LoadSkyBoxTexture("skybox\\side3.png",SKYLEFT, true, false);
SkyBox1.LoadSkyBoxTexture("skybox\\side4.png",SKYBACK, true, false);
SkyBox1.LoadSkyBoxTexture("skybox\\side2.png",SKYFRONT, true, false);
*/
//(&Lake)->SetPosition(Vector3(0 , -140.0f, 0));
//(&Lake)->SetScale(500);