Newton Tutorial

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
darkwolf
Posts: 16
Joined: Mon Oct 17, 2005 9:51 pm

Newton Tutorial

Post by darkwolf »

Hey all,

well, after trying to geht the newton physics engine to work with the irrlicht engine (v.0.14) i give up.

Maybe someone has a suggestion what is wrong.

I can load the application, but instead of having multiple boxes and instead of being able to create new boxes I can only see one.

Debugging the code shows me, that the coordinates of all the boxes created in the beginning are correct, even the setTranslation function seems to be called correctly.
But, there ist still just one box in the middle, nothing else... :shock:
I tried to get it working for several hours now, but I have no clue what is going wrong...

(i'm using the example code downloaded from the tutorial. the binaries work fine of course, but the compiled code doesnt)

using .net2003
Xaron
Posts: 310
Joined: Sun Oct 16, 2005 7:39 am
Location: Germany
Contact:

Post by Xaron »

Could you please post or upload your code?

Regards - Xaron
darkwolf
Posts: 16
Joined: Mon Oct 17, 2005 9:51 pm

Post by darkwolf »

File can be found here:

storage.freewaykillers.de/phys3.rar
pfo
Posts: 370
Joined: Mon Aug 29, 2005 10:54 pm
Location: http://web.utk.edu/~pfox1

Post by pfo »

well, after trying to geht the newton physics engine to work with the irrlicht engine (v.0.14) i give up.
No, don't give up!
instead of having multiple boxes and instead of being able to create new boxes I can only see one.
Some guesses: you aren't calling NewtonUpdate, or you are calling it with an improper timestep. Try setting the NewtonWorld size to something really big. Everything outside of the default size is disabled by Newton, it defaults to something like 10x10x10 units. Also, things might not be moving because you didn't set their transform callback up correctly, or force and torque callback.
kickBack
Posts: 13
Joined: Sat Jan 14, 2006 2:20 pm

Post by kickBack »

Have look at Mercior demo.

http://newtondynamics.com/downloads.html
http://newtondynamics.com/downloads/MerciorDemo.zip

It shows pretty much everything you have to do to implant some basic (like hinges, boxes, ragdolls e.t.c)newton functions in your project witch is made in irrlicht :).
dhenton9000
Posts: 395
Joined: Fri Apr 08, 2005 8:46 pm

Post by dhenton9000 »

http://irrforge.org/index.php/Simple_Ne ... ht_Example

very bare bones demo of newton -irrlicht uses resources from the irrlicht sdk.
darkwolf
Posts: 16
Joined: Mon Oct 17, 2005 9:51 pm

Post by darkwolf »

No, don't give up!
Oh I wont... But its a time question wether we will be able to use the physics engine or if we have to use a simplified physics system for our project...

Hmm, the strange thing is, this is the Mercior Demo Code! In the beginning I implemented everything into the Project. That didnt work, then I extracted more and more ending up just having the mercior demo code, but that code should work! Thats what confused me...
Even if I download and compile it, same behaviour, I have the feeling that I missed something very easy but I dont know what... :?

I'll have a look at the last newton irrlicht example, thanks for that. ;)
- White Box Entertainment -
Baal Cadar
Posts: 377
Joined: Fri Oct 28, 2005 10:28 am
Contact:

Post by Baal Cadar »

Post the relevant parts of your code. Where do you initialise the box positions in irrlicht and in newton. What does your force callback look like and what your translation callback. Please also post parts that otherwise affect their transformation on screen.

Did you try to enable debug line view of your Newton collisions? If so, are those placed correctly? Also of interest: What NewtonSDK-Version do you use?
darkwolf
Posts: 16
Joined: Mon Oct 17, 2005 9:51 pm

Post by darkwolf »

Post the relevant parts of your code.
I uploaded the small example and postet the link further up in this thread.
The strange thing is, it is similar to the mercior code example. Even if I use exactly that example it doesnt work and the same as explaned above happens...

I use Irrlicht 0.14 and Newton 1.5
- White Box Entertainment -
cassini
Posts: 68
Joined: Thu May 12, 2005 2:40 pm

Post by cassini »

dhenton9000 wrote:http://irrforge.org/index.php/Simple_Ne ... ht_Example

very bare bones demo of newton -irrlicht uses resources from the irrlicht sdk.
I am studing this sample but I think there is a bug here

Code: Select all

  // set the newton world size based on the bsp size
      float boxP0[3];
      float boxP1[3];
      float matrix[4][4];
	  matrix4 mmm;
	  mmm.setTranslation(vector3df(-1370,-130,-1400)*IrrToNewton);

	  NewtonBodySetMatrix(nmapbody,&mmm.M[0]);
      NewtonCollisionCalculateAABB (nmapcollision, &matrix[0][0],  &boxP0[0], &boxP1[0]);
      NewtonSetWorldSize (nWorld, (float*)boxP0, (float*)boxP1);

Matrix is never initilized before it is passed to the funtion NewtonCollisionCalculateAABB, or am I missing something
Last edited by cassini on Wed Feb 01, 2006 5:52 pm, edited 1 time in total.
dhenton9000
Posts: 395
Joined: Fri Apr 08, 2005 8:46 pm

Post by dhenton9000 »

Darkwolf, Replace this line in your code

Code: Select all

device = createDevice(EDT_OPENGL, dimension2d<s32>(800,600), 16, false, true, this);

with something like this

Code: Select all

device = createDevice(EDT_OPENGL,
                            dimension2d<s32>(640,480), 16,false,true,false,this);

The way you have it, you are passing in NULL for the event receiver. With this code in place the receiver works like a charm

cassini ---
hmm, that doesn't sound good, must mean theit isn't used anywhere . Its filled out by the NewtonCollisionCalculateAABB, but it would be a good idea to iniitalize it,given that this is C++ :lol:
Baal Cadar
Posts: 377
Joined: Fri Oct 28, 2005 10:28 am
Contact:

Post by Baal Cadar »

I debugged it too and the problem is, that you place all the boxes outside your World dimensions. A y value of 500.0f is well outside your NewtonWorldSize and thus neither transform nor force callback are ever called.

Set it to say 100 and it works fine.
This worked for me:

Code: Select all

MakeCube(vector3df((float)(x*100)-xo, 100.0f, (float)(y*100)-yo)
darkwolf
Posts: 16
Joined: Mon Oct 17, 2005 9:51 pm

Post by darkwolf »

device = createDevice(EDT_OPENGL,
dimension2d<s32>(640,480), 16,false,true,false,this);
That works perfectly :D
MakeCube(vector3df((float)(x*100)-xo, 100.0f, (float)(y*100)-yo)

Just found that out as well. 8)

I still wonder though, because this is how the code in the example looked like. :?

In any way, thanks alot for your help! Now we finally can start implementing the physics engine into our project.
In a few month time we should be able to present the first prototype of our game. (its going to be a 3D platform jump and run - it is one of our projects during our games tech course)

darkwolf
- White Box Entertainment -
Post Reply