Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/particlesystem/zSpinParticle.cxx

Go to the documentation of this file.
00001 // Filename: zSpinParticle.cxx
00002 // Created by:  charles (16Aug00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #include "zSpinParticle.h"
00020 
00021 ////////////////////////////////////////////////////////////////////
00022 //    Function : ZSpinParticle
00023 //      Access : public
00024 // Description : constructor
00025 ////////////////////////////////////////////////////////////////////
00026 ZSpinParticle::
00027 ZSpinParticle(void) :
00028   BaseParticle() {
00029   _initial_angle = 0.0f;
00030   _final_angle = 0.0f;
00031   _cur_angle = 0.0f;
00032   _angular_velocity = 0.0f;
00033   _bUseAngularVelocity = false;
00034 }
00035 
00036 ////////////////////////////////////////////////////////////////////
00037 //    Function : ZSpinParticle
00038 //      Access : public
00039 // Description : copy constructor
00040 ////////////////////////////////////////////////////////////////////
00041 ZSpinParticle::
00042 ZSpinParticle(const ZSpinParticle &copy) :
00043   BaseParticle(copy) {
00044   _initial_angle = copy._initial_angle;
00045   _final_angle = copy._final_angle;
00046   _cur_angle = copy._cur_angle;
00047   _angular_velocity = copy._angular_velocity;
00048   _bUseAngularVelocity = copy._bUseAngularVelocity;
00049 }
00050 
00051 ////////////////////////////////////////////////////////////////////
00052 //    Function : ~ZSpinParticle
00053 //      Access : public, virtual
00054 // Description : destructor
00055 ////////////////////////////////////////////////////////////////////
00056 ZSpinParticle::
00057 ~ZSpinParticle(void) {
00058 }
00059 
00060 ////////////////////////////////////////////////////////////////////
00061 //    Function : make_copy
00062 //      Access : public, virtual
00063 // Description : dynamic copier
00064 ////////////////////////////////////////////////////////////////////
00065 PhysicsObject *ZSpinParticle::
00066 make_copy(void) const {
00067   return new ZSpinParticle(*this);
00068 }
00069 
00070 ////////////////////////////////////////////////////////////////////
00071 //    Function : init
00072 //      Access : public, virtual
00073 // Description :
00074 ////////////////////////////////////////////////////////////////////
00075 void ZSpinParticle::
00076 init(void) {
00077 }
00078 
00079 ////////////////////////////////////////////////////////////////////
00080 //    Function : update
00081 //      Access : public, virtual
00082 // Description :
00083 ////////////////////////////////////////////////////////////////////
00084 void ZSpinParticle::
00085 update(void) {
00086   // if using final_angle, want age to range from [0,1] over lifespan, so use parameterized_age
00087   // for angular velocity, should be allowed to range freely upward, use regular age
00088 
00089   if(_bUseAngularVelocity) {
00090    // interpolate the current orientation
00091       _cur_angle = _initial_angle + (get_age() * _angular_velocity);
00092   } else {
00093       _cur_angle = _initial_angle + (get_parameterized_age() * (_final_angle - _initial_angle));
00094   }
00095 
00096   // normalize the result to [0..360)
00097   _cur_angle = fmod(_cur_angle, 360.0f);
00098 
00099   // if _cur_angle was negative, it is still negative after fmod,
00100   // wrap it around by adding 360
00101 
00102   // is this really necessary?  should be in range of sin/cos
00103   if(_cur_angle < 0.0f)
00104     _cur_angle += 360.0f;
00105 }
00106 
00107 ////////////////////////////////////////////////////////////////////
00108 //    Function : die
00109 //      Access : public, virtual
00110 // Description :
00111 ////////////////////////////////////////////////////////////////////
00112 void ZSpinParticle::
00113 die(void) {
00114 }
00115 
00116 ////////////////////////////////////////////////////////////////////
00117 //    Function : get_theta
00118 //      Access : public, virtual
00119 // Description :
00120 ////////////////////////////////////////////////////////////////////
00121 float ZSpinParticle::
00122 get_theta(void) const {
00123   return _cur_angle;
00124 }

Generated on Fri May 2 00:41:02 2003 for Panda by doxygen1.3