Hovering using only AddForce and SetForce

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Hovering using only AddForce and SetForce

Postby Overhertz » Mon Nov 05, 2012 4:09 pm

I've been trying to think of a way to make an object hover using newton forces, basically I want to drop in a cube, the cube should output some force to lift or push in specific direction, something like a jet engine. Anyone have any suggestions or sample of how to accomplish this? Thanks.
Ziron Programming Language
Download the Assembler HERE
User avatar
Overhertz
 
Posts: 112
Joined: Mon Jul 06, 2009 11:19 am

Re: Hovering using only AddForce and SetForce

Postby Sweenie » Tue Nov 06, 2012 3:01 am

Do you want it to hover a fixed distance above ground or should it be able to hover at any altitude?
In the first case you could just cast a ray downwards and apply a force based on the hit distance of the cast ray, much like how one would implement a spring/damper for a raycast vehicle. In this case you would use very low damping though.
In the second case I guess you would have to implement some kind of force controller that apply enough force to fight gravity, probably based on vertical velocity(downwards). The higher the downwards vertical velocity the more force to apply, with some damping as well to prevent it from bobbing up and down like crazy.
Or pretend your cube is in water and implement the force like boyancy. For example if you want the body to hover at an altitude of 100 meters, pretend that the water surface is at 100 meters and implement the forces like boyancy forces(search this forum for boyancy examples)
Sweenie
 
Posts: 503
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Hovering using only AddForce and SetForce

Postby Overhertz » Tue Nov 06, 2012 5:59 am

Hi Thanks for reply,

Probably a force controller will be the best bet, since if the box is rolled (by user) the force should push the cube forward whilst falling, I suppose I could do a check to see if the cube is facing down to check for distance and apply necessary force to lower the box to required altitude based on users power setting and if the cube faces any other directions just to apply a pre-defined force value.

Thanks for your ideas.
Ziron Programming Language
Download the Assembler HERE
User avatar
Overhertz
 
Posts: 112
Joined: Mon Jul 06, 2009 11:19 am

Re: Hovering using only AddForce and SetForce

Postby Overhertz » Tue Nov 06, 2012 10:57 am

I have an even better idea, is it possible to create a Newton Box that can pass through other objects, but still cause a collision callback? This way I will create an invisible box directly below the model box that acts as a pressure stream and whatever it intersects will have a up force pushing the model box also up.

This box could then theoretically be increased in size for higher altitude etc.
Ziron Programming Language
Download the Assembler HERE
User avatar
Overhertz
 
Posts: 112
Joined: Mon Jul 06, 2009 11:19 am

Re: Hovering using only AddForce and SetForce

Postby Julio Jerez » Tue Nov 06, 2012 11:58 am

why not simple use raycast in a dedicate force and torqe callback for that objects?
you could also cast a thick ray, by using a sphere instead of a thin raycast.

what are you doing?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Hovering using only AddForce and SetForce

Postby Overhertz » Tue Nov 06, 2012 1:14 pm

Hello Julio, it is to simulate the backblast of an flame based engine or thruster, so basically i need to have the force pushing the object in the opposite direction to the flames, so for example the box/engine faces up, flames down, the object will hover off the ground by 10 meters (as e.g.) and if the engine is twisted it will push forward.

But i want to get a realistic effect using raw physics, raycasting feels a bit fake, but with a box (as a flame), where that box touches i can create reactions to the flame based on how far the flame intersected other objects, so objects could be damaged by flames, it can also push the attached object up etc.

So if possible to create a newton body like usual, disable the simulation of this object but not the collision callback, this way I can check how much objects intersect and can add forces and damage as necessary. I think this will give the most realistic simulation. So nothing in the newtonworld should react with this object, but it still should callback that it is intersecting/colliding with another object/body
Ziron Programming Language
Download the Assembler HERE
User avatar
Overhertz
 
Posts: 112
Joined: Mon Jul 06, 2009 11:19 am

Re: Hovering using only AddForce and SetForce

Postby Julio Jerez » Tue Nov 06, 2012 3:02 pm

Overhertz wrote:So if possible to create a newton body like usual, disable the simulation of this object but not the collision callback, this way I can check how much objects intersect and can add forces and damage as necessary. I think this will give the most realistic simulation. So nothing in the newtonworld should react with this object, but it still should callback that it is intersecting/colliding with another object/body


The answer to this question is yes, If you are using core 300.
Basically you make a Kinematic body, and in the force and torque call back of the dynamics Body that represent the HoverCraft, you set the Transformation matrix of the kinematic body.
The contact for the Kinemics body will be a frame behind, but of you need the contacts to be on the same frame each time, you do not even need a Kinematic body.
You can simple make a the Box Shape, and in the force and torque callback you can call
NewtonCollide, and get the contacts in the same frame.


As for using Ray Cast, I agree ray cast will be a very fake was of doing it.
Is this a Hover Craft you are making of a Flying vehicles?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Hovering using only AddForce and SetForce

Postby Overhertz » Wed Nov 07, 2012 6:31 am

Hello Julio,

Yes I will be creating flying vehicles that have the engines/thrusters and all other parts connected at run-time and by the user.

So if I move to Newton 3 is the best bet? Is there a compiled binary for win32 ? (.dll)

But I do not really understand what it is you mean I will need to do. Could you give a small example? Thanks for your help.
Ziron Programming Language
Download the Assembler HERE
User avatar
Overhertz
 
