您的位置:首页 > 其它

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

2011-09-04 16:32 435 查看
天龙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

view
plain

void TLBBParticleFX2Plugin::install()

{

// 生成所有粒子发射器的工厂

ParticleEmitterFactory* pEmitFact;

// PolarEmitter

pEmitFact = new PolarEmitterFactory();

ParticleSystemManager::getSingleton().addEmitterFactory(pEmitFact);

mEmitterFactories.push_back(pEmitFact);

// 生成所有粒子效果器的工厂

ParticleAffectorFactory* pAffFact;

// ColourFadingAffector

pAffFact = new ColourFadingAffectorFactory();

ParticleSystemManager::getSingleton().addAffectorFactory(pAffFact);

mAffectorFactories.push_back(pAffFact);

// MovementAffector

pAffFact = new MovementAffectorFactory();

ParticleSystemManager::getSingleton().addAffectorFactory(pAffFact);

mAffectorFactories.push_back(pAffFact);

// RevolutionAffector

pAffFact = new RevolutionAffectorFactory();

ParticleSystemManager::getSingleton().addAffectorFactory(pAffFact);

mAffectorFactories.push_back(pAffFact);

// ScaleInterpolatorAffector

pAffFact = new ScaleInterpolatorAffectorFactory();

ParticleSystemManager::getSingleton().addAffectorFactory(pAffFact);

mAffectorFactories.push_back(pAffFact);

// MeshAnimationAffector

pAffFact = new MeshAnimationAffectorFactory();

ParticleSystemManager::getSingleton().addAffectorFactory(pAffFact);

mAffectorFactories.push_back(pAffFact);

// MeshRotatorAffector

pAffFact = new MeshRotatorAffectorFactory();

ParticleSystemManager::getSingleton().addAffectorFactory(pAffFact);

mAffectorFactories.push_back(pAffFact);

}

view
plain

//======================================================================

// @author:

// LYN 2009.10.29 QQ:18052887

// @remarks:

// 动画效果器

//=====================================================================

#ifndef __MeshAnimationAffector_H__

#define __MeshAnimationAffector_H__

#include "OgreMath.h"

#include "TLBBParticleFX2Prerequisites.h"

#include "OgreParticleAffector.h"

#include "OgreStringInterface.h"

#include "OgreVector3.h"

namespace Ogre {

class _OgreParticleFX2Export MeshAnimationAffector : public ParticleAffector

{

public:

/// Command object for particle emitter - see ParamCommand

class CmdAnimationName : public ParamCommand

{

public:

String doGet(const void* target) const;

void doSet(void* target, const String& val);

};

/// Command object for particle emitter - see ParamCommand

class CmdAnimationLoop : public ParamCommand

{

public:

String doGet(const void* target) const;

void doSet(void* target, const String& val);

};

/// Command object for particle emitter - see ParamCommand

class CmdAnimationSpeed : public ParamCommand

{

public:

String doGet(const void* target) const;

void doSet(void* target, const String& val);

};

public:

/** Default constructor. */

MeshAnimationAffector(ParticleSystem* psys);

/** See ParticleAffector. */

void _initParticle(Particle* pParticle);

/** See ParticleAffector. */

void _affectParticles(ParticleSystem* pSystem, Real timeElapsed);

public:

// AnimationName

void setAnimationName(const String& name);

String getAnimationName(void) const;

// AnimationLoop

void setAnimationLoop(const bool& isLoop);

bool getAnimationLoop(void) const;

// AnimationSpeed

void setAnimationSpeed(const Real& speed);

Real getAnimationSpeed(void) const;

public:

static CmdAnimationName msAnimationNameCmd;

static CmdAnimationLoop msAnimationLoopCmd;

static CmdAnimationSpeed msAnimationSpeedCmd;

protected:

String mAnimationName;

bool mAnimationLoop;

Real mAnimationSpeed;

};

}

#endif
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  library class 框架 qq
相关文章推荐