Author Topic: Box2d - 2D physics  (Read 100715 times)

Offline neseir

  • Mc. Print
  • *
  • Posts: 21
    • View Profile
Re: Box2d - 2D physics
« Reply #120 on: 2011-May-09 »
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
« Last Edit: 2011-May-09 by neseir »

Offline mentalthink

  • Prof. Inline
  • *****
  • Posts: 3375
  • Integrated Brain
    • View Profile
Re: Box2d - 2D physics
« Reply #121 on: 2011-May-11 »
HI neseir, lot of thanks I go to see this.
Thanks  :nw:

Iván J.

Offline quangdx

  • Mr. Polyvector
  • ***
  • Posts: 233
  • work hard / play hard
    • View Profile
    • Asobi tech
Re: Box2d - 2D physics
« Reply #122 on: 2011-Jul-24 »
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.
« Last Edit: 2011-Jul-24 by quangdx »
Asobi tech - the science of play.
Spare time indiegame developer.

Offline backslider

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 892
    • View Profile
Re: Box2d - 2D physics
« Reply #123 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

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10859
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Box2d - 2D physics
« Reply #124 on: 2011-Jul-25 »
wouldn't it be better to put the extended parameters into a seperate function and update "any" shape after creation?

Offline quangdx

  • Mr. Polyvector
  • ***
  • Posts: 233
  • work hard / play hard
    • View Profile
    • Asobi tech
Re: Box2d - 2D physics
« Reply #125 on: 2011-Jul-27 »
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.

Offline backslider

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 892
    • View Profile
Re: Box2d - 2D physics
« Reply #126 on: 2011-Jul-28 »
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. :)

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2795
    • View Profile
Re: Box2d - 2D physics
« Reply #127 on: 2011-Jul-28 »
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)

Offline backslider

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 892
    • View Profile
Re: Box2d - 2D physics
« Reply #128 on: 2011-Jul-28 »
*sign*

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10859
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Box2d - 2D physics
« Reply #129 on: 2011-Jul-28 »
I implemented all changes (except the parameter on creation extension - I''d like to see that in a seperate function) and updated post #1.

Offline Crivens

  • Prof. Inline
  • *****
  • Posts: 913
    • View Profile
Re: Box2d - 2D physics
« Reply #130 on: 2011-Jul-28 »
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.

Offline backslider

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 892
    • View Profile
Re: Box2d - 2D physics
« Reply #131 on: 2011-Jul-28 »
With webOS the box2d-wrapper worked fine for me!
On Android I don´t know, but why not. :)

Offline Crivens

  • Prof. Inline
  • *****
  • Posts: 913
    • View Profile
Re: Box2d - 2D physics
« Reply #132 on: 2011-Jul-28 »
That's interesting to know. Thanks for that!

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

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10859
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Box2d - 2D physics
« Reply #133 on: 2011-Jul-28 »
the iOS compiler is broken. The others are pretty up to date so no problems I hope.

Offline neseir

  • Mc. Print
  • *
  • Posts: 21
    • View Profile
Re: Box2d - 2D physics
« Reply #134 on: 2011-Jul-29 »
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]