Questions tagged [jbox2d]

JBox2D is a Java physics engine often used in games an other physics simulations and is a port/extension of the C++ physics engine, Box2D.

JBox2D is a physics engine for Java often used in games and other physics simulations, and is a port/extension of the C++ physics engine, Box2D.

Questions

Questions with the jbox2d tag should be specifically about JBox2D and its implementation. Questions about the physics engine in general should be tagged with box2d as well.

Brief Definitions

  • World contains the physics environment for a simulation
  • Body is a physics entity with any number of child fixtures. These fixtures are treated as all part of the same physics object, and will interact accordingly (they won't break up). Bodies also provide support for user-applied forces and torque.
  • Fixture contains a single shape and information about it (for example, friction and restitution).
  • Shape contains information about the basic physical properties of the physics object. (for example, the vertices of the polygon shape)
  • Joint is basically a way of adding constraints to different bodies. There are a variety of joints, including revolute, distance, and prismatic joints.

Links

JBox2D

Box2D

183 questions
1
vote
3 answers

Differentiating between ball and player in goal collision

Hey, I'm trying to make a basic hockey style game. I have the basic physics working with the pitch, a player, an opponent, and a ball. I'm struggling to figure out how I can allow the ball to travel into the goal while keeping the player and…
Rob
  • 7,039
  • 4
  • 44
  • 75
1
vote
1 answer

Box2d center mass of welded bodies?

I have a structure made up of welded bodies. I apply impulses/forces to move the structure around but I notice that the structure isn't moving perfectly straight. It begins moving in the direction of the Vector and then slowly turns, eventually…
duder2020
  • 11
  • 3
1
vote
1 answer

What is the translation of this Java method signature in plain English?

I'm porting JBox2D to Xojo. Java is not a language I know well but there are enough similarities to Xojo for this to be the easiest way to port Box2D to it. I am well into the port but I cannot fathom the meaning of this method signature: public…
Garry Pettet
  • 8,096
  • 22
  • 65
  • 103
1
vote
0 answers

I need the right Pixel Per Meter Ratio implementation using JBox2D - Not Using LibGDX

I'm building a game engine and I've added jbox2d. I'm struggling to implement the correct way of using PPM. I have 3 important classes where all the magic happens. Please review my code and SHOW me what to change. This is what I'd like to see…
1
vote
4 answers

What is the most performant 2D graphics engine for use with Android?

I have managed to make a hello world JBox2D application, and it works (I have some bouncing balls). However, I just read a comment on a forum post, which claims that JBox2D produces a lot of garbage, and so causes animation to be poor. Is this…
Nick Bolton
  • 38,276
  • 70
  • 174
  • 242
1
vote
1 answer

How to dispose box2d shapes properly?

I'm starting to create my World with Box2d in Libgdx and I have to create shapes for different game objects. The tutorial I've read said I should dispose my shapes when I'm done using them. So, I started keeping references like that: private…
Winter
  • 3,894
  • 7
  • 24
  • 56
1
vote
0 answers

How do I create composite convex polygon bodies in JBox2D?

I'm trying to make a concave polygon body in JBox2D by combining convex polygons. This is what I've tried: Vec2[][] v = { { new Vec2(-3.5f, 0), new Vec2(-3.5f, 0.5f), new Vec2(3.5f, 0.5f), new Vec2(3.5f, 0) }, { new Vec2(-3.5f, 0.5f), new…
Z3wz
  • 61
  • 1
  • 8
1
vote
2 answers

JBox2D Why is gravity reversed?

Good evening everyone. I'm requesting your help ! I'm discovering Box2D but I'm already struggling with a few things : My gravity is reversed and I don't understand why. And my second problem is that I can't manage to draw it in a debugged way. I…
Alann S.
  • 125
  • 12
1
vote
2 answers

slick2d - can't get mouse click event to work correctly

Yo!. I'm trying to make a small hobby game in Java using Slick2d, JBox2d and Tiled, but I've come across an annoying problem. My game currently consists of a spaceship flying around in a small stage. I've managed to get the movement just right, and…
Tholok
  • 53
  • 7
1
vote
0 answers

Drawing rotated bodies using JBox2D and JavaFX

I'm doing some initial experiments for a CS course, where I'm trying to use JBox2D as a physics library and drawing using JavaFX. I have had some luck draw circles that fall from the top of the screen, but now I have issues doing the same with…
freddy
  • 17
  • 8
1
vote
1 answer

Missing attributes in the WeldJointDef class in LibGdx

In the original Box2D API, the WeldJointDef class has two Attributes that I couldn't find in the LibGdx gdx.physics.box2d.joint.WeldJointDef class which are: - frequencyHz. - DampingRatio. modifying these two attributes give more flexibility to…
Wazani
  • 911
  • 1
  • 13
  • 28
1
vote
1 answer

Box2d removeJoint Fatal signal 11 (SIGSEGV)

I'm having a Fatal signal 11 (SIGSEGV) error when I try to remove a mouseJoint. My code is based on this AndEngine PhysicsMouseJointExample //physicWorld onUpdate @Override public void onUpdate(float pSecondsElapsed) { if (removeMouseJoint) { …
GuilhE
  • 11,591
  • 16
  • 75
  • 116
1
vote
1 answer

Applying a force on a costum point in box2d

I would like to apply a force to a body in jbox2d. I can apply the force on the mass center of the body, there is no problem. However, I need to apply the force to one meter above of the mass center as in the below figure. I use the below codes but…
adba
  • 477
  • 9
  • 25
1
vote
0 answers

Add random holes in the ground

In my Box2D world, I have a ground and a Dynamic Object. The ground is initially created as a box: Vec2 gravity = new Vec2(0.0f, 10.0f); world = new World(gravity); world.setWarmStarting(true); BodyDef groundBodyDef = new…
Majid Laissi
  • 19,188
  • 19
  • 68
  • 105
1
vote
3 answers

Is this the correct way of using Java 2D Graphics API?

I'm creating a graphical front-end for a JBox2D simulation. The simulation runs incrementally, and in between the updates, the contents of the simulation are supposed to be drawn. Similar to a game except without input. I only need geometric…
corazza
  • 31,222
  • 37
  • 115
  • 186