Box2d - 2D physics

Previous topic - Next topic

neseir

#120
Hi

There are a limitation in the Box2D code that limits the number of polygonvertices to 8. It is located in the b2settings.h file (line 75 : const int32 b2_maxPolygonVertices = 8;)

Regards
Eirik

mentalthink

HI neseir, lot of thanks I go to see this.
Thanks  :nw:

Iván J.

quangdx

#122
Is there a command to destroy/remove objects after they've been created?
Also there doesn't seem to be any commands to manually set the x and y position of an object that has already been created.
Any help here would be great.
Asobi tech - the science of play.
Spare time indiegame developer.

backslider

Hi there,

you should download the library from page 6 in this thread.

The direct link is: http://www.glbasic.com/forum/index.php?action=dlattach;topic=3561.0;attach=2262

Then you can use some "new" functions:

edited functions:
- b_CreateCircle (extended parameters)
- b_CreateBox    (extended parameters)
- b_CreatePoly   (extended parameters)

new functions:
- b_DestroyJoint% (function has now code to destroy joints)
- b_destroyBody    (delete bodys that you don´t need)

cheers

Kitty Hello

wouldn't it be better to put the extended parameters into a seperate function and update "any" shape after creation?

quangdx

Quote from: backslider on 2011-Jul-25
Hi there,

you should download the library from page 6 in this thread.

The direct link is: http://www.glbasic.com/forum/index.php?action=dlattach;topic=3561.0;attach=2262

Then you can use some "new" functions:

edited functions:
- b_CreateCircle (extended parameters)
- b_CreateBox    (extended parameters)
- b_CreatePoly   (extended parameters)

new functions:
- b_DestroyJoint% (function has now code to destroy joints)
- b_destroyBody    (delete bodys that you don´t need)

cheers

Many thanks dude,
So for me to manually change the location of an Object at a later point,
I have to destroy the body then recreate it in the new location?
Would be a lot easy to just update the X pos and Y pos.
Asobi tech - the science of play.
Spare time indiegame developer.

backslider

Ah, sorry.

To move an object, you have to add the following function to your box2d library
Code (glbasic) Select

FUNCTION b_BodySetXForm: body%, x, y, angle // add this function to the wrapper
INLINE
b2Vec2 pos = bBody(body)->GetPosition();
pos.x=x;
pos.y=y;
bBody(body)->SetXForm(b2Vec2(x,y), angle);
ENDINLINE
ENDFUNCTION


Somebody should update the library with all functions in this thread and put it into the first post. :)

bigsofty

I started to add some features a while back but later programers would alter a copy of the original source and erase my changes in the process. It was like running up a sandy hill... this lib desperately needs an SVN IMHO.  :S
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

backslider


Kitty Hello

I implemented all changes (except the parameter on creation extension - I''d like to see that in a seperate function) and updated post #1.

Crivens

Out of interest I've read box2d is compatible with iOS with a small change to compiler parameters, but what about Android and WebOS?

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

backslider

With webOS the box2d-wrapper worked fine for me!
On Android I don´t know, but why not. :)

Crivens

That's interesting to know. Thanks for that!

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

Kitty Hello

the iOS compiler is broken. The others are pretty up to date so no problems I hope.

neseir

Hi

Can confirm that the sample and files that are in the first post of this thread (updated 28. july) works on android but I had to add a reference to the Box2D headerfile in the "Project Options/cmp" (-I<path to the box2d files>/Box2D)

Regards
Eirik


[attachment deleted by admin]