菜鸟学习OGRE和天龙八部之十一: ParticleSystem 粒子系统基本搞定

天龙X部粒子系统在OGRE的基础上通过插件形式自定义了一些粒子系统:

 

添加发射器1个
PolarEmitter

 

添加效果器6个
ColourFading
MeshAnimationAffector
MeshRotator
Movement
Revolution
ScaleInterpolator

 

添加的Renderer 2个
mesh
texcoord_billboard

 

场景里面几乎所有都会用到,所以要想载入all.particle文件,

也要像搜狐一样写一个插件,自己实现all.article文件里面增加的粒子效果,

即使不全部实现,也最好弄个框架把.

至于怎么写,其实不算难到下不了手,至少有模板,照着OGRE自带的粒子插件

依葫芦画瓢...体力活....很累,如图,效果嘛如果要追求一摸一样就很难,差不多就行了:







17:32:15: Loading library ./Plugin_TLBBParticleFX2
17:32:15: Particle Renderer Type 'mesh' registered
17:32:15: Particle Renderer Type 'texcoord_billboard' registered
17:32:15: Installing plugin: Plugin_TLBBParticleFX2
17:32:15: Particle Emitter Type 'PolarEmitter' registered
17:32:15: Particle Affector Type 'ColourFading' registered
17:32:15: Particle Affector Type 'Movement' registered
17:32:15: Particle Affector Type 'Revolution' registered
17:32:15: Particle Affector Type 'ScaleInterpolator' registered
17:32:15: Particle Affector Type 'MeshAnimation' registered
17:32:15: Particle Affector Type 'MeshRotator' registered
17:32:15: Plugin successfully installed

 

  1. void TLBBParticleFX2Plugin::install()  
  2. {  
  3.     // 生成所有粒子发射器的工厂  
  4.     ParticleEmitterFactory* pEmitFact;  
  5.   
  6.     // PolarEmitter  
  7.     pEmitFact = new PolarEmitterFactory();  
  8.     ParticleSystemManager::getSingleton().addEmitterFactory(pEmitFact);  
  9.     mEmitterFactories.push_back(pEmitFact);  
  10.   
  11.     // 生成所有粒子效果器的工厂  
  12.     ParticleAffectorFactory* pAffFact;  
  13.   
  14.     // ColourFadingAffector  
  15.     pAffFact = new ColourFadingAffectorFactory();  
  16.     ParticleSystemManager::getSingleton().addAffectorFactory(pAffFact);  
  17.     mAffectorFactories.push_back(pAffFact);  
  18.   
  19.     // MovementAffector  
  20.     pAffFact = new MovementAffectorFactory();  
  21.     ParticleSystemManager::getSingleton().addAffectorFactory(pAffFact);  
  22.     mAffectorFactories.push_back(pAffFact);  
  23.   
  24.     // RevolutionAffector  
  25.     pAffFact = new RevolutionAffectorFactory();  
  26.     ParticleSystemManager::getSingleton().addAffectorFactory(pAffFact);  
  27.     mAffectorFactories.push_back(pAffFact);  
  28.   
  29.     // ScaleInterpolatorAffector  
  30.     pAffFact = new ScaleInterpolatorAffectorFactory();  
  31.     ParticleSystemManager::getSingleton().addAffectorFactory(pAffFact);  
  32.     mAffectorFactories.push_back(pAffFact);  
  33.   
  34.     // MeshAnimationAffector  
  35.     pAffFact = new MeshAnimationAffectorFactory();  
  36.     ParticleSystemManager::getSingleton().addAffectorFactory(pAffFact);  
  37.     mAffectorFactories.push_back(pAffFact);  
  38.   
  39.     // MeshRotatorAffector  
  40.     pAffFact = new MeshRotatorAffectorFactory();  
  41.     ParticleSystemManager::getSingleton().addAffectorFactory(pAffFact);  
  42.     mAffectorFactories.push_back(pAffFact);  
  43. }  

 

  1. //======================================================================  
  2. // @author:   
  3. //      LYN 2009.10.29 QQ:18052887  
  4. // @remarks:  
  5. //      动画效果器  
  6. //=====================================================================  
  7.   
  8. #ifndef __MeshAnimationAffector_H__  
  9. #define __MeshAnimationAffector_H__  
  10.   
  11. #include "OgreMath.h"  
  12. #include "TLBBParticleFX2Prerequisites.h"  
  13. #include "OgreParticleAffector.h"  
  14. #include "OgreStringInterface.h"  
  15. #include "OgreVector3.h"  
  16.   
  17. namespace Ogre {  
  18.   
  19.     class _OgreParticleFX2Export MeshAnimationAffector : public ParticleAffector  
  20.     {  
  21.     public:  
  22.         /// Command object for particle emitter  - see ParamCommand   
  23.         class CmdAnimationName  : public ParamCommand  
  24.         {  
  25.         public:  
  26.             String doGet(const void* target) const;  
  27.             void doSet(void* target, const String& val);  
  28.         };  
  29.   
  30.         /// Command object for particle emitter  - see ParamCommand   
  31.         class CmdAnimationLoop : public ParamCommand  
  32.         {  
  33.         public:  
  34.             String doGet(const void* target) const;  
  35.             void doSet(void* target, const String& val);  
  36.         };  
  37.   
  38.         /// Command object for particle emitter  - see ParamCommand   
  39.         class CmdAnimationSpeed : public ParamCommand  
  40.         {  
  41.         public:  
  42.             String doGet(const void* target) const;  
  43.             void doSet(void* target, const String& val);  
  44.         };  
  45.   
  46.     public:  
  47.   
  48.         /** Default constructor. */  
  49.         MeshAnimationAffector(ParticleSystem* psys);  
  50.   
  51.         /** See ParticleAffector. */  
  52.         void _initParticle(Particle* pParticle);  
  53.   
  54.         /** See ParticleAffector. */  
  55.         void _affectParticles(ParticleSystem* pSystem, Real timeElapsed);  
  56.   
  57.     public:  
  58.   
  59.         // AnimationName  
  60.         void setAnimationName(const String& name);  
  61.         String getAnimationName(voidconst;  
  62.   
  63.         // AnimationLoop  
  64.         void setAnimationLoop(const bool& isLoop);  
  65.         bool getAnimationLoop(voidconst;  
  66.   
  67.         // AnimationSpeed  
  68.         void setAnimationSpeed(const Real& speed);  
  69.         Real getAnimationSpeed(voidconst;  
  70.   
  71.     public:  
  72.   
  73.         static CmdAnimationName msAnimationNameCmd;  
  74.         static CmdAnimationLoop msAnimationLoopCmd;  
  75.         static CmdAnimationSpeed msAnimationSpeedCmd;  
  76.   
  77.     protected:  
  78.   
  79.         String mAnimationName;  
  80.         bool mAnimationLoop;  
  81.         Real mAnimationSpeed;  
  82.     };  
  83. }  
  84.   
  85. #endif  


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值