Difference between Box and Body

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Difference between Box and Body

Postby dehseth » Thu Dec 24, 2009 4:08 am

Hey guys,

yeap i'm newbie :) ... I am trying to understand newton 2. here's my question:

what's the difference between NewtonCreateBox and NewtonCreateBody.. well yeah, one returns newtoncollision and another returns newtonbody but what's the difference between them? why should I create a box and then create a body? what does a box do and a body do? :?

here's a sample code from tutorials:

Code: Select all
shape = CreateNewtonBox (world, floor, 0); // creates a box
floorBody = CreateRigidBody (world, floor, shape, 0.0f); // creates a rigid body
NewtonReleaseCollision (world, shape);


and one more thing, the 3rd row releases collision object. shouldn't I keep this collision if I want collisions? like I got two boxes which I want them to collide with each other, releasing this collision object won't affect anything? :?:

thank you all.
dehseth
 
Posts: 14
Joined: Mon Dec 21, 2009 6:32 am

Re: Difference between Box and Body

Postby JernejL » Thu Dec 24, 2009 4:45 am

Shapes are called collisions, they reprisent physical shapes in newton.

Bodies are the actual simulated objects, they use a collision to reprisent their shape, and have a mass, location, rotation and deal with physical forces.

So.. you create a box first, and then a body to use and simulate a box. you can also reuse the box for several bodies.

NewtonReleaseCollision just decreases reference count for the collision, it doesn't delete the collision instantly.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Difference between Box and Body

Postby dehseth » Thu Dec 24, 2009 4:53 am

After I create body I no logner need this collision object right? So I can release the collision object. And I now will be using this body object not the collision object. Body will collide with ther bodies and callbacks to my function, I put a force on body.. Right :?:
dehseth
 
Posts: 14
Joined: Mon Dec 21, 2009 6:32 am

Re: Difference between Box and Body

Postby JernejL » Thu Dec 24, 2009 6:38 am

The collision is still needed as it is shared for the bodies that use it. but you can release a reference immediately so that when you destroy all bodies using it at the end of app the collisions will also be deleted.

Yes, body will now automaticly collide when you use newtonupdate and apply forces in forcetorque callback so it starts moving.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Difference between Box and Body

Postby dehseth » Thu Dec 24, 2009 7:29 am

Ok thank you. :D

One more question, I am using Irrlicht engine and I am new at that too. :wink:
:arrow: Is there some kind of switch I can turn it on in Newton to see NewtonBodies in 3d application, like some kinda debugging thing? Or should I create let's say a visible cube in irllict and attach this 3d object to newton body and get along these two in newton transform callback :?:

I just want visible newton bodies is there any way to do it easily using newton?
dehseth
 
Posts: 14
Joined: Mon Dec 21, 2009 6:32 am

Re: Difference between Box and Body

Postby JernejL » Thu Dec 24, 2009 10:56 am

newton has debug rendering routines to return the rough geometry of object back to you, but you need to write routines to render that data.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Difference between Box and Body

Postby dehseth » Fri Dec 25, 2009 2:22 am

Thank you.
I'll figure it out about drawing then.
dehseth
 
Posts: 14
Joined: Mon Dec 21, 2009 6:32 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron