Problem with HingeConstraint

Software: Away3D 4.x

Jack Dracon, Newbie
Posted: 22 September 2011 01:01 PM   Total Posts: 27

I have some questions about the functionalities of the AwayPhisics.
First of all, I am trying to do a object fixed in a scene position (as the first objects of the chains in ‘ConstraintTest’ example), like a auxiliar way, I had tried to use the awphingeconstraint with the ground, just to fix it. But something weird happens. When the object is created, it start to shake and after a little time, it stopped (with your actions). What I want to know is, why that is happens? It the object trying to passing the ground and this is your reaction?

var materialColorMaterial = new ColorMaterial(0x00ff00);//---Green
   
var ground Plane = new Plane(material100100);
   
_view3D.scene.addChild(ground);
   
//---Physics of the ground-------------------------------------------------------------
   
var groundShapeAWPStaticPlaneShape = new AWPStaticPlaneShape(new Vector3D(00, -1));
   var 
groundRigidBodyAWPRigidBody = new AWPRigidBody(groundShapeground0);
   
_physWorld.addRigidBody(groundRigidBody);
   
//--------------------------------------------------------------------------------------
   //---Flipper----------------------------------------------------------------------------
   
var materialNoStaticMeshColorMaterial = new ColorMaterial(0xff0000);//---Red
   
var flipper Cube = new Cube(materialNoStaticMesh402020);
   
_view3D.scene.addChild(flipper);
   var 
flipperShape:AWPBoxShape = new AWPBoxShape(402015);
   var 
flipperRigidBody:AWPRigidBody = new AWPRigidBody(flipperShapeflipper2);
   
flipperRigidBody.position = new Vector3D(00, -25);
   
flipperRB flipperRigidBody;
   
_physWorld.addRigidBody(flipperRB);
   var 
constraint:AWPHingeConstraint = new AWPHingeConstraint(flipperRB, new Vector3D(4000), Vector3D.Z_AXISgroundRigidBody, new Vector3D(000), Vector3D.Z_AXIS);
   
_physWorld.addConstraint(constraint);
   
//--------------------------------------------------------------------------------------- 

I have other questions to do, but in the first moment, understand why that is happening, is more important than any other question.  wink
Thanks for your patience and attention. =D

   

John Brookes, Moderator
Posted: 22 September 2011 02:04 PM   Total Posts: 732   [ # 1 ]

Your setting the cube in the ground, it has to fight to esacpe, hence the shaking
flipperRigidBody.position = new Vector3D(0, 0, -25);

raise it so that it clears the ground.

Also if you dont want to attatch a rigibody to another rigidBody dont put anything in the sceond mesh parameters.
var constraint:AWPHingeConstraint = new AWPHingeConstraint(flipperRB, new Vector3D(40, 0, 0), Vector3D.Z_AXIS);

that just creats a constraint with the world at the position you set the rigibody
eg
flipperRB.position = new Vector3D(0, 200, 0);
var constraint:AWPHingeConstraint = new AWPHingeConstraint(flipperRB, new Vector3D(40, 0, 0),Vector3D.Z_AXIS);

   

Jack Dracon, Newbie
Posted: 22 September 2011 02:59 PM   Total Posts: 27   [ # 2 ]

So, I had tried that way, but doesn’t worked pretty well.
Thanks for your attention, but, do you have any other advice?  =D

(ps.: It’s better now? =D)

   

John Brookes, Moderator
Posted: 22 September 2011 03:44 PM   Total Posts: 732   [ # 3 ]

Sorry not a clue what your saying :/

   

Jack Dracon, Newbie
Posted: 22 September 2011 04:44 PM   Total Posts: 27   [ # 4 ]
JohnBrookes - 22 September 2011 03:44 PM

Sorry not a clue what your saying :/

I edited the post, now this very simple. But, I will try once more explain.
I have a object, this object have to be set in some position in the the world and it can’t fall, just stay there. That’s why I am using the HingeConstraint. wink
But, the HingeConstraint doesn’t work as I expected. It makes a kind of joint between the ground and the object. But, this joint is the problem it’s very flexible. I want to know if, I can set this flexibility. It is possible? =D

p.s.:(It’t better now? =D)

   

John Brookes, Moderator
Posted: 22 September 2011 05:22 PM   Total Posts: 732   [ # 5 ]

What I said does exactly that
You dont need to constrain it to the ground, just use the first set of parameters
that will constrain it to the world.

var flipperRigidBody:AWPRigidBody = new AWPRigidBody(flipperShapeflipper2);
flipperRigidBody.position = new Vector3D(030, -25);//<raise it higher
flipperRB flipperRigidBody;
_physWorld.addRigidBody(flipperRB);
var 
constraint:AWPHingeConstraint = new AWPHingeConstraint(flipperRB, new Vector3D(4000), Vector3D.Z_AXIS); //<you only need this
_physWorld.addConstraint(constraint); 

Right I think you just need this and not the above
By the way if your not going to move this object or other objects cant influence it.
Just set its mass to zero. (becomes a static body)
In that case you dont need the hinge.

   

Jack Dracon, Newbie
Posted: 22 September 2011 05:51 PM   Total Posts: 27   [ # 6 ]

Thanks for your suggestion. wink
But, that doesn’t work yet =\
(Did you try to test my code? because I can’t believed what it’s wrong).
About the mass set as 0: Yes, I will move the object and change your rotation.
Thanks for your attention. wink

   

John Brookes, Moderator
Posted: 22 September 2011 07:34 PM   Total Posts: 732   [ # 7 ]

ok your right, it doesnt work.

For anyone else reading to constrain a hinge to the world read above.

   

Jack Dracon, Newbie
Posted: 22 September 2011 08:25 PM   Total Posts: 27   [ # 8 ]

A curious thing is: in the example ‘ConstraintTest.as’, the first element on the chain is fixed! How? kkkk
Any other advice?
Or, that is a good feature to be considered?
(I can post as a ‘issue’ on the github of awayphysics).

Thanks for your attention. =D

   

Yang Li, Administrator
Posted: 23 September 2011 01:56 AM   Total Posts: 80   [ # 9 ]

you don’t need constrain the rigidbody to ground, just pass one rigidbody to AWPHingeConstraint:

var constraint:AWPHingeConstraint = new AWPHingeConstraint(flipperRB, new Vector3D(40, 0, 0), Vector3D.Z_AXIS);

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X