Revision: 1714
          http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=1714&view=rev
Author:   rorthomas
Date:     2011-03-01 13:34:32 +0000 (Tue, 01 Mar 2011)

Log Message:
-----------
improvedcode readability in videocamera section

Modified Paths:
--------------
    trunk/source/main/gfx/vidcam.cpp
    trunk/source/main/gfx/vidcam.h

Modified: trunk/source/main/gfx/vidcam.cpp
===================================================================
--- trunk/source/main/gfx/vidcam.cpp    2011-03-01 13:20:52 UTC (rev 1713)
+++ trunk/source/main/gfx/vidcam.cpp    2011-03-01 13:34:32 UTC (rev 1714)
@@ -41,8 +41,8 @@
        Ogre::TexturePtr rttTexPtr = 
Ogre::TextureManager::getSingleton().createManual(materialName + "_texture"
                        , 
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME
                        , Ogre::TEX_TYPE_2D
-                       , texx
-                       , texy
+                       , textureSize.x
+                       , textureSize.y
                        , 0
                        , Ogre::PF_R8G8B8
                        , Ogre::TU_RENDERTARGET
@@ -52,7 +52,7 @@
        mVidCam->setNearClipDistance(minclip);
        mVidCam->setFarClipDistance(maxclip);
        mVidCam->setFOVy(Ogre::Degree(fov));
-       mVidCam->setAspectRatio((float)texx/(float)texy);
+       mVidCam->setAspectRatio((float)textureSize.x/(float)textureSize.y);
        Ogre::Viewport *v = rttTex->addViewport(mVidCam);
        v->setClearEveryFrame(true);
        v->setBackgroundColour(camera->getViewport()->getBackgroundColour());
@@ -84,9 +84,9 @@
 
        // add user set offset
        Vector3 pos = truck->nodes[nx].smoothpos + 
-               (offx * normal) + 
-               (offy * (truck->nodes[nref].smoothpos - 
truck->nodes[ny].smoothpos)) + 
-               (offz * (truck->nodes[nref].smoothpos - 
truck->nodes[nx].smoothpos));
+               (offset.x * normal) + 
+               (offset.y * (truck->nodes[nref].smoothpos - 
truck->nodes[ny].smoothpos)) + 
+               (offset.z * (truck->nodes[nref].smoothpos - 
truck->nodes[nx].smoothpos));
 
        //orientation of camera
        Vector3 refx = truck->nodes[nx].smoothpos - 
truck->nodes[nref].smoothpos;
@@ -95,12 +95,9 @@
        refx *= -1.0f;
        Quaternion rot = Quaternion(refx, refy, -normal); // rotate towards the 
cam direction
 
-       // add user set rotation
-       rot = rot* Quaternion(Degree(rotz), Vector3::UNIT_Z) * 
Quaternion(Degree(roty), Vector3::UNIT_Y) * Quaternion(Degree(rotx), 
Vector3::UNIT_X);
-
        // set the new position / orientation to the camera
        mVidCam->setPosition(pos);
-       mVidCam->setOrientation(rot);
+       mVidCam->setOrientation(rot * rotation); // add the user rotation to 
this
 }
 
 
@@ -128,16 +125,10 @@
        v->ny = ny;
        v->nref = nref;
 
-       v->offx = offx;
-       v->offy = offy;
-       v->offz = offz;
+       v->offset      = Vector3(offx, offy, offz);
+       v->rotation    = Quaternion(Degree(rotz), Vector3::UNIT_Z) * 
Quaternion(Degree(roty), Vector3::UNIT_Y) * Quaternion(Degree(rotx), 
Vector3::UNIT_X);
+       v->textureSize = Vector2(texx, texy);
 
-       v->rotx = rotx;
-       v->roty = roty;
-       v->rotz = rotz;
-
-       v->texx = texx;
-       v->texy = texy;
        v->cammode = cammode;
        v->materialName = String(materialname);
 

Modified: trunk/source/main/gfx/vidcam.h
===================================================================
--- trunk/source/main/gfx/vidcam.h      2011-03-01 13:20:52 UTC (rev 1713)
+++ trunk/source/main/gfx/vidcam.h      2011-03-01 13:34:32 UTC (rev 1714)
@@ -39,8 +39,13 @@
        
        static VideoCamera *parseLine(Ogre::SceneManager *mSceneMgr, 
Ogre::Camera *camera, Beam *truck, const char *fname, char *line, int 
linecounter);
 
-       float fov, minclip, maxclip, offx, offy, offz, rotx, roty, rotz;
-       int nx, ny, nref, texx, texy, cammode;
+       float fov, minclip, maxclip;
+       
+       Ogre::Vector3 offset;
+       Ogre::Vector2 textureSize;
+       Ogre::Quaternion rotation;
+       
+       int nx, ny, nref, cammode;
        Ogre::String materialName, disabledTexture;
 
 protected:


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
Rigsofrods-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel

Reply via email to