//----------------------------------------------------------------------- bool VortexAffectorTranslator::translateChildObject(ScriptCompiler* compiler, const AbstractNodePtr &node) { ObjectAbstractNode* child = reinterpret_cast<ObjectAbstractNode*>(node.get()); ParticleAffector* af = any_cast<ParticleAffector*>(child->parent->context); VortexAffector* affector = static_cast<VortexAffector*>(af); DynamicAttributeTranslator dynamicAttributeTranslator; if (child->cls == token[TOKEN_ROTATION_SPEED]) { // Property: rotation_speed dynamicAttributeTranslator.translate(compiler, node); DynamicAttribute* dynamicAttribute = any_cast<DynamicAttribute*>(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); DynamicAttribute* dynamicAttribute = any_cast<DynamicAttribute*>(child->context); affector->setRotationSpeed(dynamicAttribute); return true; } return false; }
//----------------------------------------------------------------------- void VortexAffector::copyAttributesTo (ParticleAffector* affector) { ParticleAffector::copyAttributesTo(affector); VortexAffector* vortexAffector = static_cast<VortexAffector*>(affector); vortexAffector->mRotation = mRotation; vortexAffector->mRotationVector = mRotationVector; vortexAffector->setRotationSpeed(mDynamicAttributeFactory.cloneDynamicAttribute(getRotationSpeed())); }
//----------------------------------------------------------------------- bool VortexAffectorTranslator::translateChildProperty(ScriptCompiler* compiler, const AbstractNodePtr &node) { PropertyAbstractNode* prop = reinterpret_cast<PropertyAbstractNode*>(node.get()); ParticleAffector* af = any_cast<ParticleAffector*>(prop->parent->context); VortexAffector* affector = static_cast<VortexAffector*>(af); if (prop->name == token[TOKEN_ROTATION_AXIS]) { // Property: rotation_axis if (passValidateProperty(compiler, prop, token[TOKEN_ROTATION_AXIS], VAL_VECTOR3)) { Vector3 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)) { Vector3 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)) { Real val = 0.0f; if(getReal(prop->values.front(), &val)) { DynamicAttributeFixed* dynamicAttributeFixed = PU_NEW_T(DynamicAttributeFixed, MEMCATEGORY_SCENE_OBJECTS)(); 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)) { Real val = 0.0f; if(getReal(prop->values.front(), &val)) { DynamicAttributeFixed* dynamicAttributeFixed = PU_NEW_T(DynamicAttributeFixed, MEMCATEGORY_SCENE_OBJECTS)(); dynamicAttributeFixed->setValue(val); affector->setRotationSpeed(dynamicAttributeFixed); return true; } } } return false; }