Revision: 2566 http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2566&view=rev Author: ulteq Date: 2012-05-14 20:37:22 +0000 (Mon, 14 May 2012) Log Message: ----------- --Codechange: CameraSystem WIP cinecam finished
Modified Paths: -------------- trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.h Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp 2012-05-14 20:20:49 UTC (rev 2565) +++ trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.cpp 2012-05-14 20:37:22 UTC (rev 2566) @@ -28,10 +28,6 @@ CameraBehaviorVehicleCineCam::CameraBehaviorVehicleCineCam() : CameraBehaviorVehicle() { - camDist = 0.1f; - camRatio = 0.01f; - minCamDist = 0.0f; - maxCamDist = 0.5f; } void CameraBehaviorVehicleCineCam::update(const CameraManager::cameraContext_t &ctx) @@ -39,17 +35,19 @@ Vector3 dir = (ctx.mCurrTruck->nodes[ctx.mCurrTruck->cameranodepos[ctx.mCurrTruck->currentcamera]].smoothpos - ctx.mCurrTruck->nodes[ctx.mCurrTruck->cameranodedir[ctx.mCurrTruck->currentcamera]].smoothpos).normalisedCopy(); - targetDirection = -atan2(dir.dotProduct(Vector3::UNIT_X), dir.dotProduct(-Vector3::UNIT_Z)); - targetPitch = 0.0f; + Vector3 roll = (ctx.mCurrTruck->nodes[ctx.mCurrTruck->cameranodepos[ctx.mCurrTruck->currentcamera]].smoothpos + - ctx.mCurrTruck->nodes[ctx.mCurrTruck->cameranoderoll[ctx.mCurrTruck->currentcamera]].smoothpos).normalisedCopy(); - if ( camPitching ) - { - targetPitch = -asin(dir.dotProduct(Vector3::UNIT_Y)); - } + Vector3 up = dir.crossProduct(roll); - camCenterPosition = ctx.mCurrTruck->nodes[ctx.mCurrTruck->cinecameranodepos[ctx.mCurrTruck->currentcamera]].smoothpos; + roll = up.crossProduct(dir); CameraBehavior::update(ctx); + + Quaternion orientation = Quaternion(camRotX, up) * Quaternion(Degree(180.0) + camRotY, roll) * Quaternion(roll, up, dir); + + ctx.mCamera->setPosition(ctx.mCurrTruck->nodes[ctx.mCurrTruck->cinecameranodepos[ctx.mCurrTruck->currentcamera]].smoothpos); + ctx.mCamera->setOrientation(orientation); } void CameraBehaviorVehicleCineCam::activate(const CameraManager::cameraContext_t &ctx) @@ -59,7 +57,7 @@ ctx.mCamera->setFOVy(Degree(fov)); camRotX = 0.0f; - camRotY = 0.15f; + camRotY = Degree(DEFAULT_INTERNAL_CAM_PITCH); ctx.mCurrTruck->prepareInside(true); @@ -80,7 +78,6 @@ float fov = FSETTING("FOV External", 60); ctx.mCamera->setFOVy(Degree(fov)); - ctx.mCamera->roll(Radian(0)); ctx.mCurrTruck->prepareInside(false); Modified: trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.h =================================================================== --- trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.h 2012-05-14 20:20:49 UTC (rev 2565) +++ trunk/source/main/gfx/camera/CameraBehaviorVehicleCineCam.h 2012-05-14 20:37:22 UTC (rev 2566) @@ -36,6 +36,10 @@ void deactivate(const CameraManager::cameraContext_t &ctx); bool switchBehavior(const CameraManager::cameraContext_t &ctx); + +protected: + + static const int DEFAULT_INTERNAL_CAM_PITCH = -15; }; #endif // __CAMERA_BEHAVIOR_VEHICLE_INTERNAL_H_ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Rigsofrods-devel mailing list Rigsofrods-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel