[50%solved]how get the animated camera from 3ds max in ogre?

marc_antoine

12-02-2009 16:05:49

march/09/2007
free camera issue solved, but target camera is still not working well...

hi everyone,

i will start xplainning what i have and then what iwant to achieve.
1.- I have a scene in max,a very simple test scene where i have a animated target camera, the target camera first zooms out from a box and then rotates 360 degrees, and then then zooms in the box, i can see the animation in the Ofusion viewport so then i exported the scene and the animation,

2.- in my program i have th e following code:

mSceneMgr = mRoot->createSceneManager(ST_GENERIC,StringUtil::BLANK);
mCamera = mSceneMgr->createCamera("IntroCamera");
mCamera->setPosition(Vector3(0,60,0));
// Look back along +Z
mCamera->lookAt(Vector3(0,60,0));
mCamera->setNearClipDistance(5);
mViewport = mRoot->getAutoCreatedWindow()->addViewport(mCamera);
mViewport->setBackgroundColour(ColourValue(1.0, 1.0, 1.0));


and then i load the scene:

OSMScene oScene(mSceneMgr,GameManager::getRenderWindow());
oScene.initialise(nameOfTheOSMFile);//("brazo.osm");//
oScene.createScene();
mSceneMgr= oScene.getSceneManager();
mSceneMgr->setSkyBox(true, "Examples/CloudyNoonSkyBox");



then i have everything ready just to click the box so the animation starts, (i have tested by clicking the box, and then an animated box moves, so the animation code works) but the camera animation doesn't work, i think that if i subtitute my sceneManager witht he sceneManager from oFusion, it should work, but it doesn't i even get the camera from the oSceneManager like this:

mCamera=oScene.getSceneManager()->getCamera("Camera01");

i don't any error, and the camera starts in another place different than max or the coordinates i set, also the code i have to rotate and move the camera backward and forward and so, stops working like if i'm moving another camera.. so what should i do, also i would like to start the scene in the same place where my camer is placed in max...

help!! :oops: :roll: mybe this is an stupid question..but help this newbie pls...

Lioric

13-02-2009 16:06:13

You dont need to create the camera manually, it will be created automatically with the loaded scene (with all of its animations), if you dont create any camera (and a viewport) manually, the first loaded camera in the scene will be set as the default camera

Use the oScene loader lib sample demo, it will load your scene, set the camera and automatically play the animations

Or post (or send us) the scene and we will test it in the demo application and send you this

marc_antoine

17-02-2009 22:45:22

thanks lioric, i will be testing this, and i will let you know, is becouse i would like to see what the animated camera is seeing, and when the animated camerea stops i would like to control that camera with the mouse and keyboard.. is this possible?

Lioric

18-02-2009 05:30:22

Sure, simply get the animation state for the camera (using the getAnimationState method from the scene manager) and enable it, when the animation is completed you can manually control it, search this forum for more details on using animations loaded from the scene

marc_antoine

18-02-2009 10:59:52

well got it to work, i did this:
OSMScene oScene(mSceneMgr,GameManager::getRenderWindow());

oScene.initialise(nameOfTheOSMFile);

oScene.createScene();

mSceneMgr=oScene.getSceneManager();
mSceneMgr->setSkyBox(true, "Examples/CloudyNoonSkyBox");
mRoot->getAutoCreatedWindow()->getViewport(0)->setCamera(mSceneMgr->getCamera("Camera01"));
mViewport=mRoot->getAutoCreatedWindow()->getViewport(0);

OSMScene::CameraList camList = oScene.getCameraList();

if(!camList.empty()) {

// If loaded with the scene, set the first camera as the default camera
mCamera = camList[0];

// A viewport has been created and assigned to the first camera automatically
// (The TSM needs it to initialize the terrain world geometry)
}
else
{

// Create a default camera in case no cameras were saved in the scene

mCamera = mSceneMgr->createCamera("IntroCamera");
mCamera->setPosition(Vector3(0,60,0));
// Look back along +Z
mCamera->lookAt(Vector3(0,60,0));
mCamera->setNearClipDistance(5);
mViewport = mRoot->getAutoCreatedWindow()->addViewport(mCamera,1);
mViewport->setBackgroundColour(ColourValue(1.0, 1.0, 1.0));
}


i got 2 problems now:


1.- i'm using a state manager so before using the max camera i created my camera, scenemanager and viwport, then i loaded the osm file. if i have to get back to another state, let's say to a login state or something when i exit the sate and then i get back i got an rror complayning about the trying to read a section of memor and you now those errors. the compiler breaks at this line when i get back to my play state

mSceneMgr->setSkyBox(true, "Examples/CloudyNoonSkyBox"); this funny becouse the first time i enter to my play state evrything works, but the second it doesn't.... why is that?. and after trying to use the 3dsMax camera everything worked and as able to exit and get back to my play state without problems.


2.- the second thing has to do with the camera, if i try to manipulate the camera exported form MAX for example if i rotate to the left or the right the camera at the same time the camer rolls a lil bit on teh z axis, this happens after and before the animation,, is like having the camera ffected in a world coordinate system while i'm affecting it in a local coordinate sustema, i don't know, since i would like to keep using that same camera s a fisrts person camera before the animation how can i reset that?..

:S any thoughts?.

thanks in advance.

Lioric

19-02-2009 16:25:47

Probably your scene state manager changes the scene manager object, you need to review if your scene manager pointer is valid after the scene state is changed (it seems that you have a dangling pointer for the scene manager)

For the camera you might need to enable or disable fixed yaw (depending on how you need the camera to move) use the "setFixedYawAxis" method of the camera object

marc_antoine

05-03-2009 14:46:29

what does the fixed yaw method exactly does?, i had a target camera from max, and setting on/off the fixedYaw(), does nothing, anyway, i made something like this:

1.- create a sceneNode
2.- loaded the scene with ofusion
3.- asigned the scenemnager
4.- attached the camera created from the oFusion SceneManager tot he node
5.- got the camera parent node and assigned it to th sceneNode from step 1
6.- the camera is working.. also i changd the camera type to free

but the target camera stills work weird, :(

Lioric

09-03-2009 15:01:55

See the Ogre documentation on the camera fixed yaw method, it will provide you with more information and see some of the Ogre demos, most of them use the type of camera the you need