#ifndef __SIMSPHERE_H__ #define __SIMSPHERE_H__ /*************************************************************************** File: SimSphere.h Created: 01/22/02 Author: Maxim Garber Computer Science Department University of North Carolina - Chapel Hill garber@cs.unc.edu DescriptioN: Projectile sphere which interacts with cloth simulation ----------------------------------------------------------------------------. Copyright 2002 Maxim Garber *****************************************************************************/ #include "vec3fv.hpp" #include "ProjectileLaunchParams.h" class SimSphere { public: /***************************************************************************** Constructors & Destructor *****************************************************************************/ SimSphere(char* fileName); ~SimSphere(); /***************************************************************************** Launch *****************************************************************************/ void Launch(ProjectileLaunchParams params); /***************************************************************************** Accessors *****************************************************************************/ const float* GetCenter() const {return _center; } const float* GetForce() const {return _force; } float GetRadius() const {return _radius; } float GetDrawRadius() const {return _drawRadius; } float GetInverseMass() const {return _inverseMass; } bool IsActive() const {return _timeOnTheGround < _maxTimeOnGround;} /***************************************************************************** Collision Projection and External Forces *****************************************************************************/ void MoveCenter(float offset[3]) {Add3fv(_center, _center, offset);} void SetCenter (float center[3]) {Copy3fv(_center, center); } void AddForce (float force[3]) {Add3fv(_force, _force, force); } void ClearForce() {Set3fv(_force, 0.0f, 0.0f, 0.0f);} unsigned char GetIsFree() const {return _isFree; } void SetIsFree(const unsigned char isFree) {_isFree = isFree; } /***************************************************************************** Drawing *****************************************************************************/ void Draw() const; /***************************************************************************** Simulation *****************************************************************************/ void Update(const float timeStep); // timeStep in seconds private: // puck parameters float _center[3]; float _prevCenter[3]; float _force[3]; float _drawRadius; float _radius; float _inverseMass; //rendering unsigned char _color[3]; // fade out float _timeOnTheGround; float _maxTimeOnGround; // for simulation float _timeStep; float _gravity[3]; float _dampingFactor; unsigned int _numIterations; unsigned char _isFree; // true if puck is free to move ** for replay ** /***************************************************************************** Simulation Helper Functions *****************************************************************************/ void _InitializeSimulation(); void _AccumulateForces(); void _Integrate(); void _SatisfyConstraints(); }; /**************************************************************************** Function : SimSphereActive Description: predicate function to test if the sphere is alive ****************************************************************************/ inline bool SimSphereActive(SimSphere* sphere) { return sphere->IsActive(); } #endif //__SIMSPHERE_H__