Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

ViscousDrag.cpp

00001 /*************************************************************************** 00002 * This file is part of OpenCAL: Open Computer Animation Library * 00003 * I created OpenCAL as my master's thesis Computer Science (multimedia) * 00004 * at the tUL university in Diepenbeek, Belgium * 00005 * * 00006 * Copyright (C) 2003-2004 by Jeroen Dierckx * 00007 * jeroen.dierckx@student.luc.ac.be * 00008 * * 00009 ***************************************************************************/ 00010 00011 // Includes 00012 #include "ViscousDrag.h" 00013 #include <OpenCAL/PhysicalObject.h> 00014 #include <OpenCAL/PhysicsSystem.h> 00015 #include <OpenCAL/ObjectIterator.h> 00016 using namespace OpenCAL; 00017 00018 using namespace std; 00019 00020 00021 /****************************** 00022 * Constructors and destructor * 00023 ******************************/ 00024 00025 ViscousDrag::ViscousDrag(PhysicsSystem *parent, float drag) 00026 : Force(parent), m_drag(drag) 00027 { 00028 } 00029 00030 ViscousDrag::~ViscousDrag() 00031 { 00032 } 00033 00034 00035 /************************ 00036 * Get and set functions * 00037 ************************/ 00038 00039 00040 /****************** 00041 * Other functions * 00042 ******************/ 00043 00049 void ViscousDrag::execute(float seconds) 00050 { 00052 00053 //if(!m_enabled) return; 00054 Force::execute(seconds); 00055 00056 ObjectIterator it(m_parent); 00057 while(*it) 00058 { 00059 PhysicalObject *object = (PhysicalObject *) *it; 00060 object->addForce(-m_drag * object->getVelocity()); 00061 00062 ++it; 00063 } 00064 00065 /* 00066 for(unsigned int i = 0; i < m_parent->numObjects(); ++i) 00067 { 00068 PhysicalObject *object = (PhysicalObject *) m_parent->getObject(i); 00069 object->addForce(-m_drag * object->getVelocity()); 00070 } 00071 */ 00072 } 00073 00074 00075 /********************** 00076 * Protected functions * 00077 **********************/

Generated on Sun Aug 15 19:19:23 2004 for OpenCAL: Open Computer Animation Library by doxygen 1.3.8