本文整理汇总了C++中ParticleEffect类的典型用法代码示例。如果您正苦于以下问题:C++ ParticleEffect类的具体用法?C++ ParticleEffect怎么用?C++ ParticleEffect使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ParticleEffect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: XMLoadFloat4x4
void InClassProj::DrawParticles()
{
XMVECTOR eyePos = m2DCam->GetPos();
XMMATRIX proj = XMLoadFloat4x4(&mProj);
XMMATRIX view = m2DCam->GetView();
XMMATRIX vp = view * proj;
mParticleEffect->SetPerFrameParams(eyePos);
mParticleEffect->SetPerObjectParams(vp, mParticleTexture);
md3dImmediateContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST);
md3dImmediateContext->IASetInputLayout(Vertex::GetParticleVertLayout());
UINT stride = sizeof(Vertex::ParticleVertex);
UINT offset = 0;
md3dImmediateContext->IASetVertexBuffers(0, 1, &mParticleVB, &stride, &offset);
md3dImmediateContext->OMSetDepthStencilState(mNoDepthDS, 0);
float blendFactor[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
md3dImmediateContext->OMSetBlendState(mAdditiveBS, blendFactor, 0xffffffff);
D3DX11_TECHNIQUE_DESC techDesc;
mParticleEffect->GetTech()->GetDesc(&techDesc);
for (UINT p = 0; p < techDesc.Passes; ++p)
{
mParticleEffect->GetTech()->GetPassByIndex(p)->Apply(0, md3dImmediateContext);
md3dImmediateContext->Draw(mParticles.size(), 0);
}
md3dImmediateContext->OMSetBlendState(0, blendFactor, 0xffffffff);
md3dImmediateContext->OMSetDepthStencilState(NULL, 0);
}
示例2: Set
void Explosion::Set(const Vector3 position, const Color color, const float size)
{
Effect::Set(position);
rootNode_->SetScale(size);
initialMass_ = 3.0f * size;
rigidBody_->SetMass(initialMass_);
light_->SetColor(color);
light_->SetBrightness(initialBrightness_);
ParticleEffect* particleEffect = particleEmitter_->GetEffect();
Vector<ColorFrame> colorFrames;
colorFrames.Push(ColorFrame(Color(0.0f, 0.0f, 0.0f, 0.0f), 0.0f));
Color mixColor = 0.5f * (color + particleEffect->GetColorFrame(1)->color_);
colorFrames.Push(ColorFrame(mixColor, 0.1f));
colorFrames.Push(ColorFrame(mixColor*0.1f, 0.35f));
colorFrames.Push(ColorFrame(Color(0.0f, 0.0f, 0.0f, 0.0f), 0.0f));
particleEffect->SetColorFrames(colorFrames);
sampleSource_->SetGain(Min(0.5f*size, 1.0f));
sampleSource_->Play(sample_);
masterControl_->tileMaster_->AddToAffectors(WeakPtr<Node>(rootNode_), WeakPtr<RigidBody>(rigidBody_));
SubscribeToEvent(E_POSTUPDATE, URHO3D_HANDLER(Explosion, UpdateExplosion));
}
示例3: IF_PRINT_WARNING
ParticleEffect* ParticleManager::_AddEffect(const ParticleEffectDef *def, float x, float y)
{
if (!def) {
IF_PRINT_WARNING(VIDEO_DEBUG)
<< "AddEffect() failed because def was NULL!" << std::endl;
return 0;
}
if (def->_systems.empty()) {
IF_PRINT_WARNING(VIDEO_DEBUG)
<< "AddEffect() failed because def->_systems was empty!" << std::endl;
return 0;
}
ParticleEffect *effect = _CreateEffect(def);
if (!effect) {
IF_PRINT_WARNING(VIDEO_DEBUG)
<< "Could not create particle effect!" << std::endl;
return 0;
}
effect->Move(x, y);
_all_effects.push_back(effect);
_active_effects.push_back(effect);
return effect;
};
示例4: Assert
bool EnergyReceiver::AcceptMessage(const Message &message)
{
if(message.is("DestroyFinished"))
{
if(message.getData() == _uid)
{
if(_state == ER_ACTIVATED_BREAK) {
_state = ER_ACTIVATED_BREAK_FINISHFLY;
} else {
Assert(false);
}
return true;
}else{
//На остальных приемниках запускаем акцентирующий эффект реакции на прилет другого приемника в лут
if(!IsOrdered() && !IsActivatedByEnergy())
{
ParticleEffect *eff = 0;
eff = _effContUp.AddEffect("RecOnLoot");
eff->SetPos(FPoint(0.0f, 0.0f));
eff->Reset();
}
return false;
}
}
else if(message.is("JumpFinished", _uid))
{
ReleaseSquares();
Match3::RunFallColumn(GetIndex().x);
}
else if(message.is("Start"))
{
if(_order)
{
_order->InitAppear(100.f, 100.f);
}
ReleaseEffects();
if(message.getData() == "from_tutorial")
{
_localTime = -GameSettings::gamefield[_index]->_flySquarePauseStore;
}else{
_localTime = -gameInfo.getConstFloat("CRISTAL_DELAY_APPEAR_ON_RECIVER", 0.f);
}
ParticleEffect *eff1 = _effContDown.AddEffect("RDown");
eff1->SetPos(FPoint(0.0f, 0.0f));
_partUp = _effContUpStatic.AddEffect("RUp");
_partUp->SetPos(FPoint(0.0f, 0.0f));
_partUp->Reset();
_firstShowed = false;
_lockLiveEffectShowed = false;
_timeAppear = -0.2f;
_timerForAppearOrder = -1.f;
_state = ER_APPEAR;
_hideByThief = false;
}
return false;
}
示例5: clearParticleBank
void ParticleManager::clearParticleBank()
{
for (ParticleBank::iterator i = particleBank.begin(); i != particleBank.end(); i++)
{
ParticleEffect *e = (*i).second;
if (e)
{
e->destroy();
delete e;
}
}
particleBank.clear();
}
示例6: Finalize
void ParticleSystem::Render(Effect * effect)
{
ParticleEffect *pParticleEffect = static_cast<ParticleEffect*>(effect);
if(!m_finalized)
{
Finalize();
m_finalized = true;
}
pParticleEffect->SetTime(m_time);
DrawParticle(indexObject, vertexObject, pixelObject, *pParticleEffect);
}
示例7: loadParticleCallback
void loadParticleCallback(const std::string &filename, intptr_t param)
{
ParticleEffect *e = new ParticleEffect();
std::string ident;
int first = filename.find_last_of('/')+1;
ident = filename.substr(first, filename.find_last_of('.')-first);
stringToLower(ident);
e->bankLoad(ident, ParticleManager::particleBankPath);
particleBank[ident] = e;
}
示例8: stringToLower
void ParticleManager::loadParticleEffectFromBank(const std::string &name, ParticleEffect *load)
{
std::string realName = name;
stringToLower(realName);
ParticleEffect *fx = particleBank[realName];
if (fx)
fx->transfer(load);
else
{
std::ostringstream os;
os << "Did not find PE [" << name << "] in particle bank";
debugLog(os.str());
}
}
示例9: ParticleEffect
bool ParticleManager::AddParticleEffect(const std::string &effect_filename, float x, float y)
{
ParticleEffect *effect = new ParticleEffect(effect_filename);
if(!effect->IsLoaded()) {
PRINT_WARNING << "Failed to add effect to particle manager" <<
" for file: " << effect_filename << std::endl;
delete effect;
return false;
}
effect->Move(x, y);
_all_effects.push_back(effect);
_active_effects.push_back(effect);
return true;
}
示例10: InitCell
void LockBarrierBase::InitCell()
{
Game::Square *cell = Game::GetValidSquare(_pos.x, _pos.y);
cell->Reset();
cell->SetStone(false);
cell->ice = false;
cell->SetFake(true);
cell->SetWall(1);
cell->GetChip().Reset(true);
cell->barrierIndex = 1;
_effectCont.KillAllEffects();
ParticleEffect* eff = _effectCont.AddEffect("LockLive");
eff->SetPos(FPoint(0.f, LockBarrierBase::YOffset_LOCK));
eff->Reset();
eff->Update(100.f);
_effectCont.Update(0.f);
}
示例11: Effect
Explosion::Explosion(Context *context, MasterControl *masterControl, Vector3 position, Color color, double size):
Effect(context, masterControl, position),
initialMass_{static_cast<float>(3.0f*size)},
initialBrightness_{8.0f}
{
rootNode_->SetName("Explosion");
rootNode_->SetPosition(position);
rootNode_->SetScale(size);
rigidBody_ = rootNode_->CreateComponent<RigidBody>();
rigidBody_->SetMass(initialMass_);
rigidBody_->SetLinearFactor(Vector3::ONE - Vector3::UP);
light_ = rootNode_->CreateComponent<Light>();
light_->SetRange(13.0f);
light_->SetColor(color);
light_->SetBrightness(initialBrightness_);
particleEmitter_ = rootNode_->CreateComponent<ParticleEmitter>();
ParticleEffect* particleEffect = masterControl_->cache_->GetResource<ParticleEffect>("Resources/Particles/Explosion.xml");
Vector<ColorFrame> colorFrames;
colorFrames.Push(ColorFrame(Color(0.0f, 0.0f, 0.0f, 0.0f), 0.0f));
Color mixColor = 0.5f * (color + particleEffect->GetColorFrame(1)->color_);
colorFrames.Push(ColorFrame(mixColor, 0.1f));
colorFrames.Push(ColorFrame(mixColor*0.1f, 0.35f));
colorFrames.Push(ColorFrame(Color(0.0f, 0.0f, 0.0f, 0.0f), 0.0f));
particleEffect->SetColorFrames(colorFrames);
particleEmitter_->SetEffect(particleEffect);
sample_ = masterControl_->cache_->GetResource<Sound>("Resources/Samples/Explode.ogg");
sample_->SetLooped(false);
sampleSource_ = rootNode_->CreateComponent<SoundSource>();
sampleSource_->SetGain(Min(0.5f*size, 1.0f));
sampleSource_->SetSoundType(SOUND_EFFECT);
sampleSource_->Play(sample_);
masterControl_->tileMaster_->AddToAffectors(WeakPtr<Node>(rootNode_), WeakPtr<RigidBody>(rigidBody_));
SubscribeToEvent(E_POSTUPDATE, HANDLER(Explosion, UpdateExplosion));
}
示例12: Update
void LevelEndEffect::Update(float dt)
{
local_time += time_scale * dt;
float t = math::clamp(0.0f, 1.0f, local_time);
//FPoint pos = _path.getGlobalFrame(t);
float x = _pathX.getGlobalFrame(t);
float y = _pathY.getGlobalFrame(t);
_effect->SetPos(x, y);
if( local_time > 1.0f ) {
_effect->Finish();
_effect.reset();
ParticleEffect *fallEff = gameField->_effContUp.AddEffect("EndLevel_Fall");
fallEff->SetPos(320.0f, 900.0f);
fallEff->Reset();
ParticleEffect *expEff = gameField->_effContUp.AddEffect("EndLevel_Explode");
expEff->SetPos(320.0f, 700.0f);
expEff->Reset();
gameField->TriggerBonusesFromMoves();
}
}
示例13: OutputDebugString
bool InClassProj::Init()
{
if(!D3DApp::Init())
return false;
//FMOD sounds
result = FMOD::System_Create(&sys);
result = sys->getVersion(&version);
if (version < FMOD_VERSION)
{
OutputDebugString(L"FMOD lib version doesn't match header version");
}
result = sys->init(32, FMOD_INIT_NORMAL, extradriverdata);
result = sys->createSound("Sounds/choo.ogg", FMOD_DEFAULT, 0, &sound1); //fire arrow sfx (placeholder?)
result = sound1->setMode(FMOD_LOOP_OFF);
mLitTexEffect = new LitTexEffect();
mLitTexEffect->LoadEffect(L"FX/lighting.fx", md3dDevice);
mParticleEffect = new ParticleEffect();
mParticleEffect->LoadEffect(L"FX/ParticleEffect.fx", md3dDevice);
Vertex::InitLitTexLayout(md3dDevice, mLitTexEffect->GetTech());
//camera
m2DCam = new BaseCamera(XMVectorSet(0.0f, 0.0f, -0.5f, 0.0f), XMVectorSet(0.0f, 0.0f, 1.0f, 0.0f), XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f));
m2DCam->Update();
BuildSceneLights();
Vertex::InitParticleVertLayout(md3dDevice, mParticleEffect->GetTech());
BuildParticleVB();
D3DX11CreateShaderResourceViewFromFile(md3dDevice, L"Textures/TestAdditive.png", 0, 0, &mParticleTexture, 0);
BuildBlendStates();
BuildDSStates();
//font
ID3D11ShaderResourceView* font;
D3DX11CreateShaderResourceViewFromFile(md3dDevice, L"Textures/font.png", 0, 0, &font, 0);
mFont = new FontRasterizer(m2DCam, XMLoadFloat4x4(&m2DProj), mLitTexEffect, 10, 10, font, md3dDevice);
//projectile image
ID3D11ShaderResourceView* projImage;
D3DX11CreateShaderResourceViewFromFile(md3dDevice, L"Textures/arrow.png", 0, 0, &projImage, 0);
//projectile frame
projectileFrame->imageWidth = 22;
projectileFrame->imageHeight = 9;
projectileFrame->x = 0;
projectileFrame->y = 0;
projectileFrame->image = projImage;
projFrame.push_back(projectileFrame);
//bg image
Sprite::Frame* BGFrame = new Sprite::Frame();
ID3D11ShaderResourceView* BGimage;
D3DX11CreateShaderResourceViewFromFile(md3dDevice, L"Textures/TFAbgTiled.png", 0, 0, &BGimage, 0);
//bg frame
BGFrame->imageWidth = 1024;
BGFrame->imageHeight = 768;
BGFrame->x = 0;
BGFrame->y = 0;
BGFrame->image = BGimage;
std::vector<Sprite::Frame*> bgFrame;
bgFrame.push_back(BGFrame);
//Player spritesheet image
Sprite::Frame* newFrame = new Sprite::Frame();
ID3D11ShaderResourceView* image;
D3DX11CreateShaderResourceViewFromFile(md3dDevice, L"Textures/player.png", 0, 0, &image, 0);
//player frame1
newFrame->imageWidth = 96;
newFrame->imageHeight = 96;
newFrame->x = 0;
newFrame->y = 0;
newFrame->image = image;
std::vector<Sprite::Frame*> frames;
frames.push_back(newFrame);
//player frame2
newFrame = new Sprite::Frame();
newFrame->imageWidth = 96;
newFrame->imageHeight = 96;
newFrame->x = 32;
newFrame->y = 0;
newFrame->image = image;
frames.push_back(newFrame);
//player frame3
newFrame = new Sprite::Frame();
newFrame->imageWidth = 96;
newFrame->imageHeight = 96;
newFrame->x = 64;
newFrame->y = 0;
newFrame->image = image;
frames.push_back(newFrame);
//Enemy1 spritesheet image
Sprite::Frame* enemyFrame1 = new Sprite::Frame();
ID3D11ShaderResourceView* enemyImage1;
//.........这里部分代码省略.........
示例14: if
void EnergyReceiver::Update(float dt)
{
if( _state == ER_INIT || !GameSettings::gamefield[_index]->IsFlyType(Game::Square::FLY_STAY))
{
return;
}
_localTime += dt;
if(_localTime < 0)
{
return;
}
_fly_offset_y = 6.0f * math::sin(_localTime * 1.2f);
float t = math::clamp(0.f, 1.f, _timeAppear);
float ampl = math::clamp(0.f, 1.f, (1.f - _timeAppear/4.f));
ampl = 60.0f * ampl * ampl; //Очень быстрое затухание
_fly_offset_y += -40.f * (1.0f - t) + ampl * math::sin(_timeAppear*math::PI - math::PI*0.5f);
_fly_offset_y *= GameSettings::SQUARE_SCALE;
if(_hideByThief)
{
if(_hideByThiefTime < 0)
{
_hideByThiefTime += dt;
}
else if(_hideByThiefTime < 1)
{
_hideByThiefTime += dt*1.5f;
if(_hideByThiefTime >= 1)
{
_hideByThiefTime = 1.F;
}
}
}
if(_firstShowed)
{
if(_timeAppear < 0) {
_timeAppear += dt;
} else {
_timeAppear += dt*1.5f;
}
if(_timeAppear >= 1.f && _state == ER_APPEAR)
{
//_timeAppear = 1.f;
_state = ER_STAND;
}
}
if(!_firstShowed && Game::activeRect.Inflated(1).Contains(GetIndex()))
{
_firstShowed = true;
//Акцентирующий эффект при первом появлении на экране
ParticleEffect *eff2 = 0;
if(IsOrdered()) {
eff2 = _effectCellCont.AddEffect("RecStartAccentLock");
} else {
eff2 = _effectCellCont.AddEffect("RecStartAccent");
}
eff2->SetPos(FPoint(0.0f, 0.0f));
eff2->Reset();
MM::manager.PlaySample("ReceiverShow");
_timerForAppearOrder = gameInfo.getConstFloat("ShowOrderOnRecDelay", 3.f);
}
if(!IsOrdered())
{
_timerForAppearOrder = 0.f;
}
else if(_timerForAppearOrder > -1)
{
if(_timerForAppearOrder > 0)
{
_timerForAppearOrder -= dt;
}else{
_timerForAppearOrder -= dt*7.f;
}
if(_timerForAppearOrder <= 0.5f)
{
if(IsOrdered() && !_lockLiveEffectShowed)
{
ParticleEffect* eff = _effectCellCont.AddEffect("LockLive");
eff->SetPos(FPoint(0.f, LockBarrierBase::YOffset_LOCK));
eff->Reset();
_effectCellCont.Update(0.f);
_order->InitAppear(0.8f, 0.7f);
_lockLiveEffectShowed = true;
MM::manager.PlaySample("ReceiverOrderAppear");
}
}
if(_timerForAppearOrder < -1)
{
_timerForAppearOrder = -1;
}
}
if(_order)
{
//.........这里部分代码省略.........
示例15: GetEffectPtr
void CParticleManager::SetMaxParticles(int effect_id, u32 max_particles)
{
ParticleEffect *pe = GetEffectPtr(effect_id);
pe->Resize (max_particles);
}