OGRE Wiki
Support and community documentation for Ogre3D
Ogre Forums
ogre3d.org
Log in
Username:
Password:
CapsLock is on.
Remember me (for 1 year)
Log in
Home
Tutorials
Tutorials Home
Basic Tutorials
Intermediate Tutorials
Mad Marx Tutorials
In Depth Tutorials
Older Tutorials
External Tutorials
Cookbook
Cookbook Home
CodeBank
Snippets
Experiences
Ogre Articles
Libraries
Libraries Home
Alternative Languages
Assembling A Toolset
Development Tools
OGRE Libraries
List of Libraries
Tools
Tools Home
DCC Tools
DCC Tutorials
DCC Articles
DCC Resources
Assembling a production pipeline
Development
Development Home
Roadmap
Building Ogre
Installing the Ogre SDK
Setting Up An Application
Ogre Wiki Tutorial Framework
Frequently Asked Questions
Google Summer Of Code
Help Requested
Ogre Core Articles
Community
Community Home
Projects Using Ogre
Recommended Reading
Contractors
Wiki
Immediate Wiki Tasklist
Wiki Ideas
Wiki Guidelines
Article Writing Guidelines
Wiki Styles
Wiki Page Tracker
Ogre Wiki Help
Ogre Wiki Help Overview
Help - Basic Syntax
Help - Images
Help - Pages and Structures
Help - Wiki Plugins
Toolbox
Freetags
Categories
List Pages
Structures
Trackers
Statistics
Rankings
List Galleries
Ogre Lexicon
Comments
History: Talk:3rd person camera system tutorial
View page
Source of version: 1
(current)
If someone can take a look to the timing problem in the ExtendedCamera::update method, please, feel free to do it. The problem is that slow framerates and fast movement will result in bad camera updates. In any case, this system wasn't designed with that artifact in mind, and the updating is proportional, so there wouldn't be much difference (if the distance is larger, the half of the distance is still the half). The only problem is that it would take more time to reach the point than before if the performance is poor. Anyways, I think it's fine this way. I won't remove the elapsedTime parameter for that purpose :) --- For movements and such to be independent of framerate, you just have to weight them by the time since the last frame was rendered. This can be done simply with Ogre using FrameEvent::timeSinceLastFrame, wich you're already passing to ExtendedCamera::update. So all we have to add is something like : ~pp~ void update (Real elapsedTime, Vector3 cameraPosition, Vector3 targetPosition) { // Handle movement Vector3 displacement; displacement = (cameraPosition - mCameraNode->getPosition ()) * mTightness; mCameraNode->translate ( displacement * time ); displacement = (targetPosition - mTargetNode->getPosition ()) * mTightness; mTargetNode->translate ( displacement * time ); }~/pp~ So, your cinematic camera will have the same speed, regardless of performance. mTightness acts then more than a speed value, and it has to be greater than 1 for movements to be instant. However, a too large value can provoke undesired behaviours ; so, if you want to agree with the definition of mTightness, I suggest to multiply your translation vector by some fixed empiric value ''greater than 1'', like : ~pp~ node->translate ( displacement * time * someScalar ) ~/pp~ --- Just a question about : ~pp~ if( mOwnCamera ) { delete mCamera; mCamera = 0; }~/pp~ Doesn't the scene manager still have a reference to the camera ? (calling mSceneMgr->destroyAllCameras(=) causes a segfault after deleting mCamera). Shouldn't be replaced by : ~pp~ if( mOwnCamera ) { mSceneMgr->destroyCamera( mCamera ); mCamera = 0; }~/pp~ ? --- Yes, probably. I missed that, though you most likely want to write your own camera system using this method, not this base code. Thanks for pointing that out. If you can confirm this, feel free to fix that or tell me to do it. --- Syedhs, Camera::setPosition() sets the position relative to the scene node it's attached to, not world coordinates. Also, it defaults to Vector3::ZERO, so those lines are redundant. It's the same for lights, though as they are usually more attached to a single scene node, it makes sense there. !!Great Tutorial! You're the man! I was trying to work on a 3rd person camera system yesteday and today and having trouble. This is far better than what I would have come up with on my own. Thank you so much!! =D ((User:Moohasha|Moohasha)) 18:24, 11 April 2008 (BST) {DL()} I twinked the ExtendedCamera class to have a private Character* member and a method called attachObject(Character*). Doing that I was able to move a lot of the camera updating inside of the update() method instead of doing it inside of frameStarted(). So now the ExtendedCamera::update method looks like this (I added a mode enum to simplify things for me): {DL} ~pp~ void update (Real elapsedTime) { // Handle movement Vector3 displacement; Vector3 cameraPosition; Vector3 targetPosition; if( !mChar ) return; switch (mMode) { case MODE_3RDCHASE: // 3rd person chase cameraPosition = mChar->getCameraNode()->getWorldPosition(); targetPosition = mChar->getSightNode()->getWorldPosition(); break; case MODE_3RDFIXED: // 3rd person fixed cameraPosition = Vector3 (0, 200, 0); targetPosition = mChar->getSightNode ()->getWorldPosition (); break; case MODE_1ST: // 1st person cameraPosition = mChar->getWorldPosition (); targetPosition = mChar->getSightNode ()->getWorldPosition (); break; } displacement = (cameraPosition - mCameraNode->getPosition ()) * mTightness; mCameraNode->translate (displacement); displacement = (targetPosition - mTargetNode->getPosition ()) * mTightness; mTargetNode->translate (displacement); } ~/pp~ {DL()} and in frameStarted() I just have to do {DL} ~pp~ mChar->update (evt.timeSinceLastFrame, mKeyboard); mExCamera->update(evt.timeSinceLastFrame); ~/pp~ {DL()} This way I can just attach a Character to the camera and the camera takes care of all the updating, and if I want to change objects I just call attachObject() with a different instance of the Character class. :) ((User:Moohasha|Moohasha)) 19:46, 11 April 2008 (BST) {DL} --- Hey, thanks for the feedback ((User:Moohasha|Moohasha)) :) This tutorial is indeed very prone to enhancements. Indeed I developed a much ''much'' better version that I'll eventually release someday (I'm such a procrastinator!). I didn't want to overcomplicate things, so did a quick and dirty implementation showcasing a bit of its potential and possible uses, but there's definitely room for much more :) Hope you find it useful! <div align="right">''((User:Kencho|Kencho)) 02:50, 16 April 2008 (BST)''</div>
Search by Tags
Search Wiki by Freetags
Latest Changes
Minimal Ogre Collision
Artifex Terra
OpenMB
Advanced Mogre Framework
MogreSocks
Critter AI
Mogre Add-ons
MOGRE
Mogre MyGUI wrapper
MOGRE Editable Terrain Manager
...more
Search
Find
Advanced
Search Help
Online Users
23 online users