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 extern bool cmdline(const char *cmd);
501 void Game::InitGame()
504 ProcessSerialNumber PSN;
505 ProcessInfoRec pinfo;
508 /* set up process serial number */
509 PSN.highLongOfPSN = 0;
510 PSN.lowLongOfPSN = kCurrentProcess;
511 /* set up info block */
512 pinfo.processInfoLength = sizeof(pinfo);
513 pinfo.processName = NULL;
514 pinfo.processAppSpec = &pspec;
515 /* grab the vrefnum and directory */
516 err = GetProcessInformation(&PSN, &pinfo);
518 vRefNum = pspec.vRefNum;
525 numchallengelevels=14;
527 accountactive=Account::loadFile(":Data:Users");
533 whichjointstartarray[0]=righthip;
534 whichjointendarray[0]=rightfoot;
536 whichjointstartarray[1]=righthip;
537 whichjointendarray[1]=rightankle;
539 whichjointstartarray[2]=righthip;
540 whichjointendarray[2]=rightknee;
542 whichjointstartarray[3]=rightknee;
543 whichjointendarray[3]=rightankle;
545 whichjointstartarray[4]=rightankle;
546 whichjointendarray[4]=rightfoot;
548 whichjointstartarray[5]=lefthip;
549 whichjointendarray[5]=leftfoot;
551 whichjointstartarray[6]=lefthip;
552 whichjointendarray[6]=leftankle;
554 whichjointstartarray[7]=lefthip;
555 whichjointendarray[7]=leftknee;
557 whichjointstartarray[8]=leftknee;
558 whichjointendarray[8]=leftankle;
560 whichjointstartarray[9]=leftankle;
561 whichjointendarray[9]=leftfoot;
563 whichjointstartarray[10]=abdomen;
564 whichjointendarray[10]=rightshoulder;
566 whichjointstartarray[11]=abdomen;
567 whichjointendarray[11]=rightelbow;
569 whichjointstartarray[12]=abdomen;
570 whichjointendarray[12]=rightwrist;
572 whichjointstartarray[13]=abdomen;
573 whichjointendarray[13]=righthand;
575 whichjointstartarray[14]=rightshoulder;
576 whichjointendarray[14]=rightelbow;
578 whichjointstartarray[15]=rightelbow;
579 whichjointendarray[15]=rightwrist;
581 whichjointstartarray[16]=rightwrist;
582 whichjointendarray[16]=righthand;
584 whichjointstartarray[17]=abdomen;
585 whichjointendarray[17]=leftshoulder;
587 whichjointstartarray[18]=abdomen;
588 whichjointendarray[18]=leftelbow;
590 whichjointstartarray[19]=abdomen;
591 whichjointendarray[19]=leftwrist;
593 whichjointstartarray[20]=abdomen;
594 whichjointendarray[20]=lefthand;
596 whichjointstartarray[21]=leftshoulder;
597 whichjointendarray[21]=leftelbow;
599 whichjointstartarray[22]=leftelbow;
600 whichjointendarray[22]=leftwrist;
602 whichjointstartarray[23]=leftwrist;
603 whichjointendarray[23]=lefthand;
605 whichjointstartarray[24]=abdomen;
606 whichjointendarray[24]=neck;
608 whichjointstartarray[25]=neck;
609 whichjointendarray[25]=head;
611 FadeLoadingScreen(0);
615 texture.data = ( GLubyte* )malloc( 1024*1024*4 );
617 int temptexdetail=texdetail;
619 text->LoadFontTexture(":Data:Textures:Font.png");
621 texdetail=temptexdetail;
623 FadeLoadingScreen(10);
635 LOG("Initializing sound system...");
640 unsigned char rc = 0;
641 output = OPENAL_OUTPUT_ALSA; // Try alsa first...
642 if (cmdline("forceoss")) // ...but let user override that.
643 output = OPENAL_OUTPUT_OSS;
644 else if (cmdline("nosound"))
645 output = OPENAL_OUTPUT_NOSOUND;
647 OPENAL_SetOutput(output);
648 if ((rc = OPENAL_Init(44100, 32, 0)) == false)
650 // if we tried ALSA and failed, fall back to OSS.
651 if ( (output == OPENAL_OUTPUT_ALSA) && (!cmdline("forcealsa")) )
654 output = OPENAL_OUTPUT_OSS;
655 OPENAL_SetOutput(output);
656 rc = OPENAL_Init(44100, 32, 0);
663 output = OPENAL_OUTPUT_NOSOUND; // we tried! just do silence.
664 OPENAL_SetOutput(output);
665 rc = OPENAL_Init(44100, 32, 0);
668 OPENAL_Init(44100, 32, 0);
671 OPENAL_SetSFXMasterVolume((int)(volume*255));
675 emit_stream_np(stream_menutheme);
677 cursortexture.load(":Data:Textures:Cursor.png",0,1);
679 Mapcircletexture.load(":Data:Textures:MapCircle.png",0,1);
680 Mapboxtexture.load(":Data:Textures:MapBox.png",0,1);
681 Maparrowtexture.load(":Data:Textures:MapArrow.png",0,1);
683 temptexdetail=texdetail;
684 if(texdetail>2)texdetail=2;
685 Mainmenuitems[0].load(":Data:Textures:Lugaru.png",0,0);
686 Mainmenuitems[1].load(":Data:Textures:Newgame.png",0,0);
687 Mainmenuitems[2].load(":Data:Textures:Options.png",0,0);
688 Mainmenuitems[3].load(":Data:Textures:Quit.png",0,0);
689 Mainmenuitems[4].load(":Data:Textures:Eyelid.png",0,1);
690 Mainmenuitems[5].load(":Data:Textures:Resume.png",0,0);
691 Mainmenuitems[6].load(":Data:Textures:Endgame.png",0,0);
693 //LoadTexture(":Data:Textures:Eye.jpg",&Mainmenuitems[5],0,1);
694 //~ LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0); // LoadCampaign will take care of that
695 texdetail=temptexdetail;
697 FadeLoadingScreen(95);
707 newscreenwidth=screenwidth;
708 newscreenheight=screenheight;
714 void Game::LoadScreenTexture() {
715 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
717 if(!Game::screentexture)
718 glGenTextures( 1, &Game::screentexture );
719 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
722 glEnable(GL_TEXTURE_2D);
723 glBindTexture( GL_TEXTURE_2D, Game::screentexture);
724 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
725 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
727 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
730 //TODO: move LoadStuff() closer to GameTick.cpp to get rid of various vars shared in Game.h
731 void Game::LoadStuff()
733 static float temptexdetail;
734 static float viewdistdetail;
744 for(i=0;i<maxplayers;i++)
745 player[i].skeleton.drawmodel.textureptr.destroy();
748 visibleloading=0; //don't use loadscreentexture yet
749 loadscreentexture.load(":Data:Textures:fire.jpg",1,0);
752 temptexdetail=texdetail;
754 text->LoadFontTexture(":Data:Textures:Font.png");
756 texdetail=temptexdetail;
761 viewdistance=50*megascale*viewdistdetail;
773 realtexdetail=texdetail;
778 LOG("Loading weapon data...");
780 Weapon::knifetextureptr.load(":Data:Textures:knife.png",0,1);
781 Weapon::bloodknifetextureptr.load(":Data:Textures:bloodknife.png",0,1);
782 Weapon::lightbloodknifetextureptr.load(":Data:Textures:lightbloodknife.png",0,1);
783 Weapon::swordtextureptr.load(":Data:Textures:sword.jpg",1,0);
784 Weapon::bloodswordtextureptr.load(":Data:Textures:Swordblood.jpg",1,0);
785 Weapon::lightbloodswordtextureptr.load(":Data:Textures:Swordbloodlight.jpg",1,0);
786 Weapon::stafftextureptr.load(":Data:Textures:Staff.jpg",1,0);
788 Weapon::throwingknifemodel.load((char *)":Data:Models:throwingknife.solid",1);
789 Weapon::throwingknifemodel.Scale(.001,.001,.001);
790 //Weapon::throwingknifemodel.Rotate(0,0,-90);
791 Weapon::throwingknifemodel.Rotate(90,0,0);
792 Weapon::throwingknifemodel.Rotate(0,90,0);
793 Weapon::throwingknifemodel.flat=0;
794 Weapon::throwingknifemodel.CalculateNormals(1);
795 //Weapon::throwingknifemodel.ScaleNormals(-1,-1,-1);
797 Weapon::swordmodel.load((char *)":Data:Models:sword.solid",1);
798 Weapon::swordmodel.Scale(.001,.001,.001);
799 //Weapon::swordmodel.Rotate(0,0,-90);
800 Weapon::swordmodel.Rotate(90,0,0);
801 Weapon::swordmodel.Rotate(0,90,0);
802 Weapon::swordmodel.Rotate(0,0,90);
803 Weapon::swordmodel.flat=1;
804 Weapon::swordmodel.CalculateNormals(1);
805 //Weapon::swordmodel.ScaleNormals(-1,-1,-1);
807 Weapon::staffmodel.load((char *)":Data:Models:staff.solid",1);
808 Weapon::staffmodel.Scale(.005,.005,.005);
809 //Weapon::staffmodel.Rotate(0,0,-90);
810 Weapon::staffmodel.Rotate(90,0,0);
811 Weapon::staffmodel.Rotate(0,90,0);
812 Weapon::staffmodel.Rotate(0,0,90);
813 Weapon::staffmodel.flat=1;
814 Weapon::staffmodel.CalculateNormals(1);
815 //Weapon::staffmodel.ScaleNormals(-1,-1,-1);
817 terrain.shadowtexture.load(":Data:Textures:shadow.png",0,1);
818 terrain.bloodtexture.load(":Data:Textures:blood.png",0,1);
819 terrain.breaktexture.load(":Data:Textures:break.png",0,1);
820 terrain.bloodtexture2.load(":Data:Textures:blood.png",0,1);
823 terrain.footprinttexture.load(":Data:Textures:footprint.png",0,1);
824 terrain.bodyprinttexture.load(":Data:Textures:bodyprint.png",0,1);
825 hawktexture.load(":Data:Textures:hawk.png",0,1);
828 Sprite::cloudtexture.load(":Data:Textures:cloud.png",1,1);
829 Sprite::cloudimpacttexture.load(":Data:Textures:cloudimpact.png",1,1);
830 Sprite::bloodtexture.load(":Data:Textures:bloodparticle.png",1,1);
831 Sprite::snowflaketexture.load(":Data:Textures:snowflake.png",1,1);
832 Sprite::flametexture.load(":Data:Textures:flame.png",1,1);
833 Sprite::bloodflametexture.load(":Data:Textures:bloodflame.png",1,1);
834 Sprite::smoketexture.load(":Data:Textures:smoke.png",1,1);
835 Sprite::shinetexture.load(":Data:Textures:shine.png",1,0);
836 Sprite::splintertexture.load(":Data:Textures:splinter.png",1,1);
837 Sprite::leaftexture.load(":Data:Textures:leaf.png",1,1);
838 Sprite::toothtexture.load(":Data:Textures:tooth.png",1,1);
842 ReSizeGLScene(90,.01);
847 if(detail)kTextureSize=1024;
848 if(detail==1)kTextureSize=512;
849 if(detail==0)kTextureSize=256;
851 //Set up distant light
857 light.ambient[2]=.24;
860 light.location.z=-.2;
861 Normalise(&light.location);
871 texscale=.2/megascale/viewdistdetail;
872 terrain.scale=3*megascale*viewdistdetail;
874 viewer.x=terrain.size/2*terrain.scale;
875 viewer.z=terrain.size/2*terrain.scale;
877 hawk.load((char *)":Data:Models:hawk.solid",1);
878 hawk.Scale(.03,.03,.03);
880 hawk.CalculateNormals(0);
881 hawk.ScaleNormals(-1,-1,-1);
882 hawkcoords.x=terrain.size/2*terrain.scale-5-7;
883 hawkcoords.z=terrain.size/2*terrain.scale-5-7;
884 hawkcoords.y=terrain.getHeight(hawkcoords.x,hawkcoords.z)+25;
886 eye.load((char *)":Data:Models:eye.solid",1);
887 eye.Scale(.03,.03,.03);
888 eye.CalculateNormals(0);
890 cornea.load((char *)":Data:Models:cornea.solid",1);
891 cornea.Scale(.03,.03,.03);
892 cornea.CalculateNormals(0);
894 iris.load((char *)":Data:Models:iris.solid",1);
895 iris.Scale(.03,.03,.03);
896 iris.CalculateNormals(0);
898 LoadSave(":Data:Textures:Bloodfur.png",0,1,&bloodText[0],0);
899 LoadSave(":Data:Textures:Wolfbloodfur.png",0,1,&wolfbloodText[0],0);
909 //Fix knife stab, too lazy to do it manually
913 for(i=0;i<player[0].skeleton.num_joints;i++){
914 for(j=0;j<animation[knifesneakattackanim].numframes;j++){
915 animation[knifesneakattackanim].position[i][j]+=moveamount;
921 for(i=0;i<player[0].skeleton.num_joints;i++){
922 for(j=0;j<animation[knifesneakattackedanim].numframes;j++){
923 animation[knifesneakattackedanim].position[i][j]+=moveamount;
929 for(i=0;i<player[0].skeleton.num_joints;i++){
930 animation[dead1anim].position[i][1]=animation[dead1anim].position[i][0];
931 animation[dead2anim].position[i][1]=animation[dead2anim].position[i][0];
932 animation[dead3anim].position[i][1]=animation[dead3anim].position[i][0];
933 animation[dead4anim].position[i][1]=animation[dead4anim].position[i][0];
935 animation[dead1anim].speed[0]=0.001;
936 animation[dead2anim].speed[0]=0.001;
937 animation[dead3anim].speed[0]=0.001;
938 animation[dead4anim].speed[0]=0.001;
940 animation[dead1anim].speed[1]=0.001;
941 animation[dead2anim].speed[1]=0.001;
942 animation[dead3anim].speed[1]=0.001;
943 animation[dead4anim].speed[1]=0.001;
945 for(i=0;i<player[0].skeleton.num_joints;i++){
946 for(j=0;j<animation[swordsneakattackanim].numframes;j++){
947 animation[swordsneakattackanim].position[i][j]+=moveamount;
951 for(j=0;j<animation[swordsneakattackanim].numframes;j++){
952 animation[swordsneakattackanim].weapontarget[j]+=moveamount;
957 for(i=0;i<player[0].skeleton.num_joints;i++){
958 for(j=0;j<animation[swordsneakattackedanim].numframes;j++){
959 animation[swordsneakattackedanim].position[i][j]+=moveamount;
964 temptexdetail=texdetail;
966 texdetail=temptexdetail;
975 emit_sound_at(fireendsound);