Loading a .scene file in an OgreNewt project

nanolucas

09-09-2008 06:40:13

Hi there,

I've been using OgreNewt for a little while now but i can't figure out how to load a .scene file into it.

Can someone provide me with a very basic project that contains all the code i need to get a .scene loaded in?

I tried using OgreMax within the Demo01_TheBasics project with the following code:

OgreMax::OgreMaxScene* Ogremax_Scene = NULL;
Ogremax_Scene = new OgreMax::OgreMaxScene ();
LogManager::getSingleton().logMessage("Loading scene...");
Ogremax_Scene->Load("freeway/freeway.scene", mRoot->getAutoCreatedWindow());
mSceneMgr = Ogremax_Scene->GetSceneManager ();

cam = mSceneMgr->getCamera("mainCam");
cam->setPosition(90.0f, 280.0f, 535.0f);
cam->setNearClipDistance(5);
Viewport *vp = mRoot->getAutoCreatedWindow()->addViewport(cam);


But all it does is close itself and in the log it says a viewport already exists at z-0.

If i change that last line to:
Viewport *vp = mRoot->getAutoCreatedWindow()->addViewport(cam, 1, 0, 0, 1.0f / 3.0f, 1);
then it doesn't give the z-0 error, but it just crashes when it gets to 'initialising OIS'.

Is there a simpler way than using OgreMax? Or can someone provide me with an example project using OgreMax?

Any help is really appreciated.

batnom

13-09-2008 07:51:49

I've also got a similar error, any help would be great.

Ross

22-09-2008 22:45:53

Hi i have been using OgreMax with Dot scene best way I have implermented this is to look at Ogre tutorial page and look up the Ogre Dump node function
Because the dot scene loads the models to the nodes with names
I just shoved every model name to a vector of strings then passed the names to a
collisionTree in OgreNewt and done it seems to work very well its easy to implement I don’t think you need any code its simple to implement but if you still need code ask and I will post my project
For you.

nanolucas

23-09-2008 05:59:12

The purpose of a .scene file is to have an xml format file that defines all the meshes within it and loads those, is it not?

Defining the names of every mesh in an array seems to completely defeat the purpose of having a .scene file in the first place.

Also my .scene file i'm trying to load has at least 500 meshes and i don't particularly care to put the name of each one in an array.

Can anyone help me with this loading please?

feanor91

23-09-2008 06:22:53

Hi

On OgrMax website, you have the code to load a .scene file, just look at and get it. Or see that perhaps :

[url=http://www.ogre3d.org/wiki/index.php/MO]http://www.ogre3d.org/wiki/index.php/MO ... ceneLoader

Celest

23-09-2008 16:10:42

First, check your scenenode name for OgreMax SceneLoader class can load it. My parent scene node is "terrain" (hilighted node).



This is my snippet code :D :D

void loadMap(String mapName)
{
mScene->Load(mapName + ".scene",mWindow, OgreMax::OgreMaxScene::NO_OPTIONS,mSceneMgr,mSceneMgr->getRootSceneNode(),0);

Ogre::SceneNode* sNode = mScene->GetSceneManager()->getSceneNode("terrain");

OgreNewt::CollisionPrimitives::TreeCollisionSceneParser *col = new OgreNewt::CollisionPrimitives::TreeCollisionSceneParser(mWorld);
col->parseScene ( sNode, true );

OgreNewt::Body *body = new OgreNewt::Body(mWorld,col);
body->attachToNode( sNode );

delete col;


and this result (with newtonphysics debugger)



My camera is set by manual. Not need to use camera in scene file or another source.

virtual void createCamera(void)
{
mCamera = mSceneMgr->createCamera("PlayerCam");
mCamera->setPosition(Vector3(45,330,-90));
mCamera->lookAt(Vector3(96,213,-201));
mCamera->setNearClipDistance(5);
}

BardockSSJ

24-09-2008 10:36:58

my opinion is no use the .scene loader. Better way is load scene manually from own format and control elements like "door", "elevator", "switch" manually, and merge world static in huge meshes (64000 poly)