2 Copyright (C) 2003, 2010 - Wolfire Games
4 This file is part of Lugaru.
6 Lugaru is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "openal_wrapper.h"
24 #include "Animation.h"
27 extern float screenwidth,screenheight;
28 extern float viewdistance;
30 extern XYZ lightlocation;
31 extern float fadestart;
32 extern float texscale;
35 extern Skeleton testskeleton;
37 extern Terrain terrain;
38 //extern Sprites sprites;
39 extern int kTextureSize;
40 extern float texdetail;
41 extern float realtexdetail;
43 extern Objects objects;
45 extern bool cellophane;
46 extern GLubyte bloodText[512*512*3];
47 extern GLubyte wolfbloodText[512*512*3];
48 extern bool ismotionblur;
49 extern bool trilinear;
51 extern bool musictoggle;
52 extern int environment;
53 extern bool ambientsound;
54 extern float multiplier;
55 extern int netdatanew;
57 extern bool stillloading;
58 extern TGAImageRec texture;
62 extern bool visibleloading;
63 extern float flashamount,flashr,flashg,flashb;
64 extern int flashdelay;
65 extern int whichjointstartarray[26];
66 extern int whichjointendarray[26];
67 extern int difficulty;
68 extern float tintr,tintg,tintb;
69 extern float slomospeed;
70 extern bool gamestarted;
72 extern int numdialogues;
73 extern int numdialogueboxes[20];
74 extern int dialoguetype[20];
75 extern int dialogueboxlocation[20][20];
76 extern float dialogueboxcolor[20][20][3];
77 extern int dialogueboxsound[20][20];
78 extern char dialoguetext[20][20][128];
79 extern char dialoguename[20][20][64];
80 extern XYZ dialoguecamera[20][20];
81 extern float dialoguecamerayaw[20][20];
82 extern float dialoguecamerapitch[20][20];
83 extern int indialogue;
84 extern int whichdialogue;
85 extern float dialoguetime;
87 extern float accountcampaignhighscore[10];
88 extern float accountcampaignfasttime[10];
89 extern float accountcampaignscore[10];
90 extern float accountcampaigntime[10];
92 extern int accountcampaignchoicesmade[10];
93 extern int accountcampaignchoices[10][5000];
95 void LOG(const std::string &fmt, ...)
97 // !!! FIXME: write me.
104 if(Game::endgame==2){
105 Game::accountactive->endGame();
109 Account::saveFile(":Data:Users", Game::accountactive);
113 LOG("Shutting down sound system...");
115 OPENAL_StopSound(OPENAL_ALL);
117 // this is causing problems on Linux, but we'll force an _exit() a little
118 // later in the shutdown process. --ryan.
121 for (int i=0; i < sounds_count; ++i)
123 OPENAL_Sample_Free(samp[i]);
135 void Game::newGame(){
137 skybox = new SkyBox();
140 void Game::deleteGame(){
145 glDeleteTextures( 10, &Mainmenuitems[0] );
146 glDeleteTextures( 1, &cursortexture );
147 glDeleteTextures( 1, &Maparrowtexture );
148 glDeleteTextures( 1, &Mapboxtexture );
149 glDeleteTextures( 1, &Mapcircletexture );
150 glDeleteTextures( 1, &terraintexture );
151 glDeleteTextures( 1, &terraintexture2 );
152 glDeleteTextures( 1, &screentexture );
153 glDeleteTextures( 1, &screentexture2 );
154 glDeleteTextures( 1, &hawktexture );
155 glDeleteTextures( 1, &logotexture );
156 glDeleteTextures( 1, &loadscreentexture );
163 void Game::LoadTexture(const string fileName, GLuint *textureid,int mipmap, bool hasalpha) {
164 *textureid = Texture::Load(fileName,mipmap,hasalpha);
167 void Game::LoadTextureSave(const string fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize) {
168 *textureid = Texture::Load(fileName,mipmap,false,array,skinsize);
171 void LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize)
178 LOG(std::string("Loading (S)...") + fileName);
181 float temptexdetail=texdetail;
183 //upload_image( fileName );
184 //LoadTGA( fileName );
186 // Converting file to something os specific
187 char * fixedFN = ConvertFileName(fileName);
190 unsigned char fileNamep[256];
191 CopyCStringToPascal(fixedFN, fileNamep);
193 upload_image( fileNamep ,0);
194 texdetail=temptexdetail;
198 bytesPerPixel=texture.bpp/8;
201 for(i=0;i<(int)(texture.sizeY*texture.sizeX*bytesPerPixel);i++){
202 if((i+1)%4||bytesPerPixel==3){
203 array[tempnum]=texture.data[i];
212 //***************> ResizeGLScene() <******/
213 GLvoid Game::ReSizeGLScene(float fov, float pnear)
220 glViewport(0,0,screenwidth,screenheight);
222 glMatrixMode(GL_PROJECTION);
225 gluPerspective(fov,(GLfloat)screenwidth/(GLfloat)screenheight,pnear,viewdistance);
227 glMatrixMode(GL_MODELVIEW);
231 void Game::LoadingScreen()
233 static float loadprogress;
234 static AbsoluteTime time = {0,0};
235 static AbsoluteTime frametime = {0,0};
236 AbsoluteTime currTime = UpTime ();
237 double deltaTime = (float) AbsoluteDeltaToDuration (currTime, frametime);
239 if (0 > deltaTime) // if negative microseconds
240 deltaTime /= -1000000.0;
241 else // else milliseconds
244 multiplier=deltaTime;
245 if(multiplier<.001)multiplier=.001;
246 if(multiplier>10)multiplier=10;
248 frametime = currTime; // reset for next time interval
252 glClearColor(0,0,0,1);
253 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
256 loadtime+=multiplier*4;
258 loadprogress=loadtime;
259 if(loadprogress>100)loadprogress=100;
261 //loadprogress=abs(Random()%100);
265 glEnable(GL_TEXTURE_2D);
266 glBindTexture( GL_TEXTURE_2D, loadscreentexture);
267 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
268 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
269 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
270 glDisable(GL_CULL_FACE);
271 glDisable(GL_LIGHTING);
273 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
274 glPushMatrix(); // Store The Projection Matrix
275 glLoadIdentity(); // Reset The Projection Matrix
276 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
277 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
278 glPushMatrix(); // Store The Modelview Matrix
279 glLoadIdentity(); // Reset The Modelview Matrix
280 glTranslatef(screenwidth/2,screenheight/2,0);
281 glScalef((float)screenwidth/2,(float)screenheight/2,1);
282 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
284 glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
286 //glScalef(.25,.25,.25);
288 glTexCoord2f(.1-loadprogress/100,0+loadprogress/100+.3);
289 glVertex3f(-1, -1, 0.0f);
290 glTexCoord2f(.1-loadprogress/100,0+loadprogress/100+.3);
291 glVertex3f(1, -1, 0.0f);
292 glTexCoord2f(.1-loadprogress/100,1+loadprogress/100+.3);
293 glVertex3f(1, 1, 0.0f);
294 glTexCoord2f(.1-loadprogress/100,1+loadprogress/100+.3);
295 glVertex3f(-1, 1, 0.0f);
300 //glScalef(.25,.25,.25);
302 glTexCoord2f(.4+loadprogress/100,0+loadprogress/100);
303 glVertex3f(-1, -1, 0.0f);
304 glTexCoord2f(.4+loadprogress/100,0+loadprogress/100);
305 glVertex3f(1, -1, 0.0f);
306 glTexCoord2f(.4+loadprogress/100,1+loadprogress/100);
307 glVertex3f(1, 1, 0.0f);
308 glTexCoord2f(.4+loadprogress/100,1+loadprogress/100);
309 glVertex3f(-1, 1, 0.0f);
312 glDisable(GL_TEXTURE_2D);
313 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
314 glPopMatrix(); // Restore The Old Projection Matrix
315 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
316 glPopMatrix(); // Restore The Old Projection Matrix
320 glEnable(GL_TEXTURE_2D);
321 glBindTexture( GL_TEXTURE_2D, loadscreentexture);
322 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
323 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
324 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
325 glDisable(GL_CULL_FACE);
326 glDisable(GL_LIGHTING);
328 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
329 glPushMatrix(); // Store The Projection Matrix
330 glLoadIdentity(); // Reset The Projection Matrix
331 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
332 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
333 glPushMatrix(); // Store The Modelview Matrix
334 glLoadIdentity(); // Reset The Modelview Matrix
335 glTranslatef(screenwidth/2,screenheight/2,0);
336 glScalef((float)screenwidth/2*(1.5-(loadprogress)/200),(float)screenheight/2*(1.5-(loadprogress)/200),1);
337 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
339 //glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
340 glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
342 //glScalef(.25,.25,.25);
344 glTexCoord2f(0+.5,0+.5);
345 glVertex3f(-1, -1, 0.0f);
346 glTexCoord2f(1+.5,0+.5);
347 glVertex3f(1, -1, 0.0f);
348 glTexCoord2f(1+.5,1+.5);
349 glVertex3f(1, 1, 0.0f);
350 glTexCoord2f(0+.5,1+.5);
351 glVertex3f(-1, 1, 0.0f);
354 glDisable(GL_TEXTURE_2D);
355 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
356 glPopMatrix(); // Restore The Old Projection Matrix
357 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
358 glPopMatrix(); // Restore The Old Projection Matrix
362 glEnable(GL_TEXTURE_2D);
363 glBindTexture( GL_TEXTURE_2D, loadscreentexture);
364 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
365 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
366 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
367 glDisable(GL_CULL_FACE);
368 glDisable(GL_LIGHTING);
370 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
371 glPushMatrix(); // Store The Projection Matrix
372 glLoadIdentity(); // Reset The Projection Matrix
373 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
374 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
375 glPushMatrix(); // Store The Modelview Matrix
376 glLoadIdentity(); // Reset The Modelview Matrix
377 glTranslatef(screenwidth/2,screenheight/2,0);
378 glScalef((float)screenwidth/2*(100+loadprogress)/100,(float)screenheight/2*(100+loadprogress)/100,1);
379 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
381 glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,.4);
383 //glScalef(.25,.25,.25);
385 glTexCoord2f(0+.2,0+.8);
386 glVertex3f(-1, -1, 0.0f);
387 glTexCoord2f(1+.2,0+.8);
388 glVertex3f(1, -1, 0.0f);
389 glTexCoord2f(1+.2,1+.8);
390 glVertex3f(1, 1, 0.0f);
391 glTexCoord2f(0+.2,1+.8);
392 glVertex3f(-1, 1, 0.0f);
395 glDisable(GL_TEXTURE_2D);
396 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
397 glPopMatrix(); // Restore The Old Projection Matrix
398 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
399 glPopMatrix(); // Restore The Old Projection Matrix
406 if(flashamount>1)flashamount=1;
407 if(flashdelay<=0)flashamount-=multiplier;
409 if(flashamount<0)flashamount=0;
410 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
411 glDisable(GL_CULL_FACE);
412 glDisable(GL_LIGHTING);
413 glDisable(GL_TEXTURE_2D);
415 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
416 glPushMatrix(); // Store The Projection Matrix
417 glLoadIdentity(); // Reset The Projection Matrix
418 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
419 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
420 glPushMatrix(); // Store The Modelview Matrix
421 glLoadIdentity(); // Reset The Modelview Matrix
422 glScalef(screenwidth,screenheight,1);
423 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
425 glColor4f(flashr,flashg,flashb,flashamount);
427 glVertex3f(0, 0, 0.0f);
428 glVertex3f(256, 0, 0.0f);
429 glVertex3f(256, 256, 0.0f);
430 glVertex3f(0, 256, 0.0f);
432 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
433 glPopMatrix(); // Restore The Old Projection Matrix
434 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
435 glPopMatrix(); // Restore The Old Projection Matrix
436 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
437 glEnable(GL_CULL_FACE);
446 void FadeLoadingScreen(float howmuch)
448 static float loadprogress;
452 glClearColor(0,0,0,1);
453 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
455 loadprogress=howmuch;
457 //loadprogress=abs(Random()%100);
461 //glEnable(GL_TEXTURE_2D);
462 glDisable(GL_TEXTURE_2D);
463 //glBindTexture( GL_TEXTURE_2D, loadscreentexture);
464 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
465 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
466 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
467 glDisable(GL_CULL_FACE);
468 glDisable(GL_LIGHTING);
470 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
471 glPushMatrix(); // Store The Projection Matrix
472 glLoadIdentity(); // Reset The Projection Matrix
473 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
474 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
475 glPushMatrix(); // Store The Modelview Matrix
476 glLoadIdentity(); // Reset The Modelview Matrix
477 glTranslatef(screenwidth/2,screenheight/2,0);
478 glScalef((float)screenwidth/2,(float)screenheight/2,1);
479 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
481 glColor4f(loadprogress/100,0,0,1);
483 //glScalef(.25,.25,.25);
486 glVertex3f(-1, -1, 0.0f);
488 glVertex3f(1, -1, 0.0f);
490 glVertex3f(1, 1, 0.0f);
492 glVertex3f(-1, 1, 0.0f);
495 glDisable(GL_TEXTURE_2D);
496 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
497 glPopMatrix(); // Restore The Old Projection Matrix
498 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
499 glPopMatrix(); // Restore The Old Projection Matrix
507 void Game::InitGame()
510 ProcessSerialNumber PSN;
511 ProcessInfoRec pinfo;
514 /* set up process serial number */
515 PSN.highLongOfPSN = 0;
516 PSN.lowLongOfPSN = kCurrentProcess;
517 /* set up info block */
518 pinfo.processInfoLength = sizeof(pinfo);
519 pinfo.processName = NULL;
520 pinfo.processAppSpec = &pspec;
521 /* grab the vrefnum and directory */
522 err = GetProcessInformation(&PSN, &pinfo);
524 vRefNum = pspec.vRefNum;
531 numchallengelevels=14;
533 accountactive=Account::loadFile(":Data:Users");
539 whichjointstartarray[0]=righthip;
540 whichjointendarray[0]=rightfoot;
542 whichjointstartarray[1]=righthip;
543 whichjointendarray[1]=rightankle;
545 whichjointstartarray[2]=righthip;
546 whichjointendarray[2]=rightknee;
548 whichjointstartarray[3]=rightknee;
549 whichjointendarray[3]=rightankle;
551 whichjointstartarray[4]=rightankle;
552 whichjointendarray[4]=rightfoot;
554 whichjointstartarray[5]=lefthip;
555 whichjointendarray[5]=leftfoot;
557 whichjointstartarray[6]=lefthip;
558 whichjointendarray[6]=leftankle;
560 whichjointstartarray[7]=lefthip;
561 whichjointendarray[7]=leftknee;
563 whichjointstartarray[8]=leftknee;
564 whichjointendarray[8]=leftankle;
566 whichjointstartarray[9]=leftankle;
567 whichjointendarray[9]=leftfoot;
569 whichjointstartarray[10]=abdomen;
570 whichjointendarray[10]=rightshoulder;
572 whichjointstartarray[11]=abdomen;
573 whichjointendarray[11]=rightelbow;
575 whichjointstartarray[12]=abdomen;
576 whichjointendarray[12]=rightwrist;
578 whichjointstartarray[13]=abdomen;
579 whichjointendarray[13]=righthand;
581 whichjointstartarray[14]=rightshoulder;
582 whichjointendarray[14]=rightelbow;
584 whichjointstartarray[15]=rightelbow;
585 whichjointendarray[15]=rightwrist;
587 whichjointstartarray[16]=rightwrist;
588 whichjointendarray[16]=righthand;
590 whichjointstartarray[17]=abdomen;
591 whichjointendarray[17]=leftshoulder;
593 whichjointstartarray[18]=abdomen;
594 whichjointendarray[18]=leftelbow;
596 whichjointstartarray[19]=abdomen;
597 whichjointendarray[19]=leftwrist;
599 whichjointstartarray[20]=abdomen;
600 whichjointendarray[20]=lefthand;
602 whichjointstartarray[21]=leftshoulder;
603 whichjointendarray[21]=leftelbow;
605 whichjointstartarray[22]=leftelbow;
606 whichjointendarray[22]=leftwrist;
608 whichjointstartarray[23]=leftwrist;
609 whichjointendarray[23]=lefthand;
611 whichjointstartarray[24]=abdomen;
612 whichjointendarray[24]=neck;
614 whichjointstartarray[25]=neck;
615 whichjointendarray[25]=head;
617 FadeLoadingScreen(0);
621 texture.data = ( GLubyte* )malloc( 1024*1024*4 );
623 int temptexdetail=texdetail;
625 text->LoadFontTexture(":Data:Textures:Font.png");
627 texdetail=temptexdetail;
629 FadeLoadingScreen(10);
641 LOG("Initializing sound system...");
646 extern bool cmdline(const char *cmd);
647 unsigned char rc = 0;
648 output = OPENAL_OUTPUT_ALSA; // Try alsa first...
649 if (cmdline("forceoss")) // ...but let user override that.
650 output = OPENAL_OUTPUT_OSS;
651 else if (cmdline("nosound"))
652 output = OPENAL_OUTPUT_NOSOUND;
654 OPENAL_SetOutput(output);
655 if ((rc = OPENAL_Init(44100, 32, 0)) == false)
657 // if we tried ALSA and failed, fall back to OSS.
658 if ( (output == OPENAL_OUTPUT_ALSA) && (!cmdline("forcealsa")) )
661 output = OPENAL_OUTPUT_OSS;
662 OPENAL_SetOutput(output);
663 rc = OPENAL_Init(44100, 32, 0);
670 output = OPENAL_OUTPUT_NOSOUND; // we tried! just do silence.
671 OPENAL_SetOutput(output);
672 rc = OPENAL_Init(44100, 32, 0);
675 OPENAL_Init(44100, 32, 0);
678 OPENAL_SetSFXMasterVolume((int)(volume*255));
682 emit_stream_np(stream_menutheme);
684 LoadTexture(":Data:Textures:Cursor.png",&cursortexture,0,1);
686 LoadTexture(":Data:Textures:MapCircle.png",&Mapcircletexture,0,1);
687 LoadTexture(":Data:Textures:MapBox.png",&Mapboxtexture,0,1);
688 LoadTexture(":Data:Textures:MapArrow.png",&Maparrowtexture,0,1);
690 temptexdetail=texdetail;
691 if(texdetail>2)texdetail=2;
692 LoadTexture(":Data:Textures:Lugaru.png",&Mainmenuitems[0],0,0);
693 LoadTexture(":Data:Textures:Newgame.png",&Mainmenuitems[1],0,0);
694 LoadTexture(":Data:Textures:Options.png",&Mainmenuitems[2],0,0);
695 LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0);
696 LoadTexture(":Data:Textures:Eyelid.png",&Mainmenuitems[4],0,1);
697 LoadTexture(":Data:Textures:Resume.png",&Mainmenuitems[5],0,0);
698 LoadTexture(":Data:Textures:Endgame.png",&Mainmenuitems[6],0,0);
700 //LoadTexture(":Data:Textures:Eye.jpg",&Mainmenuitems[5],0,1);
701 //~ LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0); // LoadCampaign will take care of that
702 texdetail=temptexdetail;
704 FadeLoadingScreen(95);
714 newscreenwidth=screenwidth;
715 newscreenheight=screenheight;
721 void LoadScreenTexture() {
722 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
724 if(!Game::screentexture)
725 glGenTextures( 1, &Game::screentexture );
726 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
729 glEnable(GL_TEXTURE_2D);
730 glBindTexture( GL_TEXTURE_2D, Game::screentexture);
731 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
732 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
734 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
737 //TODO: move LoadStuff() closer to GameTick.cpp to get rid of various vars shared in Game.h
738 void Game::LoadStuff()
740 static float temptexdetail;
741 static float viewdistdetail;
753 for(i=0;i<maxplayers;i++)
755 glDeleteTextures(1, &player[i].skeleton.drawmodel.textureptr);
756 player[i].skeleton.drawmodel.textureptr=0;;
760 LoadTexture(":Data:Textures:fire.jpg",&loadscreentexture,1,0);
762 temptexdetail=texdetail;
764 text->LoadFontTexture(":Data:Textures:Font.png");
766 texdetail=temptexdetail;
771 viewdistance=50*megascale*viewdistdetail;
783 realtexdetail=texdetail;
788 LOG("Loading weapon data...");
790 LoadTexture(":Data:Textures:knife.png",&Weapon::knifetextureptr,0,1);
791 LoadTexture(":Data:Textures:bloodknife.png",&Weapon::bloodknifetextureptr,0,1);
792 LoadTexture(":Data:Textures:lightbloodknife.png",&Weapon::lightbloodknifetextureptr,0,1);
793 LoadTexture(":Data:Textures:sword.jpg",&Weapon::swordtextureptr,1,0);
794 LoadTexture(":Data:Textures:Swordblood.jpg",&Weapon::bloodswordtextureptr,1,0);
795 LoadTexture(":Data:Textures:Swordbloodlight.jpg",&Weapon::lightbloodswordtextureptr,1,0);
796 LoadTexture(":Data:Textures:Staff.jpg",&Weapon::stafftextureptr,1,0);
798 Weapon::throwingknifemodel.load((char *)":Data:Models:throwingknife.solid",1);
799 Weapon::throwingknifemodel.Scale(.001,.001,.001);
800 //Weapon::throwingknifemodel.Rotate(0,0,-90);
801 Weapon::throwingknifemodel.Rotate(90,0,0);
802 Weapon::throwingknifemodel.Rotate(0,90,0);
803 Weapon::throwingknifemodel.flat=0;
804 Weapon::throwingknifemodel.CalculateNormals(1);
805 //Weapon::throwingknifemodel.ScaleNormals(-1,-1,-1);
807 Weapon::swordmodel.load((char *)":Data:Models:sword.solid",1);
808 Weapon::swordmodel.Scale(.001,.001,.001);
809 //Weapon::swordmodel.Rotate(0,0,-90);
810 Weapon::swordmodel.Rotate(90,0,0);
811 Weapon::swordmodel.Rotate(0,90,0);
812 Weapon::swordmodel.Rotate(0,0,90);
813 Weapon::swordmodel.flat=1;
814 Weapon::swordmodel.CalculateNormals(1);
815 //Weapon::swordmodel.ScaleNormals(-1,-1,-1);
817 Weapon::staffmodel.load((char *)":Data:Models:staff.solid",1);
818 Weapon::staffmodel.Scale(.005,.005,.005);
819 //Weapon::staffmodel.Rotate(0,0,-90);
820 Weapon::staffmodel.Rotate(90,0,0);
821 Weapon::staffmodel.Rotate(0,90,0);
822 Weapon::staffmodel.Rotate(0,0,90);
823 Weapon::staffmodel.flat=1;
824 Weapon::staffmodel.CalculateNormals(1);
825 //Weapon::staffmodel.ScaleNormals(-1,-1,-1);
827 LoadTexture(":Data:Textures:shadow.png",&terrain.shadowtexture,0,1);
829 LoadTexture(":Data:Textures:blood.png",&terrain.bloodtexture,0,1);
831 LoadTexture(":Data:Textures:break.png",&terrain.breaktexture,0,1);
833 LoadTexture(":Data:Textures:blood.png",&terrain.bloodtexture2,0,1);
836 LoadTexture(":Data:Textures:footprint.png",&terrain.footprinttexture,0,1);
838 LoadTexture(":Data:Textures:bodyprint.png",&terrain.bodyprinttexture,0,1);
840 LoadTexture(":Data:Textures:hawk.png",&hawktexture,0,1);
842 LoadTexture(":Data:Textures:logo.png",&logotexture,0,1);
845 LoadTexture(":Data:Textures:cloud.png",&Sprite::cloudtexture,1,1);
846 LoadTexture(":Data:Textures:cloudimpact.png",&Sprite::cloudimpacttexture,1,1);
847 LoadTexture(":Data:Textures:bloodparticle.png",&Sprite::bloodtexture,1,1);
848 LoadTexture(":Data:Textures:snowflake.png",&Sprite::snowflaketexture,1,1);
849 LoadTexture(":Data:Textures:flame.png",&Sprite::flametexture,1,1);
850 LoadTexture(":Data:Textures:bloodflame.png",&Sprite::bloodflametexture,1,1);
851 LoadTexture(":Data:Textures:smoke.png",&Sprite::smoketexture,1,1);
852 LoadTexture(":Data:Textures:shine.png",&Sprite::shinetexture,1,0);
853 LoadTexture(":Data:Textures:splinter.png",&Sprite::splintertexture,1,1);
854 LoadTexture(":Data:Textures:leaf.png",&Sprite::leaftexture,1,1);
855 LoadTexture(":Data:Textures:tooth.png",&Sprite::toothtexture,1,1);
859 ReSizeGLScene(90,.01);
864 if(detail)kTextureSize=1024;
865 if(detail==1)kTextureSize=512;
866 if(detail==0)kTextureSize=256;
868 //Set up distant light
874 light.ambient[2]=.24;
877 light.location.z=-.2;
878 Normalise(&light.location);
888 texscale=.2/megascale/viewdistdetail;
889 terrain.scale=3*megascale*viewdistdetail;
891 viewer.x=terrain.size/2*terrain.scale;
892 viewer.z=terrain.size/2*terrain.scale;
894 hawk.load((char *)":Data:Models:hawk.solid",1);
895 hawk.Scale(.03,.03,.03);
897 hawk.CalculateNormals(0);
898 hawk.ScaleNormals(-1,-1,-1);
899 hawkcoords.x=terrain.size/2*terrain.scale-5-7;
900 hawkcoords.z=terrain.size/2*terrain.scale-5-7;
901 hawkcoords.y=terrain.getHeight(hawkcoords.x,hawkcoords.z)+25;
903 eye.load((char *)":Data:Models:eye.solid",1);
904 eye.Scale(.03,.03,.03);
905 eye.CalculateNormals(0);
907 cornea.load((char *)":Data:Models:cornea.solid",1);
908 cornea.Scale(.03,.03,.03);
909 cornea.CalculateNormals(0);
911 iris.load((char *)":Data:Models:iris.solid",1);
912 iris.Scale(.03,.03,.03);
913 iris.CalculateNormals(0);
915 LoadSave(":Data:Textures:Bloodfur.png",0,1,&bloodText[0],0);
916 LoadSave(":Data:Textures:Wolfbloodfur.png",0,1,&wolfbloodText[0],0);
926 //Fix knife stab, too lazy to do it manually
930 for(i=0;i<player[0].skeleton.num_joints;i++){
931 for(j=0;j<animation[knifesneakattackanim].numframes;j++){
932 animation[knifesneakattackanim].position[i][j]+=moveamount;
938 for(i=0;i<player[0].skeleton.num_joints;i++){
939 for(j=0;j<animation[knifesneakattackedanim].numframes;j++){
940 animation[knifesneakattackedanim].position[i][j]+=moveamount;
946 for(i=0;i<player[0].skeleton.num_joints;i++){
947 animation[dead1anim].position[i][1]=animation[dead1anim].position[i][0];
948 animation[dead2anim].position[i][1]=animation[dead2anim].position[i][0];
949 animation[dead3anim].position[i][1]=animation[dead3anim].position[i][0];
950 animation[dead4anim].position[i][1]=animation[dead4anim].position[i][0];
952 animation[dead1anim].speed[0]=0.001;
953 animation[dead2anim].speed[0]=0.001;
954 animation[dead3anim].speed[0]=0.001;
955 animation[dead4anim].speed[0]=0.001;
957 animation[dead1anim].speed[1]=0.001;
958 animation[dead2anim].speed[1]=0.001;
959 animation[dead3anim].speed[1]=0.001;
960 animation[dead4anim].speed[1]=0.001;
962 for(i=0;i<player[0].skeleton.num_joints;i++){
963 for(j=0;j<animation[swordsneakattackanim].numframes;j++){
964 animation[swordsneakattackanim].position[i][j]+=moveamount;
968 for(j=0;j<animation[swordsneakattackanim].numframes;j++){
969 animation[swordsneakattackanim].weapontarget[j]+=moveamount;
974 for(i=0;i<player[0].skeleton.num_joints;i++){
975 for(j=0;j<animation[swordsneakattackedanim].numframes;j++){
976 animation[swordsneakattackedanim].position[i][j]+=moveamount;
981 temptexdetail=texdetail;
983 texdetail=temptexdetail;
992 emit_sound_at(fireendsound);