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(){
141 if(skybox) delete skybox;
142 if(text) delete text;
143 terraintexture.destroy();
144 terraintexture2.destroy();
145 cursortexture.destroy();
146 Maparrowtexture.destroy();
147 Mapboxtexture.destroy();
148 Mapcircletexture.destroy();
149 hawktexture.destroy();
150 loadscreentexture.destroy();
152 for(int i=0;i<10;i++)
153 Mainmenuitems[i].destroy();
155 glDeleteTextures(1,&screentexture);
156 glDeleteTextures(1,&screentexture2);
163 void LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize)
170 LOG(std::string("Loading (S)...") + fileName);
173 float temptexdetail=texdetail;
175 //upload_image( fileName );
176 //LoadTGA( fileName );
178 // Converting file to something os specific
179 char * fixedFN = ConvertFileName(fileName);
182 unsigned char fileNamep[256];
183 CopyCStringToPascal(fixedFN, fileNamep);
185 upload_image( fileNamep ,0);
186 texdetail=temptexdetail;
190 bytesPerPixel=texture.bpp/8;
193 for(i=0;i<(int)(texture.sizeY*texture.sizeX*bytesPerPixel);i++){
194 if((i+1)%4||bytesPerPixel==3){
195 array[tempnum]=texture.data[i];
204 //***************> ResizeGLScene() <******/
205 GLvoid Game::ReSizeGLScene(float fov, float pnear)
212 glViewport(0,0,screenwidth,screenheight);
214 glMatrixMode(GL_PROJECTION);
217 gluPerspective(fov,(GLfloat)screenwidth/(GLfloat)screenheight,pnear,viewdistance);
219 glMatrixMode(GL_MODELVIEW);
223 void Game::LoadingScreen()
225 static float loadprogress;
226 static AbsoluteTime time = {0,0};
227 static AbsoluteTime frametime = {0,0};
228 AbsoluteTime currTime = UpTime ();
229 double deltaTime = (float) AbsoluteDeltaToDuration (currTime, frametime);
231 if (0 > deltaTime) // if negative microseconds
232 deltaTime /= -1000000.0;
233 else // else milliseconds
236 multiplier=deltaTime;
237 if(multiplier<.001)multiplier=.001;
238 if(multiplier>10)multiplier=10;
240 frametime = currTime; // reset for next time interval
244 glClearColor(0,0,0,1);
245 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
248 loadtime+=multiplier*4;
250 loadprogress=loadtime;
251 if(loadprogress>100)loadprogress=100;
253 //loadprogress=abs(Random()%100);
257 glEnable(GL_TEXTURE_2D);
258 loadscreentexture.bind();
259 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
260 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
261 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
262 glDisable(GL_CULL_FACE);
263 glDisable(GL_LIGHTING);
265 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
266 glPushMatrix(); // Store The Projection Matrix
267 glLoadIdentity(); // Reset The Projection Matrix
268 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
269 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
270 glPushMatrix(); // Store The Modelview Matrix
271 glLoadIdentity(); // Reset The Modelview Matrix
272 glTranslatef(screenwidth/2,screenheight/2,0);
273 glScalef((float)screenwidth/2,(float)screenheight/2,1);
274 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
276 glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
278 //glScalef(.25,.25,.25);
280 glTexCoord2f(.1-loadprogress/100,0+loadprogress/100+.3);
281 glVertex3f(-1, -1, 0.0f);
282 glTexCoord2f(.1-loadprogress/100,0+loadprogress/100+.3);
283 glVertex3f(1, -1, 0.0f);
284 glTexCoord2f(.1-loadprogress/100,1+loadprogress/100+.3);
285 glVertex3f(1, 1, 0.0f);
286 glTexCoord2f(.1-loadprogress/100,1+loadprogress/100+.3);
287 glVertex3f(-1, 1, 0.0f);
292 //glScalef(.25,.25,.25);
294 glTexCoord2f(.4+loadprogress/100,0+loadprogress/100);
295 glVertex3f(-1, -1, 0.0f);
296 glTexCoord2f(.4+loadprogress/100,0+loadprogress/100);
297 glVertex3f(1, -1, 0.0f);
298 glTexCoord2f(.4+loadprogress/100,1+loadprogress/100);
299 glVertex3f(1, 1, 0.0f);
300 glTexCoord2f(.4+loadprogress/100,1+loadprogress/100);
301 glVertex3f(-1, 1, 0.0f);
304 glDisable(GL_TEXTURE_2D);
305 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
306 glPopMatrix(); // Restore The Old Projection Matrix
307 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
308 glPopMatrix(); // Restore The Old Projection Matrix
312 glEnable(GL_TEXTURE_2D);
313 loadscreentexture.bind();
314 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
315 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
316 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
317 glDisable(GL_CULL_FACE);
318 glDisable(GL_LIGHTING);
320 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
321 glPushMatrix(); // Store The Projection Matrix
322 glLoadIdentity(); // Reset The Projection Matrix
323 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
324 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
325 glPushMatrix(); // Store The Modelview Matrix
326 glLoadIdentity(); // Reset The Modelview Matrix
327 glTranslatef(screenwidth/2,screenheight/2,0);
328 glScalef((float)screenwidth/2*(1.5-(loadprogress)/200),(float)screenheight/2*(1.5-(loadprogress)/200),1);
329 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
331 //glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
332 glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
334 //glScalef(.25,.25,.25);
336 glTexCoord2f(0+.5,0+.5);
337 glVertex3f(-1, -1, 0.0f);
338 glTexCoord2f(1+.5,0+.5);
339 glVertex3f(1, -1, 0.0f);
340 glTexCoord2f(1+.5,1+.5);
341 glVertex3f(1, 1, 0.0f);
342 glTexCoord2f(0+.5,1+.5);
343 glVertex3f(-1, 1, 0.0f);
346 glDisable(GL_TEXTURE_2D);
347 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
348 glPopMatrix(); // Restore The Old Projection Matrix
349 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
350 glPopMatrix(); // Restore The Old Projection Matrix
354 glEnable(GL_TEXTURE_2D);
355 loadscreentexture.bind();
356 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
357 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
358 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
359 glDisable(GL_CULL_FACE);
360 glDisable(GL_LIGHTING);
362 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
363 glPushMatrix(); // Store The Projection Matrix
364 glLoadIdentity(); // Reset The Projection Matrix
365 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
366 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
367 glPushMatrix(); // Store The Modelview Matrix
368 glLoadIdentity(); // Reset The Modelview Matrix
369 glTranslatef(screenwidth/2,screenheight/2,0);
370 glScalef((float)screenwidth/2*(100+loadprogress)/100,(float)screenheight/2*(100+loadprogress)/100,1);
371 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
373 glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,.4);
375 //glScalef(.25,.25,.25);
377 glTexCoord2f(0+.2,0+.8);
378 glVertex3f(-1, -1, 0.0f);
379 glTexCoord2f(1+.2,0+.8);
380 glVertex3f(1, -1, 0.0f);
381 glTexCoord2f(1+.2,1+.8);
382 glVertex3f(1, 1, 0.0f);
383 glTexCoord2f(0+.2,1+.8);
384 glVertex3f(-1, 1, 0.0f);
387 glDisable(GL_TEXTURE_2D);
388 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
389 glPopMatrix(); // Restore The Old Projection Matrix
390 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
391 glPopMatrix(); // Restore The Old Projection Matrix
398 if(flashamount>1)flashamount=1;
399 if(flashdelay<=0)flashamount-=multiplier;
401 if(flashamount<0)flashamount=0;
402 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
403 glDisable(GL_CULL_FACE);
404 glDisable(GL_LIGHTING);
405 glDisable(GL_TEXTURE_2D);
407 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
408 glPushMatrix(); // Store The Projection Matrix
409 glLoadIdentity(); // Reset The Projection Matrix
410 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
411 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
412 glPushMatrix(); // Store The Modelview Matrix
413 glLoadIdentity(); // Reset The Modelview Matrix
414 glScalef(screenwidth,screenheight,1);
415 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
417 glColor4f(flashr,flashg,flashb,flashamount);
419 glVertex3f(0, 0, 0.0f);
420 glVertex3f(256, 0, 0.0f);
421 glVertex3f(256, 256, 0.0f);
422 glVertex3f(0, 256, 0.0f);
424 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
425 glPopMatrix(); // Restore The Old Projection Matrix
426 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
427 glPopMatrix(); // Restore The Old Projection Matrix
428 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
429 glEnable(GL_CULL_FACE);
438 void FadeLoadingScreen(float howmuch)
440 static float loadprogress;
444 glClearColor(0,0,0,1);
445 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
447 loadprogress=howmuch;
449 //loadprogress=abs(Random()%100);
453 //glEnable(GL_TEXTURE_2D);
454 glDisable(GL_TEXTURE_2D);
455 //glBindTexture( GL_TEXTURE_2D, loadscreentexture);
456 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
457 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
458 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
459 glDisable(GL_CULL_FACE);
460 glDisable(GL_LIGHTING);
462 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
463 glPushMatrix(); // Store The Projection Matrix
464 glLoadIdentity(); // Reset The Projection Matrix
465 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
466 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
467 glPushMatrix(); // Store The Modelview Matrix
468 glLoadIdentity(); // Reset The Modelview Matrix
469 glTranslatef(screenwidth/2,screenheight/2,0);
470 glScalef((float)screenwidth/2,(float)screenheight/2,1);
471 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
473 glColor4f(loadprogress/100,0,0,1);
475 //glScalef(.25,.25,.25);
478 glVertex3f(-1, -1, 0.0f);
480 glVertex3f(1, -1, 0.0f);
482 glVertex3f(1, 1, 0.0f);
484 glVertex3f(-1, 1, 0.0f);
487 glDisable(GL_TEXTURE_2D);
488 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
489 glPopMatrix(); // Restore The Old Projection Matrix
490 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
491 glPopMatrix(); // Restore The Old Projection Matrix
499 void Game::InitGame()
502 ProcessSerialNumber PSN;
503 ProcessInfoRec pinfo;
506 /* set up process serial number */
507 PSN.highLongOfPSN = 0;
508 PSN.lowLongOfPSN = kCurrentProcess;
509 /* set up info block */
510 pinfo.processInfoLength = sizeof(pinfo);
511 pinfo.processName = NULL;
512 pinfo.processAppSpec = &pspec;
513 /* grab the vrefnum and directory */
514 err = GetProcessInformation(&PSN, &pinfo);
516 vRefNum = pspec.vRefNum;
523 numchallengelevels=14;
525 accountactive=Account::loadFile(":Data:Users");
531 whichjointstartarray[0]=righthip;
532 whichjointendarray[0]=rightfoot;
534 whichjointstartarray[1]=righthip;
535 whichjointendarray[1]=rightankle;
537 whichjointstartarray[2]=righthip;
538 whichjointendarray[2]=rightknee;
540 whichjointstartarray[3]=rightknee;
541 whichjointendarray[3]=rightankle;
543 whichjointstartarray[4]=rightankle;
544 whichjointendarray[4]=rightfoot;
546 whichjointstartarray[5]=lefthip;
547 whichjointendarray[5]=leftfoot;
549 whichjointstartarray[6]=lefthip;
550 whichjointendarray[6]=leftankle;
552 whichjointstartarray[7]=lefthip;
553 whichjointendarray[7]=leftknee;
555 whichjointstartarray[8]=leftknee;
556 whichjointendarray[8]=leftankle;
558 whichjointstartarray[9]=leftankle;
559 whichjointendarray[9]=leftfoot;
561 whichjointstartarray[10]=abdomen;
562 whichjointendarray[10]=rightshoulder;
564 whichjointstartarray[11]=abdomen;
565 whichjointendarray[11]=rightelbow;
567 whichjointstartarray[12]=abdomen;
568 whichjointendarray[12]=rightwrist;
570 whichjointstartarray[13]=abdomen;
571 whichjointendarray[13]=righthand;
573 whichjointstartarray[14]=rightshoulder;
574 whichjointendarray[14]=rightelbow;
576 whichjointstartarray[15]=rightelbow;
577 whichjointendarray[15]=rightwrist;
579 whichjointstartarray[16]=rightwrist;
580 whichjointendarray[16]=righthand;
582 whichjointstartarray[17]=abdomen;
583 whichjointendarray[17]=leftshoulder;
585 whichjointstartarray[18]=abdomen;
586 whichjointendarray[18]=leftelbow;
588 whichjointstartarray[19]=abdomen;
589 whichjointendarray[19]=leftwrist;
591 whichjointstartarray[20]=abdomen;
592 whichjointendarray[20]=lefthand;
594 whichjointstartarray[21]=leftshoulder;
595 whichjointendarray[21]=leftelbow;
597 whichjointstartarray[22]=leftelbow;
598 whichjointendarray[22]=leftwrist;
600 whichjointstartarray[23]=leftwrist;
601 whichjointendarray[23]=lefthand;
603 whichjointstartarray[24]=abdomen;
604 whichjointendarray[24]=neck;
606 whichjointstartarray[25]=neck;
607 whichjointendarray[25]=head;
609 FadeLoadingScreen(0);
613 texture.data = ( GLubyte* )malloc( 1024*1024*4 );
615 int temptexdetail=texdetail;
617 text->LoadFontTexture(":Data:Textures:Font.png");
619 texdetail=temptexdetail;
621 FadeLoadingScreen(10);
633 LOG("Initializing sound system...");
638 extern bool cmdline(const char *cmd);
639 unsigned char rc = 0;
640 output = OPENAL_OUTPUT_ALSA; // Try alsa first...
641 if (cmdline("forceoss")) // ...but let user override that.
642 output = OPENAL_OUTPUT_OSS;
643 else if (cmdline("nosound"))
644 output = OPENAL_OUTPUT_NOSOUND;
646 OPENAL_SetOutput(output);
647 if ((rc = OPENAL_Init(44100, 32, 0)) == false)
649 // if we tried ALSA and failed, fall back to OSS.
650 if ( (output == OPENAL_OUTPUT_ALSA) && (!cmdline("forcealsa")) )
653 output = OPENAL_OUTPUT_OSS;
654 OPENAL_SetOutput(output);
655 rc = OPENAL_Init(44100, 32, 0);
662 output = OPENAL_OUTPUT_NOSOUND; // we tried! just do silence.
663 OPENAL_SetOutput(output);
664 rc = OPENAL_Init(44100, 32, 0);
667 OPENAL_Init(44100, 32, 0);
670 OPENAL_SetSFXMasterVolume((int)(volume*255));
674 emit_stream_np(stream_menutheme);
676 cursortexture.load(":Data:Textures:Cursor.png",0,1);
678 Mapcircletexture.load(":Data:Textures:MapCircle.png",0,1);
679 Mapboxtexture.load(":Data:Textures:MapBox.png",0,1);
680 Maparrowtexture.load(":Data:Textures:MapArrow.png",0,1);
682 temptexdetail=texdetail;
683 if(texdetail>2)texdetail=2;
684 Mainmenuitems[0].load(":Data:Textures:Lugaru.png",0,0);
685 Mainmenuitems[1].load(":Data:Textures:Newgame.png",0,0);
686 Mainmenuitems[2].load(":Data:Textures:Options.png",0,0);
687 Mainmenuitems[3].load(":Data:Textures:Quit.png",0,0);
688 Mainmenuitems[4].load(":Data:Textures:Eyelid.png",0,1);
689 Mainmenuitems[5].load(":Data:Textures:Resume.png",0,0);
690 Mainmenuitems[6].load(":Data:Textures:Endgame.png",0,0);
692 //LoadTexture(":Data:Textures:Eye.jpg",&Mainmenuitems[5],0,1);
693 //~ LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0); // LoadCampaign will take care of that
694 texdetail=temptexdetail;
696 FadeLoadingScreen(95);
706 newscreenwidth=screenwidth;
707 newscreenheight=screenheight;
713 void Game::LoadScreenTexture() {
714 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
716 if(!Game::screentexture)
717 glGenTextures( 1, &Game::screentexture );
718 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
721 glEnable(GL_TEXTURE_2D);
722 glBindTexture( GL_TEXTURE_2D, Game::screentexture);
723 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
724 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
726 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
729 //TODO: move LoadStuff() closer to GameTick.cpp to get rid of various vars shared in Game.h
730 void Game::LoadStuff()
732 static float temptexdetail;
733 static float viewdistdetail;
743 for(i=0;i<maxplayers;i++)
744 player[i].skeleton.drawmodel.textureptr.destroy();
747 visibleloading=0; //don't use loadscreentexture yet
748 loadscreentexture.load(":Data:Textures:fire.jpg",1,0);
751 temptexdetail=texdetail;
753 text->LoadFontTexture(":Data:Textures:Font.png");
755 texdetail=temptexdetail;
760 viewdistance=50*megascale*viewdistdetail;
772 realtexdetail=texdetail;
777 LOG("Loading weapon data...");
779 Weapon::knifetextureptr.load(":Data:Textures:knife.png",0,1);
780 Weapon::bloodknifetextureptr.load(":Data:Textures:bloodknife.png",0,1);
781 Weapon::lightbloodknifetextureptr.load(":Data:Textures:lightbloodknife.png",0,1);
782 Weapon::swordtextureptr.load(":Data:Textures:sword.jpg",1,0);
783 Weapon::bloodswordtextureptr.load(":Data:Textures:Swordblood.jpg",1,0);
784 Weapon::lightbloodswordtextureptr.load(":Data:Textures:Swordbloodlight.jpg",1,0);
785 Weapon::stafftextureptr.load(":Data:Textures:Staff.jpg",1,0);
787 Weapon::throwingknifemodel.load((char *)":Data:Models:throwingknife.solid",1);
788 Weapon::throwingknifemodel.Scale(.001,.001,.001);
789 //Weapon::throwingknifemodel.Rotate(0,0,-90);
790 Weapon::throwingknifemodel.Rotate(90,0,0);
791 Weapon::throwingknifemodel.Rotate(0,90,0);
792 Weapon::throwingknifemodel.flat=0;
793 Weapon::throwingknifemodel.CalculateNormals(1);
794 //Weapon::throwingknifemodel.ScaleNormals(-1,-1,-1);
796 Weapon::swordmodel.load((char *)":Data:Models:sword.solid",1);
797 Weapon::swordmodel.Scale(.001,.001,.001);
798 //Weapon::swordmodel.Rotate(0,0,-90);
799 Weapon::swordmodel.Rotate(90,0,0);
800 Weapon::swordmodel.Rotate(0,90,0);
801 Weapon::swordmodel.Rotate(0,0,90);
802 Weapon::swordmodel.flat=1;
803 Weapon::swordmodel.CalculateNormals(1);
804 //Weapon::swordmodel.ScaleNormals(-1,-1,-1);
806 Weapon::staffmodel.load((char *)":Data:Models:staff.solid",1);
807 Weapon::staffmodel.Scale(.005,.005,.005);
808 //Weapon::staffmodel.Rotate(0,0,-90);
809 Weapon::staffmodel.Rotate(90,0,0);
810 Weapon::staffmodel.Rotate(0,90,0);
811 Weapon::staffmodel.Rotate(0,0,90);
812 Weapon::staffmodel.flat=1;
813 Weapon::staffmodel.CalculateNormals(1);
814 //Weapon::staffmodel.ScaleNormals(-1,-1,-1);
816 terrain.shadowtexture.load(":Data:Textures:shadow.png",0,1);
817 terrain.bloodtexture.load(":Data:Textures:blood.png",0,1);
818 terrain.breaktexture.load(":Data:Textures:break.png",0,1);
819 terrain.bloodtexture2.load(":Data:Textures:blood.png",0,1);
822 terrain.footprinttexture.load(":Data:Textures:footprint.png",0,1);
823 terrain.bodyprinttexture.load(":Data:Textures:bodyprint.png",0,1);
824 hawktexture.load(":Data:Textures:hawk.png",0,1);
827 Sprite::cloudtexture.load(":Data:Textures:cloud.png",1,1);
828 Sprite::cloudimpacttexture.load(":Data:Textures:cloudimpact.png",1,1);
829 Sprite::bloodtexture.load(":Data:Textures:bloodparticle.png",1,1);
830 Sprite::snowflaketexture.load(":Data:Textures:snowflake.png",1,1);
831 Sprite::flametexture.load(":Data:Textures:flame.png",1,1);
832 Sprite::bloodflametexture.load(":Data:Textures:bloodflame.png",1,1);
833 Sprite::smoketexture.load(":Data:Textures:smoke.png",1,1);
834 Sprite::shinetexture.load(":Data:Textures:shine.png",1,0);
835 Sprite::splintertexture.load(":Data:Textures:splinter.png",1,1);
836 Sprite::leaftexture.load(":Data:Textures:leaf.png",1,1);
837 Sprite::toothtexture.load(":Data:Textures:tooth.png",1,1);
841 ReSizeGLScene(90,.01);
846 if(detail)kTextureSize=1024;
847 if(detail==1)kTextureSize=512;
848 if(detail==0)kTextureSize=256;
850 //Set up distant light
856 light.ambient[2]=.24;
859 light.location.z=-.2;
860 Normalise(&light.location);
870 texscale=.2/megascale/viewdistdetail;
871 terrain.scale=3*megascale*viewdistdetail;
873 viewer.x=terrain.size/2*terrain.scale;
874 viewer.z=terrain.size/2*terrain.scale;
876 hawk.load((char *)":Data:Models:hawk.solid",1);
877 hawk.Scale(.03,.03,.03);
879 hawk.CalculateNormals(0);
880 hawk.ScaleNormals(-1,-1,-1);
881 hawkcoords.x=terrain.size/2*terrain.scale-5-7;
882 hawkcoords.z=terrain.size/2*terrain.scale-5-7;
883 hawkcoords.y=terrain.getHeight(hawkcoords.x,hawkcoords.z)+25;
885 eye.load((char *)":Data:Models:eye.solid",1);
886 eye.Scale(.03,.03,.03);
887 eye.CalculateNormals(0);
889 cornea.load((char *)":Data:Models:cornea.solid",1);
890 cornea.Scale(.03,.03,.03);
891 cornea.CalculateNormals(0);
893 iris.load((char *)":Data:Models:iris.solid",1);
894 iris.Scale(.03,.03,.03);
895 iris.CalculateNormals(0);
897 LoadSave(":Data:Textures:Bloodfur.png",0,1,&bloodText[0],0);
898 LoadSave(":Data:Textures:Wolfbloodfur.png",0,1,&wolfbloodText[0],0);
908 //Fix knife stab, too lazy to do it manually
912 for(i=0;i<player[0].skeleton.num_joints;i++){
913 for(j=0;j<animation[knifesneakattackanim].numframes;j++){
914 animation[knifesneakattackanim].position[i][j]+=moveamount;
920 for(i=0;i<player[0].skeleton.num_joints;i++){
921 for(j=0;j<animation[knifesneakattackedanim].numframes;j++){
922 animation[knifesneakattackedanim].position[i][j]+=moveamount;
928 for(i=0;i<player[0].skeleton.num_joints;i++){
929 animation[dead1anim].position[i][1]=animation[dead1anim].position[i][0];
930 animation[dead2anim].position[i][1]=animation[dead2anim].position[i][0];
931 animation[dead3anim].position[i][1]=animation[dead3anim].position[i][0];
932 animation[dead4anim].position[i][1]=animation[dead4anim].position[i][0];
934 animation[dead1anim].speed[0]=0.001;
935 animation[dead2anim].speed[0]=0.001;
936 animation[dead3anim].speed[0]=0.001;
937 animation[dead4anim].speed[0]=0.001;
939 animation[dead1anim].speed[1]=0.001;
940 animation[dead2anim].speed[1]=0.001;
941 animation[dead3anim].speed[1]=0.001;
942 animation[dead4anim].speed[1]=0.001;
944 for(i=0;i<player[0].skeleton.num_joints;i++){
945 for(j=0;j<animation[swordsneakattackanim].numframes;j++){
946 animation[swordsneakattackanim].position[i][j]+=moveamount;
950 for(j=0;j<animation[swordsneakattackanim].numframes;j++){
951 animation[swordsneakattackanim].weapontarget[j]+=moveamount;
956 for(i=0;i<player[0].skeleton.num_joints;i++){
957 for(j=0;j<animation[swordsneakattackedanim].numframes;j++){
958 animation[swordsneakattackedanim].position[i][j]+=moveamount;
963 temptexdetail=texdetail;
965 texdetail=temptexdetail;
974 emit_sound_at(fireendsound);