本文整理汇总了C++中PUParticleSystem3D::addObserver方法的典型用法代码示例。如果您正苦于以下问题:C++ PUParticleSystem3D::addObserver方法的具体用法?C++ PUParticleSystem3D::addObserver怎么用?C++ PUParticleSystem3D::addObserver使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PUParticleSystem3D
的用法示例。
在下文中一共展示了PUParticleSystem3D::addObserver方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: translate
//-------------------------------------------------------------------------
void PUObserverTranslator::translate(PUScriptCompiler* compiler, PUAbstractNode *node)
{
PUObjectAbstractNode* obj = reinterpret_cast<PUObjectAbstractNode*>(node);
PUObjectAbstractNode* parent = obj->parent ? reinterpret_cast<PUObjectAbstractNode*>(obj->parent) : 0;
// The name of the obj is the type of the Observer
// Remark: This can be solved by using a listener, so that obj->values is filled with type + name. Something for later
std::string type;
if(!obj->name.empty())
{
type = obj->name;
}
else
{
//compiler->addError(ScriptCompiler::CE_INVALIDPARAMETERS, obj->file, obj->line);
return;
}
// Get the factory
//ParticleObserverFactory* particleObserverFactory = ParticleSystemManager::getSingletonPtr()->getObserverFactory(type);
//if (!particleObserverFactory)
//{
// //compiler->addError(ScriptCompiler::CE_INVALIDPARAMETERS, obj->file, obj->line);
// return;
//}
PUScriptTranslator *particleObserverTranlator = PUObserverManager::Instance()->getTranslator(type);
if (!particleObserverTranlator) return;
// Create the Observer
_observer = PUObserverManager::Instance()->createObserver(type);
if (!_observer)
{
//compiler->addError(ScriptCompiler::CE_INVALIDPARAMETERS, obj->file, obj->line);
return;
}
_observer->setObserverType(type);
if (parent && parent->context)
{
PUParticleSystem3D* system = static_cast<PUParticleSystem3D *>(parent->context);
system->addObserver(_observer);
}
else
{
//// It is an alias
//mObserver->setAliasName(parent->name);
//ParticleSystemManager::getSingletonPtr()->addAlias(mObserver);
}
// The first value is the (optional) name
std::string name;
if(!obj->values.empty())
{
getString(*obj->values.front(), &name);
_observer->setName(name);
}
// Set it in the context
obj->context = _observer;
// Run through properties
for(PUAbstractNodeList::iterator i = obj->children.begin(); i != obj->children.end(); ++i)
{
if((*i)->type == ANT_PROPERTY)
{
PUPropertyAbstractNode* prop = reinterpret_cast<PUPropertyAbstractNode*>((*i));
if (prop->name == token[TOKEN_ENABLED])
{
// Property: enabled
if (passValidateProperty(compiler, prop, token[TOKEN_ENABLED], VAL_BOOL))
{
bool val;
if(getBoolean(*prop->values.front(), &val))
{
_observer->setEnabled(val);
}
}
}
else if (prop->name == token[TOKEN_OBSERVE_PARTICLE_TYPE])
{
// Property: observe_particle_type
if (passValidateProperty(compiler, prop, token[TOKEN_OBSERVE_PARTICLE_TYPE], VAL_STRING))
{
std::string val;
if(getString(*prop->values.front(), &val))
{
if (val == token[TOKEN_VISUAL_PARTICLE])
{
_observer->setParticleTypeToObserve(PUParticle3D::PT_VISUAL);
}
else if (val == token[TOKEN_EMITTER_PARTICLE])
{
_observer->setParticleTypeToObserve(PUParticle3D::PT_EMITTER);
}
else if (val == token[TOKEN_AFFECTOR_PARTICLE])
{
_observer->setParticleTypeToObserve(PUParticle3D::PT_AFFECTOR);
}
//.........这里部分代码省略.........