callbacks with physics

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
ulao
Posts: 274
Joined: Fri Mar 28, 2008 2:13 am

callbacks with physics

Post by ulao »

I'm using a irrnewt physics engine and I need to set a call back function.

So I do it like so

setCollisionCallback( inMaterial, this );

since I have to inherit IMaterialCollisionCallback for parm 2, this calls my class not a function. Is there a way to call a function?

I have to add this in my class

Code: Select all

virtual int ContactBegin(
		irr::newton::IMaterialPair* material_pair,
		irr::newton::IBody* body0,
		irr::newton::IBody* body1) {
//do stuff
		//refuse the contact (return 0)
		return 1;
	}
	virtual int ContactProcess(
		irr::newton::IMaterialPairAndContact* material_pair_and_contact
		) {
		//refuse the contact (return 0)
		return 1;
	}
	void hitGround(){ m_bGrounded = true; };

to get to the callback, but that would be the same for each object? I need to call different functions.

I could test body0 compared to bod1, but that is silly redundant since I'm calling with body1->setCallBack ( body0 ); to begin with?


any ideas?
olivehehe_03
Posts: 157
Joined: Tue Mar 20, 2007 8:30 am

Post by olivehehe_03 »

Hate to be the one to say it, but thing like IrrNewt aren't officially supported on these forums BUT, even though I'm not 100% on the question, the IrrNewt documentation and examples might help to clear things up a bit, I'm using an older SVN version, but the docs are in ..\IrrNewt\doc and the best example for you to look at for callbacks would be the one in the ..\examples\demo folder which shows creating the callback, putting your own code in it and getting it all set up to work right
Tell me what you cherish most. Give me the pleasure of taking it away.
ulao
Posts: 274
Joined: Fri Mar 28, 2008 2:13 am

Post by ulao »

IrrNewt documentation and examples might help to clear things up a bit
- Actually that is the worst part about the entire wrapper. Its hard enough to understand it half the time.


The example works fine for me, I based what I created off of it. I'm just trying to find a way to call a function in my class rather then a pointer to a new class. But it could be that it just wont work that way. I may just have to redundantly do a switch in the ContactBegin and see what was hit. Just sounds a bit strange to do it that way.

Think of it this way. If you have 20 types of objects you can encounter you would need 20 classes, for what? A simple setting of a flag? LOL sounds a bit ineffectual to me..

You are definitely right about the support, its just a creation a guy made that I dont think is around here any more. I finally got the source compiled so I may have to dive in to his code and see whats what.
FuzzYspo0N
Posts: 914
Joined: Fri Aug 03, 2007 12:43 pm
Location: South Africa
Contact:

Post by FuzzYspo0N »

Hey ulao,

I dont know if you have seen or read any of the Tumle source (i think i remember you posting in there) but this is a modified of the original, it has some weird issues but im hoping it will help explain some things about the materials and possibly the updates from the other thread..

I uploaded the file here

Code: Select all

http://www.mediafire.com/file/mjwimmdzntu/tumle0.2.zip
And, i dont know if it compiles or not (i will fix it soon actually for the latest svn) but it uses 1.53 of newton I THINK, newton had so many weird updates and secret 2.0 version in my PM's on the newton forums i just gave up on caring and used bullet instead. But, if i remember correctly i enjoyed using the materials in tumle cos they worked nicely.. There is an example for materials and material calbacks which might help
ulao
Posts: 274
Joined: Fri Mar 28, 2008 2:13 am

Post by ulao »

FuzzYspo0N thx, I'll check it out.

I dont believe I know of tumle, at least it does not ring a bell. I'm in the beginning of physics integration so I may not stay with newton. I have read good things about bullet so I may also switch, not sure yet.

Thx again, I'll take a look.
ulao
Posts: 274
Joined: Fri Mar 28, 2008 2:13 am

Post by ulao »

Wow you just solve two of my bugs...I guess the entire problem is that my function takes ( mat, func ) and yours has 3 parms all functions. . I'm not sure why I only have two but I'll look in to this.

I see your call does not have the second material that collided?

Looking at the sdk

void NewtonMaterialSetCollisionCallback( const NewtonWorld* newtonWorld, int id0, int id0, void* userData, NewtonContactBegin beginCallback, NewtonContactProcess processCallback, NewtonContactEnd endCallback)

guessing the docs meant int id0, int id1 ??

It looks like both uses are just not fully using the available parms. As to why I was so confused.

Off to modify the irrnewt source..
FuzzYspo0N
Posts: 914
Joined: Fri Aug 03, 2007 12:43 pm
Location: South Africa
Contact:

Post by FuzzYspo0N »

also, its not "my code" as u see in the readme it says "JonLT" he made the original wrapper. i wrote a few MINOR things and also, pinguindude did a lot toward it. But yea... disclaimer aside ;P

The problem is newton changes so much, i often dont know wtf is going on there with the SDK's, the last public sdk is 2004 and its 1.53, i had some random version of 2.0, i have newton folders, one of which works but none of the files have versioning, so perhaps the extra parameters are legacy random stuff. So check it out with the sdk you have :)
ulao
Posts: 274
Joined: Fri Mar 28, 2008 2:13 am

Post by ulao »

Ah well that would amount to some of the troubles then.

thx for the help, Didnt look at the comments on top to see the author, sorry there.

I see a few incarnation of bullet physics wrappers around here. Assuming you made your own is it up for viewing?

I dont think I'll stay with newton, I may look in to Brainsaw's ode.

thx again.
FuzzYspo0N
Posts: 914
Joined: Fri Aug 03, 2007 12:43 pm
Location: South Africa
Contact:

Post by FuzzYspo0N »

i prefer bullet over ODE and i am currntly using a small minimal wrapper by blindside, theres a number of bullet demos on the forums... including one made by the maker of bullet himself :)

http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=32593
Post Reply