beging use NxOgre

irado

11-05-2008 12:36:11

I am studing the code the Cakebox, into i am trying do one simple scene that
one Object(cube) move in the 3D ambient and collide with other Object.

for now my code is:


class Spikey : public TriggerContactCallback {

public:

Spikey() {
mDeletionPolicy = GC_Delete;
}

~Spikey() {}

void Stay(Shape*, Actor* actor) {

if (!actor->isDynamic())
return;

actor->addForce(NxMath::rand(-1000,1000),NxMath::rand(-1000,1000),NxMath::rand(-1000,1000));
}

};

class Sleepy : public SleepCallback {

public:

void ActorSleep(Actor* actor) {
printf("Awww. %s has fallen asleep.\n", actor->getName().c_str());
}

void ActorWake(Actor* actor) {
printf("You woke up %s!!\n", actor->getName().c_str());
}

};

...

world = new World("time-controller: ogre");
world->getPhysXDriver()->createDebuggerConnection();
scene = world->createScene("testeNx", "renderer: ogre, controller: accumulator, gravity: yes, floor: yes");

scene->setSleepCallback(new Sleepy(), GC_Delete);

TriggerContactPtrCallback<AplicationListener>* cake_ptr = new TriggerContactPtrCallback<AplicationListener>(this, &AplicationListener::In, &AplicationListener::Out);

scene->createTrigger(new SimpleBox(Vector3(5,5,5), Vector3(7.5, 2.5, 0)), cake_ptr);

scene->createBody("Boo; cube.1m.mesh", new Cube(1), Vector3(10,1,10), ActorParams("Mass: 10"));
scene->createBody("Franky; cube.1m.mesh", new Cube(1), Vector3(5,1,10), ActorParams("mass: 10"));



Into what i must add in code for move one cube, and the code for collide
the cubes(Boo and Franky).

thanks

betajaen

11-05-2008 12:49:15

Use the Actor::addForce in the direction of the other cube and multiply it by the amount of force you want.

irado

11-05-2008 13:30:06

thanks !!!!

The box move and collide with other.

i do:

Spike = scene->createBody("Boo; cube.mesh", new Cube(100), Vector3(750, 50, 10), ActorParams("Mass: 10"));
scene->createBody("Franky; cube.mesh", new Cube(100), Vector3(5,50,10), ActorParams("mass: 10"));


and

case OIS::KC_C:
Spike->addForce(Vector3(-250,100,0)*100);


Now i have other questions :D

How i put the floor is one terrain create using:

scene_mgr->setWorldGeometry("terrain.cfg");


thanks

OgreMage

11-05-2008 19:08:08

Q: What would be the difference between setWorldGeometry and using an invisible TriangleMeshShape?

betajaen

11-05-2008 19:49:39

They are completely separate. SetWorldGeomtry creates some terrain and displays it visually, TerrainMeshShape(0.9) or Terrain(1.0) creates some terrain and physically simulates it.

Apart from handling terrain, they completly seperate and unknowing of each other.

OgreMage

11-05-2008 20:04:15

So there are no physic simulations with setWorldGeometry, correct?

betajaen

11-05-2008 20:31:17

No. It's an Ogre thing.

irado

11-05-2008 20:54:20

i am trying using


Terrain terreno = Terrain("terrain.cfg",Vector3(100,1,100));


