Revision: 1631
http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=1631&view=rev
Author: rorthomas
Date: 2011-02-02 02:17:15 +0000 (Wed, 02 Feb 2011)
Log Message:
-----------
fixed camera moder for props and flexbodies
Modified Paths:
--------------
trunk/source/main/Beam.cpp
trunk/source/main/BeamData.h
trunk/source/main/BeamLoadTruck.cpp
trunk/source/main/FlexBody.cpp
trunk/source/main/FlexBody.h
trunk/source/main/MeshObject.h
trunk/source/main/SelectorWindow.cpp
Modified: trunk/source/main/Beam.cpp
===================================================================
--- trunk/source/main/Beam.cpp 2011-02-01 23:44:06 UTC (rev 1630)
+++ trunk/source/main/Beam.cpp 2011-02-02 02:17:15 UTC (rev 1631)
@@ -651,6 +651,9 @@
// printf("%i nodes, %i beams\n", free_node, free_beam);
+ // setup sounds properly
+ changedCamera();
+
// setup replay mode
bool enablereplay = (SETTINGS.getSetting("Replay mode")=="Yes");
replay=0;
@@ -4841,7 +4844,7 @@
int i=0;
for(i=0;i<free_prop;i++)
{
- if(props[i].snode) props[i].snode->setVisible(visible);
+ if(props[i].mo) props[i].mo->setVisible(visible);
if(props[i].wheel) props[i].wheel->setVisible(visible);
if(props[i].bbsnode[0])
props[i].bbsnode[0]->setVisible(visible);
if(props[i].bbsnode[1])
props[i].bbsnode[1]->setVisible(visible);
@@ -5582,6 +5585,20 @@
}
}
#endif //OPENAL
+
+ // look for props
+ for(int i=0;i<free_prop;i++)
+ {
+ bool enabled = (props[i].cameramode == -2 ||
props[i].cameramode == currentcamera);
+ if(props[i].mo) props[i].mo->setMeshEnabled(enabled);
+ }
+
+ // look for flexbodies
+ for(int i=0;i<free_flexbody;i++)
+ {
+ bool enabled = (flexbodies[i]->cameramode == -2 ||
flexbodies[i]->cameramode == currentcamera);
+ flexbodies[i]->setEnabled(enabled);
+ }
}
//Returns the number of active (non bounded) beams connected to a node
Modified: trunk/source/main/BeamData.h
===================================================================
--- trunk/source/main/BeamData.h 2011-02-01 23:44:06 UTC (rev 1630)
+++ trunk/source/main/BeamData.h 2011-02-02 02:17:15 UTC (rev 1631)
@@ -570,6 +570,7 @@
int animKeyState[10];
int lastanimKS[10];
Ogre::Real wheelrotdegree;
+ int cameramode;
MeshObject *mo;
};
Modified: trunk/source/main/BeamLoadTruck.cpp
===================================================================
--- trunk/source/main/BeamLoadTruck.cpp 2011-02-01 23:44:06 UTC (rev 1630)
+++ trunk/source/main/BeamLoadTruck.cpp 2011-02-02 02:17:15 UTC (rev 1631)
@@ -80,6 +80,7 @@
// some temp vars used
Real inertia_startDelay=-1, inertia_stopDelay=-1;
char inertia_default_startFunction[50]="",
inertia_default_stopFunction[50]="";
+ int shadowmode = 1;
while (!ds->eof())
{
@@ -284,12 +285,46 @@
if(!strcmp("slidenode_connect_instantly", line))
slideNodesConnectInstantly=true;
- if (!strncmp("disable_shadows", line, 15))
+ if (!strncmp("set_shadows", line, 11))
{
+ int mode;
+ int result = sscanf(line,"set_shadows %i", &mode);
+ if (result < 1 || result == EOF)
+ {
+ LogManager::getSingleton().logMessage("Error
parsing File (set_shadows) " + String(fname) +" line " +
StringConverter::toString(linecounter) + ". trying to continue ...");
+ continue;
+ }
+ shadowmode = mode;
+ }
+
+ if (!strncmp("prop_camera_mode", line, 16))
+ {
+ int mode = -2;
+ int result = sscanf(line,"prop_camera_mode %i", &mode);
+ if (result < 1 || result == EOF)
+ {
+ LogManager::getSingleton().logMessage("Error
parsing File (prop_camera_mode) " + String(fname) +" line " +
StringConverter::toString(linecounter) + ". trying to continue ...");
+ continue;
+ }
+
// always use the last prop
prop_t *prop = &props[free_prop-1];
- if(prop->mo) prop->mo->setCastShadows(false);
+ if(prop->mo) prop->cameramode = mode;
+ }
+ if (!strncmp("flexbody_camera_mode", line, 20))
+ {
+ int mode = -2;
+ int result = sscanf(line,"flexbody_camera_mode %i",
&mode);
+ if (result < 1 || result == EOF)
+ {
+ LogManager::getSingleton().logMessage("Error
parsing File (flexbody_camera_mode) " + String(fname) +" line " +
StringConverter::toString(linecounter) + ". trying to continue ...");
+ continue;
+ }
+
+ // always use the last flexbody
+ FlexBody *flex = flexbodies[free_flexbody-1];
+ if(flex) flex->cameramode = mode;
}
if (!strncmp("add_animation", line, 13))
@@ -2235,17 +2270,17 @@
// create the meshs scenenode
props[free_prop].snode =
manager->getRootSceneNode()->createChildSceneNode();
// now create the mesh
- MeshObject *mo = new MeshObject(manager, meshname, "",
props[free_prop].snode, enable_background_loading);
- mo->setSimpleMaterialColour(ColourValue(1, 1, 0));
- mo->setSkin(usedSkin);
- mo->setMaterialFunctionMapper(materialFunctionMapper);
- props[free_prop].mo = mo;
+ props[free_prop].mo = new MeshObject(manager, meshname,
"", props[free_prop].snode, enable_background_loading);
+
props[free_prop].mo->setSimpleMaterialColour(ColourValue(1, 1, 0));
+ props[free_prop].mo->setSkin(usedSkin);
+
props[free_prop].mo->setMaterialFunctionMapper(materialFunctionMapper);
+ props[free_prop].mo->setCastShadows(shadowmode!=0);
//hack for the spinprops
if (!strncmp("spinprop", meshname, 8))
{
props[free_prop].spinner=1;
- mo->setCastShadows(false);
+ props[free_prop].mo->setCastShadows(false);
props[free_prop].snode->setVisible(false);
}
if (!strncmp("pale", meshname, 4))
@@ -2256,7 +2291,7 @@
if (!strncmp("seat", meshname, 4) && !driversseatfound)
{
driversseatfound=true;
- mo->setMaterialName("driversseat");
+
props[free_prop].mo->setMaterialName("driversseat");
driverSeat = &props[free_prop];
}
else if (!strncmp("seat2", meshname, 5) &&
!driversseatfound)
@@ -3092,7 +3127,7 @@
LogManager::getSingleton().logMessage("flexbodies limit reached
("+StringConverter::toString(MAX_FLEXBODIES)+"): " + String(fname) +" line " +
StringConverter::toString(linecounter) + ". trying to continue ...");
continue;
}
- flexbodies[free_flexbody]=new FlexBody(manager, nodes,
free_node, meshname, uname, ref, nx, ny, offset, rot, line+6,
materialFunctionMapper, usedSkin);
+ flexbodies[free_flexbody]=new FlexBody(manager, nodes,
free_node, meshname, uname, ref, nx, ny, offset, rot, line+6,
materialFunctionMapper, usedSkin, (shadowmode!=0));
free_flexbody++;
}
else if (mode==44)
Modified: trunk/source/main/FlexBody.cpp
===================================================================
--- trunk/source/main/FlexBody.cpp 2011-02-01 23:44:06 UTC (rev 1630)
+++ trunk/source/main/FlexBody.cpp 2011-02-02 02:17:15 UTC (rev 1631)
@@ -23,7 +23,7 @@
#include "skin.h"
-FlexBody::FlexBody(SceneManager *manager, node_t *nds, int numnds, char*
meshname, char* uname, int ref, int nx, int ny, Vector3 offset, Quaternion rot,
char* setdef, MaterialFunctionMapper *mfm, Skin *usedSkin)
+FlexBody::FlexBody(SceneManager *manager, node_t *nds, int numnds, char*
meshname, char* uname, int ref, int nx, int ny, Vector3 offset, Quaternion rot,
char* setdef, MaterialFunctionMapper *mfm, Skin *usedSkin, bool enableShadows)
{
nodes=nds;
numnodes=numnds;
@@ -31,6 +31,8 @@
cx=nx; nodes[cx].iIsSkin=true;
cy=ny; nodes[cy].iIsSkin=true;
coffset=offset;
+ cameramode=-2; // all cameras
+ enabled=true;
haveshadows=(manager->getShadowTechnique()==SHADOWTYPE_STENCIL_MODULATIVE ||
manager->getShadowTechnique()==SHADOWTYPE_STENCIL_ADDITIVE);
havetangents=false;
@@ -465,6 +467,7 @@
snode=manager->getRootSceneNode()->createChildSceneNode();
snode->attachObject(ent);
snode->setPosition(position);
+ //ent->setCastShadows(enableShadows);
#if 0
// XXX TODO: fix 1.7 LODs
@@ -510,9 +513,17 @@
}
+void FlexBody::setEnabled(bool e)
+{
+ setVisible(e);
+ enabled = e;
+}
+
void FlexBody::setVisible(bool visible)
{
- if(snode) snode->setVisible(visible);
+ if(!enabled) return;
+ if(snode)
+ snode->setVisible(visible);
}
void FlexBody::printMeshInfo(Mesh* mesh)
@@ -563,6 +574,7 @@
Vector3 FlexBody::flexit()
{
+ if(!enabled) return Vector3::ZERO;
if (haveblend) updateBlend();
//compute the local center
@@ -635,6 +647,7 @@
void FlexBody::writeBlend()
{
+ if(!enabled) return;
if (!haveblend) return;
ARGB *cpt=srccolors;
if (hasshared)
@@ -651,6 +664,7 @@
void FlexBody::updateBlend() //so easy!
{
+ if(!enabled) return;
bool changed=false;
for (int i=0; i<(int)vertex_count; i++)
{
Modified: trunk/source/main/FlexBody.h
===================================================================
--- trunk/source/main/FlexBody.h 2011-02-01 23:44:06 UTC (rev 1630)
+++ trunk/source/main/FlexBody.h 2011-02-02 02:17:15 UTC (rev 1631)
@@ -94,7 +94,7 @@
Ogre::MeshPtr msh;
public:
- FlexBody(SceneManager *manager, node_t *nds, int numnodes, char*
meshname, char* uname, int ref, int nx, int ny, Vector3 offset, Quaternion rot,
char* setdef, MaterialFunctionMapper *mfm, Skin *usedSkin);
+ FlexBody(SceneManager *manager, node_t *nds, int numnodes, char*
meshname, char* uname, int ref, int nx, int ny, Vector3 offset, Quaternion rot,
char* setdef, MaterialFunctionMapper *mfm, Skin *usedSkin, bool forceNoShadows);
/* void getMeshInformation(Mesh* mesh,size_t &vertex_count,Vector3*
&vertices,
size_t &index_count, unsigned* &indices,
@@ -110,6 +110,10 @@
void updateBlend();
void writeBlend();
SceneNode *getSceneNode() { return snode; };
+
+ int cameramode;
+ bool enabled;
+ void setEnabled(bool e);
};
Modified: trunk/source/main/MeshObject.h
===================================================================
--- trunk/source/main/MeshObject.h 2011-02-01 23:44:06 UTC (rev 1630)
+++ trunk/source/main/MeshObject.h 2011-02-02 02:17:15 UTC (rev 1631)
@@ -42,6 +42,8 @@
, skin(0)
, castshadows(true)
, mfm(0)
+ , enabled(true)
+ , visible(true)
{
// create a new sceneNode if not existing
if(!sceneNode)
@@ -107,11 +109,26 @@
{
sceneNode->getAttachedObject(0)->setCastShadows(b);
}
+ }
+ void setMeshEnabled(bool e)
+ {
+ setVisible(e);
+ enabled = e;
}
+ void setVisible(bool b)
+ {
+ if(!enabled) return;
+ visible = b;
+ if(loaded && sceneNode)
+ sceneNode->setVisible(b);
+ }
+
+
Ogre::MeshPtr getMesh() { return mesh; };
Ogre::Entity *getEntity() { return ent; };
+ //Ogre::SceneNode *getSceneNode() { return sceneNode; };
protected:
Ogre::SceneManager *smgr;
@@ -130,8 +147,11 @@
Skin *skin;
bool castshadows;
MaterialFunctionMapper *mfm;
+ bool enabled;
+ bool visible;
+
void postProcess()
{
loaded=true;
@@ -153,7 +173,7 @@
sceneNode->getAttachedObject(0)->setCastShadows(castshadows);
- sceneNode->setVisible(true);
+ sceneNode->setVisible(visible);
}
void loadMesh()
Modified: trunk/source/main/SelectorWindow.cpp
===================================================================
--- trunk/source/main/SelectorWindow.cpp 2011-02-01 23:44:06 UTC (rev
1630)
+++ trunk/source/main/SelectorWindow.cpp 2011-02-02 02:17:15 UTC (rev
1631)
@@ -164,6 +164,7 @@
{
mSelectedTruck = nullptr;
mSelectionDone = true;
+ hide();
}
void SelectorWindow::eventComboChangePositionTypeComboBox(MyGUI::ComboBoxPtr
_sender, size_t _index)
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