Revision: 1630
http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=1630&view=rev
Author: rorthomas
Date: 2011-02-01 23:44:06 +0000 (Tue, 01 Feb 2011)
Log Message:
-----------
* added ability to disable shadows for props:
http://www.rigsofrods.com/wiki/pages/Truck_Description_File#Props
* added soundsources2: ability to enable/disable sounds depending on the camera
view (great for interior sounds):
http://www.rigsofrods.com/wiki/pages/Truck_Description_File#Soundsources2
Modified Paths:
--------------
trunk/source/main/Beam.cpp
trunk/source/main/Beam.h
trunk/source/main/BeamData.h
trunk/source/main/BeamLoadTruck.cpp
trunk/source/main/RoRFrameListener.cpp
trunk/source/main/RoRPrerequisites.h
trunk/source/main/SoundManager.cpp
trunk/source/main/SoundManager.h
trunk/source/main/SoundScriptManager.cpp
trunk/source/main/SoundScriptManager.h
Modified: trunk/source/main/Beam.cpp
===================================================================
--- trunk/source/main/Beam.cpp 2011-02-01 12:56:24 UTC (rev 1629)
+++ trunk/source/main/Beam.cpp 2011-02-01 23:44:06 UTC (rev 1630)
@@ -520,7 +520,7 @@
if (networked) state=NETWORKED; //required for proper loading
sleepcount=0;
freecinecamera=0;
- currentcamera=0;
+ currentcamera=-1; // -1 = external
cinecameranodepos[0]=-1;
cameranodepos[0]=-1;
cameranodedir[0]=-1;
@@ -1399,7 +1399,7 @@
return free_node-first_wheel_node;
}
-void Beam::addSoundSource(SoundScriptInstance *ssi, int nodenum)
+void Beam::addSoundSource(SoundScriptInstance *ssi, int nodenum, int type)
{
if (!ssi) return; //fizzle
if (free_soundsource==MAX_SOUNDSCRIPTS_PER_TRUCK)
@@ -1409,6 +1409,7 @@
}
soundsources[free_soundsource].ssi=ssi;
soundsources[free_soundsource].nodenum=nodenum;
+ soundsources[free_soundsource].type=type;
free_soundsource++;
}
@@ -5568,6 +5569,21 @@
return NULL;
}
+void Beam::changedCamera()
+{
+ // change sound setup
+#ifdef USE_OPENAL
+ if(ssm)
+ {
+ for (int i=0; i<free_soundsource; i++)
+ {
+ bool enabled = (soundsources[i].type == -2 ||
soundsources[i].type == currentcamera);
+ soundsources[i].ssi->setEnabled(enabled);
+ }
+ }
+#endif //OPENAL
+}
+
//Returns the number of active (non bounded) beams connected to a node
int Beam::nodeBeamConnections(int nodeid)
{
Modified: trunk/source/main/Beam.h
===================================================================
--- trunk/source/main/Beam.h 2011-02-01 12:56:24 UTC (rev 1629)
+++ trunk/source/main/Beam.h 2011-02-01 23:44:06 UTC (rev 1630)
@@ -208,7 +208,7 @@
//! @{ audio related functions
void setupDefaultSoundSources();
- void addSoundSource(SoundScriptInstance *ssi, int nodenum);
+ void addSoundSource(SoundScriptInstance *ssi, int nodenum, int type=-1);
void updateSoundSources();
//! @}
@@ -388,6 +388,9 @@
node_t *getNodes();
int nodeBeamConnections(int nodeid);
+
+ void changedCamera();
+
float getTotalMass(bool withLocked=true);
void recalc_masses();
int getWheelNodeCount();
Modified: trunk/source/main/BeamData.h
===================================================================
--- trunk/source/main/BeamData.h 2011-02-01 12:56:24 UTC (rev 1629)
+++ trunk/source/main/BeamData.h 2011-02-01 23:44:06 UTC (rev 1630)
@@ -368,6 +368,7 @@
{
SoundScriptInstance* ssi;
int nodenum;
+ int type;
};
struct contacter
@@ -569,6 +570,7 @@
int animKeyState[10];
int lastanimKS[10];
Ogre::Real wheelrotdegree;
+ MeshObject *mo;
};
struct exhaust
Modified: trunk/source/main/BeamLoadTruck.cpp
===================================================================
--- trunk/source/main/BeamLoadTruck.cpp 2011-02-01 12:56:24 UTC (rev 1629)
+++ trunk/source/main/BeamLoadTruck.cpp 2011-02-01 23:44:06 UTC (rev 1630)
@@ -177,6 +177,7 @@
if (!strncmp("materialflarebindings",line, 21)) {mode=46;
continue;};
if (!strcmp("disabledefaultsounds",line))
{disable_default_sounds=true;continue;};
if (!strcmp("soundsources",line)) {mode=47;continue;};
+ if (!strcmp("soundsources2",line)) {mode=67;continue;};
if (!strcmp("envmap",line)) {mode=48;continue;};
if (!strcmp("managedmaterials",line)) {mode=49;continue;};
if (!strncmp("sectionconfig",line, 13))
{savedmode=mode;mode=50; /* NOT continue */};
@@ -283,6 +284,14 @@
if(!strcmp("slidenode_connect_instantly", line))
slideNodesConnectInstantly=true;
+ if (!strncmp("disable_shadows", line, 15))
+ {
+ // always use the last prop
+ prop_t *prop = &props[free_prop-1];
+ if(prop->mo) prop->mo->setCastShadows(false);
+
+ }
+
if (!strncmp("add_animation", line, 13))
{
/*
@@ -2230,6 +2239,7 @@
mo->setSimpleMaterialColour(ColourValue(1, 1, 0));
mo->setSkin(usedSkin);
mo->setMaterialFunctionMapper(materialFunctionMapper);
+ props[free_prop].mo = mo;
//hack for the spinprops
if (!strncmp("spinprop", meshname, 8))
@@ -3154,6 +3164,20 @@
if(ssm) addSoundSource(ssm->createInstance(script,
trucknum, NULL), ref);
#endif //OPENAL
}
+ else if (mode==67)
+ {
+ //parse soundsources2
+ int ref, type;
+ char script[256];
+ int result = sscanf(line,"%i, %i, %s", &ref, &type,
script);
+ if (result < 2 || result == EOF) {
+ LogManager::getSingleton().logMessage("Error
parsing File (soundsource2) " + String(fname) +" line " +
StringConverter::toString(linecounter) + ". trying to continue ...");
+ continue;
+ }
+#ifdef USE_OPENAL
+ if(ssm) addSoundSource(ssm->createInstance(script,
trucknum, NULL), ref, type);
+#endif //OPENAL
+ }
else if (mode==48)
{
// parse envmap
Modified: trunk/source/main/RoRFrameListener.cpp
===================================================================
--- trunk/source/main/RoRFrameListener.cpp 2011-02-01 12:56:24 UTC (rev
1629)
+++ trunk/source/main/RoRFrameListener.cpp 2011-02-01 23:44:06 UTC (rev
1630)
@@ -3689,13 +3689,13 @@
//camera mode
if
(INPUTENGINE.getEventBoolValueBounce(EV_CAMERA_CHANGE) && cameramode !=
CAMERA_FREE && cameramode != CAMERA_FREE_FIXED)
{
- if (cameramode==CAMERA_INT &&
trucks[current_truck]->currentcamera<trucks[current_truck]->freecinecamera-1)
+ if (cameramode==CAMERA_INT &&
trucks[current_truck]->currentcamera < trucks[current_truck]->freecinecamera-1)
{
trucks[current_truck]->currentcamera++;
+
trucks[current_truck]->changedCamera();
}
else
{
-
trucks[current_truck]->currentcamera=0;
if (cameramode==CAMERA_INT)
{
//end of internal cam
@@ -3703,7 +3703,9 @@
camRotY=pushcamRotY;
trucks[current_truck]->prepareInside(false);
if(ow)
ow->showDashboardOverlays(true, trucks[current_truck]->driveable);
+
trucks[current_truck]->currentcamera=-1;
//if(bigMap)
bigMap->setVisibility(true);
+
trucks[current_truck]->changedCamera();
}
cameramode++;
if (cameramode==CAMERA_INT)
@@ -3723,8 +3725,11 @@
else
ow->showDashboardOverlays(false, 0);
}
+
trucks[current_truck]->currentcamera=0;
+
trucks[current_truck]->changedCamera();
}
- if (cameramode==CAMERA_END)
cameramode=0;
+
+ if (cameramode==CAMERA_END)
cameramode = CAMERA_EXT;
}
}
//camera mode
Modified: trunk/source/main/RoRPrerequisites.h
===================================================================
--- trunk/source/main/RoRPrerequisites.h 2011-02-01 12:56:24 UTC (rev
1629)
+++ trunk/source/main/RoRPrerequisites.h 2011-02-01 23:44:06 UTC (rev
1630)
@@ -52,6 +52,7 @@
class HeightFinder;
class MaterialFunctionMapper;
class MapTextureCreator;
+class MeshObject;
class Mirrors;
class Network;
class OverlayWrapper;
Modified: trunk/source/main/SoundManager.cpp
===================================================================
--- trunk/source/main/SoundManager.cpp 2011-02-01 12:56:24 UTC (rev 1629)
+++ trunk/source/main/SoundManager.cpp 2011-02-01 23:44:06 UTC (rev 1630)
@@ -496,10 +496,14 @@
position=Vector3::ZERO;
velocity=Vector3::ZERO;
loop=false;
+ enabled=true;
}
void Sound::computeAudibility(Vector3 from)
{
+ // hack to disable sounds :)
+ if(!enabled) from=Vector3(999999,999999,999999);
+
//mutex is supposed to be taken
//first check if the sound is finished!
if (!loop && hardware_index!=-1 && should_play)
@@ -530,6 +534,20 @@
return false;
}
+void Sound::setEnabled(bool e)
+{
+ pthread_mutex_lock(&sm->audio_mutex);
+ enabled = e;
+ pthread_mutex_unlock(&sm->audio_mutex);
+}
+
+bool Sound::getEnabled()
+{
+ pthread_mutex_lock(&sm->audio_mutex);
+ return enabled;
+ pthread_mutex_unlock(&sm->audio_mutex);
+}
+
void Sound::play()
{
pthread_mutex_lock(&sm->audio_mutex);
Modified: trunk/source/main/SoundManager.h
===================================================================
--- trunk/source/main/SoundManager.h 2011-02-01 12:56:24 UTC (rev 1629)
+++ trunk/source/main/SoundManager.h 2011-02-01 23:44:06 UTC (rev 1630)
@@ -69,6 +69,11 @@
float gain;
float pitch;
bool loop;
+ bool enabled;
+
+ void setEnabled(bool e);
+ bool getEnabled();
+
Vector3 position;
Vector3 velocity;
private:
Modified: trunk/source/main/SoundScriptManager.cpp
===================================================================
--- trunk/source/main/SoundScriptManager.cpp 2011-02-01 12:56:24 UTC (rev
1629)
+++ trunk/source/main/SoundScriptManager.cpp 2011-02-01 23:44:06 UTC (rev
1630)
@@ -707,5 +707,13 @@
stopSound->play();
}
}
+
+void SoundScriptInstance::setEnabled(bool e)
+{
+ for (int i=0; i<templ->free_sound; i++)
+ {
+ sounds[i]->setEnabled(e);
+ }
+}
#endif //OPENAL
Modified: trunk/source/main/SoundScriptManager.h
===================================================================
--- trunk/source/main/SoundScriptManager.h 2011-02-01 12:56:24 UTC (rev
1629)
+++ trunk/source/main/SoundScriptManager.h 2011-02-01 23:44:06 UTC (rev
1630)
@@ -163,6 +163,8 @@
void start();
void stop();
int truck;
+
+ void setEnabled(bool e);
SoundScriptTemplate* templ;
private:
SoundManager* sm;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Rigsofrods-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel