123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649 |
- /****************************************************************************
- Copyright (C) 2013 Henry van Merode. All rights reserved.
- Copyright (c) 2015-2016 Chukong Technologies Inc.
- Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
-
- http://www.cocos2d-x.org
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
- ****************************************************************************/
- #include "CCPUEmitterTranslator.h"
- #include "extensions/Particle3D/PU/CCPUParticleSystem3D.h"
- #include "extensions/Particle3D/PU/CCPUDynamicAttribute.h"
- #include "extensions/Particle3D/PU/CCPUDynamicAttributeTranslator.h"
- #include "extensions/Particle3D/PU/CCPUEmitterManager.h"
- NS_CC_BEGIN
- PUEmitterTranslator::PUEmitterTranslator()
- :_emitter(nullptr)
- {
- }
- //-------------------------------------------------------------------------
- void PUEmitterTranslator::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 emitter
- // 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;
- }
-
- //// Get the factory
- //ParticleEmitterFactory* particleEmitterFactory = ParticleSystemManager::getSingletonPtr()->getEmitterFactory(type);
- //if (!particleEmitterFactory)
- //{
- // compiler->addError(ScriptCompiler::CE_INVALIDPARAMETERS, obj->file, obj->line);
- // return;
- //}
- PUScriptTranslator *particleEmitterTranlator = PUEmitterManager::Instance()->getTranslator(type);
- if (!particleEmitterTranlator) return;
- //// Create the emitter
- //mEmitter = ParticleSystemManager::getSingletonPtr()->createEmitter(type);
- //if (!mEmitter)
- //{
- // compiler->addError(ScriptCompiler::CE_INVALIDPARAMETERS, obj->file, obj->line);
- // return;
- //}
- _emitter = PUEmitterManager::Instance()->createEmitter(type);
- if (!_emitter) return;
- _emitter->setEmitterType(type);
- if (parent && parent->context)
- {
- PUParticleSystem3D* system = static_cast<PUParticleSystem3D*>(parent->context);
- system->addEmitter(_emitter);
- }
- // The first value is the (optional) name
- std::string name;
- if(!obj->values.empty())
- {
- getString(*obj->values.front(), &name);
- _emitter->setName(name);
- }
- // Set it in the context
- obj->context = _emitter;
- // 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))
- {
- _emitter->setEnabled(val);
- }
- }
- }
- else if (prop->name == token[TOKEN_POSITION])
- {
- // Property: position
- if (passValidateProperty(compiler, prop, token[TOKEN_POSITION], VAL_VECTOR3))
- {
- Vec3 val;
- if(getVector3(prop->values.begin(), prop->values.end(), &val))
- {
- //mEmitter->position = val;
- //mEmitter->originalPosition = val;
- _emitter->setLocalPosition(val);
- }
- }
- }
- else if (prop->name == token[TOKEN_EMITTER_DIRECTION])
- {
- // Property: direction
- if (passValidateProperty(compiler, prop, token[TOKEN_EMITTER_DIRECTION], VAL_VECTOR3))
- {
- Vec3 val;
- if(getVector3(prop->values.begin(), prop->values.end(), &val))
- {
- _emitter->setParticleDirection(val);
- }
- }
- }
- else if (prop->name == token[TOKEN_EMITTER_ORIENTATION])
- {
- // Property: orientation
- if (passValidateProperty(compiler, prop, token[TOKEN_EMITTER_ORIENTATION], VAL_QUATERNION))
- {
- Quaternion val;
- if(getQuaternion(prop->values.begin(), prop->values.end(), &val))
- {
- _emitter->setParticleOrientation(val);
- }
- }
- }
- else if (prop->name == token[TOKEN_EMITTER_START_ORIENTATION_RANGE])
- {
- // Property: start_orientation_range
- if (passValidateProperty(compiler, prop, token[TOKEN_EMITTER_START_ORIENTATION_RANGE], VAL_QUATERNION))
- {
- Quaternion val;
- if(getQuaternion(prop->values.begin(), prop->values.end(), &val))
- {
- _emitter->setParticleOrientationRangeStart(val);
- }
- }
- }
- else if (prop->name == token[TOKEN_EMITTER_ORIENTATION_RANGE_START])
- {
- // Property: range_start_orientation (deprecated and replaced by start_orientation_range)
- if (passValidateProperty(compiler, prop, token[TOKEN_EMITTER_ORIENTATION_RANGE_START], VAL_QUATERNION))
- {
- Quaternion val;
- if(getQuaternion(prop->values.begin(), prop->values.end(), &val))
- {
- _emitter->setParticleOrientationRangeStart(val);
- }
- }
- }
- else if (prop->name == token[TOKEN_EMITTER_END_ORIENTATION_RANGE])
- {
- // Property: end_orientation_range
- if (passValidateProperty(compiler, prop, token[TOKEN_EMITTER_END_ORIENTATION_RANGE], VAL_QUATERNION))
- {
- Quaternion val;
- if(getQuaternion(prop->values.begin(), prop->values.end(), &val))
- {
- _emitter->setParticleOrientationRangeEnd(val);
- }
- }
- }
- else if (prop->name == token[TOKEN_EMITTER_ORIENTATION_RANGE_END])
- {
- // Property: range_end_orientation (deprecated and replaced by end_orientation_range)
- if (passValidateProperty(compiler, prop, token[TOKEN_EMITTER_ORIENTATION_RANGE_END], VAL_QUATERNION))
- {
- Quaternion val;
- if(getQuaternion(prop->values.begin(), prop->values.end(), &val))
- {
- _emitter->setParticleOrientationRangeEnd(val);
- }
- }
- }
- else if (prop->name == token[TOKEN_EMITTER_EMISSION_RATE])
- {
- // Property: emission_rate
- // If it is a property, it is a fixed value
- if (passValidateProperty(compiler, prop, token[TOKEN_EMITTER_EMISSION_RATE], VAL_REAL))
- {
- float val = 0.0f;
- if(getFloat(*prop->values.front(), &val))
- {
- PUDynamicAttributeFixed* dynamicAttributeFixed = new (std::nothrow) PUDynamicAttributeFixed();
- dynamicAttributeFixed->setValue(val);
- _emitter->setDynEmissionRate(dynamicAttributeFixed);
- }
- }
- }
- else if (prop->name == token[TOKEN_TIME_TO_LIVE])
- {
- // Property: time_to_live
- // If it is a property, it is a fixed value
- if (passValidateProperty(compiler, prop, token[TOKEN_TIME_TO_LIVE], VAL_REAL))
- {
- float val = 0.0f;
- if(getFloat(*prop->values.front(), &val))
- {
- PUDynamicAttributeFixed* dynamicAttributeFixed = new (std::nothrow) PUDynamicAttributeFixed();
- dynamicAttributeFixed->setValue(val);
- _emitter->setDynTotalTimeToLive(dynamicAttributeFixed);
- }
- }
- }
- else if (prop->name == token[TOKEN_EMITTER_MASS])
- {
- // Property: mass
- // If it is a property, it is a fixed value
- if (passValidateProperty(compiler, prop, token[TOKEN_EMITTER_MASS], VAL_REAL))
- {
- float val = 0.0f;
- if(getFloat(*prop->values.front(), &val))
- {
- PUDynamicAttributeFixed* dynamicAttributeFixed = new (std::nothrow) PUDynamicAttributeFixed();
- dynamicAttributeFixed->setValue(val);
- _emitter->setDynParticleMass(dynamicAttributeFixed);
- }
- }
- }
- else if (prop->name == token[TOKEN_EMITTER_START_TEXCOORDS_RANGE])
- {
- // Property: start_texture_coords_range
- if (passValidateProperty(compiler, prop, token[TOKEN_EMITTER_START_TEXCOORDS_RANGE], VAL_UINT))
- {
- unsigned int val = 0;
- if(getUInt(*prop->values.front(), &val))
- {
- _emitter->setParticleTextureCoordsRangeStart(val);
- }
- }
- }
- else if (prop->name == token[TOKEN_EMITTER_START_TEXCOORDS])
- {
- // Property: start_texture_coords (deprecated and replaced by start_texture_coords_range)
- if (passValidateProperty(compiler, prop, token[TOKEN_EMITTER_START_TEXCOORDS], VAL_UINT))
- {
- unsigned int val = 0;
- if(getUInt(*prop->values.front(), &val))
- {
- _emitter->setParticleTextureCoordsRangeStart(val);
- }
- }
- }
- else if (prop->name == token[TOKEN_EMITTER_END_TEXCOORDS_RANGE])
- {
- // Property: end_texture_coords_range
- if (passValidateProperty(compiler, prop, token[TOKEN_EMITTER_END_TEXCOORDS_RANGE], VAL_UINT))
- {
- unsigned int val = 0;
- if(getUInt(*prop->values.front(), &val))
- {
- _emitter->setParticleTextureCoordsRangeEnd(val);
- }
- }
- }
- else if (prop->name == token[TOKEN_EMITTER_END_TEXCOORDS])
- {
- // Property: end_texture_coords (deprecated and replaced by end_texture_coords_range)
- if (passValidateProperty(compiler, prop, token[TOKEN_EMITTER_END_TEXCOORDS], VAL_UINT))
- {
- unsigned int val = 0;
- if(getUInt(*prop->values.front(), &val))
- {
- _emitter->setParticleTextureCoordsRangeEnd(val);
- }
- }
- }
- else if (prop->name == token[TOKEN_EMITTER_TEXCOORDS])
- {
- // Property: texture_coords
- if (passValidateProperty(compiler, prop, token[TOKEN_EMITTER_TEXCOORDS], VAL_UINT))
- {
- unsigned int val = 0;
- if(getUInt(*prop->values.front(), &val))
- {
- _emitter->setParticleTextureCoords(val);
- }
- }
- }
- else if (prop->name == token[TOKEN_EMITTER_START_COLOUR_RANGE])
- {
- // Property: start_colour_range
- if (passValidateProperty(compiler, prop, token[TOKEN_EMITTER_START_COLOUR_RANGE], VAL_COLOURVALUE))
- {
- Vec4 val;
- if(getVector4(prop->values.begin(), prop->values.end(), &val))
- {
- _emitter->setParticleColorRangeStart(val);
- }
- }
- }
- else if (prop->name == token[TOKEN_EMITTER_END_COLOUR_RANGE])
- {
- // Property: end_colour_range
- if (passValidateProperty(compiler, prop, token[TOKEN_EMITTER_END_COLOUR_RANGE], VAL_COLOURVALUE))
- {
- Vec4 val;
- if(getVector4(prop->values.begin(), prop->values.end(), &val))
- {
- _emitter->setParticleColorRangeEnd(val);
- }
- }
- }
- else if (prop->name == token[TOKEN_EMITTER_COLOUR])
- {
- // Property: colour
- if (passValidateProperty(compiler, prop, token[TOKEN_EMITTER_COLOUR], VAL_COLOURVALUE))
- {
- Vec4 val;
- if(getVector4(prop->values.begin(), prop->values.end(), &val))
- {
- _emitter->setParticleColor(val);
- }
- }
- }
- else if (prop->name == token[TOKEN_VELOCITY])
- {
- // Property: velocity
- // If it is a property, it is a fixed value
- if (passValidateProperty(compiler, prop, token[TOKEN_VELOCITY], VAL_REAL))
- {
- float val = 0.0f;
- if(getFloat(*prop->values.front(), &val))
- {
- PUDynamicAttributeFixed* dynamicAttributeFixed = new (std::nothrow) PUDynamicAttributeFixed();
- dynamicAttributeFixed->setValue(val);
- _emitter->setDynVelocity(dynamicAttributeFixed);
- }
- }
- }
- else if (prop->name == token[TOKEN_EMITTER_DURATION])
- {
- // Property: duration
- // If it is a property, it is a fixed value
- if (passValidateProperty(compiler, prop, token[TOKEN_EMITTER_DURATION], VAL_REAL))
- {
- float val = 0.0f;
- if(getFloat(*prop->values.front(), &val))
- {
- PUDynamicAttributeFixed* dynamicAttributeFixed = new (std::nothrow) PUDynamicAttributeFixed();
- dynamicAttributeFixed->setValue(val);
- _emitter->setDynDuration(dynamicAttributeFixed);
- }
- }
- }
- else if (prop->name == token[TOKEN_EMITTER_REPEAT_DELAY])
- {
- // Property: repeat_delay
- // If it is a property, it is a fixed value
- if (passValidateProperty(compiler, prop, token[TOKEN_EMITTER_REPEAT_DELAY], VAL_REAL))
- {
- float val = 0.0f;
- if(getFloat(*prop->values.front(), &val))
- {
- PUDynamicAttributeFixed* dynamicAttributeFixed = new (std::nothrow) PUDynamicAttributeFixed();
- dynamicAttributeFixed->setValue(val);
- _emitter->setDynRepeatDelay(dynamicAttributeFixed);
- }
- }
- }
- else if (prop->name == token[TOKEN_EMITTER_EMITS])
- {
- // Property: emits
- if (passValidatePropertyNumberOfValues(compiler, prop, token[TOKEN_EMITTER_EMITS], 2))
- {
- std::string particleType;
- PUAbstractNodeList::const_iterator it = prop->values.begin();
- if (getString(**it, &particleType))
- {
- if (particleType == token[TOKEN_VISUAL_PARTICLE])
- {
- _emitter->setEmitsType(PUParticle3D::PT_VISUAL);
- }
- else if (particleType == token[TOKEN_EMITTER_PARTICLE])
- {
- _emitter->setEmitsType(PUParticle3D::PT_EMITTER);
- }
- else if (particleType == token[TOKEN_AFFECTOR_PARTICLE])
- {
- _emitter->setEmitsType(PUParticle3D::PT_AFFECTOR);
- }
- else if (particleType == token[TOKEN_TECHNIQUE_PARTICLE])
- {
- _emitter->setEmitsType(PUParticle3D::PT_TECHNIQUE);
- }
- else if (particleType == token[TOKEN_SYSTEM_PARTICLE])
- {
- _emitter->setEmitsType(PUParticle3D::PT_SYSTEM);
- }
- ++it;
- if (getString(**it, &name))
- {
- _emitter->setEmitsName(name);
- }
- }
- }
- }
- else if (prop->name == token[TOKEN_ANGLE])
- {
- // Property: angle
- // If it is a property, it is a fixed value
- if (passValidateProperty(compiler, prop, token[TOKEN_ANGLE], VAL_REAL))
- {
- float val = 0.0f;
- if(getFloat(*prop->values.front(), &val))
- {
- PUDynamicAttributeFixed* dynamicAttributeFixed = new (std::nothrow) PUDynamicAttributeFixed();
- dynamicAttributeFixed->setValue(val);
- _emitter->setDynAngle(dynamicAttributeFixed);
- }
- }
- }
- else if (prop->name == token[TOKEN_EMITTER_ALL_PARTICLE_DIM])
- {
- // Property: all_particle_dimensions
- // If it is a property, it is a fixed value
- if (passValidateProperty(compiler, prop, token[TOKEN_EMITTER_ALL_PARTICLE_DIM], VAL_REAL))
- {
- float val = 0.0f;
- if(getFloat(*prop->values.front(), &val))
- {
- PUDynamicAttributeFixed* dynamicAttributeFixed = new (std::nothrow) PUDynamicAttributeFixed();
- dynamicAttributeFixed->setValue(val);
- _emitter->setDynParticleAllDimensions(dynamicAttributeFixed);
- }
- }
- }
- else if (prop->name == token[TOKEN_EMITTER_PARTICLE_WIDTH])
- {
- // Property: particle_width
- // If it is a property, it is a fixed value
- if (passValidateProperty(compiler, prop, token[TOKEN_EMITTER_PARTICLE_WIDTH], VAL_REAL))
- {
- float val = 0.0f;
- if(getFloat(*prop->values.front(), &val))
- {
- PUDynamicAttributeFixed* dynamicAttributeFixed = new (std::nothrow) PUDynamicAttributeFixed();
- dynamicAttributeFixed->setValue(val);
- _emitter->setDynParticleWidth(dynamicAttributeFixed);
- }
- }
- }
- else if (prop->name == token[TOKEN_EMITTER_PARTICLE_HEIGHT])
- {
- // Property: particle_height
- // If it is a property, it is a fixed value
- if (passValidateProperty(compiler, prop, token[TOKEN_EMITTER_PARTICLE_HEIGHT], VAL_REAL))
- {
- float val = 0.0f;
- if(getFloat(*prop->values.front(), &val))
- {
- PUDynamicAttributeFixed* dynamicAttributeFixed = new (std::nothrow) PUDynamicAttributeFixed();
- dynamicAttributeFixed->setValue(val);
- _emitter->setDynParticleHeight(dynamicAttributeFixed);
- }
- }
- }
- else if (prop->name == token[TOKEN_EMITTER_PARTICLE_DEPTH])
- {
- // Property: particle_depth
- // If it is a property, it is a fixed value
- if (passValidateProperty(compiler, prop, token[TOKEN_EMITTER_PARTICLE_DEPTH], VAL_REAL))
- {
- float val = 0.0f;
- if(getFloat(*prop->values.front(), &val))
- {
- PUDynamicAttributeFixed* dynamicAttributeFixed = new (std::nothrow) PUDynamicAttributeFixed();
- dynamicAttributeFixed->setValue(val);
- _emitter->setDynParticleDepth(dynamicAttributeFixed);
- }
- }
- }
- else if (prop->name == token[TOKEN_EMITTER_AUTO_DIRECTION])
- {
- // Property: auto_direction
- if (passValidateProperty(compiler, prop, token[TOKEN_EMITTER_AUTO_DIRECTION], VAL_BOOL))
- {
- bool val;
- if(getBoolean(*prop->values.front(), &val))
- {
- _emitter->setAutoDirection(val);
- }
- }
- }
- else if (prop->name == token[TOKEN_KEEP_LOCAL])
- {
- // Property: keep_local
- if (passValidateProperty(compiler, prop, token[TOKEN_KEEP_LOCAL], VAL_BOOL))
- {
- bool val;
- if(getBoolean(*prop->values.front(), &val))
- {
- _emitter->setKeepLocal(val);
- }
- }
- }
- else if (prop->name == token[TOKEN_EMITTER_FORCE_EMISSION])
- {
- // Property: force_emission
- if (passValidateProperty(compiler, prop, token[TOKEN_EMITTER_FORCE_EMISSION], VAL_BOOL))
- {
- bool val;
- if(getBoolean(*prop->values.front(), &val))
- {
- _emitter->setForceEmission(val);
- }
- }
- }
- else if (particleEmitterTranlator->translateChildProperty(compiler, *i))
- {
- // Parsed the property by another translator; do nothing
- }
- else
- {
- errorUnexpectedProperty(compiler, prop);
- }
- }
- else if((*i)->type == ANT_OBJECT)
- {
- PUObjectAbstractNode* child = reinterpret_cast<PUObjectAbstractNode*>((*i));
- PUDynamicAttributeTranslator dynamicAttributeTranslator;
- if (child->cls == token[TOKEN_EMITTER_EMISSION_RATE])
- {
- // Property: emission_rate
- dynamicAttributeTranslator.translate(compiler, *i);
- PUDynamicAttribute* dynamicAttribute = static_cast<PUDynamicAttribute*>(child->context);
- _emitter->setDynEmissionRate(dynamicAttribute);
- }
- else if (child->cls == token[TOKEN_TIME_TO_LIVE])
- {
- // Property: time_to_live
- dynamicAttributeTranslator.translate(compiler, *i);
- PUDynamicAttribute* dynamicAttribute = static_cast<PUDynamicAttribute*>(child->context);
- _emitter->setDynTotalTimeToLive(dynamicAttribute);
- }
- else if (child->cls == token[TOKEN_EMITTER_MASS])
- {
- // Property: mass
- dynamicAttributeTranslator.translate(compiler, *i);
- PUDynamicAttribute* dynamicAttribute = static_cast<PUDynamicAttribute*>(child->context);
- _emitter->setDynParticleMass(dynamicAttribute);
- }
- else if (child->cls == token[TOKEN_VELOCITY])
- {
- // Property: velocity
- dynamicAttributeTranslator.translate(compiler, *i);
- PUDynamicAttribute* dynamicAttribute = static_cast<PUDynamicAttribute*>(child->context);
- _emitter->setDynVelocity(dynamicAttribute);
- }
- else if (child->cls == token[TOKEN_EMITTER_DURATION])
- {
- // Property: duration
- dynamicAttributeTranslator.translate(compiler, *i);
- PUDynamicAttribute* dynamicAttribute = static_cast<PUDynamicAttribute*>(child->context);
- _emitter->setDynDuration(dynamicAttribute);
- }
- else if (child->cls == token[TOKEN_EMITTER_REPEAT_DELAY])
- {
- // Property: repeat_delay
- dynamicAttributeTranslator.translate(compiler, *i);
- PUDynamicAttribute* dynamicAttribute = static_cast<PUDynamicAttribute*>(child->context);
- _emitter->setDynRepeatDelay(dynamicAttribute);
- }
- else if (child->cls == token[TOKEN_ANGLE])
- {
- // Property: angle
- dynamicAttributeTranslator.translate(compiler, *i);
- PUDynamicAttribute* dynamicAttribute = static_cast<PUDynamicAttribute*>(child->context);
- _emitter->setDynAngle(dynamicAttribute);
- }
- else if (child->cls == token[TOKEN_EMITTER_ALL_PARTICLE_DIM])
- {
- // Property: all_particle_dimensions
- dynamicAttributeTranslator.translate(compiler, *i);
- PUDynamicAttribute* dynamicAttribute = static_cast<PUDynamicAttribute*>(child->context);
- _emitter->setDynParticleAllDimensions(dynamicAttribute);
- }
- else if (child->cls == token[TOKEN_EMITTER_PARTICLE_WIDTH])
- {
- // Property: particle_width
- dynamicAttributeTranslator.translate(compiler, *i);
- PUDynamicAttribute* dynamicAttribute = static_cast<PUDynamicAttribute*>(child->context);
- _emitter->setDynParticleWidth(dynamicAttribute);
- }
- else if (child->cls == token[TOKEN_EMITTER_PARTICLE_HEIGHT])
- {
- // Property: particle_height
- dynamicAttributeTranslator.translate(compiler, *i);
- PUDynamicAttribute* dynamicAttribute = static_cast<PUDynamicAttribute*>(child->context);
- _emitter->setDynParticleHeight(dynamicAttribute);
- }
- else if (child->cls == token[TOKEN_EMITTER_PARTICLE_DEPTH])
- {
- // Property: particle_depth
- dynamicAttributeTranslator.translate(compiler, *i);
- PUDynamicAttribute* dynamicAttribute = static_cast<PUDynamicAttribute*>(child->context);
- _emitter->setDynParticleDepth(dynamicAttribute);
- }
- else if (child->cls == token[TOKEN_CAMERA_DEPENDENCY])
- {
- //// Property: it can only be a camera_dependency for emission rate
- //CameraDependency* cameraDependency = PU_NEW_T(CameraDependency, MEMCATEGORY_SCRIPTING)();
- //child->context = Any(cameraDependency);
- //CameraDependencyTranslator cameraDependencyTranslator;
- //cameraDependencyTranslator.translate(compiler, *i);
- //Real threshold = cameraDependency->getThreshold();
- //mEmitter->setEmissionRateCameraDependency(threshold * threshold, cameraDependency->isIncrease());
- //// Delete the camera dependency
- //PU_DELETE_T(cameraDependency, CameraDependency, MEMCATEGORY_SCRIPTING);
- }
- else if (particleEmitterTranlator->translateChildObject(compiler, *i))
- {
- // Parsed the object by another translator; do nothing
- }
- else
- {
- processNode(compiler, *i);
- }
- }
- else
- {
- errorUnexpectedToken(compiler, *i);
- }
- }
- }
- NS_CC_END
|