Revision: 1597
http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=1597&view=rev
Author: rorthomas
Date: 2011-01-26 01:11:31 +0000 (Wed, 26 Jan 2011)
Log Message:
-----------
fixed camera
closes #174
Modified Paths:
--------------
trunk/source/main/Beam.cpp
trunk/source/main/Beam.h
Modified: trunk/source/main/Beam.cpp
===================================================================
--- trunk/source/main/Beam.cpp 2011-01-24 23:54:49 UTC (rev 1596)
+++ trunk/source/main/Beam.cpp 2011-01-26 01:11:31 UTC (rev 1597)
@@ -727,6 +727,20 @@
sendStreamSetup();
}
+
+ // calculate average camera offset relative to cinecamera
+ if(freecinecamera > 0)
+ {
+ Vector3 apos = Vector3::ZERO;
+ for (i=0; i<free_node; i++)
+ apos += nodes[i].AbsPosition;
+ Vector3 avg_pos = apos / free_node;
+
+ cinecam_avg_offset = nodes[cinecameranodepos[0]].AbsPosition -
avg_pos;
+ }
+ LogManager::getSingleton().logMessage("cinecamera offset for external
camera: " + StringConverter::toString(cinecam_avg_offset));
+
+
//updateDebugOverlay();
}
@@ -2669,25 +2683,25 @@
if (trucks[t]->reset_requested)
trucks[t]->SyncReset();
if (trucks[t]->state!=SLEEPING &&
trucks[t]->state!=NETWORKED && trucks[t]->state!=RECYCLE)
{
- // calculate average position
- Vector3 aposition=Vector3::ZERO;
- int nodesnum=0;
- for (int n=0; n<trucks[t]->free_node;
n++)
+ // calculate average position (and
smooth)
+ if(trucks[t]->freecinecamera > 0)
{
-//
trucks[t]->nodes[n].smoothpos=trucks[t]->nodes[n].tsmooth/steps;
+ // fix for detaching beams
+ trucks[t]->position =
trucks[t]->nodes[cinecameranodepos[0]].AbsPosition - cinecam_avg_offset;
+ for (int n=0;
n<trucks[t]->free_node; n++)
+ {
trucks[t]->nodes[n].smoothpos = trucks[t]->nodes[n].AbsPosition;
-
if((trucks[t]->nodes[n].AbsPosition -
trucks[t]->nodes[0].AbsPosition).squaredLength() >
trucks[t]->nodes[n].iDistance * 25)
- {
- // loose node,
ignore ...
- } else
- {
- // valid node
- aposition +=
trucks[t]->nodes[n].smoothpos;
- nodesnum++;
- }
-//
trucks[t]->nodes[n].tsmooth=Vector3::ZERO;
+ }
+ } else
+ {
+ Vector3 aposition =
Vector3::ZERO;
+ for (int n=0;
n<trucks[t]->free_node; n++)
+ {
+
trucks[t]->nodes[n].smoothpos = trucks[t]->nodes[n].AbsPosition;
+ aposition +=
trucks[t]->nodes[n].smoothpos;
+ }
+ trucks[t]->position = aposition
/ free_node;
}
- trucks[t]->position = aposition /
nodesnum;
}
if (floating_origin_enable &&
trucks[t]->nodes[0].RelPosition.length()>100.0)
{
@@ -2721,17 +2735,25 @@
if (trucks[t]->reset_requested)
trucks[t]->SyncReset();
if (trucks[t]->state!=SLEEPING &&
trucks[t]->state!=NETWORKED && trucks[t]->state!=RECYCLE)
{
- // average position
- Vector3 aposition=Vector3::ZERO;
-
- // TODO Unused Varaible
- //int nodesnum=0;
- for (int n=0; n<trucks[t]->free_node;
n++)
+ // calculate average position (and
smooth)
+ if(trucks[t]->freecinecamera > 0)
{
-
trucks[t]->nodes[n].smoothpos=trucks[t]->nodes[n].AbsPosition;
- aposition +=
trucks[t]->nodes[n].smoothpos;
+ // fix for detaching beams
+ trucks[t]->position =
trucks[t]->nodes[cinecameranodepos[0]].AbsPosition - cinecam_avg_offset;
+ for (int n=0;
n<trucks[t]->free_node; n++)
+ {
+
trucks[t]->nodes[n].smoothpos = trucks[t]->nodes[n].AbsPosition;
+ }
+ } else
+ {
+ Vector3 aposition =
Vector3::ZERO;
+ for (int n=0;
n<trucks[t]->free_node; n++)
+ {
+
trucks[t]->nodes[n].smoothpos = trucks[t]->nodes[n].AbsPosition;
+ aposition +=
trucks[t]->nodes[n].smoothpos;
+ }
+ trucks[t]->position = aposition
/ free_node;
}
- trucks[t]->position = aposition /
free_node;
}
if (floating_origin_enable &&
trucks[t]->nodes[0].RelPosition.length()>100.0)
{
@@ -2764,17 +2786,26 @@
if (state!=SLEEPING && state!=NETWORKED &&
state!=RECYCLE)
{
- // average position
- Vector3 aposition=Vector3::ZERO;
-
- // TODO Unused Varaible
- //int nodesnum=0;
- for (int n=0; n<free_node; n++)
+ // calculate average position (and smooth)
+ if(trucks[t]->freecinecamera > 0)
{
- nodes[n].smoothpos=nodes[n].AbsPosition;
- aposition += nodes[n].smoothpos;
+ // fix for detaching beams
+ trucks[t]->position =
trucks[t]->nodes[cinecameranodepos[0]].AbsPosition - cinecam_avg_offset;
+ for (int n=0; n<trucks[t]->free_node;
n++)
+ {
+ trucks[t]->nodes[n].smoothpos =
trucks[t]->nodes[n].AbsPosition;
+ }
+ } else
+ {
+ Vector3 aposition = Vector3::ZERO;
+ for (int n=0; n<trucks[t]->free_node;
n++)
+ {
+ trucks[t]->nodes[n].smoothpos =
trucks[t]->nodes[n].AbsPosition;
+ aposition +=
trucks[t]->nodes[n].smoothpos;
+ }
+ trucks[t]->position = aposition /
free_node;
}
- position = aposition / free_node;
+
}
if (floating_origin_enable &&
nodes[0].RelPosition.length()>100.0)
{
Modified: trunk/source/main/Beam.h
===================================================================
--- trunk/source/main/Beam.h 2011-01-24 23:54:49 UTC (rev 1596)
+++ trunk/source/main/Beam.h 2011-01-26 01:11:31 UTC (rev 1597)
@@ -394,6 +394,7 @@
node_t *addNode(Ogre::Vector3 pos);
String speedomat, tachomat;
float speedoMax;
+ Ogre::Vector3 cinecam_avg_offset;
bool useMaxRPMforGUI;
Ogre::String realtruckfilename;
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