A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by perkins » Sun Apr 13, 2014 5:48 pm
So I'm trying to get a basic test program to work, just a world with a single object that moves, using 64 bit linux. NewtonBodySetTransformCallback seems to work, the function I register with it gets called once an update. NewtonBodySetForceAndTorqueCallback does not seem to work. I notice it is commented out in some of the tutorials, has it been replaced? Or am I just not setting something up properly... Anyway, here is the code:
http://pastebin.com/AaEPh6cm compiled via
gcc $PWD/libNewton.so -o tst -lstdc++ -lpthread -lrt tst.c
run via
LD_LIBRARY_PATH=$PWD ./tst
It outputs
0
In transformCallback
1
In transformCallback
In transformCallback
In transformCallback
In transformCallback
Note that forceAndTorqueCallback does not get called.
Also, NewtonBodyGetForce and NewtonBodyGetVelocity give 0 for both the force and the velocity. I know I must be missing something obvious, but I would appreciate some pointers on what to do differently.
-
perkins
-
- Posts: 22
- Joined: Sat Dec 24, 2011 9:41 pm
by perkins » Sun Apr 13, 2014 6:21 pm
It seems that the body is going to seelp, even though autosleep is off. I do see that the NewtonBodySetForce only works from withint ForceAndTorqueCallback, but I still don't understand why the body is falling asleep without ever calling forceAndTorqueCallback and with autosleep off...
-
perkins
-
- Posts: 22
- Joined: Sat Dec 24, 2011 9:41 pm
by JoeJ » Mon Apr 14, 2014 4:12 am
Sounds like you forgot to set the force tourque callback at body creation - NewtonBodySetForceAndTorqueCallback (body, funcPtr) ?
Thus no force, velocity and sleep.
For me turning off autosleep only works properly when i call it from within force tourque callback, otherwise obies ignored my setting and kept falling to sleep, which is confusing.
-

JoeJ
-
- Posts: 1489
- Joined: Tue Dec 21, 2010 6:18 pm
by Julio Jerez » Mon Apr 14, 2014 11:16 am
you created a kinematic body but you are using as if it was dynamic
- Code: Select all
NewtonWorld* world= NewtonCreate();
NewtonCollision *collision=NewtonCreateBox(world, 10, 10, 10, 1, 0);
NewtonBody *box=NewtonCreateKinematicBody(world, collision, matrix);
NewtonBodySetMassMatrix(box, 1, 1, 1, 1);
kinematic bodies sleep 100% of the time because they are not part of the dynamics updates,
they only particulate on a dynamcis update as contact generators when other dynamic bodies collide with them.
try making it a body dynamics
NewtonBody *box=NewtonCreateDynmaicBody(world, collision, matrix);
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by perkins » Mon Apr 14, 2014 12:23 pm
Ah, that seems rather obvious now, and thanks Joe for mentioning the sleep only working from within the callback. I should be off and running now

-
perkins
-
- Posts: 22
- Joined: Sat Dec 24, 2011 9:41 pm
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 1 guest