本文整理汇总了C++中ParticleEmitter::onNewDataBlock方法的典型用法代码示例。如果您正苦于以下问题:C++ ParticleEmitter::onNewDataBlock方法的具体用法?C++ ParticleEmitter::onNewDataBlock怎么用?C++ ParticleEmitter::onNewDataBlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParticleEmitter
的用法示例。
在下文中一共展示了ParticleEmitter::onNewDataBlock方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setEmitterDataBlock
void ParticleEmitterNode::setEmitterDataBlock(ParticleEmitterData* data)
{
if ( isServerObject() )
{
setMaskBits( EmitterDBMask );
}
else
{
ParticleEmitter* pEmitter = NULL;
if ( data )
{
// Create emitter with new datablock
pEmitter = new ParticleEmitter;
pEmitter->onNewDataBlock( data, false );
if( pEmitter->registerObject() == false )
{
Con::warnf(ConsoleLogEntry::General, "Could not register base emitter for particle of class: %s", data->getName() ? data->getName() : data->getIdString() );
delete pEmitter;
return;
}
}
// Replace emitter
if ( mEmitter )
mEmitter->deleteWhenEmpty();
mEmitter = pEmitter;
}
mEmitterDatablock = data;
}
示例2: onAdd
//--------------------------------------------------------------------------
// OnAdd
//--------------------------------------------------------------------------
bool Splash::onAdd()
{
// first check if we have a server connection, if we dont then this is on the server
// and we should exit, then check if the parent fails to add the object
NetConnection* conn = NetConnection::getConnectionToServer();
if(!conn || !Parent::onAdd())
return false;
if( !mDataBlock )
{
Con::errorf("Splash::onAdd - Fail - No datablock");
return false;
}
mDelayMS = mDataBlock->delayMS + sgRandom.randI( -mDataBlock->delayVariance, mDataBlock->delayVariance );
mEndingMS = mDataBlock->lifetimeMS + sgRandom.randI( -mDataBlock->lifetimeVariance, mDataBlock->lifetimeVariance );
mVelocity = mDataBlock->velocity;
mHeight = mDataBlock->height;
mTimeSinceLastRing = 1.0 / mDataBlock->ejectionFreq;
for( U32 i=0; i<SplashData::NUM_EMITTERS; i++ )
{
if( mDataBlock->emitterList[i] != NULL )
{
ParticleEmitter * pEmitter = new ParticleEmitter;
pEmitter->onNewDataBlock( mDataBlock->emitterList[i], false );
if( !pEmitter->registerObject() )
{
Con::warnf( ConsoleLogEntry::General, "Could not register emitter for particle of class: %s", mDataBlock->getName() );
delete pEmitter;
pEmitter = NULL;
}
mEmitterList[i] = pEmitter;
}
}
spawnExplosion();
mObjBox.minExtents = Point3F( -1, -1, -1 );
mObjBox.maxExtents = Point3F( 1, 1, 1 );
resetWorldBox();
gClientSceneGraph->addObjectToScene(this);
removeFromProcessList();
ClientProcessList::get()->addObject(this);
conn->addObject(this);
return true;
}
示例3: updateTrailEmitter
void Etherform::updateTrailEmitter(F32 dt)
{
if(mDamageState == Destroyed)
return;
if(!mDataBlock->jetEmitter[EtherformData::TrailEmitter])
return;
ParticleEmitter* emitter = mJetEmitter[EtherformData::TrailEmitter];
// Particle trail emitter
F32 speed = this->getVelocity().len();
if(speed > mDataBlock->minTrailSpeed)
{
if(!bool(emitter))
{
emitter = new ParticleEmitter;
emitter->onNewDataBlock(mDataBlock->jetEmitter[EtherformData::TrailEmitter], false);
emitter->registerObject();
mJetEmitter[EtherformData::TrailEmitter] = emitter;
}
MatrixF mat = this->getRenderTransform();
Point3F pos,axis;
//mat.getColumn(1,&axis);
axis = this->getVelocity(); axis.normalize();
mat.getColumn(3,&pos);
emitter->emitParticles(pos,true,axis,getVelocity(),(U32)(dt * 1000));
}
else
{
if(bool(emitter))
{
emitter->deleteWhenEmpty();
mJetEmitter[EtherformData::TrailEmitter] = 0;
}
}
}
示例4: onAdd
bool Projectile::onAdd()
{
if(!Parent::onAdd())
return false;
if( !mDataBlock )
{
Con::errorf("Projectile::onAdd - Fail - Not datablock");
return false;
}
if (isServerObject())
{
ShapeBase* ptr;
if (Sim::findObject(mSourceObjectId, ptr))
{
mSourceObject = ptr;
// Since we later do processAfter( mSourceObject ) we must clearProcessAfter
// if it is deleted. SceneObject already handles this in onDeleteNotify so
// all we need to do is register for the notification.
deleteNotify( ptr );
}
else
{
if (mSourceObjectId != -1)
Con::errorf(ConsoleLogEntry::General, "Projectile::onAdd: mSourceObjectId is invalid");
mSourceObject = NULL;
}
// If we're on the server, we need to inherit some of our parent's velocity
//
mCurrTick = 0;
}
else
{
if (bool(mDataBlock->projectileShape))
{
mProjectileShape = new TSShapeInstance(mDataBlock->projectileShape, isClientObject());
if (mDataBlock->activateSeq != -1)
{
mActivateThread = mProjectileShape->addThread();
mProjectileShape->setTimeScale(mActivateThread, 1);
mProjectileShape->setSequence(mActivateThread, mDataBlock->activateSeq, 0);
}
}
if (mDataBlock->particleEmitter != NULL)
{
ParticleEmitter* pEmitter = new ParticleEmitter;
pEmitter->onNewDataBlock(mDataBlock->particleEmitter,false);
if (pEmitter->registerObject() == false)
{
Con::warnf(ConsoleLogEntry::General, "Could not register particle emitter for particle of class: %s", mDataBlock->getName());
delete pEmitter;
pEmitter = NULL;
}
mParticleEmitter = pEmitter;
}
if (mDataBlock->particleWaterEmitter != NULL)
{
ParticleEmitter* pEmitter = new ParticleEmitter;
pEmitter->onNewDataBlock(mDataBlock->particleWaterEmitter,false);
if (pEmitter->registerObject() == false)
{
Con::warnf(ConsoleLogEntry::General, "Could not register particle emitter for particle of class: %s", mDataBlock->getName());
delete pEmitter;
pEmitter = NULL;
}
mParticleWaterEmitter = pEmitter;
}
}
if (mSourceObject.isValid())
processAfter(mSourceObject);
// Setup our bounding box
if (bool(mDataBlock->projectileShape) == true)
mObjBox = mDataBlock->projectileShape->bounds;
else
mObjBox = Box3F(Point3F(0, 0, 0), Point3F(0, 0, 0));
MatrixF initialTransform( true );
initialTransform.setPosition( mCurrPosition );
setTransform( initialTransform ); // calls resetWorldBox
addToScene();
if ( PHYSICSMGR )
mPhysicsWorld = PHYSICSMGR->getWorld( isServerObject() ? "server" : "client" );
return true;
}
示例5: onAdd
bool Projectile::onAdd()
{
if(!Parent::onAdd())
return false;
if (isServerObject())
{
ShapeBase* ptr;
if (Sim::findObject(mSourceObjectId, ptr))
mSourceObject = ptr;
else
{
if (mSourceObjectId != -1)
Con::errorf(ConsoleLogEntry::General, "Projectile::onAdd: mSourceObjectId is invalid");
mSourceObject = NULL;
}
// If we're on the server, we need to inherit some of our parent's velocity
//
mCurrTick = 0;
}
else
{
if (bool(mDataBlock->projectileShape))
{
mProjectileShape = new TSShapeInstance(mDataBlock->projectileShape, isClientObject());
if (mDataBlock->activateSeq != -1)
{
mActivateThread = mProjectileShape->addThread();
mProjectileShape->setTimeScale(mActivateThread, 1);
mProjectileShape->setSequence(mActivateThread, mDataBlock->activateSeq, 0);
}
}
if (mDataBlock->particleEmitter != NULL)
{
ParticleEmitter* pEmitter = new ParticleEmitter;
pEmitter->onNewDataBlock(mDataBlock->particleEmitter);
if (pEmitter->registerObject() == false)
{
Con::warnf(ConsoleLogEntry::General, "Could not register particle emitter for particle of class: %s", mDataBlock->getName());
delete pEmitter;
pEmitter = NULL;
}
mParticleEmitter = pEmitter;
}
if (mDataBlock->particleWaterEmitter != NULL)
{
ParticleEmitter* pEmitter = new ParticleEmitter;
pEmitter->onNewDataBlock(mDataBlock->particleWaterEmitter);
if (pEmitter->registerObject() == false)
{
Con::warnf(ConsoleLogEntry::General, "Could not register particle emitter for particle of class: %s", mDataBlock->getName());
delete pEmitter;
pEmitter = NULL;
}
mParticleWaterEmitter = pEmitter;
}
}
if (mSourceObject.isValid())
processAfter(mSourceObject);
// Setup our bounding box
if (bool(mDataBlock->projectileShape) == true)
mObjBox = mDataBlock->projectileShape->bounds;
else
mObjBox = Box3F(Point3F(0, 0, 0), Point3F(0, 0, 0));
resetWorldBox();
addToScene();
if ( gPhysicsPlugin )
mPhysicsWorld = gPhysicsPlugin->getWorld( isServerObject() ? "Server" : "Client" );
return true;
}