I understand that, but can you answer my questions from my previous post? Do I understand this whole coordinate system with Box2d correctly?
Frozen box?
General DiscussionYou need to distinguish between how the example code works and how the engine works. The examples use a specific convention. The engine will accept any convention with a right-handed coordinate system.
For your code you can pick any convention you want. Y-up, Y-down, Y-at 45 degrees North West. Box2D doesn't care about this.
The Box2D examples use Y-up (as in up to the top of your monitor). Gravity points down (negative Y). But you don't need to use the same convention as the examples. It is an arbitrary convention that works easily with OpenGL.
Given that Box2D doesn't care or know how you draw things, there is no way to tell Box2D about your screen. All you can do is position shapes and bodies and run the simulation. Then you extract the results from Box2D to draw
Are you confused about the world AABB? The world AABB should be around 2 times bigger than your game world. Your game world should be roughly centered in the world AABB. The world AABB is not your screen, it is just a way of telling Box2D the size of your simulated world.
For your code you can pick any convention you want. Y-up, Y-down, Y-at 45 degrees North West. Box2D doesn't care about this.
The Box2D examples use Y-up (as in up to the top of your monitor). Gravity points down (negative Y). But you don't need to use the same convention as the examples. It is an arbitrary convention that works easily with OpenGL.
Quote:
Ok, so instead of X=0 and Y=0 at the top left of the screen, X=0 and Y=0 is at the center of screen? Or the center of the current world? And is there a way to make Box2d operate with X=0 and Y=0 at the top left of SCREEN? i.e., setup the program to do so.
Given that Box2D doesn't care or know how you draw things, there is no way to tell Box2D about your screen. All you can do is position shapes and bodies and run the simulation. Then you extract the results from Box2D to draw
Are you confused about the world AABB? The world AABB should be around 2 times bigger than your game world. Your game world should be roughly centered in the world AABB. The world AABB is not your screen, it is just a way of telling Box2D the size of your simulated world.
Alright, I got it. Thanks, now I can go back to writing my program. 😀
Wait, a minute. I took a small break from programming and now I'm back, but I just remember something. Even when I don't draw the boxes and only check the rotation values for my dynamic box, it always reads 0.00000000. Never changes. According to the example, it should collide with my static box and roll, bounce, etc. What going on? As I said before, All my box2d code is EXACTLY the same as the example.
The box in the HelloWorld example doesn't tumble.
Oh, alright then. Thanks.
Well, I still haven't found the answer to why my box refuses to drop after it falls to the y position that is equal to the y extent...why is it doing this?
Can you provide code to reproduce this problem?
Sure..just look at your HelloWorld example 😉 . My code is identical to it. The only difference is that I'm calling Step() in my logic loop which runs at a speed of 200 loops per second, and my drawing function is called when the logic loop tells it to (every x logic loops). Also, all the values in box2d that I'm passing to define things, are all in terms of pixels in my application. So a box with extends 20 by 20 will be drawn as a 40 by 40 box and a world that is defined as 100 by 100 will be 100 pixels by 100 pixels, etc . Maybe that is the problem? ❓
blargmob wrote:
Well, I still haven't found the answer to why my box refuses to drop after it falls to the y position that is equal to the y extent...why is it doing this?
Sorry, I haven't read the entire thread, but is the box falling off the edge of the world (outside the aabb you used to create the world)? In my editor, objects would freeze when they went outside that region.
Original thread: https://box2d.org/forum/viewtopic.php?t=242