Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (623)
Games in Android Showcase (176)
games submitted by our members
Games in WIP (676)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Phys2D - AngleJoint  (Read 2918 times)
0 Members and 1 Guest are viewing this topic.
Offline faboz14

Senior Newbie

« Posted 2008-11-28 09:45:24 »

Hi !

I am using Phys2D and I am very happy with DistanceJoint, SlideJoint and FixedJoint: all the constraints are respected by the API

Problem occurs when I use the AngleJoint of FixedAngleJoint

I tried to use it as the example in test/net/phys2D/raw/test/
         Body b1 = new Body( "" , new Box(1f,1f), 1f );  
         Body b2 = new Body( "" , new Box(1f,1f), 1f );
         Body b3 = new Body( "" , new Box(1f,1f), 1f );
         world.add( b1 );
         world.add( b2 );
         world.add( b3 );
         b1.setPosition( 100 , 100 );
         b2.setPosition( 100 , 200 );
         b3.setPosition( 200 , 100 );
         generateDistanceJoint( b1 , b2 );
         generateDistanceJoint( b1 , b3 );
         FixedAngleJoint angleJoint1 = new FixedAngleJoint( b1 , b2 , new Vector2f(0,0),  new Vector2f(0,0) , 0.1f   );
         world.add( angleJoint1 );
         FixedAngleJoint angleJoint2 = new FixedAngleJoint( b1 , b3, new Vector2f(0,0),  new Vector2f(0,0) , 0.1f  );
         world.add( angleJoint2 );

   public DistanceJoint generateDistanceJoint( Body bodyA , Body bodyB )
      Point2D pointA = new Point2D.Float( bodyA.getLastPosition().getX() , bodyA.getLastPosition().getY() );
      Point2D pointB = new Point2D.Float( bodyB.getLastPosition().getX() , bodyB.getLastPosition().getY() );
      float distance = (float) pointA.distance( pointB );
      DistanceJoint distanceJoint = new DistanceJoint( bodyA , bodyB , new Vector2f(0,0) , new Vector2f(0,0), distance );
      distanceJointList.add( distanceJoint );
      world.add( distanceJoint );
      return distanceJoint;

The only thing I am trying to do is to make an angular constraint with 3 points b1, b2, b3, and to define the angle b2-b1-b3

any idea ? am I totally wrong ?
Offline ewjordan

Junior Devvie

« Reply #1 - Posted 2008-11-28 16:02:03 »

What is going wrong with the way you're doing it now?

It sounds to me like you're just trying to lock all three bodies together in a fixed location, in which case wouldn't you just use a FixedJoint?  Though I'll admit I'm not too familiar with the joint types in Phys2d...
Offline faboz14

Senior Newbie

« Reply #2 - Posted 2008-12-01 08:39:49 »

The angular constraint is not respected.

And also, if the 3 points do not start with the good angle, the system do not correct it...  Undecided

I am planning to search for an other free physic engine because of that...
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kevglass

« JGO Spiffy Duke »

Medals: 272
Projects: 25
Exp: 18 years

Coder, Trainee Pixel Artist, Game Reviewer

« Reply #3 - Posted 2008-12-01 08:49:09 »

I'd suggest JBox2D Smiley


Offline faboz14

Senior Newbie

« Reply #4 - Posted 2008-12-01 08:58:03 »

Thank you, I will have a look at it, and will come back here to tell you if it had fixed my problem !
Offline faboz14

Senior Newbie

« Reply #5 - Posted 2008-12-04 11:54:57 »

Well, Angle Joint is planed but not active for the moment in JBox2d..

I have another question : I am creating a system that is maybe a bit too complex : I want to create a mecanical piston. So I have 2 boxes which are linked together and a 3rd one is sliding between the two first.

The system is ok, but sometimes it seems the impulses are getting nervous and objects overlap and vibrate, then the system explode.

any idea ?
Offline faboz14

Senior Newbie

« Reply #6 - Posted 2008-12-04 15:46:45 »

I found the solution so I put it here:

as the number of object involve in the same system of constraint grows, I had to switch the World constructor from QuadSpaceStrategy to BruteCollisionStrategy

and it works !

Offline ewjordan

Junior Devvie

« Reply #7 - Posted 2008-12-05 00:51:48 »

Well, Angle Joint is planed but not active for the moment in JBox2d..
Again, I'm not entirely sure what you're looking to do here.  To my knowledge, an angle joint in Phys2d pins the bodies together at a point, and constrains the angle that they are allowed to move to around that point; a fixed angle joint would set the upper and lower limits equal to each other, right?  In JBox2d this corresponds to a RevoluteJoint with equal lower and upper limits, but you should be be to do this just fine in either Phys2d or JBox2d, so I'm not sure what's exactly missing.

Unless you're looking for some other kind of behavior?  Maybe a picture would help?

FWIW, we don't have current plans to add other joint types to JBox2d, except for the line joint from Box2d (coming in a future update to JBox2d when I have some time); any other joint requests should be directed to Erin Catto at, if you can convince him to put them into the C++ engine they will eventually get into JBox2d as well (and if you desperately need something that's in the C++ version, ask me and I'll bump that feature up on the priority list).  But generally speaking, we don't add stuff that Erin doesn't add to Box2d.
Offline faboz14

Senior Newbie

« Reply #8 - Posted 2008-12-05 08:26:26 »

Thank you very much: you are right: I had a lack of information about angleJoint !

so I have everything I need !

Thank you !
Offline faboz14

Senior Newbie

« Reply #9 - Posted 2008-12-05 10:23:00 »

I can't achieve to create this:

Click to Play

I would like to create an object sliding to an other...

I guess I need a fixedAngleJoint to make both object in the same alignement, and a distanceJoint to constrain the moving distance from one to another... but do I need to create object around the sliding one to constrain it ? or is there an other joint I should add ?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline faboz14

Senior Newbie

« Reply #10 - Posted 2008-12-10 09:04:17 »

I love phys2D !

the only thing missing is the clone for the Body Object !
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

BurntPizza (28 views)
2015-10-08 03:11:46

BurntPizza (16 views)
2015-10-08 00:30:40

BurntPizza (19 views)
2015-10-07 17:15:53

BurntPizza (32 views)
2015-10-07 02:11:23

KaiHH (38 views)
2015-10-06 20:22:20

KaiHH (16 views)
2015-10-06 19:41:59

BurntPizza (32 views)
2015-10-06 19:04:48

basil_ (46 views)
2015-09-30 17:04:40

shadowstryker (25 views)
2015-09-29 15:55:06

TheSpaceHedgehog (31 views)
2015-09-29 01:58:48
Math: Inequality properties
by Roquen
2015-10-01 13:30:46

Math: Inequality properties
by Roquen
2015-09-30 16:06:05

HotSpot Options
by Roquen
2015-08-29 11:33:11

Rendering resources
by Roquen
2015-08-17 12:42:29

Rendering resources
by Roquen
2015-08-17 09:36:56

Rendering resources
by Roquen
2015-08-13 07:40:51

Networking Resources
by Roquen
2015-08-13 07:40:43

List of Learning Resources
by gouessej
2015-07-09 11:29:36 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!