but i dont know what i must put the params, into i get message erros :(, Into what the correct?

I dont find the method TriangleMeshShape(). I search in the NxOgre, Actor, world and scene, this method is member that what class?

OgreMage

11-05-2008 21:29:04

According to the previous post in this topic,

It's an Ogre thing.

perhaps posting in the [b]Ogre Forum[/b] will benefit you more?

betajaen

11-05-2008 22:10:13

I dont find the method TriangleMeshShape(). I search in the NxOgre, Actor, world and scene, this method is member that what class?

Again. Like I told OgreMage. The NxOgre Terrain shape has nothing to do, or works with the Ogre Terrain system. It is up to you to create whatever code needed for them to work together.

It seems your jumping 10 steps ahead here, and missing all of the basics.

irado

12-05-2008 12:20:45

Ok, no is bad idea, when i know more about nxogre i can try this. I know that i am do simple question, but i dont find reply, in shortguide, look the cakebox, or in other posts the forum, i know too that i am give more work.

Into my terrain or floor, it must one .mesh? And If my .mesh your shape is of the one terrain, how i can do this in the code for createBody(), because the shape no is one cube, or sphere for one terrain.

I find this topic
http://www.ogre3d.org/phpBB2addons/view ... ht=terrain

but i dont find the method TerrainShape().

thanks again :D

betajaen

12-05-2008 12:27:23

No. It's just your mixing names of classes and terms from different libraries and versions all together. It's confusing you, and confusing us.

Let me clear things for you.

1. Terrains are not meshes. They are image files loaded in and displayed on the screen; either using the default Terrain SceneManager that comes with Ogre; or the other Terrain addons.

2. NxOgre can use Terrain. It is handled via a Shape which is in a static Actor.
- In Bleeding (1.0), the shape is called "Terrain". It loads heightfields (xhf) converted from RAW images using Flour.
- In 0.9, the shape is called "TerrainShape". It loads heightfields from images using the Ogre Image classes.

3. You have to position and scale the Actor to the right position to the terrain displayed on the screen. Because there are so many terrain libraries around, NxOgre does not pick favourites, and makes you right the code to do it. It isn't hard, it's just fiddly.

4. Use Intellisense; Your IDE supports it. Just type NxOgre:: then hit ctrl+space, you'll see all the classes of NxOgre in plain English. If you don't have intellisense then use Doxygen to parse the source and generate some documentation for you.

Terrain is a tricky and advanced topic. It's not meant for beginners - as there are many parameters for tweaking to get it right.

irado

12-05-2008 12:53:20

I use the Visual C++, it have Intellisense :D, for this i say that i search in the NxOgre, Scene, and World and dont find the methods.

I will try the Flour.

I will be back :D

irado

12-05-2008 13:55:58

I add one Heightfield with the code using the flour too:


Resources::ResourceSystem::getSingleton()->addHeightfieldAs("file://hftest.xhf", "wave");
Resources::Heightfield* hf = Resources::ResourceSystem::getSingleton()->getHeightfield("wave");
scene->createActor("Trotters", new Terrain(hf, float3(1500,50,1500), "", "centering: xz-above, hole-material: 65535"), Ogre::Vector3(64, 0, 64), "static: yes");


but i dont see the heightfield, what is the error?

thanks

betajaen

12-05-2008 14:12:58

As I've said twice. It doesn't display the height field. NxOgre is a physics library, not a rendering library.

irado

12-05-2008 14:19:53

ok so sorry, i will try one things

irado

13-05-2008 02:22:55

I can see the shape the actors or body? only polygon for example.

thanks

irado

17-05-2008 19:25:19

One very simples question. What i use for i create one method that i can know when one cube collide with other for example.

I use trigger? Hit Report? Callback?

One simple word help more :D

thanks very much.

betajaen

17-05-2008 19:35:52

ActorCallback with ActorGroups.

OgreMage

17-05-2008 19:35:59

http://www.ogre3d.org/phpBB2addons/viewtopic.php?t=5171

irado

17-05-2008 19:43:27

very very thanks a lot betajaen and OgreMage. I will study to learn :D

thanks

irado

17-05-2008 21:29:57

i try do what this page say:

http://www.ogre3d.org/phpBB2addons/view ... 7130#27130

my code is:


class myCallback {

public:

void TurnRed(Actor* a, Actor* b) {
Body* bd = static_cast<Body*>(b);
bd->addForce(Vector3(5000,1,1));

}

void TurnYellow(Actor* a, Actor* b) {
Body* bd = static_cast<Body*>(b);
}

void Jiggle(Actor* a, Actor* b) {
b->addForce(Vector3(NxMath::rand(-10,10), NxMath::rand(-10,10), NxMath::rand(-10,10)) * b->getMass());
}
};


in create the bodys:


primGrupo = scene->createActorGroup("prim");
segGrupo = scene->createActorGroup("sec");

Spike = scene->createBody("Boo; cube.mesh", new Cube(100), Vector3(1000, 350, 900), ActorParams("Mass: 10, group: prim"));

scene->createBody(vp.mIdentifier, new Cube(100*(Ogre::Vector3(vp.mGraphicsModelScale.x,vp.mGraphicsModelScale.y, vp.mGraphicsModelScale.z))), Vector3(800,150,900), vp, ActorParams("mass: 10, group: sec"));

myCallback *mCallback = new myCallback();

primGrupo->setCallback<myCallback>(mCallback, &myCallback::TurnRed, &myCallback::TurnYellow, &myCallback::Jiggle);
primGrupo->setCollisionCallback(segGrupo, NX_NOTIFY_ALL, true);



I try run the project and show the messeage of error:


c:\ogresdk\nxogre\include\NxOgreGroup.h(173) : error C2661: 'NxOgre::GroupCallback::GroupCallback' : no overloaded function takes 5 arguments
1> .\src\AplicationListener.cpp(151) : see reference to function template instantiation 'void NxOgre::ActorGroup::setCallback<myCallback>(T *,void (__thiscall myCallback::* )(NxOgre::Actor *,NxOgre::Actor *),void (__thiscall myCallback::* )(NxOgre::Actor *,NxOgre::Actor *),void (__thiscall myCallback::* )(NxOgre::Actor *,NxOgre::Actor *),bool)' being compiled
1> with
1> [
1> T=myCallback
1> ]


Whats the problem? What I must do?

thanks

betajaen

17-05-2008 22:10:03

It's a bug which you could of searched for. One post down from yours <sigh>

http://www.ogre3d.org/phpBB2addons/viewtopic.php?t=7238

irado

18-05-2008 03:05:47

I dont understand very well the cody of the post. I need one help.

One part is the code of the NxOgre, and the other I add in my code.


myCallback *mCallback = new myCallback();
GroupCallback cb = new GroupCallback(mCallback, &myCallback::TurnRed, &myCallback::TurnYellow, &myCallback::Jiggle);


and show the error:


.\src\AplicationListener.cpp(151) : error C2440: 'initializing' : cannot convert from 'NxOgre::GroupCallback *' to 'NxOgre::GroupCallback'
1> No constructor could take the source type, or constructor overload resolution was ambiguous


I really need one help.

thanks

gugus

18-05-2008 09:27:29

GroupCallback cb
should be
GroupCallback* cb :wink:

BloodyFanatic

18-05-2008 10:37:17

@irado:
maybe you should learn c++ FIRST, then Ogre and THEN NxOgre. that kind of error should one fix him/herself...
and do what betajaen said: USE THE SEARCH! Stop asking stupid time-consuming questions that are already solved or easy solvable by yourself...

betajaen

18-05-2008 11:25:27

Well, at least he's keeping them to one thread, rather like some people. :roll:

irado

18-05-2008 13:08:56

Well, Well, Well,

I really dont read one tutorial of the C++, but i use Ogre a long time, I learn others add-ons, many give more work, how NxOgre, but I try, try and I get use.

My english is very very simple, but I try read, often I use the google translator, but I dont quit.

If one people search me, and ask me one thing, for my stupid this is, I reply, because one question can is simply for me but very hard for other.

I use the search of the forum, I ever search before one question(though this can not opnion true), I test things before one question(though I dont know this error the C/C++, into the things that i try dont compile without erros).

If you dont like my question dont read it and dont reply. I really thanks the betajaen, OgreMage and gugus, because them are help me. While you reply this form, want appear, I will study and learn, for help others peoples better in the future.

t+

BloodyFanatic

18-05-2008 17:16:16

sorry for being a little bit offensive, but that was a must... your last question was a c++ specific one, which could also occurred without nxogre...

i will help with nxogre stuff when i can and your question wasn't answered somewhere else yet. :)

I really dont read one tutorial of the C++, but i use Ogre a long time, I learn others add-ons, many give more work, how NxOgre, but I try, try and I get use.

if i understand you correctly, you haven't read c++ tutorials?! how can you use ogre then? or nxogre? you really need atleast a basic knowledge of c++ :wink:

irado

20-05-2008 00:57:30

No problem :D, I read tutorial about C, but how the language is very similar and I know Java and Object-Oriented Programming into I understand many things.

I really dont know what i can try more. I write:


myCallback *mCallback = new myCallback();
GroupCallback *cb = new GroupCallback(mCallback, &myCallback::TurnRed, &myCallback::TurnYellow, &myCallback::Jiggle);


I try:


primGrupo->setCallback(mCallback);



primGrupo->setCallback(cb);



primGrupo->setCallback(mCallback, &myCallback::TurnRed, &myCallback::TurnYellow, &myCallback::Jiggle);



primGrupo->setCallback<myCallback>(mCallback, &myCallback::TurnRed, &myCallback::TurnYellow, &myCallback::Jiggle);


and the project dont run and the error is in this line.

What the problem?

irado

28-05-2008 02:02:56

hello i am be back.

How nobody reply my previous post(maybe is more one simples question), into i try other way, into my code are this form:


class AplicationListener : public FrameListener, public OIS::KeyListener, public OIS::MouseListener,
public OIS::JoyStickListener, public CThread, public GroupCallback::InheritedCallback
{

...

void onStartTouch(Actor* a, Actor* b);
void onEndTouch(Actor* a, Actor* b);
void onTouch(Actor* a, Actor* b);



and


primGrupo = scene->createActorGroup("prim");
segGrupo = scene->createActorGroup("sec");

Spike = scene->createBody("Boo; cube.mesh", new Cube(100), Vector3(1000, 250, 900), ActorParams("Mass: 10, Group: prim"));
body = scene->createBody("Franky; cube.mesh", new Cube(100), Vector3(500, 450, 900), ActorParams("mass: 10, group: sec"));

primGrupo->setCallback(this);
primGrupo->setCollisionCallback(segGrupo, NX_NOTIFY_ALL, true);

....

void AplicationListener::onStartTouch(Actor* a, Actor* b) {
scene_mgr->getSceneNode("roboNode")->setScale(Vector3(3,3,3));

}

void AplicationListener::onEndTouch(Actor* a, Actor* b) {


}

void AplicationListener::onTouch(Actor* a, Actor* b) {

}




The project run no problem, but when the cubes Boo and Franky collide or touch the robot dont change your scale.

What the error?

thanks

irado

01-06-2008 15:49:10

Anybody can say one word for help? The code are correct and this not are implemented yet?

gugus

01-06-2008 16:11:43

That's strange...
It should be something like
onStartTouch(Actor*, Actor*, ContactStream*)
and not
onStartTouch(Actor* a, Actor* b);
I don't know how it can compile(unless you use 0.9)...

irado

02-06-2008 00:39:54

Yeeeeeeeeesssssssssssss,

very very thanks gugus, the error is only this i change the params of the methods to:


void onStartTouch(Actor*, Actor*, ContactStream*);
void onEndTouch(Actor*, Actor*, ContactStream*);
void onTouch(Actor*, Actor*, ContactStream*);


and


void AplicationListener::onStartTouch(Actor*, Actor*, ContactStream*) {


}

void AplicationListener::onEndTouch(Actor*, Actor*, ContactStream*) {


}

void AplicationListener::onTouch(Actor*, Actor*, ContactStream*) {
scene_mgr->getSceneNode("roboNode")->setScale(Vector3(3,3,3));

}


The robot scale change :D. I can write the tutoriais.

thanks again.