trueaxis.com Forum Index trueaxis.com
True Axis Physics SDK Forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

any way to simulate Drag or air resistance?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    trueaxis.com Forum Index -> Getting Started
View previous topic :: View next topic  
Author Message
Mouse



Joined: 24 Nov 2007
Posts: 6

PostPosted: Sun Nov 25, 2007 9:59 pm    Post subject: any way to simulate Drag or air resistance? Reply with quote

Is there any way to simulate Drag or air resistance? so if you throw a projectile through the air will it slow down?

EDIT: Better example would be something moving through water.
Back to top
View user's profile Send private message
luke
Site Admin


Joined: 15 Oct 2004
Posts: 621

PostPosted: Wed Nov 28, 2007 10:51 am    Post subject: Reply with quote

There is no in build method, however, you can do it your self.
Here is a fairly simple and generic method for approximating air resistance.
Code:

const float fAirResistance = 0.01f; // what every value you like
const Vec3& v3LinearVelocity = pDynamicObject->GetLinearVelocity();
float fSpeed = v3LinearVelocity.GetMagnitude();
if (fSpeed > 0.0f)
{
    Vec3 v3VelocityDirection = v3LinearVelocity / fSpeed;
    fSpeed -= fAirResistance * fSpeed * fSpeed * fDt; // this could be replace with any formular for air or fluid resistance 
    if (fSpeed < 0.0f)
        fSpeed = 0.0f;
    // fSpeed *= exp(-fAirResistance * fDt); // Alternative drag formular
    pDynamicObject->SetLinearVelocity(v3VelocityDirection  * fSpeed;
}
Back to top
View user's profile Send private message Send e-mail
Mouse



Joined: 24 Nov 2007
Posts: 6

PostPosted: Wed Nov 28, 2007 3:14 pm    Post subject: Reply with quote

That's was I was thinking of doing - except that I was going to apply a reverse force for the drag rather than change the velocity explictly - but this way might be easier.
Back to top
View user's profile Send private message
luke
Site Admin


Joined: 15 Oct 2004
Posts: 621

PostPosted: Thu Nov 29, 2007 2:03 am    Post subject: Reply with quote

Either way. But setting the velocity directly sometimes makes life easier.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    trueaxis.com Forum Index -> Getting Started All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group