bool PUVortexAffectorTranslator::translateChildObject( PUScriptCompiler* compiler, PUAbstractNode *node ) { PUObjectAbstractNode* child = reinterpret_cast<PUObjectAbstractNode*>(node); PUAffector* af = static_cast<PUAffector*>(child->parent->context); PUVortexAffector* affector = static_cast<PUVortexAffector*>(af); PUDynamicAttributeTranslator dynamicAttributeTranslator; if (child->cls == token[TOKEN_ROTATION_SPEED]) { // Property: rotation_speed dynamicAttributeTranslator.translate(compiler, node); PUDynamicAttribute* dynamicAttribute = static_cast<PUDynamicAttribute*>(child->context); affector->setRotationSpeed(dynamicAttribute); return true; } else if (child->cls == token[TOKEN_VORTEX_ROTATION_SPEED]) { // Property: vortex_aff_speed (deprecated and replaced by 'rotation_speed') dynamicAttributeTranslator.translate(compiler, node); PUDynamicAttribute* dynamicAttribute = static_cast<PUDynamicAttribute*>(child->context); affector->setRotationSpeed(dynamicAttribute); return true; } return false; }
void PUVortexAffector::copyAttributesTo( PUAffector* affector ) { PUAffector::copyAttributesTo(affector); PUVortexAffector* vortexAffector = static_cast<PUVortexAffector*>(affector); vortexAffector->_rotation = _rotation; vortexAffector->_rotationVector = _rotationVector; vortexAffector->setRotationSpeed(getRotationSpeed()->clone()); }
//------------------------------------------------------------------------- bool PUVortexAffectorTranslator::translateChildProperty( PUScriptCompiler* compiler, PUAbstractNode *node ) { PUPropertyAbstractNode* prop = reinterpret_cast<PUPropertyAbstractNode*>(node); PUAffector* af = static_cast<PUAffector*>(prop->parent->context); PUVortexAffector* affector = static_cast<PUVortexAffector*>(af); if (prop->name == token[TOKEN_ROTATION_AXIS]) { // Property: rotation_axis if (passValidateProperty(compiler, prop, token[TOKEN_ROTATION_AXIS], VAL_VECTOR3)) { Vec3 val; if(getVector3(prop->values.begin(), prop->values.end(), &val)) { affector->setRotationVector(val); return true; } } } else if (prop->name == token[TOKEN_VORTEX_ROTATION_VECTOR]) { // Property: vortex_aff_vector (deprecated and replaced by 'rotation_axis') if (passValidateProperty(compiler, prop, token[TOKEN_VORTEX_ROTATION_VECTOR], VAL_VECTOR3)) { Vec3 val; if(getVector3(prop->values.begin(), prop->values.end(), &val)) { affector->setRotationVector(val); return true; } } } else if (prop->name == token[TOKEN_ROTATION_SPEED]) { // Property: rotation_speed if (passValidateProperty(compiler, prop, token[TOKEN_ROTATION_SPEED], VAL_REAL)) { float val = 0.0f; if(getFloat(*prop->values.front(), &val)) { PUDynamicAttributeFixed* dynamicAttributeFixed = new (std::nothrow) PUDynamicAttributeFixed(); dynamicAttributeFixed->setValue(val); affector->setRotationSpeed(dynamicAttributeFixed); return true; } } } else if (prop->name == token[TOKEN_VORTEX_ROTATION_SPEED]) { // Property: vortex_aff_speed (deprecated and replaced by 'rotation_speed') if (passValidateProperty(compiler, prop, token[TOKEN_VORTEX_ROTATION_SPEED], VAL_REAL)) { float val = 0.0f; if(getFloat(*prop->values.front(), &val)) { PUDynamicAttributeFixed* dynamicAttributeFixed = new (std::nothrow) PUDynamicAttributeFixed(); dynamicAttributeFixed->setValue(val); affector->setRotationSpeed(dynamicAttributeFixed); return true; } } } return false; }