Box2D coordinate conversion issue

Hello Processing community.

I am following the most popular and the greatest coding teacher, Daniel Shiffman on youtube now.

Currently, I am on the Box2D chapters. While I am playing with PBox2D, found one issue which has been bothering me for 2 days, I think there is something wrong with the PBox2D lib but I am not sure. The issue I think it is something related to coordinate conversion.

I have uploaded the sketch code to https://github.com/bizkitj/JBox2D-Processing

In Boundary.pde
If I enable line 14 and disable line 15, then it is not working correctly.

In BoundaryEdge.pde it simply not what I am expecting.
image

Did I do something stupid?
How can I fix this?

Another questions about the Box2D.position.set( this must be the centroid of the shape?) If so, for irregular shape, how do you know the centroid?

Thank you for looking into this.

1 Like

Hi – thank you for this question, with code provided and illustration.

Would like to help, but this kind of question is hard to answer. You don’t say:

  1. what you expect to happen
  2. what, specifically, is happening instead

It is also unclear what you have uploaded – the line 14/15, have you uploaded it in “expected” or “unexpected” state, and what does changing those lines represent? When I quickly swap them, run, and click the mouse, I can’t tell what (is supposed to have) changed.

Also, processing sketches are invalid unless in a folder of the same name. To make it easier for people to access them via github, put them in a subfolder of the repo–with the correct folder name – otherwise they download broken. This is especially hard with multi-pde sketches, as we have to guess which of the files is the lead file, and should be the folder name.

Hello

Thank you for your reply.
Yes, it was my bad for not making things clearer.

Anyway, I have fixed the issue.
The issue caused by me,pixel to world cord, world cord to pixel ,must keep this in mind all the time…

Thank you again for looking into this.

2 Likes