In Nxogre1.0, where is body->getNode() , getEntity()

kidcdf

23-04-2008 14:31:24

I think these methods are useful,because I can get Ogre point from Nxogre::Body,but I can't find the similar methods in Actor's methods list.

BYW: Nxogre1.0 changes a lot, how can I rewrite the old codes and learn the new structure of Nxogre in a short time

betajaen

23-04-2008 14:37:44

You get it from the NodeRenderable; assuming your using Ogre as a Renderer and a OgreNodeRenderable as the NodeRenderable.

kidcdf

24-04-2008 05:11:37

You get it from the NodeRenderable; assuming your using Ogre as a Renderer and a OgreNodeRenderable as the NodeRenderable.
here are some original codes,how can I chang them to NxOgre1.021 version?

body->getEntity()->getboundingbox()
body->getNode()->setPosition()
body->getNode()->setDirection()
body->getNode()->yaw()
body->getNode()->_getDerivedPosition()
body->getNode()->attachObject()
...

I found "body->mNodeRenderable",but it's protected and there is no methods I need in NodeRenderable class.

Thx for help

betajaen

24-04-2008 09:08:38

Yes, I just told you. You get it from the Renderable, there is an accessor method which you use to cast it into a OgreNodeRenderable (assuming you are using the Ogre renderer provided).

Caphalor

24-04-2008 16:35:34

This is also discussed here (I also posted some code).

kidcdf

25-04-2008 03:59:48

There are hundreds of "getNode()->" in my project, now I have to change all of them to "((NxOgre::OgreNodeRenderer*)body->getRenderer())->getNode()",right?

Another question is:
Is Ogre the default renderer embeded in Nxogre? Does that mean I need not to "mScene->setSceneRenderer(new OgreSceneRenderer(mScene)); " ?

I found these codes here:
http://www.ogre3d.org/phpBB2addons/view ... t=irrlicht

I really consider that it's nice if you write some code snips of useing getNode() for Ogre user rather than just telling us theory.

Anyway,the strong system"NxOgre" is only written by one person, the lack of help documents is obvious,so we need more detailed help, especially for jackaroo

betajaen

25-04-2008 09:47:29

You DON'T have you use the Body class in your own code. You can write your own based upon the Actor which uses the OgreNodeRenderable up to the sky.

Body is abstract in the way it renders because it has to cover not only different types of rendering (NodeBased, MeshBased, etc.) but cover different possible rendering systems; Ogre at the moment, but in the future DirectX, OpenGL, Irrlicht, etc. Which is the reason why you have to cast it the NodeRenderable into a OgreNodeRenderable.

But if you use an inherited Actor (which I strongly recommend with any serious application using NxOgre) using an OgreNodeRenderable you wouldn't have this problem.

And that code snippet you may use. Is a hack, and not the proper way of doing it - and can cause crashes.

kidcdf

25-04-2008 13:40:46

come on! just give example, It's too hard to use your bleeding! maybe you think it is easy to control,because it's made by you!

betajaen

25-04-2008 13:49:48

Le Sigh.

// Weed out the actors.
if (actor->voidPtr->RenderPtr == 0) {
return;
}

// Get the Renderable.
NxOgre::Renderable* renderable = actor->voidPtr->RenderPtr->getRenderable();

// Check to see if it's an Ogre one.
if (renderable->getHashType() == NxOgreClass_OgreNodeRenderable) {
NxOgre::OgreNodeRenderable* nodeRenderable = static_cast<OgreNodeRenderable*>(renderable);
nodeRenderable->go_nuts();
}

betajaen

25-04-2008 14:01:03

