Irrlicht 1.7.2 and Newton 2.XX (Complete NOOB needs help!)

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: Irrlicht 1.7.2 and Newton 2.XX (Complete NOOB needs help

Postby joepaddyroe » Thu Feb 17, 2011 9:00 am

Hi Julio,

Thanks for that!

So basically I have to define some kind of 2D float array eg: float matrix[4][4]

Is this supposed to define the extents of the collision mesh or whatever?

Thanks.
joepaddyroe
 
Posts: 16
Joined: Wed Feb 16, 2011 7:54 am

Re: Irrlicht 1.7.2 and Newton 2.XX (Complete NOOB needs help

Postby ledahut » Thu Feb 17, 2011 9:12 am

Is this supposed to define the extents of the collision mesh or whatever?

No this matrix 4*4 is the rotation and position of the body in global world.
Need to be normalized (no scale) except the last row (x,y,z position).
A identity matrix (four '1' at diagonal) have no rotation and (0,0,0) position.
ledahut
 
Posts: 98
Joined: Mon Jun 21, 2010 8:03 am
Location: France

Re: Irrlicht 1.7.2 and Newton 2.XX (Complete NOOB needs help

Postby joepaddyroe » Thu Feb 17, 2011 10:27 am

Hi ledahut,

Thanks for that.

I guess the matrix is something I will have to define and then apply to the object using callbacks or something.

I'll have alook at the tutorials again.

Cheers.
joepaddyroe
 
Posts: 16
Joined: Wed Feb 16, 2011 7:54 am

Re: Irrlicht 1.7.2 and Newton 2.XX (Complete NOOB needs help

Postby ledahut » Thu Feb 17, 2011 10:38 am

You said you were complete noob in your title :) ok
Matrix for 3D program store information of object. Look on internet.

In irrlicht for example (I never used this one), you can create 3d cube and set direction/rotation/position/angle...
So you need to retrieve the transformation matrix[4][4] from your cube and send it to newton at the body creation.

Nine month ago I didn't know how 3d matrix worked, in 2 week I fully understand the concept. Again look on internet.
ledahut
 
Posts: 98
Joined: Mon Jun 21, 2010 8:03 am
Location: France

Re: Irrlicht 1.7.2 and Newton 2.XX (Complete NOOB needs help

Postby joepaddyroe » Thu Feb 17, 2011 11:55 am

Hi ledahut,

Oh, ok, I think I get it now.

I have run into another issue now though :?

I have defined everything inside a game class init() function.

The issue I have is that when I go to use the callbacks to these functions:

void PhysicsApplyForceAndTorque (const NewtonBody* body);
void PhysicsSetTransform (const NewtonBody* body, const dFloat* matrix);

It throws two errors:

error C3867: 'Game::PhysicsSetTransform': function call missing argument list; use '&Game::PhysicsSetTransform' to create a pointer to member
error C3867: 'Game::PhysicsApplyForceAndTorque': function call missing argument list; use '&Game::PhysicsApplyForceAndTorque' to create a pointer to member

My pointer and reference skills aren't too good.

Am I on the right track here?

Somebody mentioned on a google search that you can't callback a memeber function unless you make them static?

I got this when I made the two functions static:

1>c:\users\joe\documents\visual studio 2008\projects\irrlicht1\irrlicht1\src\game.cpp(139) : error C2664: 'NewtonBodySetTransformCallback' : cannot convert parameter 2 from 'void (__cdecl *)(const NewtonBody *,const float *)' to 'NewtonSetTransform'
1> None of the functions with this name in scope match the target type
1>c:\users\joe\documents\visual studio 2008\projects\irrlicht1\irrlicht1\src\game.cpp(140) : error C2664: 'NewtonBodySetForceAndTorqueCallback' : cannot convert parameter 2 from 'void (__cdecl *)(const NewtonBody *)' to 'NewtonApplyForceAndTorque'
1> None of the functions with this name in scope match the target type

Not sure what to do now?

Thanks for your help!
joepaddyroe
 
Posts: 16
Joined: Wed Feb 16, 2011 7:54 am

Re: Irrlicht 1.7.2 and Newton 2.XX (Complete NOOB needs help

Postby ledahut » Thu Feb 17, 2011 12:22 pm

You procedure definition need more parameters:
void PhysicsApplyForceAndTorque (const NewtonBody* body);
void PhysicsSetTransform (const NewtonBody* body, const dFloat* matrix);

see
http://newtondynamics.com/wiki/index.ph ... eAndTorque
http://newtondynamics.com/wiki/index.ph ... tTransform
After that it should work.


Somebody mentioned on a google search that you can't callback a memeber function unless you make them static?

If function or procedure are declared in a class (so they are object methods) you can NOT pass them to newton with SetCallback.
But you can declare static function in class (see oriented object manuals).

In your case they are methods of the 'Game' class so they need to be static (=owned by the class , and accessible in runtime by instances of 'Game' class).
ledahut
 
Posts: 98
Joined: Mon Jun 21, 2010 8:03 am
Location: France

Re: Irrlicht 1.7.2 and Newton 2.XX (Complete NOOB needs help

Postby joepaddyroe » Thu Feb 17, 2011 1:22 pm

Thans very much ledahut!

The scene is running now, except no physics as far ai I can see, I'll keep digging, I'm probably missing something important.

Cheers
joepaddyroe
 
Posts: 16
Joined: Wed Feb 16, 2011 7:54 am

Re: Irrlicht 1.7.2 and Newton 2.XX (Complete NOOB needs help

Postby joepaddyroe » Thu Feb 17, 2011 4:01 pm

Ok, this is weird!

This example now works: http://newtondynamics.com/wiki/index.ph ... h_Irrlicht

Except for when I assign a texture to either the box(floor) or the sphere.

At the moment, it's running fine just when I turn the textures on it crashes on startup!

It says that this line is the culprit:

collision = NewtonCreateBox (nWorld, size.m_x, size.m_y, size.m_z, NULL, 0);

but it only happens when textures have been assigned.

Any thoughts anyone?

Thanks.
joepaddyroe
 
Posts: 16
Joined: Wed Feb 16, 2011 7:54 am

Re: Irrlicht 1.7.2 and Newton 2.XX (Complete NOOB needs help

Postby ledahut » Fri Feb 18, 2011 4:24 am

This tutorial seem using old newton game dynamics engine.
I can't help you with texture, I don't use Irrlicht.

But this line is false (the last two argument):
collision = NewtonCreateBox (nWorld, size.m_x, size.m_y, size.m_z, NULL, 0);

Try
collision = NewtonCreateBox (nWorld, size.m_x, size.m_y, size.m_z, 0, NULL);
ledahut
 
Posts: 98
Joined: Mon Jun 21, 2010 8:03 am
Location: France

Re: Irrlicht 1.7.2 and Newton 2.XX (Complete NOOB needs help

Postby joepaddyroe » Mon Feb 21, 2011 9:06 am

Hi Folks,

Starting to make progress now thanks to all your help!

I'm now trying to make a collision tree out of a mesh file, like the way the examples show with the quake map.

I can get the quake map working fine, but as soon as I try and introduce another mesh-type/level, an exception is thrown.

Are there only specific mesh types that can be used and if so, which ones?

Cheers!
joepaddyroe
 
Posts: 16
Joined: Wed Feb 16, 2011 7:54 am

Re: Irrlicht 1.7.2 and Newton 2.XX (Complete NOOB needs help

Postby joepaddyroe » Mon Feb 21, 2011 4:24 pm

Actually!

Problem solved.

I saw this post for anyone who's interested: http://irrlicht.sourceforge.net/phpBB2/ ... b73026acc8

The fact that I was trying to read texture coordinates on the mesh as opposed to vertices was messing things up.

Also, for anyone who's interested, I was trying to scale up the input mesh with Irrlicht before passing it into the tree and Newton didn't like this.

Anyway, it's all good now!
joepaddyroe
 
Posts: 16
Joined: Wed Feb 16, 2011 7:54 am

Re: Irrlicht 1.7.2 and Newton 2.XX (Complete NOOB needs help

Postby ledahut » Tue Feb 22, 2011 4:27 am

I was trying to scale up the input mesh with Irrlicht before passing it into the tree and Newton didn't like this.

Newton does not support scalled matrix.
But you can scale your mesh vertices position before creating the tree collision and it will work.
ledahut
 
Posts: 98
Joined: Mon Jun 21, 2010 8:03 am
Location: France

Re: Irrlicht 1.7.2 and Newton 2.XX (Complete NOOB needs help

Postby joepaddyroe » Wed Feb 23, 2011 5:54 am

Oh ok!

Thanks leahut, that's good to know as I have been trying to keep things scaled to a little human figure I have set up in Max!

Live and learn, Cheers.

By the way, would you happen to know of any good character controller tutorial, besides the one that comes witht the sdk?
joepaddyroe
 
Posts: 16
Joined: Wed Feb 16, 2011 7:54 am

Previous

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests