+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+
+This file is part of Lugaru.
+
+Lugaru is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
/**> HEADER FILES <**/
+#include "Game.h"
#include "Skeleton.h"
+#include "openal_wrapper.h"
extern float multiplier;
extern float gravity;
extern Skeleton testskeleton;
extern Terrain terrain;
-extern FSOUND_SAMPLE *samp[100];
+extern OPENAL_SAMPLE *samp[100];
extern int channels[100];
extern Objects objects;
extern Sprites sprites;
extern int whichjointstartarray[26];
extern int whichjointendarray[26];
-#include "Game.h"
extern Game * pgame;
extern bool visibleloading;
-extern "C" void PlaySoundEx(int channel, FSOUND_SAMPLE *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused);
+extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
void dealloc2(void* param){
free(param);
objects.SphereCheckPossible(&terrainlight, 1);
/*
for(i=0; i<num_joints; i++){
- oldpos[i]=joints[i].position;
+ oldpos[i]=joints[i].position;
}*/
//Add velocity
//if(!isnormal(joints[i].velocity.x)||!isnormal(joints[i].velocity.y)||!isnormal(joints[i].velocity.z))joints[i].velocity=0;
joints[i].position=joints[i].position+joints[i].velocity*multiplier;
groundlevel=.15;
- if(joints[i].label==head)groundlevel=.8;
- if(joints[i].label==righthand||joints[i].label==rightwrist||joints[i].label==rightelbow)groundlevel=.2;
- if(joints[i].label==lefthand||joints[i].label==leftwrist||joints[i].label==leftelbow)groundlevel=.2;
+ if(joints[i].label==head)groundlevel=.8;
+ if(joints[i].label==righthand||joints[i].label==rightwrist||joints[i].label==rightelbow)groundlevel=.2;
+ if(joints[i].label==lefthand||joints[i].label==leftwrist||joints[i].label==leftelbow)groundlevel=.2;
joints[i].position.y-=groundlevel;
//if(!joints[i].locked&&!broken)joints[i].velocity+=joints[i].velchange*multiplier*10*(500-longdead)/500;
joints[i].oldvelocity=joints[i].velocity;
vel[0]=joints[jointlabels[head]].velocity.x;
vel[1]=joints[jointlabels[head]].velocity.y;
vel[2]=joints[jointlabels[head]].velocity.z;
- PlaySoundEx( landsound1, samp[landsound1], NULL, TRUE);
- FSOUND_3D_SetAttributes(channels[landsound1], gLoc, vel);
- FSOUND_SetVolume(channels[landsound1], 128);
- FSOUND_SetPaused(channels[landsound1], FALSE);
+ PlaySoundEx( landsound1, samp[landsound1], NULL, true);
+ OPENAL_3D_SetAttributes(channels[landsound1], gLoc, vel);
+ OPENAL_SetVolume(channels[landsound1], 128);
+ OPENAL_SetPaused(channels[landsound1], false);
breaking=1;
}
vel[0]=joints[jointlabels[head]].velocity.x;
vel[1]=joints[jointlabels[head]].velocity.y;
vel[2]=joints[jointlabels[head]].velocity.z;
- PlaySoundEx( landsound2, samp[landsound2], NULL, TRUE);
- FSOUND_3D_SetAttributes(channels[landsound2], gLoc, vel);
- FSOUND_SetVolume(channels[landsound2], 128);
- FSOUND_SetPaused(channels[landsound2], FALSE);
+ PlaySoundEx( landsound2, samp[landsound2], NULL, true);
+ OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
+ OPENAL_SetVolume(channels[landsound2], 128);
+ OPENAL_SetPaused(channels[landsound2], false);
}
terrainnormal=DoRotation(objects.model[k].facenormals[whichhit],0,objects.rotation[k],0)*-1;
vel[0]=joints[jointlabels[head]].velocity.x;
vel[1]=joints[jointlabels[head]].velocity.y;
vel[2]=joints[jointlabels[head]].velocity.z;
- PlaySoundEx( breaksound2, samp[breaksound2], NULL, TRUE);
- FSOUND_3D_SetAttributes(channels[breaksound2], gLoc, vel);
- FSOUND_SetVolume(channels[breaksound2], 300);
- FSOUND_SetPaused(channels[breaksound2], FALSE);
+ PlaySoundEx( breaksound2, samp[breaksound2], NULL, true);
+ OPENAL_3D_SetAttributes(channels[breaksound2], gLoc, vel);
+ OPENAL_SetVolume(channels[breaksound2], 300);
+ OPENAL_SetPaused(channels[breaksound2], false);
envsound[numenvsounds]=*coords;
envsoundvol[numenvsounds]=64;
vel[1]=joints[i].velocity.y;
vel[2]=joints[i].velocity.z;
if(tutoriallevel!=1||id==0){
- PlaySoundEx( landsound1, samp[landsound1], NULL, TRUE);
- FSOUND_3D_SetAttributes(channels[landsound1], gLoc, vel);
- FSOUND_SetVolume(channels[landsound1], 128);
- FSOUND_SetPaused(channels[landsound1], FALSE);
+ PlaySoundEx( landsound1, samp[landsound1], NULL, true);
+ OPENAL_3D_SetAttributes(channels[landsound1], gLoc, vel);
+ OPENAL_SetVolume(channels[landsound1], 128);
+ OPENAL_SetPaused(channels[landsound1], false);
}
breaking=1;
}
vel[1]=joints[i].velocity.y;
vel[2]=joints[i].velocity.z;
if(tutoriallevel!=1||id==0){
- PlaySoundEx( landsound2, samp[landsound2], NULL, TRUE);
- FSOUND_3D_SetAttributes(channels[landsound2], gLoc, vel);
- FSOUND_SetVolume(channels[landsound2], 128);
- FSOUND_SetPaused(channels[landsound2], FALSE);
+ PlaySoundEx( landsound2, samp[landsound2], NULL, true);
+ OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
+ OPENAL_SetVolume(channels[landsound2], 128);
+ OPENAL_SetPaused(channels[landsound2], false);
}
}
vel[0]=joints[i].velocity.x;
vel[1]=joints[i].velocity.y;
vel[2]=joints[i].velocity.z;
- PlaySoundEx( breaksound2, samp[breaksound2], NULL, TRUE);
- FSOUND_3D_SetAttributes(channels[breaksound2], gLoc, vel);
- FSOUND_SetVolume(channels[breaksound2], 300);
- FSOUND_SetPaused(channels[breaksound2], FALSE);
+ PlaySoundEx( breaksound2, samp[breaksound2], NULL, true);
+ OPENAL_3D_SetAttributes(channels[breaksound2], gLoc, vel);
+ OPENAL_SetVolume(channels[breaksound2], 300);
+ OPENAL_SetPaused(channels[breaksound2], false);
envsound[numenvsounds]=*coords;
envsoundvol[numenvsounds]=64;
if(findLengthfast(&bounceness)>2500){
Normalise(&bounceness);
bounceness=bounceness*50;
- }
+ }
joints[i].velocity+=bounceness*elasticity;
vel[1]=joints[i].velocity.y;
vel[2]=joints[i].velocity.z;
if(tutoriallevel!=1||id==0){
- PlaySoundEx( landsound1, samp[landsound1], NULL, TRUE);
- FSOUND_3D_SetAttributes(channels[landsound1], gLoc, vel);
- FSOUND_SetVolume(channels[landsound1], 128);
- FSOUND_SetPaused(channels[landsound1], FALSE);
+ PlaySoundEx( landsound1, samp[landsound1], NULL, true);
+ OPENAL_3D_SetAttributes(channels[landsound1], gLoc, vel);
+ OPENAL_SetVolume(channels[landsound1], 128);
+ OPENAL_SetPaused(channels[landsound1], false);
}
breaking=1;
}
vel[1]=joints[i].velocity.y;
vel[2]=joints[i].velocity.z;
if(tutoriallevel!=1||id==0){
- PlaySoundEx( landsound2, samp[landsound2], NULL, TRUE);
- FSOUND_3D_SetAttributes(channels[landsound2], gLoc, vel);
- FSOUND_SetVolume(channels[landsound2], 128);
- FSOUND_SetPaused(channels[landsound2], FALSE);
+ PlaySoundEx( landsound2, samp[landsound2], NULL, true);
+ OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
+ OPENAL_SetVolume(channels[landsound2], 128);
+ OPENAL_SetPaused(channels[landsound2], false);
}
}
vel[0]=joints[i].velocity.x;
vel[1]=joints[i].velocity.y;
vel[2]=joints[i].velocity.z;
- PlaySoundEx( breaksound2, samp[breaksound2], NULL, TRUE);
- FSOUND_3D_SetAttributes(channels[breaksound2], gLoc, vel);
- FSOUND_SetVolume(channels[breaksound2], 300);
- FSOUND_SetPaused(channels[breaksound2], FALSE);
+ PlaySoundEx( breaksound2, samp[breaksound2], NULL, true);
+ OPENAL_3D_SetAttributes(channels[breaksound2], gLoc, vel);
+ OPENAL_SetVolume(channels[breaksound2], 300);
+ OPENAL_SetPaused(channels[breaksound2], false);
envsound[numenvsounds]=*coords;
envsoundvol[numenvsounds]=64;
for(i=0; i<num_joints; i++){
groundlevel=.15;
- if(joints[i].label==head)groundlevel=.8;
- if(joints[i].label==righthand||joints[i].label==rightwrist||joints[i].label==rightelbow)groundlevel=.2;
- if(joints[i].label==lefthand||joints[i].label==leftwrist||joints[i].label==leftelbow)groundlevel=.2;
+ if(joints[i].label==head)groundlevel=.8;
+ if(joints[i].label==righthand||joints[i].label==rightwrist||joints[i].label==rightelbow)groundlevel=.2;
+ if(joints[i].label==lefthand||joints[i].label==leftwrist||joints[i].label==leftelbow)groundlevel=.2;
joints[i].position.y+=groundlevel;
joints[i].mass=1;
if(joints[i].label==lefthip||joints[i].label==leftknee||joints[i].label==leftankle||joints[i].label==righthip||joints[i].label==rightknee||joints[i].label==rightankle)joints[i].mass=2;
glVertex3f(muscles[i].parent1->position.x,muscles[i].parent1->position.y,muscles[i].parent1->position.z);
glVertex3f(muscles[i].parent2->position.x,muscles[i].parent2->position.y,muscles[i].parent2->position.z);
}
- }
+ }
glEnd();
if(muscleview!=2){
joints[whichjoint].parent=&joints[which];
joints[whichjoint].hasparent=1;
joints[whichjoint].length=findDistance(&joints[whichjoint].position,&joints[whichjoint].parent->position);
- }
+ }
}
}
funpackf(tfile, "Bf Bf Bf", &weapontarget[i].x,&weapontarget[i].y,&weapontarget[i].z);
}
- fclose(tfile);
+ fclose(tfile);
}
startoffset=0;
funpackf(tfile, "Bi", &lowforwardjoints[j]);
}
for(j=0;j<num_muscles;j++){
- for(i=0;i<muscles[j].numvertices;i++){
- for(int k=0;k<num_models;k++){
+ for(i=0;i<muscles[j].numvertices;i++){
+ for(int k=0;k<num_models;k++){
if(muscles[j].numvertices&&muscles[j].vertices[i]<model[k].vertexNum)model[k].owner[muscles[j].vertices[i]]=j;
}
}
model[k].CalculateNormals(0);
}
}
- fclose(tfile);
+ fclose(tfile);
tfile=fopen( lowfilename, "rb" );
if(1){
}
lSize=sizeof(int);
for(j=0;j<num_muscles;j++){
- for(i=0;i<muscles[j].numverticeslow;i++){
+ for(i=0;i<muscles[j].numverticeslow;i++){
if(muscles[j].numverticeslow&&muscles[j].verticeslow[i]<modellow.vertexNum)modellow.owner[muscles[j].verticeslow[i]]=j;
}
}
}
lSize=sizeof(int);
for(j=0;j<num_muscles;j++){
- for(i=0;i<muscles[j].numverticesclothes;i++){
+ for(i=0;i<muscles[j].numverticesclothes;i++){
if(muscles[j].numverticesclothes&&muscles[j].verticesclothes[i]<modelclothes.vertexNum)modelclothes.owner[muscles[j].verticesclothes[i]]=j;
}
}
}
modelclothes.CalculateNormals(0);
}
- fclose(tfile);
+ fclose(tfile);
for(i=0;i<num_joints;i++){
for(j=0;j<num_joints;j++){