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)
167 LOG(std::string("Loading (S)...") + fileName);
170 float temptexdetail = texdetail;
173 // Converting file to something os specific
174 char * fixedFN = ConvertFileName(fileName);
177 unsigned char fileNamep[256];
178 CopyCStringToPascal(fixedFN, fileNamep);
180 upload_image( fileNamep , 0);
181 texdetail = temptexdetail;
183 int bytesPerPixel = texture.bpp / 8;
186 for (int i = 0; i < (int)(texture.sizeY * texture.sizeX * bytesPerPixel); i++) {
187 if ((i + 1) % 4 || bytesPerPixel == 3) {
188 array[tempnum] = texture.data[i];
196 //***************> ResizeGLScene() <******/
197 GLvoid Game::ReSizeGLScene(float fov, float pnear)
199 if (screenheight == 0) {
203 glViewport(0, 0, screenwidth, screenheight);
205 glMatrixMode(GL_PROJECTION);
208 gluPerspective(fov, (GLfloat)screenwidth / (GLfloat)screenheight, pnear, viewdistance);
210 glMatrixMode(GL_MODELVIEW);
214 void Game::LoadingScreen()
216 static float loadprogress;
217 //~ static AbsoluteTime time = {0, 0};
218 static AbsoluteTime frametime = {0, 0};
219 AbsoluteTime currTime = UpTime ();
220 double deltaTime = (float) AbsoluteDeltaToDuration (currTime, frametime);
222 if (0 > deltaTime) // if negative microseconds
223 deltaTime /= -1000000.0;
224 else // else milliseconds
227 multiplier = deltaTime;
228 if (multiplier < .001)
232 if (multiplier > .05) {
233 frametime = currTime; // reset for next time interval
237 glClearColor(0, 0, 0, 1);
238 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
241 loadtime += multiplier * 4;
243 loadprogress = loadtime;
244 if (loadprogress > 100)
247 //loadprogress=abs(Random()%100);
251 glEnable(GL_TEXTURE_2D);
252 loadscreentexture.bind();
253 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
254 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
255 glDisable(GL_DEPTH_TEST);
256 glDisable(GL_CULL_FACE);
257 glDisable(GL_LIGHTING);
259 glMatrixMode(GL_PROJECTION);
262 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
263 glMatrixMode(GL_MODELVIEW);
266 glTranslatef(screenwidth / 2, screenheight / 2, 0);
267 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
268 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
270 glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, 1);
272 //glScalef(.25,.25,.25);
274 glTexCoord2f(.1 - loadprogress / 100, 0 + loadprogress / 100 + .3);
275 glVertex3f(-1, -1, 0.0f);
276 glTexCoord2f(.1 - loadprogress / 100, 0 + loadprogress / 100 + .3);
277 glVertex3f(1, -1, 0.0f);
278 glTexCoord2f(.1 - loadprogress / 100, 1 + loadprogress / 100 + .3);
279 glVertex3f(1, 1, 0.0f);
280 glTexCoord2f(.1 - loadprogress / 100, 1 + loadprogress / 100 + .3);
281 glVertex3f(-1, 1, 0.0f);
286 //glScalef(.25,.25,.25);
288 glTexCoord2f(.4 + loadprogress / 100, 0 + loadprogress / 100);
289 glVertex3f(-1, -1, 0.0f);
290 glTexCoord2f(.4 + loadprogress / 100, 0 + loadprogress / 100);
291 glVertex3f(1, -1, 0.0f);
292 glTexCoord2f(.4 + loadprogress / 100, 1 + loadprogress / 100);
293 glVertex3f(1, 1, 0.0f);
294 glTexCoord2f(.4 + loadprogress / 100, 1 + loadprogress / 100);
295 glVertex3f(-1, 1, 0.0f);
298 glDisable(GL_TEXTURE_2D);
299 glMatrixMode(GL_PROJECTION);
301 glMatrixMode(GL_MODELVIEW);
306 glEnable(GL_TEXTURE_2D);
307 loadscreentexture.bind();
308 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
309 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
310 glDisable(GL_DEPTH_TEST);
311 glDisable(GL_CULL_FACE);
312 glDisable(GL_LIGHTING);
314 glMatrixMode(GL_PROJECTION);
317 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
318 glMatrixMode(GL_MODELVIEW);
321 glTranslatef(screenwidth / 2, screenheight / 2, 0);
322 glScalef((float)screenwidth / 2 * (1.5 - (loadprogress) / 200), (float)screenheight / 2 * (1.5 - (loadprogress) / 200), 1);
323 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
325 //glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
326 glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, 1);
328 //glScalef(.25,.25,.25);
330 glTexCoord2f(0 + .5, 0 + .5);
331 glVertex3f(-1, -1, 0.0f);
332 glTexCoord2f(1 + .5, 0 + .5);
333 glVertex3f(1, -1, 0.0f);
334 glTexCoord2f(1 + .5, 1 + .5);
335 glVertex3f(1, 1, 0.0f);
336 glTexCoord2f(0 + .5, 1 + .5);
337 glVertex3f(-1, 1, 0.0f);
340 glDisable(GL_TEXTURE_2D);
341 glMatrixMode(GL_PROJECTION);
343 glMatrixMode(GL_MODELVIEW);
348 glEnable(GL_TEXTURE_2D);
349 loadscreentexture.bind();
350 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
351 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
352 glDisable(GL_DEPTH_TEST);
353 glDisable(GL_CULL_FACE);
354 glDisable(GL_LIGHTING);
356 glMatrixMode(GL_PROJECTION);
359 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
360 glMatrixMode(GL_MODELVIEW);
363 glTranslatef(screenwidth / 2, screenheight / 2, 0);
364 glScalef((float)screenwidth / 2 * (100 + loadprogress) / 100, (float)screenheight / 2 * (100 + loadprogress) / 100, 1);
365 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
367 glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, .4);
369 //glScalef(.25,.25,.25);
371 glTexCoord2f(0 + .2, 0 + .8);
372 glVertex3f(-1, -1, 0.0f);
373 glTexCoord2f(1 + .2, 0 + .8);
374 glVertex3f(1, -1, 0.0f);
375 glTexCoord2f(1 + .2, 1 + .8);
376 glVertex3f(1, 1, 0.0f);
377 glTexCoord2f(0 + .2, 1 + .8);
378 glVertex3f(-1, 1, 0.0f);
381 glDisable(GL_TEXTURE_2D);
382 glMatrixMode(GL_PROJECTION);
384 glMatrixMode(GL_MODELVIEW);
391 if (flashamount > 0) {
395 flashamount -= multiplier;
399 glDisable(GL_DEPTH_TEST);
400 glDisable(GL_CULL_FACE);
401 glDisable(GL_LIGHTING);
402 glDisable(GL_TEXTURE_2D);
404 glMatrixMode(GL_PROJECTION);
407 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
408 glMatrixMode(GL_MODELVIEW);
411 glScalef(screenwidth, screenheight, 1);
412 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
414 glColor4f(flashr, flashg, flashb, flashamount);
416 glVertex3f(0, 0, 0.0f);
417 glVertex3f(256, 0, 0.0f);
418 glVertex3f(256, 256, 0.0f);
419 glVertex3f(0, 256, 0.0f);
421 glMatrixMode(GL_PROJECTION);
423 glMatrixMode(GL_MODELVIEW);
425 glEnable(GL_DEPTH_TEST);
426 glEnable(GL_CULL_FACE);
435 void FadeLoadingScreen(float howmuch)
437 static float loadprogress;
441 glClearColor(0, 0, 0, 1);
442 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
444 loadprogress = howmuch;
446 //loadprogress=abs(Random()%100);
450 //glEnable(GL_TEXTURE_2D);
451 glDisable(GL_TEXTURE_2D);
452 //glBindTexture( GL_TEXTURE_2D, loadscreentexture);
453 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
454 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
455 glDisable(GL_DEPTH_TEST);
456 glDisable(GL_CULL_FACE);
457 glDisable(GL_LIGHTING);
459 glMatrixMode(GL_PROJECTION);
462 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
463 glMatrixMode(GL_MODELVIEW);
466 glTranslatef(screenwidth / 2, screenheight / 2, 0);
467 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
468 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
470 glColor4f(loadprogress / 100, 0, 0, 1);
472 //glScalef(.25,.25,.25);
475 glVertex3f(-1, -1, 0.0f);
477 glVertex3f(1, -1, 0.0f);
479 glVertex3f(1, 1, 0.0f);
481 glVertex3f(-1, 1, 0.0f);
484 glDisable(GL_TEXTURE_2D);
485 glMatrixMode(GL_PROJECTION);
487 glMatrixMode(GL_MODELVIEW);
496 extern bool cmdline(const char *cmd);
498 void Game::InitGame()
501 ProcessSerialNumber PSN;
502 ProcessInfoRec pinfo;
505 /* set up process serial number */
506 PSN.highLongOfPSN = 0;
507 PSN.lowLongOfPSN = kCurrentProcess;
508 /* set up info block */
509 pinfo.processInfoLength = sizeof(pinfo);
510 pinfo.processName = NULL;
511 pinfo.processAppSpec = &pspec;
512 /* grab the vrefnum and directory */
513 err = GetProcessInformation(&PSN, &pinfo);
515 vRefNum = pspec.vRefNum;
522 numchallengelevels = 14;
524 accountactive = Account::loadFile(":Data:Users");
530 whichjointstartarray[0] = righthip;
531 whichjointendarray[0] = rightfoot;
533 whichjointstartarray[1] = righthip;
534 whichjointendarray[1] = rightankle;
536 whichjointstartarray[2] = righthip;
537 whichjointendarray[2] = rightknee;
539 whichjointstartarray[3] = rightknee;
540 whichjointendarray[3] = rightankle;
542 whichjointstartarray[4] = rightankle;
543 whichjointendarray[4] = rightfoot;
545 whichjointstartarray[5] = lefthip;
546 whichjointendarray[5] = leftfoot;
548 whichjointstartarray[6] = lefthip;
549 whichjointendarray[6] = leftankle;
551 whichjointstartarray[7] = lefthip;
552 whichjointendarray[7] = leftknee;
554 whichjointstartarray[8] = leftknee;
555 whichjointendarray[8] = leftankle;
557 whichjointstartarray[9] = leftankle;
558 whichjointendarray[9] = leftfoot;
560 whichjointstartarray[10] = abdomen;
561 whichjointendarray[10] = rightshoulder;
563 whichjointstartarray[11] = abdomen;
564 whichjointendarray[11] = rightelbow;
566 whichjointstartarray[12] = abdomen;
567 whichjointendarray[12] = rightwrist;
569 whichjointstartarray[13] = abdomen;
570 whichjointendarray[13] = righthand;
572 whichjointstartarray[14] = rightshoulder;
573 whichjointendarray[14] = rightelbow;
575 whichjointstartarray[15] = rightelbow;
576 whichjointendarray[15] = rightwrist;
578 whichjointstartarray[16] = rightwrist;
579 whichjointendarray[16] = righthand;
581 whichjointstartarray[17] = abdomen;
582 whichjointendarray[17] = leftshoulder;
584 whichjointstartarray[18] = abdomen;
585 whichjointendarray[18] = leftelbow;
587 whichjointstartarray[19] = abdomen;
588 whichjointendarray[19] = leftwrist;
590 whichjointstartarray[20] = abdomen;
591 whichjointendarray[20] = lefthand;
593 whichjointstartarray[21] = leftshoulder;
594 whichjointendarray[21] = leftelbow;
596 whichjointstartarray[22] = leftelbow;
597 whichjointendarray[22] = leftwrist;
599 whichjointstartarray[23] = leftwrist;
600 whichjointendarray[23] = lefthand;
602 whichjointstartarray[24] = abdomen;
603 whichjointendarray[24] = neck;
605 whichjointstartarray[25] = neck;
606 whichjointendarray[25] = head;
608 FadeLoadingScreen(0);
612 texture.data = ( GLubyte* )malloc( 1024 * 1024 * 4 );
614 int temptexdetail = texdetail;
616 text->LoadFontTexture(":Data:Textures:Font.png");
618 texdetail = temptexdetail;
620 FadeLoadingScreen(10);
632 LOG("Initializing sound system...");
635 unsigned char rc = 0;
636 int output = OPENAL_OUTPUT_ALSA; // Try alsa first...
637 if (cmdline("forceoss")) // ...but let user override that.
638 output = OPENAL_OUTPUT_OSS;
639 else if (cmdline("nosound"))
640 output = OPENAL_OUTPUT_NOSOUND;
642 OPENAL_SetOutput(output);
643 if ((rc = OPENAL_Init(44100, 32, 0)) == false) {
644 // if we tried ALSA and failed, fall back to OSS.
645 if ( (output == OPENAL_OUTPUT_ALSA) && (!cmdline("forcealsa")) ) {
647 output = OPENAL_OUTPUT_OSS;
648 OPENAL_SetOutput(output);
649 rc = OPENAL_Init(44100, 32, 0);
655 output = OPENAL_OUTPUT_NOSOUND; // we tried! just do silence.
656 OPENAL_SetOutput(output);
657 rc = OPENAL_Init(44100, 32, 0);
660 OPENAL_Init(44100, 32, 0);
663 OPENAL_SetSFXMasterVolume((int)(volume * 255));
667 emit_stream_np(stream_menutheme);
669 cursortexture.load(":Data:Textures:Cursor.png", 0, 1);
671 Mapcircletexture.load(":Data:Textures:MapCircle.png", 0, 1);
672 Mapboxtexture.load(":Data:Textures:MapBox.png", 0, 1);
673 Maparrowtexture.load(":Data:Textures:MapArrow.png", 0, 1);
675 temptexdetail = texdetail;
678 Mainmenuitems[0].load(":Data:Textures:Lugaru.png", 0, 0);
679 Mainmenuitems[1].load(":Data:Textures:Newgame.png", 0, 0);
680 Mainmenuitems[2].load(":Data:Textures:Options.png", 0, 0);
681 Mainmenuitems[3].load(":Data:Textures:Quit.png", 0, 0);
682 Mainmenuitems[4].load(":Data:Textures:Eyelid.png", 0, 1);
683 Mainmenuitems[5].load(":Data:Textures:Resume.png", 0, 0);
684 Mainmenuitems[6].load(":Data:Textures:Endgame.png", 0, 0);
686 //LoadTexture(":Data:Textures:Eye.jpg",&Mainmenuitems[5],0,1);
687 //~ LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0); // LoadCampaign will take care of that
688 texdetail = temptexdetail;
690 FadeLoadingScreen(95);
700 newscreenwidth = screenwidth;
701 newscreenheight = screenheight;
707 void Game::LoadScreenTexture()
709 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
711 if (!Game::screentexture)
712 glGenTextures( 1, &Game::screentexture );
713 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
716 glEnable(GL_TEXTURE_2D);
717 glBindTexture( GL_TEXTURE_2D, Game::screentexture);
718 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
719 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
721 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
724 //TODO: move LoadStuff() closer to GameTick.cpp to get rid of various vars shared in Game.h
725 void Game::LoadStuff()
727 static float temptexdetail;
728 static float viewdistdetail;
738 for (auto p:Person::players) {
739 p->skeleton.drawmodel.textureptr.destroy();
742 i = abs(Random() % 4);
743 visibleloading = 0; //don't use loadscreentexture yet
744 loadscreentexture.load(":Data:Textures:fire.jpg", 1, 0);
747 temptexdetail = texdetail;
749 text->LoadFontTexture(":Data:Textures:Font.png");
751 texdetail = temptexdetail;
756 viewdistance = 50 * megascale * viewdistdetail;
768 realtexdetail = texdetail;
770 LOG("Loading weapon data...");
772 Weapon::knifetextureptr.load(":Data:Textures:knife.png", 0, 1);
773 Weapon::bloodknifetextureptr.load(":Data:Textures:bloodknife.png", 0, 1);
774 Weapon::lightbloodknifetextureptr.load(":Data:Textures:lightbloodknife.png", 0, 1);
775 Weapon::swordtextureptr.load(":Data:Textures:sword.jpg", 1, 0);
776 Weapon::bloodswordtextureptr.load(":Data:Textures:Swordblood.jpg", 1, 0);
777 Weapon::lightbloodswordtextureptr.load(":Data:Textures:Swordbloodlight.jpg", 1, 0);
778 Weapon::stafftextureptr.load(":Data:Textures:Staff.jpg", 1, 0);
780 Weapon::throwingknifemodel.load((char *)":Data:Models:throwingknife.solid", 1);
781 Weapon::throwingknifemodel.Scale(.001, .001, .001);
782 //Weapon::throwingknifemodel.Rotate(0,0,-90);
783 Weapon::throwingknifemodel.Rotate(90, 0, 0);
784 Weapon::throwingknifemodel.Rotate(0, 90, 0);
785 Weapon::throwingknifemodel.flat = 0;
786 Weapon::throwingknifemodel.CalculateNormals(1);
787 //Weapon::throwingknifemodel.ScaleNormals(-1,-1,-1);
789 Weapon::swordmodel.load((char *)":Data:Models:sword.solid", 1);
790 Weapon::swordmodel.Scale(.001, .001, .001);
791 //Weapon::swordmodel.Rotate(0,0,-90);
792 Weapon::swordmodel.Rotate(90, 0, 0);
793 Weapon::swordmodel.Rotate(0, 90, 0);
794 Weapon::swordmodel.Rotate(0, 0, 90);
795 Weapon::swordmodel.flat = 1;
796 Weapon::swordmodel.CalculateNormals(1);
797 //Weapon::swordmodel.ScaleNormals(-1,-1,-1);
799 Weapon::staffmodel.load((char *)":Data:Models:staff.solid", 1);
800 Weapon::staffmodel.Scale(.005, .005, .005);
801 //Weapon::staffmodel.Rotate(0,0,-90);
802 Weapon::staffmodel.Rotate(90, 0, 0);
803 Weapon::staffmodel.Rotate(0, 90, 0);
804 Weapon::staffmodel.Rotate(0, 0, 90);
805 Weapon::staffmodel.flat = 1;
806 Weapon::staffmodel.CalculateNormals(1);
807 //Weapon::staffmodel.ScaleNormals(-1,-1,-1);
809 terrain.shadowtexture.load(":Data:Textures:shadow.png", 0, 1);
810 terrain.bloodtexture.load(":Data:Textures:blood.png", 0, 1);
811 terrain.breaktexture.load(":Data:Textures:break.png", 0, 1);
812 terrain.bloodtexture2.load(":Data:Textures:blood.png", 0, 1);
815 terrain.footprinttexture.load(":Data:Textures:footprint.png", 0, 1);
816 terrain.bodyprinttexture.load(":Data:Textures:bodyprint.png", 0, 1);
817 hawktexture.load(":Data:Textures:hawk.png", 0, 1);
820 Sprite::cloudtexture.load(":Data:Textures:cloud.png", 1, 1);
821 Sprite::cloudimpacttexture.load(":Data:Textures:cloudimpact.png", 1, 1);
822 Sprite::bloodtexture.load(":Data:Textures:bloodparticle.png", 1, 1);
823 Sprite::snowflaketexture.load(":Data:Textures:snowflake.png", 1, 1);
824 Sprite::flametexture.load(":Data:Textures:flame.png", 1, 1);
825 Sprite::bloodflametexture.load(":Data:Textures:bloodflame.png", 1, 1);
826 Sprite::smoketexture.load(":Data:Textures:smoke.png", 1, 1);
827 Sprite::shinetexture.load(":Data:Textures:shine.png", 1, 0);
828 Sprite::splintertexture.load(":Data:Textures:splinter.png", 1, 1);
829 Sprite::leaftexture.load(":Data:Textures:leaf.png", 1, 1);
830 Sprite::toothtexture.load(":Data:Textures:tooth.png", 1, 1);
834 ReSizeGLScene(90, .01);
846 //Set up distant light
847 light.color[0] = .95;
848 light.color[1] = .95;
850 light.ambient[0] = .2;
851 light.ambient[1] = .2;
852 light.ambient[2] = .24;
853 light.location.x = 1;
854 light.location.y = 1;
855 light.location.z = -.2;
856 Normalise(&light.location);
866 texscale = .2 / megascale / viewdistdetail;
867 terrain.scale = 3 * megascale * viewdistdetail;
869 viewer.x = terrain.size / 2 * terrain.scale;
870 viewer.z = terrain.size / 2 * terrain.scale;
872 hawk.load((char *)":Data:Models:hawk.solid", 1);
873 hawk.Scale(.03, .03, .03);
874 hawk.Rotate(90, 1, 1);
875 hawk.CalculateNormals(0);
876 hawk.ScaleNormals(-1, -1, -1);
877 hawkcoords.x = terrain.size / 2 * terrain.scale - 5 - 7;
878 hawkcoords.z = terrain.size / 2 * terrain.scale - 5 - 7;
879 hawkcoords.y = terrain.getHeight(hawkcoords.x, hawkcoords.z) + 25;
881 eye.load((char *)":Data:Models:eye.solid", 1);
882 eye.Scale(.03, .03, .03);
883 eye.CalculateNormals(0);
885 cornea.load((char *)":Data:Models:cornea.solid", 1);
886 cornea.Scale(.03, .03, .03);
887 cornea.CalculateNormals(0);
889 iris.load((char *)":Data:Models:iris.solid", 1);
890 iris.Scale(.03, .03, .03);
891 iris.CalculateNormals(0);
893 LoadSave(":Data:Textures:Bloodfur.png", 0, 1, &bloodText[0], 0);
894 LoadSave(":Data:Textures:Wolfbloodfur.png", 0, 1, &wolfbloodText[0], 0);
904 //Fix knife stab, too lazy to do it manually
908 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
909 for (j = 0; j < animation[knifesneakattackanim].numframes; j++) {
910 animation[knifesneakattackanim].position[i][j] += moveamount;
916 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
917 for (j = 0; j < animation[knifesneakattackedanim].numframes; j++) {
918 animation[knifesneakattackedanim].position[i][j] += moveamount;
924 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
925 animation[dead1anim].position[i][1] = animation[dead1anim].position[i][0];
926 animation[dead2anim].position[i][1] = animation[dead2anim].position[i][0];
927 animation[dead3anim].position[i][1] = animation[dead3anim].position[i][0];
928 animation[dead4anim].position[i][1] = animation[dead4anim].position[i][0];
930 animation[dead1anim].speed[0] = 0.001;
931 animation[dead2anim].speed[0] = 0.001;
932 animation[dead3anim].speed[0] = 0.001;
933 animation[dead4anim].speed[0] = 0.001;
935 animation[dead1anim].speed[1] = 0.001;
936 animation[dead2anim].speed[1] = 0.001;
937 animation[dead3anim].speed[1] = 0.001;
938 animation[dead4anim].speed[1] = 0.001;
940 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
941 for (j = 0; j < animation[swordsneakattackanim].numframes; j++) {
942 animation[swordsneakattackanim].position[i][j] += moveamount;
946 for (j = 0; j < animation[swordsneakattackanim].numframes; j++) {
947 animation[swordsneakattackanim].weapontarget[j] += moveamount;
952 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
953 for (j = 0; j < animation[swordsneakattackedanim].numframes; j++) {
954 animation[swordsneakattackedanim].position[i][j] += moveamount;
959 temptexdetail = texdetail;
961 texdetail = temptexdetail;
965 if (!screentexture) {
969 if (targetlevel != 7) {
970 emit_sound_at(fireendsound);