A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by Carli » Wed Jun 16, 2010 2:29 pm
Hi,
i need to implement some flying things in my Game:
- a Blimp (flying slowly and stable, filled with helium)
- a Bird (fly behaviour should look realistic)
- a Glider (should fly with aerodynamics, without motor)
What are the basic ideas to reach the most realistic behaviour with newton?
Should i work with per-frame-applied forces?
Or is an impulse system the better way to do?
How should i calculate the forces to keep an object stable in the air?
-
Carli
-
- Posts: 245
- Joined: Fri Oct 02, 2009 5:28 am
by Julio Jerez » Wed Jun 16, 2010 4:25 pm
you can do it in tow ways.
The simpler way is you make you own force and torqe callback and apply the forces.
the more advance way if to make a unilatera joint and use as a object controller.
the is addconstration you can add forces, and constrain rows in case you need it.
I like the secund method because your body do no nee to have special foce and torque funtion, jts teh gravity
and you can just add force to these in teh call back. plsu you cna controll teh body in more direct way by usin contratin row in case you need it.
in both cases you need to know the physics of the forces that generate the fly.
for example fo a baloon the force is produced by the weight of the air displaced by the volume of the baloom.
for a bird and a glider they flight because they Vernulli effect of air moving around an airfoil.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Carli » Thu Jun 17, 2010 4:04 am
what exactly is a constrain row?
Do you know some wiki page where I can read about it?
-
Carli
-
- Posts: 245
- Joined: Fri Oct 02, 2009 5:28 am
by Julio Jerez » Thu Jun 17, 2010 8:56 am
it is the infomation a joint need to produce teh exact forces to generate teh efect the joint is disigned to do.
you do not have to worry about tah for now, you iwll fidn he nee when you need it.
in you case you can see the joint as a componed you can add to teh body in addition to teh force an torque callback, but that is more flexible.
basically if you add teh blank costom jopint to teh body, teh engie will do as followe
NewtonUpdate
call forceAndToque
calculate collisions
apply forces
call ApplyJointConstraint to calculate velocityes
Integrate
call JointVelocity to canculate impulse
Calculate matrix
as you can see the joint give you a chance to see what is affecting the body, you cna just add teh forces and toque of fligh.
for example in the ray cast car teh joint add suspension forces, in your case you add aerdynamics forces.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Carli » Thu Jun 17, 2010 9:44 am
Julio Jerez wrote: call ApplyJointConstraint to calculate velocityes
there is no such function, not in the header, not in the joint library (i'm using pascal)
-
Carli
-
- Posts: 245
- Joined: Fri Oct 02, 2009 5:28 am
by Julio Jerez » Thu Jun 17, 2010 10:45 am
The joint library has a c inteface exactlt teh same way that Newton.c
check JointLibrary.h
here i steh funtion
- Code: Select all
#ifdef __cplusplus
extern "C" {
#endif
// Generic joint call back and user data
typedef struct NewtonUserJoint{} NewtonUserJoint;
typedef void (*NewtonUserJointDestructorCallback) (const NewtonUserJoint* me);
typedef void (*NewtonUserJointSubmitConstraintCallback) (const NewtonUserJoint* me, dFloat timestep, int threadIndex);
// generic joint functions
JOINTLIBRARY_API void CustomDestroyJoint(const NewtonUserJoint *joint);
JOINTLIBRARY_API NewtonJoint* CustomGetNewtonJoint (const NewtonUserJoint *joint);
JOINTLIBRARY_API int CustomGetJointID (const NewtonUserJoint *joint);
JOINTLIBRARY_API void CustomSetJointID (const NewtonUserJoint *joint, int rttI);
JOINTLIBRARY_API const NewtonBody* CustomGetBody0 (const NewtonUserJoint *joint);
JOINTLIBRARY_API const NewtonBody* CustomGetBody1 (const NewtonUserJoint *joint);
JOINTLIBRARY_API int CustomGetBodiesCollisionState (const NewtonUserJoint *joint);
JOINTLIBRARY_API void CustomSetBodiesCollisionState (const NewtonUserJoint *joint, int state);
JOINTLIBRARY_API void* CustomGetUserData (const NewtonUserJoint *joint);
JOINTLIBRARY_API void CustomSetUserData (const NewtonUserJoint *joint, void* userData);
JOINTLIBRARY_API void CustomSetDestructorCallback (const NewtonUserJoint *joint, NewtonUserJointDestructorCallback callback);
JOINTLIBRARY_API void CustomSetSubmitContraintCallback (const NewtonUserJoint *joint, NewtonUserJointSubmitConstraintCallback callback);
// this is a plain blank joint that can be used by advanced users who want to make their own joints
// but that can only use languages that can only interface with C code.
// we recommend using the CPP library to make the joints and then add a C interface, but this join is here for completion
typedef void (*BlankJointGetInfo) (const NewtonUserJoint* me, NewtonJointRecord* info);
JOINTLIBRARY_API NewtonUserJoint* CustomCreateBlankJoint(int maxDof, const NewtonBody* body0, const NewtonBody* body1, BlankJointGetInfo info);
you make a blank joint and you registe teh pointer to teh callback you want.
you callback have the signature
typedef void (*NewtonUserJointSubmitConstraintCallback) (const NewtonUserJoint* me, dFloat timestep, int threadIndex);
and you register with
JOINTLIBRARY_API void CustomSetSubmitContraintCallback (const NewtonUserJoint *joint, NewtonUserJointSubmitConstraintCallback callback);
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Stucuk » Thu Jun 17, 2010 8:29 pm
Carli wrote:Julio Jerez wrote: call ApplyJointConstraint to calculate velocityes
there is no such function, not in the header, not in the joint library (i'm using pascal)
Look at the Pascal 1.53 version for an
idea of how its done. As i said in your other topic about joints noone has made a 2.0 version of the joints(The "Pascal Joints" are separate to the Joint Library, there Custom Joints). I have no clue if the 1.53 Pascal joint unit can actually be used in 2.0 without modification or if there have been too many changes but they both seem to do things in the same/simmiler way.
-

Stucuk
-
- Posts: 801
- Joined: Sat Mar 12, 2005 3:54 pm
- Location: Scotland
-
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 1 guest