Posts: 112
Joined: Mon Jul 06, 2009 11:19 am

Re: Hovering using only AddForce and SetForce

Postby Julio Jerez » Wed Nov 07, 2012 9:53 am

core 300 have two type of bodies: dynamics and kinematic.
dynamics are the same as they were in previuos cores.
kinematics are bodies that do not react to forces, only to velocity. They get contacts and averything else, but contacts are not consider for collision resolution.
they are good for triggers volumes, players controllers, and things like you mentioned
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Hovering using only AddForce and SetForce

Postby Overhertz » Wed Nov 07, 2012 10:55 am

Aha, super that sounds exactly like what I need, I will give it a mess around with core 3 and see if i can get things working, if not i will reply here again, meanwhile is there a ready .dll for core 3? Thanks again Julio.
Ziron Programming Language
Download the Assembler HERE
User avatar
Overhertz
 
Posts: 112
Joined: Mon Jul 06, 2009 11:19 am

Re: Hovering using only AddForce and SetForce

Postby Julio Jerez » Wed Nov 07, 2012 11:22 am

if you sync to SVN you can get the compile DLL fo rteh engine.

The engine contain all core funtionality, but most demos us teh higher level Joint Library wich is a static library righ now.
you you can just add that library to you project compile it with any compiler

I new funtionality of core 300 is the addition of pre and post listeners,
This is a method to integrate pluggins with teh engine that get update form with in teh engien and that can work in parallel with teh engine.

In the joint library ther is a base class to make such plugins, and it is use for managin Player controller and Vehicle controller.
you can make use that you plug you FlyingHoverCraft controller, and there you can place yourr vehicle logic

Dwonload core 300 from SVN and try builing it. so you can see how flexible and powerful it really is.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Hovering using only AddForce and SetForce

Postby Overhertz » Wed Nov 07, 2012 12:19 pm

I am not using c++ for this project so using the classes is off the menu, but if i can use the external c functions to accomplish this task I will be more than happy.
Ziron Programming Language
Download the Assembler HERE
User avatar
Overhertz
 
Posts: 112
Joined: Mon Jul 06, 2009 11:19 am

Re: Hovering using only AddForce and SetForce

Postby Overhertz » Wed Nov 07, 2012 6:49 pm

OK so i've updated to Newton Core 3, and I am having a strange problem, it seems objects now act very unrealistic and objects will often decide to fall through the ground or do other strange movements. I have left almost everything like it was in Newton 2, only now I've changed NewtonCreateBody to NewtonCreateDynamicBody. Is there something special i need to do for Newton3 to work correctly?

Also it seems NewtonBodySetCentreOfMass and NewtonBodySetMassMatrix now have ___ appended to the name, do i need to change these to something different?

Edit: Maybe it is problem now with my terrain class since NewtonCreateBody is now Dynamic body ? Or is this still fine?
Ziron Programming Language
Download the Assembler HERE
User avatar
Overhertz
 
Posts: 112
Joined: Mon Jul 06, 2009 11:19 am

Re: Hovering using only AddForce and SetForce

Postby Julio Jerez » Wed Nov 07, 2012 7:08 pm

this is a typical fution for creation a body

Code: Select all
NewtonBody* CreateSimpleBody (NewtonWorld* const world, void* const userData, dFloat mass, const dMatrix& matrix, NewtonCollision* const collision, int materialId)
{
   //create the rigid body
   NewtonBody* const rigidBody = NewtonCreateDynamicBody (world, collision, &matrix[0][0]);

   //  old method obsolete
   //dVector origin;
   //dVector inertia;
   //NewtonConvexCollisionCalculateInertialMatrix (collision, &inertia[0], &origin[0]);   
   //dFloat Ixx = mass * inertia[0];
   //dFloat Iyy = mass * inertia[1];
   //dFloat Izz = mass * inertia[2];
   //NewtonBodySetCentreOfMass (rigidBody, &origin[0]);
   //NewtonBodySetMassMatrix (rigidBody, mass, Ixx, Iyy, Izz);

   // use a more convenient function for setting mass and inertia matrix
   NewtonBodySetMassProperties (rigidBody, mass, collision);

   // save the pointer to the graphic object with the body.
   NewtonBodySetUserData (rigidBody, userData);

   // assign the wood id
   NewtonBodySetMaterialGroupID (rigidBody, materialId);

   //  set continue collision mode
   // NewtonBodySetContinuousCollisionMode (rigidBody, continueCollisionMode);

   // set a destructor for this rigid body
   NewtonBodySetDestructorCallback (rigidBody, PhysicsBodyDestructor);

   // set the transform call back function
   NewtonBodySetTransformCallback (rigidBody, DemoEntity::TransformCallback);

   // set the force and torque call back function
   NewtonBodySetForceAndTorqueCallback (rigidBody, PhysicsApplyGravityForce);
   return rigidBody;
}
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Hovering using only AddForce and SetForce

Postby Julio Jerez » Wed Nov 07, 2012 7:11 pm

Overhertz wrote:Edit: Maybe it is problem now with my terrain class since NewtonCreateBody is now Dynamic body ? Or is this still fine?


In Newton a dynamcis body is a body that participate in force base physical constatrationed dynamics,
in that sence a "static bodies" are dynamcic bodie, (they jsut happen to have infinite mass)
you terrain should be a dynamics body
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests