activate a hinge

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

activate a hinge

Postby Scorpion » Thu Aug 21, 2008 3:04 pm

hello,
I created 2 bodies(one with mass 0, the other one with a callback for gravity) and added a hinge(wihtout an callback). If I start the game the hinge does not move until a body touches it...that looks ugly, because the connected body should touch the bottom

here a little ascii art:

Code: Select all
hinge          object
  _              _
|O|-------------|_|

--------ground------


So my question is: is there a way to activate that hinge, it seems like activating the attached bodies doesn't do anything

Thank you for the help
Scorpion
Scorpion
 
Posts: 12
Joined: Tue Jan 22, 2008 5:53 pm

Re: activate a hinge

Postby Sweenie » Fri Aug 22, 2008 2:03 am

It's not the hinge that is the problem.
Constraints can't "fall asleep", but if the two connected bodies are asleep, the constraint won't update.
The body with mass 0 will always be asleep, but the moving body shouldn't be. Somehow I guess it falls asleep before it has a chance to pick up speed.
Have you set the right inertia values for the moving body, or maybe too much damping?
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: activate a hinge

Postby Scorpion » Fri Aug 22, 2008 8:59 am

This is how I calculate the inertia for the body:
Code: Select all
NewtonConvexCollisionCalculateInertialMatrix(collision, inertia, centerofmass);
NewtonBodySetMassMatrix(body, mass, mass * inertia[0], mass * inertia[1], mass * inertia[2]);


I set the body to always active and in it's callback i add gravity:
Code: Select all
NewtonBodySetForce(body, vectorf(0,0,-9.8*mass));


So just in theory it should fall until it reaches the ground. Anything I'm doing wrong? =(
Scorpion
 
Posts: 12
Joined: Tue Jan 22, 2008 5:53 pm

Re: activate a hinge

Postby Sweenie » Fri Aug 22, 2008 10:05 am

Hmm, odd.

Does the body fall as usual on it's own?, that is, if you skip creating the hinge constraint.
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: activate a hinge

Postby Scorpion » Fri Aug 22, 2008 10:47 am

without it's working (and falling) fine, but I already tried that

I have the same problem by a button I was creating: It was an body on a slider and I added a upward force. but sometimes, if something lay on it, so that it stands still it didn't move up anymore (I set the body to active, too)

So I suppose there must be some kind of sleep state for hinges, but I don't find a way to deactivate it.

edit: it looks like if I set a force in the forceAndTorque callback of the body it does not get applied...as example gravity
Scorpion
 
Posts: 12
Joined: Tue Jan 22, 2008 5:53 pm

Re: activate a hinge

Postby Sweenie » Fri Aug 22, 2008 8:09 pm

How are you activating the body?

NewtonBodySetAutoFreeze(body, 0) and then NewtonWorldUnfreezeBody(world, body) ?
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: activate a hinge

Postby Scorpion » Sun Aug 24, 2008 9:29 am

Code: Select all
NewtonBodySetAutoFreeze(body,0);
NewtonWorldUnfreezeBody(nworld, body);


I don't really understand, why there is no 'normal' gravity applied, when its connected with a hinge
Scorpion
 
Posts: 12
Joined: Tue Jan 22, 2008 5:53 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 16 guests

cron