[NEWTON] NewtonBodySetForce

Posted By: kasimir

[NEWTON] NewtonBodySetForce - 12/29/08 08:34

Hi,
i started with Newton, and i would ask if it is possible to set forces outside the callback function?
so i can use it like NewtonBodySetVelocity in each other funtion?

THX kasimir
Posted By: kasimir

Re: [NEWTON] NewtonBodySetForce - 01/11/09 20:12

so i did it include into the callback function using 3 skills...

but it does not work this way i like to have it...

i tried to move physic objects with mouse before with ODE - this works nice, but if i do this same way with Newton an object hiting a wall gets stuck / looking not nice...

with ODE this looks still smooth:
Youtube Video - ODE

so how i do this:

-calculate a vector from the clicked object to the 3d mouse position
-clear all velocities
-add force

two examples with Newton:
Youtube

so does anyone know a better way than mine?!

THX KASIMIR
Posted By: kasimir

Re: [NEWTON] NewtonBodySetForce - 01/25/09 16:48

so i get it work with newton like ode using forces!

but i modified the callback-function this way to add forces, i know thats is not nice frown
Code:
void onforceandtorque(NewtonBody* body)
{
	float mass, ixx, iyy, izz;
	NewtonBodyGetMassMatrix(body, &mass, &ixx, &iyy, &izz);

	ENTITY* entity = NewtonBodyGetUserData(body);
	VECTOR force;
	
	NewtonBodySetForce(body, vectorf(0, 0, - 50 * mass));
		
	force.x = entity.skill20;
	force.y = entity.skill21;
	force.z = entity.skill22;
	
	NewtonBodyAddForce(body, vectorf(force.x, force.y, force.z));
	
	entity.skill20 = 0;
	entity.skill21 = 0;
	entity.skill22 = 0;
	
}


now i am using 3 skills to save forces applied to an newtonobject, but it isn't the best way i like to have...

so does anyone know a better way to solf this problem???

[EDIT]
How can i apply forces out of the center / origin of a physic obect?
I want to drag them with help of the mouse!


© 2024 lite-C Forums