aboutsummaryrefslogtreecommitdiff
path: root/visualization
diff options
context:
space:
mode:
Diffstat (limited to 'visualization')
-rw-r--r--visualization/extrasmeltutils.cpp33
-rw-r--r--visualization/extrasmeltutils.hpp54
2 files changed, 87 insertions, 0 deletions
diff --git a/visualization/extrasmeltutils.cpp b/visualization/extrasmeltutils.cpp
index d77cc4b..160f7d6 100644
--- a/visualization/extrasmeltutils.cpp
+++ b/visualization/extrasmeltutils.cpp
@@ -1,6 +1,7 @@
#include <cstdarg>
#include "extrasmeltutils.hpp"
SMELT* smEntity3DBuffer::sm=NULL;
+SMELT* smParticle::sm=NULL;
smVertex makeVertex(float x,float y,float z,DWORD color,float tx,float ty)
{smVertex v;v.x=x;v.y=y;v.z=z;v.col=color;v.tx=tx;v.ty=ty;return v;}
void smEntity3D::addVerices(int n,...)
@@ -59,3 +60,35 @@ void smEntity3DBuffer::drawBatch()
sm->smDrawCustomIndexedVertices(&vertices[0],&indices[0],vertices.size(),indices.size(),BLEND_ALPHABLEND,0);
vertices.clear();indices.clear();
}
+smParticle::smParticle(){sm=smGetInterface(SMELT_APILEVEL);}
+smParticle::~smParticle(){sm->smRelease();}
+void smParticle::render()
+{sm->smRenderQuad(&q);}
+void smParticle::update()
+{
+ clifespan+=sm->smGetDelta();
+ vel=vel+accel;pos=pos+vel;rotv=rotv+rota;rot=rot+rotv;
+ size=clifespan/lifespan*(finalsize-initsize)+initsize;
+ color=ARGB(
+ (DWORD)(clifespan/lifespan*(GETA(finalcolor)-GETA(initcolor)+GETA(initcolor))),
+ (DWORD)(clifespan/lifespan*(GETR(finalcolor)-GETR(initcolor)+GETR(initcolor))),
+ (DWORD)(clifespan/lifespan*(GETG(finalcolor)-GETG(initcolor)+GETG(initcolor))),
+ (DWORD)(clifespan/lifespan*(GETB(finalcolor)-GETB(initcolor)+GETB(initcolor))));
+ //set up the quad
+}
+smParticleSystem::smParticleSystem(){particles.clear();posGenerator=NULL;}
+smParticleSystem::~smParticleSystem()
+{for(int i=0;i<particles.size();++i)delete particles[i];particles.clear();}
+void smParticleSystem::setParticleSystemInfo(smParticleSystemInfo _psinfo)
+{psinfo=_psinfo;}
+void smParticleSystem::setPos(smvec3d _pos){pos=_pos;}
+void smParticleSystem::setPSEmissionPosGen(smPSEmissionPositionGenerator *_gen)
+{posGenerator=_gen;}
+void smParticleSystem::startPS()
+{}
+void smParticleSystem::stopPS()
+{}
+void smParticleSystem::updatePS()
+{}
+void smParticleSystem::renderPS()
+{}
diff --git a/visualization/extrasmeltutils.hpp b/visualization/extrasmeltutils.hpp
index 8a4a1bc..092fbfb 100644
--- a/visualization/extrasmeltutils.hpp
+++ b/visualization/extrasmeltutils.hpp
@@ -29,5 +29,59 @@ class smEntity3DBuffer
void drawBatch();
};
+class smPSEmissionPositionGenerator
+{
+ public:
+ virtual smvec3d genPos();
+};
+class smParticleSystemInfo
+{
+ public:
+ smvec3d vel,velvar,acc,accvar;
+ smvec3d rotv,rotvvar,rota,rotavar;
+ double lifespan,lifespanvar;
+ int maxcount,emissioncount,ecvar;
+ double emissiondelay,edvar;
+ double initsize,initsizevar;
+ double finalsize,finalsizevar;
+ DWORD initcolor,initcolorvar;
+ DWORD finalcolor,finalcolorvar;
+ SMTEX texture;int blend;
+};
+class smParticle
+{
+ friend class smParticleSystem;
+ private:
+ static SMELT* sm;
+ smvec3d pos,rot;
+ smvec3d vel,accel,rotv,rota;
+ double lifespan,clifespan;
+ double initsize,finalsize,size;
+ DWORD color,initcolor,finalcolor;
+ smQuad q;
+ public:
+ smParticle();
+ ~smParticle();
+ void render();
+ void update();
+};
+class smParticleSystem
+{
+ private:
+ std::vector<smParticle*> particles;
+ smParticleSystemInfo psinfo;
+ smvec3d pos;
+ smPSEmissionPositionGenerator* posGenerator;
+ public:
+ smParticleSystem();
+ ~smParticleSystem();
+ void setParticleSystemInfo(smParticleSystemInfo _psinfo);
+ void setPos(smvec3d _pos);
+ void setPSEmissionPosGen(smPSEmissionPositionGenerator* _gen);
+ void startPS();
+ void stopPS();
+ void updatePS();
+ void renderPS();
+};
extern smVertex makeVertex(float x,float y,float z,DWORD color,float tx,float ty);
#endif // EXTRASMELTUTILS_H