loaded .osm, but scene is empty

sacer_carabus

24-05-2007 21:17:54

hi.

I am trying to use oFusion like this:


OSMScene oScene;
oScene.initialise("lightmap.osm");
oScene.createScene();


and run my application. Scene is empty.

I use adobe_jail_final.max from tutorial. With it in Max9, I do:
1. oFusion->Export Scene.
2. print lightmap.osm.
3. cheking 'copy textures', setting folder
4. copy OgreMeshUpgrader (get it from here http://www.kineticrealities.com/meshupdater.zip) in folder with .mesh and .osm
5. upgrading all .mesh with this such bat file:


lfnfor off
for %%x in (*.mesh) do OgreMeshUpgrade -b -t %%x


All .mesh are OK to upgrade, but Door.mesh - on it upgrader crashes.

my application is pure ExampleApplication plus above code in createScene. All compiled OK. I copy it Ogre's Sample/Common/Debug, and add to resources.cfg path to lightmap.osm and textures.

Ogre.log is OK too, it's like:


22:50:32: Mesh: Loading Box01.mesh.
//....many boxes get loaded....
22:50:32: ********************************
22:50:32: ** oSceneLoader: Scene loaded **
22:50:32: ********************************


So what is wrong?

Paulov

24-05-2007 21:23:41

hi

I´m an artist but I suffered this thing a couple of weeks ago.

When you run meshupdater to solve the AABB problem you update the meshes to Eithort. May be you are running a previos version.

That was what happened to me.

Good luck

Evak

24-05-2007 23:10:02

we have been having problems with the ofusion scene loader too. It only happens when you let Ofusion create a scene manager, in which case one mesh will draw if your lucky, and all the rest load but do not display.

About a week ago weI sent source for a test app, and later the media and a max scene to be tested. Hopefully we will hear something soon.

At the moment were using our own scene manager instead of the one Ofusion would normaly create, this works fine, but means you have to handle some of the OSM global scene environment settings (BG color, skybox etc) yourself.

We were thinking it strange that we were the only ones having this behaviour :(

sacer_carabus

25-05-2007 22:06:30

yes! it works!

one difference I was needed:


OSMScene oScene(mSceneMgr, mWindow);


You NEED to pass your mSceneMgr and your mWindow to OSMScene object. Let's see on OSMScene ctor:


OSMScene::OSMScene(SceneManager* pSceneMgr, RenderWindow* win)
{
mSceneMgr = pSceneMgr;

if(win)
mWindow = win;
else
mWindow = Ogre::Root::getSingleton().getAutoCreatedWindow();

mCallbacks = 0;
}


and at createScene method, which we call shortly after ctor:

if(mSceneMgr == NULL)
{

if(rootElem->FirstChildElement("sceneManager"))
pParent = createSceneManager(rootElem, bHandled);
else
mSceneMgr = Root::getSingleton().createSceneManager(ST_GENERIC);
}


So, if we don't pass our pSceneMgr, it will be NULL in createScene. I did not dig in what rootElem is, but may be my code goes to 'else' branch and inside OSMScene object was another mSceneMgr and another mWindow, and all loaded fine, just to another place that we see on.

Anyway it works. Thanks for hint.

Lioric

25-05-2007 22:46:11

See the oSceneLoader demo application code, it overrides the sceneManager, the camera and the viewports creation methods as they are handled by the loader lib (use your own scene manager and viewports if you dont need to load scene that uses different SM)


// The scene manager will be created by the Scene Loader lib
void chooseSceneManager(void) {}
void createCamera(void) {}
void createViewports(void) {}


After you call createScene, you should use a similar code:



// Get the scene manager autocreated or loaded from the scene file
mSceneMgr = oScene.getSceneManager();

// Get the list of cameras loaded with the scene
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("PlayerCam");
// Position it at 500 in Z direction
mCamera->setPosition(Vector3(0,0,500));
// Look back along -Z
mCamera->lookAt(Vector3(0,0,-300));
mCamera->setNearClipDistance(5);

// If a viewport was not automatically created, (no cameras saved in the scene)
// create a default viewport, entire window
Viewport* vp = mWindow->addViewport(mCamera);
vp->setBackgroundColour(ColourValue(0,0,0));

// Alter the camera aspect ratio to match the viewport
mCamera->setAspectRatio(
Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
}


Using autocreated Scene managers should be working correctly

sacer_carabus

26-05-2007 04:45:56


Using autocreated Scene managers should be working correctly


Yes, it may do the gob but only when we load the scene right after start, and then get SceneManager from it to do the rest of our init process. But what if we need get SceneManager now to do init and not setup scene? I mean if at the begging of game we must load menu, and after menu - some scene. We need SceneManager to load menu. But get it from OSMScene we can only after

//create and setup the scene in the root node
oScene.createScene();


So one of the way out - to pass your mSceneManager and mWindow to OSMScene ctor, do

oScene.initialise("some.osm");

but not now

oScene.createScene();

and continue init of our app with our mSceneMgr. And may be some time later - to load scene.

Lioric

26-05-2007 17:09:01

Yes, the support for any scene setup method you need is there, either autocreating scene managers or using your own