Multiple scenes

tx

06-03-2007 11:28:25

Hi!

Im having some problems on how to implent my spaceship in a game.

I want to have two scenes, one for the interior of the ship and one for the exterior.

Now I don't want the objects in the inside to be affected by acceleration of the ship. And not any turning and such either (gravity should remain the same).

So I was thinking, two scenes. The first one has a static body of the interior (meshShape). And a character controller + items in the ship. The second will have the outside of the ship and planets, and stations.

Now the problem is. With a static interior and a dynamic exterior how can I make the work together.

First I was looking into if it was possible to define where 0 (start position of the scene) is in the world.

But as the physics really don't have anything to do with the graphics that might only be stupid. Perhaps I could attach the interiors scenenode to the exteriors?

An ideas on this?

tx

06-03-2007 11:37:35

I also added some code which I think was needed in the nxogre_body.h.

Any reason why such methods doesn't exist yet?


void body::addEntity(Ogre::Entity* pEntity)
{
if (!pEntity)
{
error::getSingleton().Throw("pEntity was NULL in " + Ogre::String(__FUNCTION__), nxOgre::error::FATAL);
return;
}

if (!mNode)
{
error::getSingleton().Throw("mNode was NULL in " + Ogre::String(__FUNCTION__), nxOgre::error::FATAL);
return;
}

if (mNode)
{
mNode->attachObject(pEntity);
}
}

void body::addEntity(Ogre::Entity* pEntity, Ogre::SceneNode* pNode)
{
if (!pEntity)
{
error::getSingleton().Throw("pEntity was NULL in " + Ogre::String(__FUNCTION__), nxOgre::error::FATAL);
return;
}

if (!pNode)
{
error::getSingleton().Throw("pNode was NULL in " + Ogre::String(__FUNCTION__), nxOgre::error::FATAL);
return;
}

mNode = pNode;
mNode->attachObject(pEntity);

}

void body::setNode(Ogre::SceneNode* pNode)
{
if (!pNode)
{
error::getSingleton().Throw("pNode was NULL in " + Ogre::String(__FUNCTION__), nxOgre::error::FATAL);
return;
}

mNode = pNode;
return;
}

Ogre::SceneNode* getNode() { return mNode; }

betajaen

06-03-2007 12:16:44

setNode is done via the params<rigidBody> via:

mScene->createBody(...., params<rigidbody>("node: myNode"));

addEntity exists in many different forms.
getNode can just be used by body->mNode. Same thing.

Anyway for your first question:

Why not have two scenes(one for interior and one for exterior) sharing the same scenemanager? You don't have to have the planets literally thousands of miles away, just make them a few km's away and scale them down.

tx

06-03-2007 13:12:33

Well addEntity(Entity*) was not implented, it gave a linker error and when I checked thrue the code it for sure wasn't there :D

And the both scenes do share the same scenemanager :)

But I got it working now sort of. The static interior is a child node of the dynamic exterior. It's only the debug lines that remains on place, I don't think there is anything to do about that. And of course applying the force from the camera can be a bit tricky now I guess.

Anyway I love this addon, and I find the code very easy to read 8)

tx

06-03-2007 14:51:34

I also added some code which I think was needed in the nxogre_body.h.

Any reason why such methods doesn't exist yet?


I just realised I was a bit confused. mNode and mEntity is public, and im not used to public variables in classes :lol:

betajaen

06-03-2007 17:03:06

Ahh. I feel it's just best to keep them open, incase someone directly needs access to them.

Enjoy NxOgre ;)