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) {
122 OPENAL_Sample_Free(samp[i]);
136 skybox = new SkyBox();
139 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)
207 if (screenheight == 0) {
211 glViewport(0, 0, screenwidth, screenheight);
213 glMatrixMode(GL_PROJECTION);
216 gluPerspective(fov, (GLfloat)screenwidth / (GLfloat)screenheight, pnear, viewdistance);
218 glMatrixMode(GL_MODELVIEW);
222 void Game::LoadingScreen()
224 static float loadprogress;
225 static AbsoluteTime time = {0, 0};
226 static AbsoluteTime frametime = {0, 0};
227 AbsoluteTime currTime = UpTime ();
228 double deltaTime = (float) AbsoluteDeltaToDuration (currTime, frametime);
230 if (0 > deltaTime) // if negative microseconds
231 deltaTime /= -1000000.0;
232 else // else milliseconds
235 multiplier = deltaTime;
236 if (multiplier < .001)multiplier = .001;
237 if (multiplier > 10)multiplier = 10;
238 if (multiplier > .05) {
239 frametime = currTime; // reset for next time interval
243 glClearColor(0, 0, 0, 1);
244 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
247 loadtime += multiplier * 4;
249 loadprogress = loadtime;
250 if (loadprogress > 100)loadprogress = 100;
252 //loadprogress=abs(Random()%100);
256 glEnable(GL_TEXTURE_2D);
257 loadscreentexture.bind();
258 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
259 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
260 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
261 glDisable(GL_CULL_FACE);
262 glDisable(GL_LIGHTING);
264 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
265 glPushMatrix(); // Store The Projection Matrix
266 glLoadIdentity(); // Reset The Projection Matrix
267 glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen
268 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
269 glPushMatrix(); // Store The Modelview Matrix
270 glLoadIdentity(); // Reset The Modelview Matrix
271 glTranslatef(screenwidth / 2, screenheight / 2, 0);
272 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
273 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
275 glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, 1);
277 //glScalef(.25,.25,.25);
279 glTexCoord2f(.1 - loadprogress / 100, 0 + loadprogress / 100 + .3);
280 glVertex3f(-1, -1, 0.0f);
281 glTexCoord2f(.1 - loadprogress / 100, 0 + loadprogress / 100 + .3);
282 glVertex3f(1, -1, 0.0f);
283 glTexCoord2f(.1 - loadprogress / 100, 1 + loadprogress / 100 + .3);
284 glVertex3f(1, 1, 0.0f);
285 glTexCoord2f(.1 - loadprogress / 100, 1 + loadprogress / 100 + .3);
286 glVertex3f(-1, 1, 0.0f);
291 //glScalef(.25,.25,.25);
293 glTexCoord2f(.4 + loadprogress / 100, 0 + loadprogress / 100);
294 glVertex3f(-1, -1, 0.0f);
295 glTexCoord2f(.4 + loadprogress / 100, 0 + loadprogress / 100);
296 glVertex3f(1, -1, 0.0f);
297 glTexCoord2f(.4 + loadprogress / 100, 1 + loadprogress / 100);
298 glVertex3f(1, 1, 0.0f);
299 glTexCoord2f(.4 + loadprogress / 100, 1 + loadprogress / 100);
300 glVertex3f(-1, 1, 0.0f);
303 glDisable(GL_TEXTURE_2D);
304 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
305 glPopMatrix(); // Restore The Old Projection Matrix
306 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
307 glPopMatrix(); // Restore The Old Projection Matrix
311 glEnable(GL_TEXTURE_2D);
312 loadscreentexture.bind();
313 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
314 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
315 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
316 glDisable(GL_CULL_FACE);
317 glDisable(GL_LIGHTING);
319 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
320 glPushMatrix(); // Store The Projection Matrix
321 glLoadIdentity(); // Reset The Projection Matrix
322 glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen
323 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
324 glPushMatrix(); // Store The Modelview Matrix
325 glLoadIdentity(); // Reset The Modelview Matrix
326 glTranslatef(screenwidth / 2, screenheight / 2, 0);
327 glScalef((float)screenwidth / 2 * (1.5 - (loadprogress) / 200), (float)screenheight / 2 * (1.5 - (loadprogress) / 200), 1);
328 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
330 //glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
331 glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, 1);
333 //glScalef(.25,.25,.25);
335 glTexCoord2f(0 + .5, 0 + .5);
336 glVertex3f(-1, -1, 0.0f);
337 glTexCoord2f(1 + .5, 0 + .5);
338 glVertex3f(1, -1, 0.0f);
339 glTexCoord2f(1 + .5, 1 + .5);
340 glVertex3f(1, 1, 0.0f);
341 glTexCoord2f(0 + .5, 1 + .5);
342 glVertex3f(-1, 1, 0.0f);
345 glDisable(GL_TEXTURE_2D);
346 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
347 glPopMatrix(); // Restore The Old Projection Matrix
348 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
349 glPopMatrix(); // Restore The Old Projection Matrix
353 glEnable(GL_TEXTURE_2D);
354 loadscreentexture.bind();
355 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
356 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
357 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
358 glDisable(GL_CULL_FACE);
359 glDisable(GL_LIGHTING);
361 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
362 glPushMatrix(); // Store The Projection Matrix
363 glLoadIdentity(); // Reset The Projection Matrix
364 glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen
365 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
366 glPushMatrix(); // Store The Modelview Matrix
367 glLoadIdentity(); // Reset The Modelview Matrix
368 glTranslatef(screenwidth / 2, screenheight / 2, 0);
369 glScalef((float)screenwidth / 2 * (100 + loadprogress) / 100, (float)screenheight / 2 * (100 + loadprogress) / 100, 1);
370 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
372 glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, .4);
374 //glScalef(.25,.25,.25);
376 glTexCoord2f(0 + .2, 0 + .8);
377 glVertex3f(-1, -1, 0.0f);
378 glTexCoord2f(1 + .2, 0 + .8);
379 glVertex3f(1, -1, 0.0f);
380 glTexCoord2f(1 + .2, 1 + .8);
381 glVertex3f(1, 1, 0.0f);
382 glTexCoord2f(0 + .2, 1 + .8);
383 glVertex3f(-1, 1, 0.0f);
386 glDisable(GL_TEXTURE_2D);
387 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
388 glPopMatrix(); // Restore The Old Projection Matrix
389 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
390 glPopMatrix(); // Restore The Old Projection Matrix
396 if (flashamount > 0) {
397 if (flashamount > 1)flashamount = 1;
398 if (flashdelay <= 0)flashamount -= multiplier;
400 if (flashamount < 0)flashamount = 0;
401 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
402 glDisable(GL_CULL_FACE);
403 glDisable(GL_LIGHTING);
404 glDisable(GL_TEXTURE_2D);
406 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
407 glPushMatrix(); // Store The Projection Matrix
408 glLoadIdentity(); // Reset The Projection Matrix
409 glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen
410 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
411 glPushMatrix(); // Store The Modelview Matrix
412 glLoadIdentity(); // Reset The Modelview Matrix
413 glScalef(screenwidth, screenheight, 1);
414 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
416 glColor4f(flashr, flashg, flashb, flashamount);
418 glVertex3f(0, 0, 0.0f);
419 glVertex3f(256, 0, 0.0f);
420 glVertex3f(256, 256, 0.0f);
421 glVertex3f(0, 256, 0.0f);
423 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
424 glPopMatrix(); // Restore The Old Projection Matrix
425 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
426 glPopMatrix(); // Restore The Old Projection Matrix
427 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
428 glEnable(GL_CULL_FACE);
437 void FadeLoadingScreen(float howmuch)
439 static float loadprogress;
443 glClearColor(0, 0, 0, 1);
444 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
446 loadprogress = howmuch;
448 //loadprogress=abs(Random()%100);
452 //glEnable(GL_TEXTURE_2D);
453 glDisable(GL_TEXTURE_2D);
454 //glBindTexture( GL_TEXTURE_2D, loadscreentexture);
455 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
456 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
457 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
458 glDisable(GL_CULL_FACE);
459 glDisable(GL_LIGHTING);
461 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
462 glPushMatrix(); // Store The Projection Matrix
463 glLoadIdentity(); // Reset The Projection Matrix
464 glOrtho(0, screenwidth, 0, screenheight, -100, 100); // Set Up An Ortho Screen
465 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
466 glPushMatrix(); // Store The Modelview Matrix
467 glLoadIdentity(); // Reset The Modelview Matrix
468 glTranslatef(screenwidth / 2, screenheight / 2, 0);
469 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
470 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
472 glColor4f(loadprogress / 100, 0, 0, 1);
474 //glScalef(.25,.25,.25);
477 glVertex3f(-1, -1, 0.0f);
479 glVertex3f(1, -1, 0.0f);
481 glVertex3f(1, 1, 0.0f);
483 glVertex3f(-1, 1, 0.0f);
486 glDisable(GL_TEXTURE_2D);
487 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
488 glPopMatrix(); // Restore The Old Projection Matrix
489 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
490 glPopMatrix(); // Restore The Old Projection Matrix
498 extern bool cmdline(const char *cmd);
500 void Game::InitGame()
503 ProcessSerialNumber PSN;
504 ProcessInfoRec pinfo;
507 /* set up process serial number */
508 PSN.highLongOfPSN = 0;
509 PSN.lowLongOfPSN = kCurrentProcess;
510 /* set up info block */
511 pinfo.processInfoLength = sizeof(pinfo);
512 pinfo.processName = NULL;
513 pinfo.processAppSpec = &pspec;
514 /* grab the vrefnum and directory */
515 err = GetProcessInformation(&PSN, &pinfo);
517 vRefNum = pspec.vRefNum;
524 numchallengelevels = 14;
526 accountactive = Account::loadFile(":Data:Users");
532 whichjointstartarray[0] = righthip;
533 whichjointendarray[0] = rightfoot;
535 whichjointstartarray[1] = righthip;
536 whichjointendarray[1] = rightankle;
538 whichjointstartarray[2] = righthip;
539 whichjointendarray[2] = rightknee;
541 whichjointstartarray[3] = rightknee;
542 whichjointendarray[3] = rightankle;
544 whichjointstartarray[4] = rightankle;
545 whichjointendarray[4] = rightfoot;
547 whichjointstartarray[5] = lefthip;
548 whichjointendarray[5] = leftfoot;
550 whichjointstartarray[6] = lefthip;
551 whichjointendarray[6] = leftankle;
553 whichjointstartarray[7] = lefthip;
554 whichjointendarray[7] = leftknee;
556 whichjointstartarray[8] = leftknee;
557 whichjointendarray[8] = leftankle;
559 whichjointstartarray[9] = leftankle;
560 whichjointendarray[9] = leftfoot;
562 whichjointstartarray[10] = abdomen;
563 whichjointendarray[10] = rightshoulder;
565 whichjointstartarray[11] = abdomen;
566 whichjointendarray[11] = rightelbow;
568 whichjointstartarray[12] = abdomen;
569 whichjointendarray[12] = rightwrist;
571 whichjointstartarray[13] = abdomen;
572 whichjointendarray[13] = righthand;
574 whichjointstartarray[14] = rightshoulder;
575 whichjointendarray[14] = rightelbow;
577 whichjointstartarray[15] = rightelbow;
578 whichjointendarray[15] = rightwrist;
580 whichjointstartarray[16] = rightwrist;
581 whichjointendarray[16] = righthand;
583 whichjointstartarray[17] = abdomen;
584 whichjointendarray[17] = leftshoulder;
586 whichjointstartarray[18] = abdomen;
587 whichjointendarray[18] = leftelbow;
589 whichjointstartarray[19] = abdomen;
590 whichjointendarray[19] = leftwrist;
592 whichjointstartarray[20] = abdomen;
593 whichjointendarray[20] = lefthand;
595 whichjointstartarray[21] = leftshoulder;
596 whichjointendarray[21] = leftelbow;
598 whichjointstartarray[22] = leftelbow;
599 whichjointendarray[22] = leftwrist;
601 whichjointstartarray[23] = leftwrist;
602 whichjointendarray[23] = lefthand;
604 whichjointstartarray[24] = abdomen;
605 whichjointendarray[24] = neck;
607 whichjointstartarray[25] = neck;
608 whichjointendarray[25] = head;
610 FadeLoadingScreen(0);
614 texture.data = ( GLubyte* )malloc( 1024 * 1024 * 4 );
616 int temptexdetail = texdetail;
618 text->LoadFontTexture(":Data:Textures:Font.png");
620 texdetail = temptexdetail;
622 FadeLoadingScreen(10);
634 LOG("Initializing sound system...");
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) {
648 // if we tried ALSA and failed, fall back to OSS.
649 if ( (output == OPENAL_OUTPUT_ALSA) && (!cmdline("forcealsa")) ) {
651 output = OPENAL_OUTPUT_OSS;
652 OPENAL_SetOutput(output);
653 rc = OPENAL_Init(44100, 32, 0);
659 output = OPENAL_OUTPUT_NOSOUND; // we tried! just do silence.
660 OPENAL_SetOutput(output);
661 rc = OPENAL_Init(44100, 32, 0);
664 OPENAL_Init(44100, 32, 0);
667 OPENAL_SetSFXMasterVolume((int)(volume * 255));
671 emit_stream_np(stream_menutheme);
673 cursortexture.load(":Data:Textures:Cursor.png", 0, 1);
675 Mapcircletexture.load(":Data:Textures:MapCircle.png", 0, 1);
676 Mapboxtexture.load(":Data:Textures:MapBox.png", 0, 1);
677 Maparrowtexture.load(":Data:Textures:MapArrow.png", 0, 1);
679 temptexdetail = texdetail;
680 if (texdetail > 2)texdetail = 2;
681 Mainmenuitems[0].load(":Data:Textures:Lugaru.png", 0, 0);
682 Mainmenuitems[1].load(":Data:Textures:Newgame.png", 0, 0);
683 Mainmenuitems[2].load(":Data:Textures:Options.png", 0, 0);
684 Mainmenuitems[3].load(":Data:Textures:Quit.png", 0, 0);
685 Mainmenuitems[4].load(":Data:Textures:Eyelid.png", 0, 1);
686 Mainmenuitems[5].load(":Data:Textures:Resume.png", 0, 0);
687 Mainmenuitems[6].load(":Data:Textures:Endgame.png", 0, 0);
689 //LoadTexture(":Data:Textures:Eye.jpg",&Mainmenuitems[5],0,1);
690 //~ LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0); // LoadCampaign will take care of that
691 texdetail = temptexdetail;
693 FadeLoadingScreen(95);
703 newscreenwidth = screenwidth;
704 newscreenheight = screenheight;
710 void Game::LoadScreenTexture()
712 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
714 if (!Game::screentexture)
715 glGenTextures( 1, &Game::screentexture );
716 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
719 glEnable(GL_TEXTURE_2D);
720 glBindTexture( GL_TEXTURE_2D, Game::screentexture);
721 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
722 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
724 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
727 //TODO: move LoadStuff() closer to GameTick.cpp to get rid of various vars shared in Game.h
728 void Game::LoadStuff()
730 static float temptexdetail;
731 static float viewdistdetail;
741 for (i = 0; i < maxplayers; i++)
742 player[i].skeleton.drawmodel.textureptr.destroy();
744 i = abs(Random() % 4);
745 visibleloading = 0; //don't use loadscreentexture yet
746 loadscreentexture.load(":Data:Textures:fire.jpg", 1, 0);
749 temptexdetail = texdetail;
751 text->LoadFontTexture(":Data:Textures:Font.png");
753 texdetail = temptexdetail;
758 viewdistance = 50 * megascale * viewdistdetail;
770 realtexdetail = texdetail;
775 LOG("Loading weapon data...");
777 Weapon::knifetextureptr.load(":Data:Textures:knife.png", 0, 1);
778 Weapon::bloodknifetextureptr.load(":Data:Textures:bloodknife.png", 0, 1);
779 Weapon::lightbloodknifetextureptr.load(":Data:Textures:lightbloodknife.png", 0, 1);
780 Weapon::swordtextureptr.load(":Data:Textures:sword.jpg", 1, 0);
781 Weapon::bloodswordtextureptr.load(":Data:Textures:Swordblood.jpg", 1, 0);
782 Weapon::lightbloodswordtextureptr.load(":Data:Textures:Swordbloodlight.jpg", 1, 0);
783 Weapon::stafftextureptr.load(":Data:Textures:Staff.jpg", 1, 0);
785 Weapon::throwingknifemodel.load((char *)":Data:Models:throwingknife.solid", 1);
786 Weapon::throwingknifemodel.Scale(.001, .001, .001);
787 //Weapon::throwingknifemodel.Rotate(0,0,-90);
788 Weapon::throwingknifemodel.Rotate(90, 0, 0);
789 Weapon::throwingknifemodel.Rotate(0, 90, 0);
790 Weapon::throwingknifemodel.flat = 0;
791 Weapon::throwingknifemodel.CalculateNormals(1);
792 //Weapon::throwingknifemodel.ScaleNormals(-1,-1,-1);
794 Weapon::swordmodel.load((char *)":Data:Models:sword.solid", 1);
795 Weapon::swordmodel.Scale(.001, .001, .001);
796 //Weapon::swordmodel.Rotate(0,0,-90);
797 Weapon::swordmodel.Rotate(90, 0, 0);
798 Weapon::swordmodel.Rotate(0, 90, 0);
799 Weapon::swordmodel.Rotate(0, 0, 90);
800 Weapon::swordmodel.flat = 1;
801 Weapon::swordmodel.CalculateNormals(1);
802 //Weapon::swordmodel.ScaleNormals(-1,-1,-1);
804 Weapon::staffmodel.load((char *)":Data:Models:staff.solid", 1);
805 Weapon::staffmodel.Scale(.005, .005, .005);
806 //Weapon::staffmodel.Rotate(0,0,-90);
807 Weapon::staffmodel.Rotate(90, 0, 0);
808 Weapon::staffmodel.Rotate(0, 90, 0);
809 Weapon::staffmodel.Rotate(0, 0, 90);
810 Weapon::staffmodel.flat = 1;
811 Weapon::staffmodel.CalculateNormals(1);
812 //Weapon::staffmodel.ScaleNormals(-1,-1,-1);
814 terrain.shadowtexture.load(":Data:Textures:shadow.png", 0, 1);
815 terrain.bloodtexture.load(":Data:Textures:blood.png", 0, 1);
816 terrain.breaktexture.load(":Data:Textures:break.png", 0, 1);
817 terrain.bloodtexture2.load(":Data:Textures:blood.png", 0, 1);
820 terrain.footprinttexture.load(":Data:Textures:footprint.png", 0, 1);
821 terrain.bodyprinttexture.load(":Data:Textures:bodyprint.png", 0, 1);
822 hawktexture.load(":Data:Textures:hawk.png", 0, 1);
825 Sprite::cloudtexture.load(":Data:Textures:cloud.png", 1, 1);
826 Sprite::cloudimpacttexture.load(":Data:Textures:cloudimpact.png", 1, 1);
827 Sprite::bloodtexture.load(":Data:Textures:bloodparticle.png", 1, 1);
828 Sprite::snowflaketexture.load(":Data:Textures:snowflake.png", 1, 1);
829 Sprite::flametexture.load(":Data:Textures:flame.png", 1, 1);
830 Sprite::bloodflametexture.load(":Data:Textures:bloodflame.png", 1, 1);
831 Sprite::smoketexture.load(":Data:Textures:smoke.png", 1, 1);
832 Sprite::shinetexture.load(":Data:Textures:shine.png", 1, 0);
833 Sprite::splintertexture.load(":Data:Textures:splinter.png", 1, 1);
834 Sprite::leaftexture.load(":Data:Textures:leaf.png", 1, 1);
835 Sprite::toothtexture.load(":Data:Textures:tooth.png", 1, 1);
839 ReSizeGLScene(90, .01);
844 if (detail)kTextureSize = 1024;
845 if (detail == 1)kTextureSize = 512;
846 if (detail == 0)kTextureSize = 256;
848 //Set up distant light
849 light.color[0] = .95;
850 light.color[1] = .95;
852 light.ambient[0] = .2;
853 light.ambient[1] = .2;
854 light.ambient[2] = .24;
855 light.location.x = 1;
856 light.location.y = 1;
857 light.location.z = -.2;
858 Normalise(&light.location);
868 texscale = .2 / megascale / viewdistdetail;
869 terrain.scale = 3 * megascale * viewdistdetail;
871 viewer.x = terrain.size / 2 * terrain.scale;
872 viewer.z = terrain.size / 2 * terrain.scale;
874 hawk.load((char *)":Data:Models:hawk.solid", 1);
875 hawk.Scale(.03, .03, .03);
876 hawk.Rotate(90, 1, 1);
877 hawk.CalculateNormals(0);
878 hawk.ScaleNormals(-1, -1, -1);
879 hawkcoords.x = terrain.size / 2 * terrain.scale - 5 - 7;
880 hawkcoords.z = terrain.size / 2 * terrain.scale - 5 - 7;
881 hawkcoords.y = terrain.getHeight(hawkcoords.x, hawkcoords.z) + 25;
883 eye.load((char *)":Data:Models:eye.solid", 1);
884 eye.Scale(.03, .03, .03);
885 eye.CalculateNormals(0);
887 cornea.load((char *)":Data:Models:cornea.solid", 1);
888 cornea.Scale(.03, .03, .03);
889 cornea.CalculateNormals(0);
891 iris.load((char *)":Data:Models:iris.solid", 1);
892 iris.Scale(.03, .03, .03);
893 iris.CalculateNormals(0);
895 LoadSave(":Data:Textures:Bloodfur.png", 0, 1, &bloodText[0], 0);
896 LoadSave(":Data:Textures:Wolfbloodfur.png", 0, 1, &wolfbloodText[0], 0);
906 //Fix knife stab, too lazy to do it manually
910 for (i = 0; i < player[0].skeleton.num_joints; i++) {
911 for (j = 0; j < animation[knifesneakattackanim].numframes; j++) {
912 animation[knifesneakattackanim].position[i][j] += moveamount;
918 for (i = 0; i < player[0].skeleton.num_joints; i++) {
919 for (j = 0; j < animation[knifesneakattackedanim].numframes; j++) {
920 animation[knifesneakattackedanim].position[i][j] += moveamount;
926 for (i = 0; i < player[0].skeleton.num_joints; i++) {
927 animation[dead1anim].position[i][1] = animation[dead1anim].position[i][0];
928 animation[dead2anim].position[i][1] = animation[dead2anim].position[i][0];
929 animation[dead3anim].position[i][1] = animation[dead3anim].position[i][0];
930 animation[dead4anim].position[i][1] = animation[dead4anim].position[i][0];
932 animation[dead1anim].speed[0] = 0.001;
933 animation[dead2anim].speed[0] = 0.001;
934 animation[dead3anim].speed[0] = 0.001;
935 animation[dead4anim].speed[0] = 0.001;
937 animation[dead1anim].speed[1] = 0.001;
938 animation[dead2anim].speed[1] = 0.001;
939 animation[dead3anim].speed[1] = 0.001;
940 animation[dead4anim].speed[1] = 0.001;
942 for (i = 0; i < player[0].skeleton.num_joints; i++) {
943 for (j = 0; j < animation[swordsneakattackanim].numframes; j++) {
944 animation[swordsneakattackanim].position[i][j] += moveamount;
948 for (j = 0; j < animation[swordsneakattackanim].numframes; j++) {
949 animation[swordsneakattackanim].weapontarget[j] += moveamount;
954 for (i = 0; i < player[0].skeleton.num_joints; i++) {
955 for (j = 0; j < animation[swordsneakattackedanim].numframes; j++) {
956 animation[swordsneakattackedanim].position[i][j] += moveamount;
961 temptexdetail = texdetail;
963 texdetail = temptexdetail;
967 if (!screentexture) {
971 if (targetlevel != 7) {
972 emit_sound_at(fireendsound);