source: GTP/branches/IllumWPdeliver2008dec/IlluminationWP/demos/Standalone/Hierarchical Systems Demo [OpenGL]/RESOURCES/include/My3DGraphRes/Particle.h @ 3255

Revision 3255, 1.3 KB checked in by szirmay, 15 years ago (diff)
Line 
1#pragma once
2
3#include "Vector.h"
4
5class Particle
6{
7public:
8        Particle(void);
9        ~Particle(void);
10
11        Vector m_Color;
12        bool refrcol;
13        int m_ID;
14       
15private:
16        Vector m_Position;
17        Vector m_Velocity;
18
19       
20        float m_Size;
21        float m_D_Size;
22public:
23        unsigned int m_Time_to_Live; //if 0 live forever
24        unsigned int m_Age;
25
26        void setPosition(Vector position);
27        void setPosition(double x, double y, double z);
28        Vector& getPosition(void);
29        void getPosition(double& x, double& y, double& z);
30        void setVelocity(Vector velocity){m_Velocity=velocity;}
31        void setTimetoLive(unsigned int ttl){m_Time_to_Live=ttl;}
32        void setSize(double size){m_Size=size;}
33        double getSize(){return m_Size;}
34
35        double m_Distance;
36       
37        bool operator < (Particle& op){return(m_Distance<op.m_Distance);}
38        bool operator > (Particle& op){return(m_Distance>=op.m_Distance);}
39
40        bool LiveMore(unsigned int Dt)
41        {
42                if(m_Time_to_Live==0)//live forever
43                        return true;
44
45                m_Age+=Dt;             
46
47                if(m_Age>m_Time_to_Live)
48                {
49                        return false;
50                }
51                else
52                {                       
53                        return true;
54                }
55                       
56        }
57
58        void Refresh(unsigned int Dt)
59        {
60        Vector dir=m_Velocity*(((double)Dt)/1000);
61                m_Position+=dir;
62               
63                if(m_Time_to_Live!=0)
64                {
65                        float live=float(((float)(m_Age))/((float)(m_Time_to_Live)));                           
66                        m_Color.w=sin(live*M_PI);       
67                }
68                               
69        }
70
71        Particle *m_NextParticle;
72};
Note: See TracBrowser for help on using the repository browser.