Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

dragcontroller.cpp

Go to the documentation of this file.
00001 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*-
00002    this file is part of rcssserver3D
00003    Fri May 9 2003
00004    Copyright (C) 2003 Koblenz University
00005    $Id: dragcontroller.cpp,v 1.1 2004/04/05 08:45:45 rollmark Exp $
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; version 2 of the License.
00010 
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014    GNU General Public License for more details.
00015 
00016    You should have received a copy of the GNU General Public License
00017    along with this program; if not, write to the Free Software
00018    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019 */
00020 #include "dragcontroller.h"
00021 #include "body.h"
00022 
00023 using namespace oxygen;
00024 using namespace salt;
00025 
00026 DragController::DragController()
00027 {
00028     mLinearDrag = 0.1f;
00029     mAngularDrag = 0.1f;
00030 }
00031 
00032 DragController::~DragController()
00033 {
00034 }
00035 
00036 void DragController::PrePhysicsUpdateInternal(float /*deltaTime*/)
00037 {
00038     if (mBody.get() == 0)
00039     {
00040         return;
00041     }
00042 
00043     if (mLinearDrag > 0)
00044     {
00045         // apply linear drag
00046         Vector3f vel = mBody->GetVelocity() * mLinearDrag * -1;
00047         mBody->AddForce(vel);
00048     }
00049 
00050     if (mAngularDrag > 0)
00051     {
00052         // apply angular drag
00053         Vector3f vel = mBody->GetAngularVelocity() * mAngularDrag * -1;
00054         mBody->AddTorque(vel);
00055     }
00056 }
00057 
00058 float DragController::GetLinearDrag()
00059 {
00060     return mLinearDrag;
00061 }
00062 
00063 void DragController::SetLinearDrag(float d)
00064 {
00065     mLinearDrag = d;
00066 }
00067 
00068 float DragController::GetAngularDrag()
00069 {
00070     return mAngularDrag;
00071 }
00072 
00073 void DragController::SetAngularDrag(float d)
00074 {
00075     mAngularDrag = d;
00076 }
00077 
00078 

Generated on Thu Apr 6 15:25:37 2006 for rcssserver3d by  doxygen 1.4.4