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 frametime = {0, 0};
218 AbsoluteTime currTime = UpTime ();
219 double deltaTime = (float) AbsoluteDeltaToDuration (currTime, frametime);
221 if (0 > deltaTime) // if negative microseconds
222 deltaTime /= -1000000.0;
223 else // else milliseconds
226 multiplier = deltaTime;
227 if (multiplier < .001)
231 if (multiplier > .05) {
232 frametime = currTime; // reset for next time interval
236 glClearColor(0, 0, 0, 1);
237 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
240 loadtime += multiplier * 4;
242 loadprogress = loadtime;
243 if (loadprogress > 100)
248 glEnable(GL_TEXTURE_2D);
249 loadscreentexture.bind();
250 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
251 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
252 glDisable(GL_DEPTH_TEST);
253 glDisable(GL_CULL_FACE);
254 glDisable(GL_LIGHTING);
256 glMatrixMode(GL_PROJECTION);
259 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
260 glMatrixMode(GL_MODELVIEW);
263 glTranslatef(screenwidth / 2, screenheight / 2, 0);
264 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
265 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
267 glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, 1);
270 glTexCoord2f(.1 - loadprogress / 100, 0 + loadprogress / 100 + .3);
271 glVertex3f(-1, -1, 0.0f);
272 glTexCoord2f(.1 - loadprogress / 100, 0 + loadprogress / 100 + .3);
273 glVertex3f(1, -1, 0.0f);
274 glTexCoord2f(.1 - loadprogress / 100, 1 + loadprogress / 100 + .3);
275 glVertex3f(1, 1, 0.0f);
276 glTexCoord2f(.1 - loadprogress / 100, 1 + loadprogress / 100 + .3);
277 glVertex3f(-1, 1, 0.0f);
283 glTexCoord2f(.4 + loadprogress / 100, 0 + loadprogress / 100);
284 glVertex3f(-1, -1, 0.0f);
285 glTexCoord2f(.4 + loadprogress / 100, 0 + loadprogress / 100);
286 glVertex3f(1, -1, 0.0f);
287 glTexCoord2f(.4 + loadprogress / 100, 1 + loadprogress / 100);
288 glVertex3f(1, 1, 0.0f);
289 glTexCoord2f(.4 + loadprogress / 100, 1 + loadprogress / 100);
290 glVertex3f(-1, 1, 0.0f);
293 glDisable(GL_TEXTURE_2D);
294 glMatrixMode(GL_PROJECTION);
296 glMatrixMode(GL_MODELVIEW);
301 glEnable(GL_TEXTURE_2D);
302 loadscreentexture.bind();
303 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
304 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
305 glDisable(GL_DEPTH_TEST);
306 glDisable(GL_CULL_FACE);
307 glDisable(GL_LIGHTING);
309 glMatrixMode(GL_PROJECTION);
312 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
313 glMatrixMode(GL_MODELVIEW);
316 glTranslatef(screenwidth / 2, screenheight / 2, 0);
317 glScalef((float)screenwidth / 2 * (1.5 - (loadprogress) / 200), (float)screenheight / 2 * (1.5 - (loadprogress) / 200), 1);
318 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
320 glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, 1);
323 glTexCoord2f(0 + .5, 0 + .5);
324 glVertex3f(-1, -1, 0.0f);
325 glTexCoord2f(1 + .5, 0 + .5);
326 glVertex3f(1, -1, 0.0f);
327 glTexCoord2f(1 + .5, 1 + .5);
328 glVertex3f(1, 1, 0.0f);
329 glTexCoord2f(0 + .5, 1 + .5);
330 glVertex3f(-1, 1, 0.0f);
333 glDisable(GL_TEXTURE_2D);
334 glMatrixMode(GL_PROJECTION);
336 glMatrixMode(GL_MODELVIEW);
341 glEnable(GL_TEXTURE_2D);
342 loadscreentexture.bind();
343 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
344 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
345 glDisable(GL_DEPTH_TEST);
346 glDisable(GL_CULL_FACE);
347 glDisable(GL_LIGHTING);
349 glMatrixMode(GL_PROJECTION);
352 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
353 glMatrixMode(GL_MODELVIEW);
356 glTranslatef(screenwidth / 2, screenheight / 2, 0);
357 glScalef((float)screenwidth / 2 * (100 + loadprogress) / 100, (float)screenheight / 2 * (100 + loadprogress) / 100, 1);
358 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
360 glColor4f(loadprogress / 100, loadprogress / 100, loadprogress / 100, .4);
363 glTexCoord2f(0 + .2, 0 + .8);
364 glVertex3f(-1, -1, 0.0f);
365 glTexCoord2f(1 + .2, 0 + .8);
366 glVertex3f(1, -1, 0.0f);
367 glTexCoord2f(1 + .2, 1 + .8);
368 glVertex3f(1, 1, 0.0f);
369 glTexCoord2f(0 + .2, 1 + .8);
370 glVertex3f(-1, 1, 0.0f);
373 glDisable(GL_TEXTURE_2D);
374 glMatrixMode(GL_PROJECTION);
376 glMatrixMode(GL_MODELVIEW);
383 if (flashamount > 0) {
387 flashamount -= multiplier;
391 glDisable(GL_DEPTH_TEST);
392 glDisable(GL_CULL_FACE);
393 glDisable(GL_LIGHTING);
394 glDisable(GL_TEXTURE_2D);
396 glMatrixMode(GL_PROJECTION);
399 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
400 glMatrixMode(GL_MODELVIEW);
403 glScalef(screenwidth, screenheight, 1);
404 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
406 glColor4f(flashr, flashg, flashb, flashamount);
408 glVertex3f(0, 0, 0.0f);
409 glVertex3f(256, 0, 0.0f);
410 glVertex3f(256, 256, 0.0f);
411 glVertex3f(0, 256, 0.0f);
413 glMatrixMode(GL_PROJECTION);
415 glMatrixMode(GL_MODELVIEW);
417 glEnable(GL_DEPTH_TEST);
418 glEnable(GL_CULL_FACE);
427 void FadeLoadingScreen(float howmuch)
429 static float loadprogress;
433 glClearColor(0, 0, 0, 1);
434 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
436 loadprogress = howmuch;
440 glDisable(GL_TEXTURE_2D);
441 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
442 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
443 glDisable(GL_DEPTH_TEST);
444 glDisable(GL_CULL_FACE);
445 glDisable(GL_LIGHTING);
447 glMatrixMode(GL_PROJECTION);
450 glOrtho(0, screenwidth, 0, screenheight, -100, 100);
451 glMatrixMode(GL_MODELVIEW);
454 glTranslatef(screenwidth / 2, screenheight / 2, 0);
455 glScalef((float)screenwidth / 2, (float)screenheight / 2, 1);
456 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
458 glColor4f(loadprogress / 100, 0, 0, 1);
462 glVertex3f(-1, -1, 0.0f);
464 glVertex3f(1, -1, 0.0f);
466 glVertex3f(1, 1, 0.0f);
468 glVertex3f(-1, 1, 0.0f);
471 glDisable(GL_TEXTURE_2D);
472 glMatrixMode(GL_PROJECTION);
474 glMatrixMode(GL_MODELVIEW);
483 extern bool cmdline(const char *cmd);
485 void Game::InitGame()
488 ProcessSerialNumber PSN;
489 ProcessInfoRec pinfo;
492 /* set up process serial number */
493 PSN.highLongOfPSN = 0;
494 PSN.lowLongOfPSN = kCurrentProcess;
495 /* set up info block */
496 pinfo.processInfoLength = sizeof(pinfo);
497 pinfo.processName = NULL;
498 pinfo.processAppSpec = &pspec;
499 /* grab the vrefnum and directory */
500 err = GetProcessInformation(&PSN, &pinfo);
502 vRefNum = pspec.vRefNum;
509 numchallengelevels = 14;
511 accountactive = Account::loadFile(":Data:Users");
517 whichjointstartarray[0] = righthip;
518 whichjointendarray[0] = rightfoot;
520 whichjointstartarray[1] = righthip;
521 whichjointendarray[1] = rightankle;
523 whichjointstartarray[2] = righthip;
524 whichjointendarray[2] = rightknee;
526 whichjointstartarray[3] = rightknee;
527 whichjointendarray[3] = rightankle;
529 whichjointstartarray[4] = rightankle;
530 whichjointendarray[4] = rightfoot;
532 whichjointstartarray[5] = lefthip;
533 whichjointendarray[5] = leftfoot;
535 whichjointstartarray[6] = lefthip;
536 whichjointendarray[6] = leftankle;
538 whichjointstartarray[7] = lefthip;
539 whichjointendarray[7] = leftknee;
541 whichjointstartarray[8] = leftknee;
542 whichjointendarray[8] = leftankle;
544 whichjointstartarray[9] = leftankle;
545 whichjointendarray[9] = leftfoot;
547 whichjointstartarray[10] = abdomen;
548 whichjointendarray[10] = rightshoulder;
550 whichjointstartarray[11] = abdomen;
551 whichjointendarray[11] = rightelbow;
553 whichjointstartarray[12] = abdomen;
554 whichjointendarray[12] = rightwrist;
556 whichjointstartarray[13] = abdomen;
557 whichjointendarray[13] = righthand;
559 whichjointstartarray[14] = rightshoulder;
560 whichjointendarray[14] = rightelbow;
562 whichjointstartarray[15] = rightelbow;
563 whichjointendarray[15] = rightwrist;
565 whichjointstartarray[16] = rightwrist;
566 whichjointendarray[16] = righthand;
568 whichjointstartarray[17] = abdomen;
569 whichjointendarray[17] = leftshoulder;
571 whichjointstartarray[18] = abdomen;
572 whichjointendarray[18] = leftelbow;
574 whichjointstartarray[19] = abdomen;
575 whichjointendarray[19] = leftwrist;
577 whichjointstartarray[20] = abdomen;
578 whichjointendarray[20] = lefthand;
580 whichjointstartarray[21] = leftshoulder;
581 whichjointendarray[21] = leftelbow;
583 whichjointstartarray[22] = leftelbow;
584 whichjointendarray[22] = leftwrist;
586 whichjointstartarray[23] = leftwrist;
587 whichjointendarray[23] = lefthand;
589 whichjointstartarray[24] = abdomen;
590 whichjointendarray[24] = neck;
592 whichjointstartarray[25] = neck;
593 whichjointendarray[25] = head;
595 FadeLoadingScreen(0);
599 texture.data = ( GLubyte* )malloc( 1024 * 1024 * 4 );
601 int temptexdetail = texdetail;
603 text->LoadFontTexture(":Data:Textures:Font.png");
605 texdetail = temptexdetail;
607 FadeLoadingScreen(10);
619 LOG("Initializing sound system...");
622 unsigned char rc = 0;
623 int output = OPENAL_OUTPUT_ALSA; // Try alsa first...
624 if (cmdline("forceoss")) // ...but let user override that.
625 output = OPENAL_OUTPUT_OSS;
626 else if (cmdline("nosound"))
627 output = OPENAL_OUTPUT_NOSOUND;
629 OPENAL_SetOutput(output);
630 if ((rc = OPENAL_Init(44100, 32, 0)) == false) {
631 // if we tried ALSA and failed, fall back to OSS.
632 if ( (output == OPENAL_OUTPUT_ALSA) && (!cmdline("forcealsa")) ) {
634 output = OPENAL_OUTPUT_OSS;
635 OPENAL_SetOutput(output);
636 rc = OPENAL_Init(44100, 32, 0);
642 output = OPENAL_OUTPUT_NOSOUND; // we tried! just do silence.
643 OPENAL_SetOutput(output);
644 rc = OPENAL_Init(44100, 32, 0);
647 OPENAL_Init(44100, 32, 0);
650 OPENAL_SetSFXMasterVolume((int)(volume * 255));
654 emit_stream_np(stream_menutheme);
656 cursortexture.load(":Data:Textures:Cursor.png", 0, 1);
658 Mapcircletexture.load(":Data:Textures:MapCircle.png", 0, 1);
659 Mapboxtexture.load(":Data:Textures:MapBox.png", 0, 1);
660 Maparrowtexture.load(":Data:Textures:MapArrow.png", 0, 1);
662 temptexdetail = texdetail;
665 Mainmenuitems[0].load(":Data:Textures:Lugaru.png", 0, 0);
666 Mainmenuitems[1].load(":Data:Textures:Newgame.png", 0, 0);
667 Mainmenuitems[2].load(":Data:Textures:Options.png", 0, 0);
668 Mainmenuitems[3].load(":Data:Textures:Quit.png", 0, 0);
669 Mainmenuitems[4].load(":Data:Textures:Eyelid.png", 0, 1);
670 Mainmenuitems[5].load(":Data:Textures:Resume.png", 0, 0);
671 Mainmenuitems[6].load(":Data:Textures:Endgame.png", 0, 0);
673 //LoadTexture(":Data:Textures:Eye.jpg",&Mainmenuitems[5],0,1);
674 //~ LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0); // LoadCampaign will take care of that
675 texdetail = temptexdetail;
677 FadeLoadingScreen(95);
687 newscreenwidth = screenwidth;
688 newscreenheight = screenheight;
694 void Game::LoadScreenTexture()
696 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
698 if (!Game::screentexture)
699 glGenTextures( 1, &Game::screentexture );
700 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
703 glEnable(GL_TEXTURE_2D);
704 glBindTexture( GL_TEXTURE_2D, Game::screentexture);
705 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
706 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
708 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
711 //TODO: move LoadStuff() closer to GameTick.cpp to get rid of various vars shared in Game.h
712 void Game::LoadStuff()
714 static float temptexdetail;
715 static float viewdistdetail;
725 for (auto p:Person::players) {
726 p->skeleton.drawmodel.textureptr.destroy();
729 i = abs(Random() % 4);
730 visibleloading = 0; //don't use loadscreentexture yet
731 loadscreentexture.load(":Data:Textures:fire.jpg", 1, 0);
734 temptexdetail = texdetail;
736 text->LoadFontTexture(":Data:Textures:Font.png");
738 texdetail = temptexdetail;
743 viewdistance = 50 * megascale * viewdistdetail;
755 realtexdetail = texdetail;
757 LOG("Loading weapon data...");
759 Weapon::knifetextureptr.load(":Data:Textures:knife.png", 0, 1);
760 Weapon::bloodknifetextureptr.load(":Data:Textures:bloodknife.png", 0, 1);
761 Weapon::lightbloodknifetextureptr.load(":Data:Textures:lightbloodknife.png", 0, 1);
762 Weapon::swordtextureptr.load(":Data:Textures:sword.jpg", 1, 0);
763 Weapon::bloodswordtextureptr.load(":Data:Textures:Swordblood.jpg", 1, 0);
764 Weapon::lightbloodswordtextureptr.load(":Data:Textures:Swordbloodlight.jpg", 1, 0);
765 Weapon::stafftextureptr.load(":Data:Textures:Staff.jpg", 1, 0);
767 Weapon::throwingknifemodel.load((char *)":Data:Models:throwingknife.solid", 1);
768 Weapon::throwingknifemodel.Scale(.001, .001, .001);
769 //Weapon::throwingknifemodel.Rotate(0,0,-90);
770 Weapon::throwingknifemodel.Rotate(90, 0, 0);
771 Weapon::throwingknifemodel.Rotate(0, 90, 0);
772 Weapon::throwingknifemodel.flat = 0;
773 Weapon::throwingknifemodel.CalculateNormals(1);
774 //Weapon::throwingknifemodel.ScaleNormals(-1,-1,-1);
776 Weapon::swordmodel.load((char *)":Data:Models:sword.solid", 1);
777 Weapon::swordmodel.Scale(.001, .001, .001);
778 //Weapon::swordmodel.Rotate(0,0,-90);
779 Weapon::swordmodel.Rotate(90, 0, 0);
780 Weapon::swordmodel.Rotate(0, 90, 0);
781 Weapon::swordmodel.Rotate(0, 0, 90);
782 Weapon::swordmodel.flat = 1;
783 Weapon::swordmodel.CalculateNormals(1);
784 //Weapon::swordmodel.ScaleNormals(-1,-1,-1);
786 Weapon::staffmodel.load((char *)":Data:Models:staff.solid", 1);
787 Weapon::staffmodel.Scale(.005, .005, .005);
788 //Weapon::staffmodel.Rotate(0,0,-90);
789 Weapon::staffmodel.Rotate(90, 0, 0);
790 Weapon::staffmodel.Rotate(0, 90, 0);
791 Weapon::staffmodel.Rotate(0, 0, 90);
792 Weapon::staffmodel.flat = 1;
793 Weapon::staffmodel.CalculateNormals(1);
794 //Weapon::staffmodel.ScaleNormals(-1,-1,-1);
796 terrain.shadowtexture.load(":Data:Textures:shadow.png", 0, 1);
797 terrain.bloodtexture.load(":Data:Textures:blood.png", 0, 1);
798 terrain.breaktexture.load(":Data:Textures:break.png", 0, 1);
799 terrain.bloodtexture2.load(":Data:Textures:blood.png", 0, 1);
802 terrain.footprinttexture.load(":Data:Textures:footprint.png", 0, 1);
803 terrain.bodyprinttexture.load(":Data:Textures:bodyprint.png", 0, 1);
804 hawktexture.load(":Data:Textures:hawk.png", 0, 1);
807 Sprite::cloudtexture.load(":Data:Textures:cloud.png", 1, 1);
808 Sprite::cloudimpacttexture.load(":Data:Textures:cloudimpact.png", 1, 1);
809 Sprite::bloodtexture.load(":Data:Textures:bloodparticle.png", 1, 1);
810 Sprite::snowflaketexture.load(":Data:Textures:snowflake.png", 1, 1);
811 Sprite::flametexture.load(":Data:Textures:flame.png", 1, 1);
812 Sprite::bloodflametexture.load(":Data:Textures:bloodflame.png", 1, 1);
813 Sprite::smoketexture.load(":Data:Textures:smoke.png", 1, 1);
814 Sprite::shinetexture.load(":Data:Textures:shine.png", 1, 0);
815 Sprite::splintertexture.load(":Data:Textures:splinter.png", 1, 1);
816 Sprite::leaftexture.load(":Data:Textures:leaf.png", 1, 1);
817 Sprite::toothtexture.load(":Data:Textures:tooth.png", 1, 1);
821 ReSizeGLScene(90, .01);
833 //Set up distant light
834 light.color[0] = .95;
835 light.color[1] = .95;
837 light.ambient[0] = .2;
838 light.ambient[1] = .2;
839 light.ambient[2] = .24;
840 light.location.x = 1;
841 light.location.y = 1;
842 light.location.z = -.2;
843 Normalise(&light.location);
853 texscale = .2 / megascale / viewdistdetail;
854 terrain.scale = 3 * megascale * viewdistdetail;
856 viewer.x = terrain.size / 2 * terrain.scale;
857 viewer.z = terrain.size / 2 * terrain.scale;
859 hawk.load((char *)":Data:Models:hawk.solid", 1);
860 hawk.Scale(.03, .03, .03);
861 hawk.Rotate(90, 1, 1);
862 hawk.CalculateNormals(0);
863 hawk.ScaleNormals(-1, -1, -1);
864 hawkcoords.x = terrain.size / 2 * terrain.scale - 5 - 7;
865 hawkcoords.z = terrain.size / 2 * terrain.scale - 5 - 7;
866 hawkcoords.y = terrain.getHeight(hawkcoords.x, hawkcoords.z) + 25;
868 eye.load((char *)":Data:Models:eye.solid", 1);
869 eye.Scale(.03, .03, .03);
870 eye.CalculateNormals(0);
872 cornea.load((char *)":Data:Models:cornea.solid", 1);
873 cornea.Scale(.03, .03, .03);
874 cornea.CalculateNormals(0);
876 iris.load((char *)":Data:Models:iris.solid", 1);
877 iris.Scale(.03, .03, .03);
878 iris.CalculateNormals(0);
880 LoadSave(":Data:Textures:Bloodfur.png", 0, 1, &bloodText[0], 0);
881 LoadSave(":Data:Textures:Wolfbloodfur.png", 0, 1, &wolfbloodText[0], 0);
891 //Fix knife stab, too lazy to do it manually
895 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
896 for (j = 0; j < animation[knifesneakattackanim].numframes; j++) {
897 animation[knifesneakattackanim].position[i][j] += moveamount;
903 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
904 for (j = 0; j < animation[knifesneakattackedanim].numframes; j++) {
905 animation[knifesneakattackedanim].position[i][j] += moveamount;
911 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
912 animation[dead1anim].position[i][1] = animation[dead1anim].position[i][0];
913 animation[dead2anim].position[i][1] = animation[dead2anim].position[i][0];
914 animation[dead3anim].position[i][1] = animation[dead3anim].position[i][0];
915 animation[dead4anim].position[i][1] = animation[dead4anim].position[i][0];
917 animation[dead1anim].speed[0] = 0.001;
918 animation[dead2anim].speed[0] = 0.001;
919 animation[dead3anim].speed[0] = 0.001;
920 animation[dead4anim].speed[0] = 0.001;
922 animation[dead1anim].speed[1] = 0.001;
923 animation[dead2anim].speed[1] = 0.001;
924 animation[dead3anim].speed[1] = 0.001;
925 animation[dead4anim].speed[1] = 0.001;
927 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
928 for (j = 0; j < animation[swordsneakattackanim].numframes; j++) {
929 animation[swordsneakattackanim].position[i][j] += moveamount;
933 for (j = 0; j < animation[swordsneakattackanim].numframes; j++) {
934 animation[swordsneakattackanim].weapontarget[j] += moveamount;
939 for (i = 0; i < Person::players[0]->skeleton.num_joints; i++) {
940 for (j = 0; j < animation[swordsneakattackedanim].numframes; j++) {
941 animation[swordsneakattackedanim].position[i][j] += moveamount;
946 temptexdetail = texdetail;
948 texdetail = temptexdetail;
952 if (!screentexture) {
956 if (targetlevel != 7) {
957 emit_sound_at(fireendsound);