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 modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 Lugaru 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. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
21 #include "openal_wrapper.h"
22 #include "Animation.h"
25 extern float screenwidth, screenheight;
26 extern float viewdistance;
28 extern XYZ lightlocation;
29 extern float fadestart;
30 extern float texscale;
33 extern Skeleton testskeleton;
35 extern Terrain terrain;
36 //extern Sprites sprites;
37 extern int kTextureSize;
38 extern float texdetail;
39 extern float realtexdetail;
41 extern Objects objects;
43 extern bool cellophane;
44 extern GLubyte bloodText[512 * 512 * 3];
45 extern GLubyte wolfbloodText[512 * 512 * 3];
46 extern bool ismotionblur;
47 extern bool trilinear;
49 extern bool musictoggle;
50 extern int environment;
51 extern bool ambientsound;
52 extern float multiplier;
53 extern int netdatanew;
55 extern bool stillloading;
56 extern TGAImageRec texture;
60 extern bool visibleloading;
61 extern float flashamount, flashr, flashg, flashb;
62 extern int flashdelay;
63 extern int whichjointstartarray[26];
64 extern int whichjointendarray[26];
65 extern int difficulty;
66 extern float tintr, tintg, tintb;
67 extern float slomospeed;
68 extern bool gamestarted;
70 extern int numdialogues;
71 extern int numdialogueboxes[20];
72 extern int dialoguetype[20];
73 extern int dialogueboxlocation[20][20];
74 extern float dialogueboxcolor[20][20][3];
75 extern int dialogueboxsound[20][20];
76 extern char dialoguetext[20][20][128];
77 extern char dialoguename[20][20][64];
78 extern XYZ dialoguecamera[20][20];
79 extern float dialoguecamerayaw[20][20];
80 extern float dialoguecamerapitch[20][20];
81 extern int indialogue;
82 extern int whichdialogue;
83 extern float dialoguetime;
85 extern float accountcampaignhighscore[10];
86 extern float accountcampaignfasttime[10];
87 extern float accountcampaignscore[10];
88 extern float accountcampaigntime[10];
90 extern int accountcampaignchoicesmade[10];
91 extern int accountcampaignchoices[10][5000];
93 void LOG(const std::string &fmt, ...)
95 // !!! FIXME: write me.
102 if (Game::endgame == 2) {
103 Game::accountactive->endGame();
107 Account::saveFile(":Data:Users", Game::accountactive);
111 LOG("Shutting down sound system...");
113 OPENAL_StopSound(OPENAL_ALL);
115 // this is causing problems on Linux, but we'll force an _exit() a little
116 // later in the shutdown process. --ryan.
119 for (int i = 0; i < sounds_count; ++i) {
120 OPENAL_Sample_Free(samp[i]);
134 skybox = new SkyBox();
137 void Game::deleteGame()
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)
240 if (multiplier > .05) {
241 frametime = currTime; // reset for next time interval
245 glClearColor(0, 0, 0, 1);
246 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
249 loadtime += multiplier * 4;
251 loadprogress = loadtime;
252 if (loadprogress > 100)
255 //loadprogress=abs(Random()%100);
259 glEnable(GL_TEXTURE_2D);
260 loadscreentexture.bind();
261 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
262 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
263 glDisable(GL_DEPTH_TEST);
264 glDisable(GL_CULL_FACE);
265 glDisable(GL_LIGHTING);
267 glMatrixMode(GL_PROJECTION);
270 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
271 glMatrixMode(GL_MODELVIEW);
274 glTranslatef(screenwidth / 2, screenheight / 2, 0);
275 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
276 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
278 glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, 1);
280 //glScalef(.25,.25,.25);
282 glTexCoord2f(.1 - loadprogress / 100, 0 + loadprogress / 100 + .3);
283 glVertex3f(-1, -1, 0.0f);
284 glTexCoord2f(.1 - loadprogress / 100, 0 + loadprogress / 100 + .3);
285 glVertex3f(1, -1, 0.0f);
286 glTexCoord2f(.1 - loadprogress / 100, 1 + loadprogress / 100 + .3);
287 glVertex3f(1, 1, 0.0f);
288 glTexCoord2f(.1 - loadprogress / 100, 1 + loadprogress / 100 + .3);
289 glVertex3f(-1, 1, 0.0f);
294 //glScalef(.25,.25,.25);
296 glTexCoord2f(.4 + loadprogress / 100, 0 + loadprogress / 100);
297 glVertex3f(-1, -1, 0.0f);
298 glTexCoord2f(.4 + loadprogress / 100, 0 + loadprogress / 100);
299 glVertex3f(1, -1, 0.0f);
300 glTexCoord2f(.4 + loadprogress / 100, 1 + loadprogress / 100);
301 glVertex3f(1, 1, 0.0f);
302 glTexCoord2f(.4 + loadprogress / 100, 1 + loadprogress / 100);
303 glVertex3f(-1, 1, 0.0f);
306 glDisable(GL_TEXTURE_2D);
307 glMatrixMode(GL_PROJECTION);
309 glMatrixMode(GL_MODELVIEW);
314 glEnable(GL_TEXTURE_2D);
315 loadscreentexture.bind();
316 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
317 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
318 glDisable(GL_DEPTH_TEST);
319 glDisable(GL_CULL_FACE);
320 glDisable(GL_LIGHTING);
322 glMatrixMode(GL_PROJECTION);
325 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
326 glMatrixMode(GL_MODELVIEW);
329 glTranslatef(screenwidth / 2, screenheight / 2, 0);
330 glScalef((float)screenwidth / 2 * (1.5 - (loadprogress) / 200), (float)screenheight / 2 * (1.5 - (loadprogress) / 200), 1);
331 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
333 //glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
334 glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, 1);
336 //glScalef(.25,.25,.25);
338 glTexCoord2f(0 + .5, 0 + .5);
339 glVertex3f(-1, -1, 0.0f);
340 glTexCoord2f(1 + .5, 0 + .5);
341 glVertex3f(1, -1, 0.0f);
342 glTexCoord2f(1 + .5, 1 + .5);
343 glVertex3f(1, 1, 0.0f);
344 glTexCoord2f(0 + .5, 1 + .5);
345 glVertex3f(-1, 1, 0.0f);
348 glDisable(GL_TEXTURE_2D);
349 glMatrixMode(GL_PROJECTION);
351 glMatrixMode(GL_MODELVIEW);
356 glEnable(GL_TEXTURE_2D);
357 loadscreentexture.bind();
358 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
359 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
360 glDisable(GL_DEPTH_TEST);
361 glDisable(GL_CULL_FACE);
362 glDisable(GL_LIGHTING);
364 glMatrixMode(GL_PROJECTION);
367 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
368 glMatrixMode(GL_MODELVIEW);
371 glTranslatef(screenwidth / 2, screenheight / 2, 0);
372 glScalef((float)screenwidth / 2 * (100 + loadprogress) / 100, (float)screenheight / 2 * (100 + loadprogress) / 100, 1);
373 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
375 glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, .4);
377 //glScalef(.25,.25,.25);
379 glTexCoord2f(0 + .2, 0 + .8);
380 glVertex3f(-1, -1, 0.0f);
381 glTexCoord2f(1 + .2, 0 + .8);
382 glVertex3f(1, -1, 0.0f);
383 glTexCoord2f(1 + .2, 1 + .8);
384 glVertex3f(1, 1, 0.0f);
385 glTexCoord2f(0 + .2, 1 + .8);
386 glVertex3f(-1, 1, 0.0f);
389 glDisable(GL_TEXTURE_2D);
390 glMatrixMode(GL_PROJECTION);
392 glMatrixMode(GL_MODELVIEW);
399 if (flashamount > 0) {
403 flashamount -= multiplier;
407 glDisable(GL_DEPTH_TEST);
408 glDisable(GL_CULL_FACE);
409 glDisable(GL_LIGHTING);
410 glDisable(GL_TEXTURE_2D);
412 glMatrixMode(GL_PROJECTION);
415 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
416 glMatrixMode(GL_MODELVIEW);
419 glScalef(screenwidth, screenheight, 1);
420 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
422 glColor4f(flashr, flashg, flashb, flashamount);
424 glVertex3f(0, 0, 0.0f);
425 glVertex3f(256, 0, 0.0f);
426 glVertex3f(256, 256, 0.0f);
427 glVertex3f(0, 256, 0.0f);
429 glMatrixMode(GL_PROJECTION);
431 glMatrixMode(GL_MODELVIEW);
433 glEnable(GL_DEPTH_TEST);
434 glEnable(GL_CULL_FACE);
443 void FadeLoadingScreen(float howmuch)
445 static float loadprogress;
449 glClearColor(0, 0, 0, 1);
450 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
452 loadprogress = howmuch;
454 //loadprogress=abs(Random()%100);
458 //glEnable(GL_TEXTURE_2D);
459 glDisable(GL_TEXTURE_2D);
460 //glBindTexture( GL_TEXTURE_2D, loadscreentexture);
461 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
462 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
463 glDisable(GL_DEPTH_TEST);
464 glDisable(GL_CULL_FACE);
465 glDisable(GL_LIGHTING);
467 glMatrixMode(GL_PROJECTION);
470 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
471 glMatrixMode(GL_MODELVIEW);
474 glTranslatef(screenwidth / 2, screenheight / 2, 0);
475 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
476 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
478 glColor4f(loadprogress / 100, 0, 0, 1);
480 //glScalef(.25,.25,.25);
483 glVertex3f(-1, -1, 0.0f);
485 glVertex3f(1, -1, 0.0f);
487 glVertex3f(1, 1, 0.0f);
489 glVertex3f(-1, 1, 0.0f);
492 glDisable(GL_TEXTURE_2D);
493 glMatrixMode(GL_PROJECTION);
495 glMatrixMode(GL_MODELVIEW);
504 extern bool cmdline(const char *cmd);
506 void Game::InitGame()
509 ProcessSerialNumber PSN;
510 ProcessInfoRec pinfo;
513 /* set up process serial number */
514 PSN.highLongOfPSN = 0;
515 PSN.lowLongOfPSN = kCurrentProcess;
516 /* set up info block */
517 pinfo.processInfoLength = sizeof(pinfo);
518 pinfo.processName = NULL;
519 pinfo.processAppSpec = &pspec;
520 /* grab the vrefnum and directory */
521 err = GetProcessInformation(&PSN, &pinfo);
523 vRefNum = pspec.vRefNum;
530 numchallengelevels = 14;
532 accountactive = Account::loadFile(":Data:Users");
538 whichjointstartarray[0] = righthip;
539 whichjointendarray[0] = rightfoot;
541 whichjointstartarray[1] = righthip;
542 whichjointendarray[1] = rightankle;
544 whichjointstartarray[2] = righthip;
545 whichjointendarray[2] = rightknee;
547 whichjointstartarray[3] = rightknee;
548 whichjointendarray[3] = rightankle;
550 whichjointstartarray[4] = rightankle;
551 whichjointendarray[4] = rightfoot;
553 whichjointstartarray[5] = lefthip;
554 whichjointendarray[5] = leftfoot;
556 whichjointstartarray[6] = lefthip;
557 whichjointendarray[6] = leftankle;
559 whichjointstartarray[7] = lefthip;
560 whichjointendarray[7] = leftknee;
562 whichjointstartarray[8] = leftknee;
563 whichjointendarray[8] = leftankle;
565 whichjointstartarray[9] = leftankle;
566 whichjointendarray[9] = leftfoot;
568 whichjointstartarray[10] = abdomen;
569 whichjointendarray[10] = rightshoulder;
571 whichjointstartarray[11] = abdomen;
572 whichjointendarray[11] = rightelbow;
574 whichjointstartarray[12] = abdomen;
575 whichjointendarray[12] = rightwrist;
577 whichjointstartarray[13] = abdomen;
578 whichjointendarray[13] = righthand;
580 whichjointstartarray[14] = rightshoulder;
581 whichjointendarray[14] = rightelbow;
583 whichjointstartarray[15] = rightelbow;
584 whichjointendarray[15] = rightwrist;
586 whichjointstartarray[16] = rightwrist;
587 whichjointendarray[16] = righthand;
589 whichjointstartarray[17] = abdomen;
590 whichjointendarray[17] = leftshoulder;
592 whichjointstartarray[18] = abdomen;
593 whichjointendarray[18] = leftelbow;
595 whichjointstartarray[19] = abdomen;
596 whichjointendarray[19] = leftwrist;
598 whichjointstartarray[20] = abdomen;
599 whichjointendarray[20] = lefthand;
601 whichjointstartarray[21] = leftshoulder;
602 whichjointendarray[21] = leftelbow;
604 whichjointstartarray[22] = leftelbow;
605 whichjointendarray[22] = leftwrist;
607 whichjointstartarray[23] = leftwrist;
608 whichjointendarray[23] = lefthand;
610 whichjointstartarray[24] = abdomen;
611 whichjointendarray[24] = neck;
613 whichjointstartarray[25] = neck;
614 whichjointendarray[25] = head;
616 FadeLoadingScreen(0);
620 texture.data = ( GLubyte* )malloc( 1024 * 1024 * 4 );
622 int temptexdetail = texdetail;
624 text->LoadFontTexture(":Data:Textures:Font.png");
626 texdetail = temptexdetail;
628 FadeLoadingScreen(10);
640 LOG("Initializing sound system...");
645 unsigned char rc = 0;
646 output = OPENAL_OUTPUT_ALSA; // Try alsa first...
647 if (cmdline("forceoss")) // ...but let user override that.
648 output = OPENAL_OUTPUT_OSS;
649 else if (cmdline("nosound"))
650 output = OPENAL_OUTPUT_NOSOUND;
652 OPENAL_SetOutput(output);
653 if ((rc = OPENAL_Init(44100, 32, 0)) == false) {
654 // if we tried ALSA and failed, fall back to OSS.
655 if ( (output == OPENAL_OUTPUT_ALSA) && (!cmdline("forcealsa")) ) {
657 output = OPENAL_OUTPUT_OSS;
658 OPENAL_SetOutput(output);
659 rc = OPENAL_Init(44100, 32, 0);
665 output = OPENAL_OUTPUT_NOSOUND; // we tried! just do silence.
666 OPENAL_SetOutput(output);
667 rc = OPENAL_Init(44100, 32, 0);
670 OPENAL_Init(44100, 32, 0);
673 OPENAL_SetSFXMasterVolume((int)(volume * 255));
677 emit_stream_np(stream_menutheme);
679 cursortexture.load(":Data:Textures:Cursor.png", 0, 1);
681 Mapcircletexture.load(":Data:Textures:MapCircle.png", 0, 1);
682 Mapboxtexture.load(":Data:Textures:MapBox.png", 0, 1);
683 Maparrowtexture.load(":Data:Textures:MapArrow.png", 0, 1);
685 temptexdetail = texdetail;
688 Mainmenuitems[0].load(":Data:Textures:Lugaru.png", 0, 0);
689 Mainmenuitems[1].load(":Data:Textures:Newgame.png", 0, 0);
690 Mainmenuitems[2].load(":Data:Textures:Options.png", 0, 0);
691 Mainmenuitems[3].load(":Data:Textures:Quit.png", 0, 0);
692 Mainmenuitems[4].load(":Data:Textures:Eyelid.png", 0, 1);
693 Mainmenuitems[5].load(":Data:Textures:Resume.png", 0, 0);
694 Mainmenuitems[6].load(":Data:Textures:Endgame.png", 0, 0);
696 //LoadTexture(":Data:Textures:Eye.jpg",&Mainmenuitems[5],0,1);
697 //~ LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0); // LoadCampaign will take care of that
698 texdetail = temptexdetail;
700 FadeLoadingScreen(95);
710 newscreenwidth = screenwidth;
711 newscreenheight = screenheight;
717 void Game::LoadScreenTexture()
719 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
721 if (!Game::screentexture)
722 glGenTextures( 1, &Game::screentexture );
723 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
726 glEnable(GL_TEXTURE_2D);
727 glBindTexture( GL_TEXTURE_2D, Game::screentexture);
728 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
729 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
731 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
734 //TODO: move LoadStuff() closer to GameTick.cpp to get rid of various vars shared in Game.h
735 void Game::LoadStuff()
737 static float temptexdetail;
738 static float viewdistdetail;
748 for (auto p:Person::players) {
749 p->skeleton.drawmodel.textureptr.destroy();
752 i = abs(Random() % 4);
753 visibleloading = 0; //don't use loadscreentexture yet
754 loadscreentexture.load(":Data:Textures:fire.jpg", 1, 0);
757 temptexdetail = texdetail;
759 text->LoadFontTexture(":Data:Textures:Font.png");
761 texdetail = temptexdetail;
766 viewdistance = 50 * megascale * viewdistdetail;
778 realtexdetail = texdetail;
780 LOG("Loading weapon data...");
782 Weapon::knifetextureptr.load(":Data:Textures:knife.png", 0, 1);
783 Weapon::bloodknifetextureptr.load(":Data:Textures:bloodknife.png", 0, 1);
784 Weapon::lightbloodknifetextureptr.load(":Data:Textures:lightbloodknife.png", 0, 1);
785 Weapon::swordtextureptr.load(":Data:Textures:sword.jpg", 1, 0);
786 Weapon::bloodswordtextureptr.load(":Data:Textures:Swordblood.jpg", 1, 0);
787 Weapon::lightbloodswordtextureptr.load(":Data:Textures:Swordbloodlight.jpg", 1, 0);
788 Weapon::stafftextureptr.load(":Data:Textures:Staff.jpg", 1, 0);
790 Weapon::throwingknifemodel.load((char *)":Data:Models:throwingknife.solid", 1);
791 Weapon::throwingknifemodel.Scale(.001, .001, .001);
792 //Weapon::throwingknifemodel.Rotate(0,0,-90);
793 Weapon::throwingknifemodel.Rotate(90, 0, 0);
794 Weapon::throwingknifemodel.Rotate(0, 90, 0);
795 Weapon::throwingknifemodel.flat = 0;
796 Weapon::throwingknifemodel.CalculateNormals(1);
797 //Weapon::throwingknifemodel.ScaleNormals(-1,-1,-1);
799 Weapon::swordmodel.load((char *)":Data:Models:sword.solid", 1);
800 Weapon::swordmodel.Scale(.001, .001, .001);
801 //Weapon::swordmodel.Rotate(0,0,-90);
802 Weapon::swordmodel.Rotate(90, 0, 0);
803 Weapon::swordmodel.Rotate(0, 90, 0);
804 Weapon::swordmodel.Rotate(0, 0, 90);
805 Weapon::swordmodel.flat = 1;
806 Weapon::swordmodel.CalculateNormals(1);
807 //Weapon::swordmodel.ScaleNormals(-1,-1,-1);
809 Weapon::staffmodel.load((char *)":Data:Models:staff.solid", 1);
810 Weapon::staffmodel.Scale(.005, .005, .005);
811 //Weapon::staffmodel.Rotate(0,0,-90);
812 Weapon::staffmodel.Rotate(90, 0, 0);
813 Weapon::staffmodel.Rotate(0, 90, 0);
814 Weapon::staffmodel.Rotate(0, 0, 90);
815 Weapon::staffmodel.flat = 1;
816 Weapon::staffmodel.CalculateNormals(1);
817 //Weapon::staffmodel.ScaleNormals(-1,-1,-1);
819 terrain.shadowtexture.load(":Data:Textures:shadow.png", 0, 1);
820 terrain.bloodtexture.load(":Data:Textures:blood.png", 0, 1);
821 terrain.breaktexture.load(":Data:Textures:break.png", 0, 1);
822 terrain.bloodtexture2.load(":Data:Textures:blood.png", 0, 1);
825 terrain.footprinttexture.load(":Data:Textures:footprint.png", 0, 1);
826 terrain.bodyprinttexture.load(":Data:Textures:bodyprint.png", 0, 1);
827 hawktexture.load(":Data:Textures:hawk.png", 0, 1);
830 Sprite::cloudtexture.load(":Data:Textures:cloud.png", 1, 1);
831 Sprite::cloudimpacttexture.load(":Data:Textures:cloudimpact.png", 1, 1);
832 Sprite::bloodtexture.load(":Data:Textures:bloodparticle.png", 1, 1);
833 Sprite::snowflaketexture.load(":Data:Textures:snowflake.png", 1, 1);
834 Sprite::flametexture.load(":Data:Textures:flame.png", 1, 1);
835 Sprite::bloodflametexture.load(":Data:Textures:bloodflame.png", 1, 1);
836 Sprite::smoketexture.load(":Data:Textures:smoke.png", 1, 1);
837 Sprite::shinetexture.load(":Data:Textures:shine.png", 1, 0);
838 Sprite::splintertexture.load(":Data:Textures:splinter.png", 1, 1);
839 Sprite::leaftexture.load(":Data:Textures:leaf.png", 1, 1);
840 Sprite::toothtexture.load(":Data:Textures:tooth.png", 1, 1);
844 ReSizeGLScene(90, .01);
856 //Set up distant light
857 light.color[0] = .95;
858 light.color[1] = .95;
860 light.ambient[0] = .2;
861 light.ambient[1] = .2;
862 light.ambient[2] = .24;
863 light.location.x = 1;
864 light.location.y = 1;
865 light.location.z = -.2;
866 Normalise(&light.location);
876 texscale = .2 / megascale / viewdistdetail;
877 terrain.scale = 3 * megascale * viewdistdetail;
879 viewer.x = terrain.size / 2 * terrain.scale;
880 viewer.z = terrain.size / 2 * terrain.scale;
882 hawk.load((char *)":Data:Models:hawk.solid", 1);
883 hawk.Scale(.03, .03, .03);
884 hawk.Rotate(90, 1, 1);
885 hawk.CalculateNormals(0);
886 hawk.ScaleNormals(-1, -1, -1);
887 hawkcoords.x = terrain.size / 2 * terrain.scale - 5 - 7;
888 hawkcoords.z = terrain.size / 2 * terrain.scale - 5 - 7;
889 hawkcoords.y = terrain.getHeight(hawkcoords.x, hawkcoords.z) + 25;
891 eye.load((char *)":Data:Models:eye.solid", 1);
892 eye.Scale(.03, .03, .03);
893 eye.CalculateNormals(0);
895 cornea.load((char *)":Data:Models:cornea.solid", 1);
896 cornea.Scale(.03, .03, .03);
897 cornea.CalculateNormals(0);
899 iris.load((char *)":Data:Models:iris.solid", 1);
900 iris.Scale(.03, .03, .03);
901 iris.CalculateNormals(0);
903 LoadSave(":Data:Textures:Bloodfur.png", 0, 1, &bloodText[0], 0);
904 LoadSave(":Data:Textures:Wolfbloodfur.png", 0, 1, &wolfbloodText[0], 0);
914 //Fix knife stab, too lazy to do it manually
918 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
919 for (j = 0; j < animation[knifesneakattackanim].numframes; j++) {
920 animation[knifesneakattackanim].position[i][j] += moveamount;
926 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
927 for (j = 0; j < animation[knifesneakattackedanim].numframes; j++) {
928 animation[knifesneakattackedanim].position[i][j] += moveamount;
934 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
935 animation[dead1anim].position[i][1] = animation[dead1anim].position[i][0];
936 animation[dead2anim].position[i][1] = animation[dead2anim].position[i][0];
937 animation[dead3anim].position[i][1] = animation[dead3anim].position[i][0];
938 animation[dead4anim].position[i][1] = animation[dead4anim].position[i][0];
940 animation[dead1anim].speed[0] = 0.001;
941 animation[dead2anim].speed[0] = 0.001;
942 animation[dead3anim].speed[0] = 0.001;
943 animation[dead4anim].speed[0] = 0.001;
945 animation[dead1anim].speed[1] = 0.001;
946 animation[dead2anim].speed[1] = 0.001;
947 animation[dead3anim].speed[1] = 0.001;
948 animation[dead4anim].speed[1] = 0.001;
950 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
951 for (j = 0; j < animation[swordsneakattackanim].numframes; j++) {
952 animation[swordsneakattackanim].position[i][j] += moveamount;
956 for (j = 0; j < animation[swordsneakattackanim].numframes; j++) {
957 animation[swordsneakattackanim].weapontarget[j] += moveamount;
962 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
963 for (j = 0; j < animation[swordsneakattackedanim].numframes; j++) {
964 animation[swordsneakattackedanim].position[i][j] += moveamount;
969 temptexdetail = texdetail;
971 texdetail = temptexdetail;
975 if (!screentexture) {
979 if (targetlevel != 7) {
980 emit_sound_at(fireendsound);