Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (523)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (591)
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 2649 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/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 ?
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
Online kevglass

« JGO Spiffy Duke »


Medals: 197
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


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

I'd suggest JBox2D Smiley

Kev

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 !

 Smiley
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 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.
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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Gibbo3771 (6 views)
2014-11-24 19:59:16

trollwarrior1 (35 views)
2014-11-22 12:13:56

xFryIx (73 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50

digdugdiggy (46 views)
2014-11-12 21:10:15

digdugdiggy (40 views)
2014-11-12 21:09:33

kovacsa (66 views)
2014-11-07 19:57:14

TehJavaDev (70 views)
2014-11-03 22:04:50

BurntPizza (68 views)
2014-11-03 18:54:52

moogie (83 views)
2014-11-03 06:22:04
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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
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!