AssertionError JBox2D
in
Contributed Library Questions
•
2 years ago
hi, i'm trying to make polygon using JBox2D library. but it's giving me AssertionError. I have try to google the answer, but didn't find any.
this is the complete log of the error
Exception in thread "Animation Thread" java.lang.AssertionError
at org.jbox2d.collision.PolygonShape.computeCentroid(PolygonShape.java:338)
at org.jbox2d.collision.PolygonShape.<init>(PolygonShape.java:122)
at org.jbox2d.collision.Shape.create(Shape.java:273)
at org.jbox2d.dynamics.Body.createShape(Body.java:345)
at org.jbox2d.p5.Physics.createPolygon(Physics.java:477)
at my_test_jbox2d.bataJ(my_test_jbox2d.java:90)
at my_test_jbox2d.setup(my_test_jbox2d.java:46)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:722)
and this is my code
- //BoxWrap2D
- import org.jbox2d.p5.*;
- //JBox2D
- import org.jbox2d.dynamics.contacts.*;
- import org.jbox2d.dynamics.*;
- import org.jbox2d.common.*;
- import org.jbox2d.collision.*;
- import org.jbox2d.dynamics.joints.*;
- Physics fisika;
- World dunia;
- void setup(){
- size(400, 700, P3D);
- smooth();
- frameRate(60);
- initScene();
- bataI(100, 200);
- bataJ(250, 400);
- }
- void draw(){
- background(0);
- }
- void initScene(){
- //ukuran layar applet
- float screenW = width;
- float screenH = height;
- //besarnya gravitasi (meter/detik^2) - JBox2D telah menyesuaikannya ke dalam pixel. gravY = -10.0 adalah ukuran yg mirip dengan gravitasi nyata
- float gravX = 0.0;
- float gravY = -10.0;
- //ukuran dari Axis-Aligned Bounding Box (pixel). Objek yang berada di luar area ini akan berhenti/ membeku
- float screenAABBWidth = width;
- float screenAABBHeight = height;
- //ukuran panjang dan lebar dari garis tepi (pixel). Usahakan ukuran border lebih kecil dari ukuran AABB. Untuk menghapus border, gunakan fisika.removeBorder();
- float borderBoxWidth = width;
- float borderBoxHeight = height;
- //defaultnya berisi 10, yang berarti 10 pixel == 1 meter.
- float pixelsPerMeter = 10.0;
- fisika = new Physics(this, screenW, screenH,
- gravX, gravY,
- screenAABBWidth, screenAABBHeight,
- borderBoxWidth, borderBoxHeight,
- pixelsPerMeter);
- //fisika.removeBorder();
- fisika.setDensity(1.0);
- }
- void bataI(int x, int y){
- fisika.createPolygon(x, y,
- x, y+30,
- x+10, y+30,
- x+10, y);
- }
- void bataJ(int x, int y){
- fisika.createPolygon(x, y,
- x+20, y,
- x+20, y+30,
- x+10, y+30,
- x+10, y+10,
- x, y+10);
- }
thanks for the help..
EDIT : the error is from the clas bataJ(). the class bataI() is working fine
1