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

Spring.h

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 #ifndef OPENCAL_SPRING_H 00012 #define OPENCAL_SPRING_H 00013 00014 // Includes 00015 #include <OpenCAL/global.h> 00016 #include <OpenCAL/Force.h> 00017 00018 namespace OpenCAL 00019 { 00020 // Forward declarations 00021 class PhysicalObject; 00022 00026 class OPENCAL_API Spring: public Force 00027 { 00028 protected: 00029 // Member variables 00030 PhysicalObject *m_object1, *m_object2; 00031 float m_stiffness, m_damping; 00032 float m_restLength, m_snapFactor; 00033 00034 public: 00035 // Constructors and destructor 00036 Spring(PhysicsSystem *parent, PhysicalObject *object1 = 0, PhysicalObject *object2 = 0); 00037 virtual ~Spring(); 00038 00039 // Get functions 00040 const PhysicalObject *getObject1() const { return m_object1; } 00041 PhysicalObject *getObject1() { return m_object1; } 00042 const PhysicalObject *getObject2() const { return m_object2; } 00043 PhysicalObject *getObject2() { return m_object2; } 00044 float getStiffness() const { return m_stiffness; } 00045 float getDamping() const { return m_damping; } 00046 float getRestLength() const { return m_restLength; } 00047 float getSnapFactor() const { return m_snapFactor; } 00048 bool doesSnap() { return (m_snapFactor > 1.0f); } 00049 bool isConnected() { return (m_object1 && m_object2); } 00050 00051 // Set functions 00052 void setObject1(PhysicalObject *object) { m_object1 = object; } 00053 void setObject2(PhysicalObject *object) { m_object2 = object; } 00054 void setStiffness(float stiffness) { m_stiffness = stiffness; } 00055 void setDamping(float damping) { m_damping = damping; } 00056 void setRestLength(float restLength) { m_restLength = restLength; } 00057 void setSnapFactor(float snapFactor) { m_snapFactor = snapFactor; } 00058 void setNoSnap() { m_snapFactor = 0.0f; } 00059 00060 // Execute functions 00061 void initialize(); 00062 void execute(float seconds); 00063 00064 // Render functions 00065 void render(); 00066 00067 // Other functions 00068 void connect(PhysicalObject *object1, PhysicalObject *object2) { m_object1 = object1; m_object2 = object2; } 00069 void calculateRestLength(); 00070 /* 00071 #ifdef USE_OPENGL 00072 virtual void drawGL(); 00073 #endif // USE_OPENGL 00074 */ 00075 }; 00076 } 00077 00078 #endif // OPENCAL_SPRING_H

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