Java-Gaming.org Hi !
 Featured games (90) games approved by the League of Dukes Games in Showcase (753) Games in Android Showcase (228) games submitted by our members Games in WIP (842) 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 4103 times) 0 Members and 1 Guest are viewing this topic.
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/AngularConstraint.java
 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32 `          {         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 ?
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...
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...

I am planning to search for an other free physic engine because of that...
 Games published by our own members! Check 'em out!
kevglass

« JGO Spiffy Duke »

Medals: 319
Projects: 25
Exp: 22 years

Coder, Trainee Pixel Artist, Game Reviewer

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

I'd suggest JBox2D

Kev

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 !
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 ?
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 !

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 box2d.org, 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.
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 !
faboz14

Senior Newbie

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

I can't achieve to create this:

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!
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

 ivj94 (582 views) 2018-03-24 14:47:39 ivj94 (46 views) 2018-03-24 14:46:31 ivj94 (374 views) 2018-03-24 14:43:53 Solater (61 views) 2018-03-17 05:04:08 nelsongames (108 views) 2018-03-05 17:56:34 Gornova (150 views) 2018-03-02 22:15:33 buddyBro (691 views) 2018-02-28 16:59:18 buddyBro (91 views) 2018-02-28 16:45:17 xxMrPHDxx (493 views) 2017-12-31 17:17:51 xxMrPHDxx (730 views) 2017-12-31 17:15:51
 Java Gaming Resourcesby philfrei2017-12-05 19:38:37Java Gaming Resourcesby philfrei2017-12-05 19:37:39Java Gaming Resourcesby philfrei2017-12-05 19:36:10Java Gaming Resourcesby philfrei2017-12-05 19:33:10List of Learning Resourcesby elect2017-03-13 14:05:44List of Learning Resourcesby elect2017-03-13 14:04:45SF/X Librariesby philfrei2017-03-02 08:45:19SF/X Librariesby philfrei2017-03-02 08:44:05
 java-gaming.org 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‑gaming.org