123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- #ifndef __CC_PARTICLE_3D_RENDER_H__
- #define __CC_PARTICLE_3D_RENDER_H__
- #include <vector>
- #include "renderer/CCRenderState.h"
- #include "base/CCRef.h"
- #include "math/CCMath.h"
- NS_CC_BEGIN
- class ParticleSystem3D;
- class Renderer;
- class MeshCommand;
- class Sprite3D;
- class GLProgramState;
- class IndexBuffer;
- class VertexBuffer;
- class Texture2D;
- class CC_DLL Particle3DRender : public Ref
- {
- friend class ParticleSystem3D;
- public:
- virtual void render(Renderer* renderer, const Mat4 &transform, ParticleSystem3D* particleSystem) = 0;
-
- virtual void notifyStart();
-
- virtual void notifyStop();
-
- virtual void notifyRescaled(const Vec3& scale);
-
- void setVisible(bool isVisible) { _isVisible = isVisible; }
-
- bool isVisible() const { return _isVisible; }
- void setDepthTest(bool isDepthTest);
- void setDepthWrite(bool isDepthWrite);
- void setBlendFunc(const BlendFunc& blendFunc);
- void copyAttributesTo (Particle3DRender *render);
- virtual void reset(){}
- CC_CONSTRUCTOR_ACCESS:
- Particle3DRender();
- virtual ~Particle3DRender();
-
- protected:
- ParticleSystem3D *_particleSystem;
- RenderState::StateBlock* _stateBlock;
- bool _isVisible;
- Vec3 _rendererScale;
- bool _depthTest;
- bool _depthWrite;
- };
- class CC_DLL Particle3DQuadRender : public Particle3DRender
- {
- public:
- static Particle3DQuadRender* create(const std::string& texFile = "");
-
- virtual void render(Renderer* renderer, const Mat4 &transform, ParticleSystem3D* particleSystem) override;
- virtual void reset()override;
- CC_CONSTRUCTOR_ACCESS:
- Particle3DQuadRender();
- virtual ~Particle3DQuadRender();
- protected:
- bool initQuadRender(const std::string& texFile);
-
- protected:
- MeshCommand* _meshCommand;
- Texture2D* _texture;
- GLProgramState* _glProgramState;
- IndexBuffer* _indexBuffer;
- VertexBuffer* _vertexBuffer;
-
- struct posuvcolor
- {
- Vec3 position;
- Vec2 uv;
- Vec4 color;
- };
- std::vector<posuvcolor> _posuvcolors;
- std::vector<unsigned short> _indexData;
- std::string _texFile;
- };
- class CC_DLL Particle3DModelRender : public Particle3DRender
- {
- public:
- static Particle3DModelRender* create(const std::string& modelFile, const std::string &texFile = "");
- virtual void render(Renderer* renderer, const Mat4 &transform, ParticleSystem3D* particleSystem) override;
-
- virtual void reset()override;
- CC_CONSTRUCTOR_ACCESS:
- Particle3DModelRender();
- virtual ~Particle3DModelRender();
-
- protected:
- std::vector<Sprite3D *> _spriteList;
- std::string _modelFile;
- std::string _texFile;
- Vec3 _spriteSize;
- };
- NS_CC_END
- #endif
|