class TestActor : public Actor, public RenderableSource {

public:

TestActor(const NxString& name, const NxOgre::Pose& pose, Shape* shape, Scene* scene, const ActorParams& params = ActorParams())
: Actor(name, scene, shape, pose, params)
{

// Hardcoded.
// If using the Ogre rendered, mName is the name of the SceneNode to create (because the type is create not use.)
// The model is the name of the mesh which the entity will be created (because the type is a resource, not a reference.)

NodeRenderableParams visualParams("identifier: " + mName + ", identifier-type: create, model: cube.1m.mesh, model-type: resource");

mRenderable = mOwner->getSceneRenderer()->createNodeRenderable(visualParams);
mNodeRenderable = static_cast<NodeRenderable*>(mRenderable);
mVoidPointer->RenderPtr = this;
setRenderMode(RM_Interpolate);

if (mNodeRenderable->getHashType() == NxOgreClass_OgreNodeRenderable)
mOgreNodeRenderable = static_cast<OgreNodeRenderable*>(mNodeRenderable);

mOwner->getSceneRenderer()->registerSource(this);

}

~TestActor() {
mOwner->getSceneRenderer()->unregisterSource(this);
if (mRenderable) {
delete mRenderable;
mRenderable = 0;
}
}

NxOgre::Pose getSourcePose(const NxOgre::TimeStep&) const {
return getGlobalPose();
}

SceneNode* getNode() {
return mOgreNodeRenderable->getNode();
}

// etc.

protected:

NodeRenderable* mNodeRenderable;
OgreNodeRenderable* mOgreNodeRenderable;

};



for (int i=0;i < 32;i++)
new TestActor("Test", Vector3(0, 3 + i, 0), new Cube(1), mScene, "mass: 10");


Not hard isn't it?

kidcdf

25-04-2008 14:17:42

Then I use the same way to create "My Ogre Body?" like

class TestBody : public Body, public RenderableSource {

public:

TestBody(const NxString& name, const NxOgre::Pose& pose, Shape* shape, Scene* scene, const ActorParams& params = ActorParams())
: Body(name, scene, shape, pose, params)
{
NodeRenderableParams visualParams("identifier: " + mName + ", identifier-type: create, model: cube.1m.mesh, model-type: resource");

mRenderable = mOwner->getSceneRenderer()->createNodeRenderable(visualParams);
mNodeRenderable = static_cast<NodeRenderable*>(mRenderable);
mVoidPointer->RenderPtr = this;
setRenderMode(RM_Interpolate);

if (mNodeRenderable->getHashType() == NxOgreClass_OgreNodeRenderable)
mOgreNodeRenderable = static_cast<OgreNodeRenderable*>(mNodeRenderable);

mOwner->getSceneRenderer()->registerSource(this);

}

~TestBody() {
mOwner->getSceneRenderer()->unregisterSource(this);
if (mRenderable) {
delete mRenderable;
mRenderable = 0;
}
}

NxOgre::Pose getSourcePose(const NxOgre::TimeStep&) const {
return getGlobalPose();
}

SceneNode* getNode() {
return mOgreNodeRenderable->getNode();
}

// etc.

protected:

NodeRenderable* mNodeRenderable;
OgreNodeRenderable* mOgreNodeRenderable;

};


then:
TestBody body = new TestBody("Test", Vector3(0, 3 + i, 0), new Cube(1), mScene, "mass: 10");

And so does the Character?

betajaen

25-04-2008 14:22:50

No you don't do it, this piece of code does it for you:

mRenderable = mOwner->getSceneRenderer()->createNodeRenderable(visualParams);
mNodeRenderable = static_cast<NodeRenderable*>(mRenderable);
mVoidPointer->RenderPtr = this;
setRenderMode(RM_Interpolate);

if (mNodeRenderable->getHashType() == NxOgreClass_OgreNodeRenderable)
mOgreNodeRenderable = static_cast<OgreNodeRenderable*>(mNodeRenderable);


And there is no Character system in 1.0

kidcdf

25-04-2008 14:51:37

I am totally confused...

1. What's NxOgre::CharacterSystem ? you said there's no character any more?

2. I have found your piece of codes in NxOgreBody.cpp, and should I use it in following ways?

NxOgre::NodeRenderableParams param;
param.?????? //what can I do next? oh my god,I just want to render body with OgreRenderer.
NxOgre::Body body=NxScene->createBody(name+";"+filename,shape,
Vector3(0,0,0),param);

betajaen

25-04-2008 15:03:46

Here. I've written a short article.

http://www.nxogre.org/Inheriting_Actor_ ... type_class

Just read the first section. The RenderableFactory isn't in the SVN yet.

kidcdf

25-04-2008 15:33:59

I created the "TestActor" which use OgreRenderer and tell the scene to render this Actor, every simulation, but is it related to creatBody?

I just created a testActor, but do not know what the param "visualParams" should be

betajaen

25-04-2008 15:40:23

It's not Rocket Surgery.

identifier Name of the SceneNode
identifier-type Set to "create" to create a SceneNode, "use" to use an existing one.
model Name of the mesh to use
model-type Set to "resource" to use the Ogre resource system.