Transformation getTrafo() { Transformation t; t.pos = getVector3(); t.rotation = getMatrix3(); t.scale = getFloat(); t.velocity = getVector3(); return t; }
/** * @inheritDoc */ void PlayerNetworkObject::Update(f32 DeltaTime) { ASSERT(m_bInitialized); // Send the packet everytime it's dirty or for a heartbeat bool heartbeat_triggered = !m_heartbeat.is_stopped() && m_heartbeat.elapsed().wall >= m_heartbeat_delay; if (m_velocityDirty || m_rotationDirty || heartbeat_triggered) { bool velocityNotNull = m_velocity != Math::Vector3::Zero; bool rotationNotNull = m_rotation != Math::Vector3::Zero; m_heartbeat.stop(); if (velocityNotNull || rotationNotNull) { m_heartbeat.start(); } Proto::ObjectUpdated objectUpdated; Proto::Object* object = objectUpdated.add_objects(); object->set_id(m_entity->getId()); object->set_name(m_entity->getName()); Proto::SystemObject* systemObject = object->add_systemobjects(); systemObject->set_type(Proto::SystemType_Name(Proto::SystemType::Network)); systemObject->set_systemtype(Proto::SystemType::Network); if (m_velocityDirty || velocityNotNull) { m_velocityDirty = false; Proto::Property* positionProperty = systemObject->add_properties(); positionProperty->set_name("Position"); getVector3(&m_position, positionProperty->mutable_value()); Proto::Property* velocityProperty = systemObject->add_properties(); velocityProperty->set_name("Velocity"); getVector3(&m_velocity, velocityProperty->mutable_value()); } if (m_rotationDirty || rotationNotNull) { m_rotationDirty = false; Proto::Property* orientationProperty = systemObject->add_properties(); orientationProperty->set_name("Orientation"); getQuaternion(&m_orientation, orientationProperty->mutable_value()); Proto::Property* rotationProperty = systemObject->add_properties(); rotationProperty->set_name("Rotation"); getVector3(&m_rotation, rotationProperty->mutable_value()); } std::string data; objectUpdated.AppendToString(&data); DownstreamMessageProto downstreamMessage; downstreamMessage.set_type(DownstreamMessageProto::PLAYER_MOVE); downstreamMessage.set_data(data); GetSystemScene<NetworkScene>()->GetSystem<NetworkSystem>()->getNetworkService()->send(downstreamMessage); } }
//----------------------------------------------------------------------- bool PositionEmitterTranslator::translateChildProperty(Ogre::ScriptCompiler* compiler, const Ogre::AbstractNodePtr &node) { Ogre::PropertyAbstractNode* prop = reinterpret_cast<Ogre::PropertyAbstractNode*>(node.get()); ParticleEmitter* em = Ogre::any_cast<ParticleEmitter*>(prop->parent->context); PositionEmitter* emitter = static_cast<PositionEmitter*>(em); if (prop->name == token[TOKEN_POS_ADD_POSITION]) { // Property: add_position if (passValidateProperty(compiler, prop, token[TOKEN_POS_ADD_POSITION], VAL_VECTOR3)) { Ogre::Vector3 val; if(getVector3(prop->values.begin(), prop->values.end(), &val)) { emitter->addPosition(val); return true; } } } else if (prop->name == token[TOKEN_POS_RANDOMIZE]) { // Property: random_position if (passValidateProperty(compiler, prop, token[TOKEN_POS_RANDOMIZE], VAL_BOOL)) { bool val; if(getBoolean(prop->values.front(), &val)) { emitter->setRandomized(val); return true; } } } return false; }
Transformation NIFStream::getTrafo() { Transformation t; t.pos = getVector3(); t.rotation = getMatrix3(); t.scale = getFloat(); return t; }
//------------------------------------------------------------------------- bool PUPlaneColliderTranslator::translateChildProperty( PUScriptCompiler* compiler, PUAbstractNode *node ) { PUPropertyAbstractNode* prop = reinterpret_cast<PUPropertyAbstractNode*>(node); PUAffector* af = static_cast<PUAffector*>(prop->parent->context); PUPlaneCollider* affector = static_cast<PUPlaneCollider*>(af); if (prop->name == token[TOKEN_NORMAL]) { // Property: normal if (passValidateProperty(compiler, prop, token[TOKEN_NORMAL], VAL_VECTOR3)) { Vec3 val; if(getVector3(prop->values.begin(), prop->values.end(), &val)) { affector->setNormal(val); return true; } } } else if (prop->name == token[TOKEN_PLANECOLL_NORMAL]) { // Property: plane_collider_normal (deprecated and replaced by 'normal') if (passValidateProperty(compiler, prop, token[TOKEN_PLANECOLL_NORMAL], VAL_VECTOR3)) { Vec3 val; if(getVector3(prop->values.begin(), prop->values.end(), &val)) { affector->setNormal(val); return true; } } } else { // Parse the BaseCollider PUBaseColliderTranslator baseColliderTranslator; return baseColliderTranslator.translateChildProperty(compiler, node); } return false; }
//------------------------------------------------------------------------- bool ScriptTranslator::passValidatePropertyValidVector3(Ogre::ScriptCompiler* compiler, Ogre::PropertyAbstractNode* prop) { Ogre::Vector3 val; if(getVector3(prop->values.begin(), prop->values.end(), &val)) { return true; } compiler->addError(Ogre::ScriptCompiler::CE_INVALIDPARAMETERS, prop->file, prop->line, "PU Compiler: " + prop->values.front()->getValue() + " is not a valid Vector3"); return false; }
//----------------------------------------------------------------------- bool PathFollowerTranslator::translateChildProperty(ScriptCompiler* compiler, const AbstractNodePtr &node) { PropertyAbstractNode* prop = reinterpret_cast<PropertyAbstractNode*>(node.get()); ParticleAffector* af = any_cast<ParticleAffector*>(prop->parent->context); PathFollower* affector = static_cast<PathFollower*>(af); if (prop->name == token[TOKEN_PATH_POINT]) { // Property: path_follower_point if (passValidateProperty(compiler, prop, token[TOKEN_PATH_POINT], VAL_VECTOR3)) { Vector3 val; if(getVector3(prop->values.begin(), prop->values.end(), &val)) { affector->addPoint(val); return true; } } } return false; }
/** * @inheritDoc */ void PlayerInputObject::createShot(void) { Proto::Object shotProto; shotProto.set_id(ObjectId::gen().str()); shotProto.set_name("Shot"); shotProto.set_template_("ShotTemplate"); auto physicSystemObject = shotProto.add_systemobjects(); physicSystemObject->set_systemtype(Proto::SystemType::Physic); physicSystemObject->set_type("Movable"); auto positionProperty = physicSystemObject->add_properties(); positionProperty->set_name("Position"); getVector3(&m_position, positionProperty->mutable_value()); auto orientationProperty = physicSystemObject->add_properties(); orientationProperty->set_name("Orientation"); getQuaternion(&m_orientation, orientationProperty->mutable_value()); auto networkSystemObject = shotProto.add_systemobjects(); networkSystemObject->set_systemtype(Proto::SystemType::Network); networkSystemObject->set_type("Replicable"); m_createObjectQueue->push_back(shotProto); PostChanges(System::Changes::Generic::CreateObject); }
// ------------------------------------------------------------------- // File parsing method. void ObjFileParser::parseFile() { if (m_DataIt == m_DataItEnd) return; // only update every 100KB or it'll be too slow const unsigned int updateProgressEveryBytes = 100 * 1024; unsigned int progressCounter = 0; const unsigned int bytesToProcess = std::distance(m_DataIt, m_DataItEnd); const unsigned int progressTotal = 3 * bytesToProcess; const unsigned int progressOffset = bytesToProcess; unsigned int processed = 0; DataArrayIt lastDataIt = m_DataIt; while (m_DataIt != m_DataItEnd) { // Handle progress reporting processed += std::distance(lastDataIt, m_DataIt); lastDataIt = m_DataIt; if (processed > (progressCounter * updateProgressEveryBytes)) { progressCounter++; m_progress->UpdateFileRead(progressOffset + processed*2, progressTotal); } // parse line switch (*m_DataIt) { case 'v': // Parse a vertex texture coordinate { ++m_DataIt; if (*m_DataIt == ' ' || *m_DataIt == '\t') { size_t numComponents = getNumComponentsInLine(); if (numComponents == 3) { // read in vertex definition getVector3(m_pModel->m_Vertices); } else if (numComponents == 6) { // read vertex and vertex-color getTwoVectors3(m_pModel->m_Vertices, m_pModel->m_VertexColors); } } else if (*m_DataIt == 't') { // read in texture coordinate ( 2D or 3D ) ++m_DataIt; getVector( m_pModel->m_TextureCoord ); } else if (*m_DataIt == 'n') { // Read in normal vector definition ++m_DataIt; getVector3( m_pModel->m_Normals ); } } break; case 'p': // Parse a face, line or point statement case 'l': case 'f': { getFace(*m_DataIt == 'f' ? aiPrimitiveType_POLYGON : (*m_DataIt == 'l' ? aiPrimitiveType_LINE : aiPrimitiveType_POINT)); } break; case '#': // Parse a comment { getComment(); } break; case 'u': // Parse a material desc. setter { getMaterialDesc(); } break; case 'm': // Parse a material library or merging group ('mg') { if (*(m_DataIt + 1) == 'g') getGroupNumberAndResolution(); else getMaterialLib(); } break; case 'g': // Parse group name { getGroupName(); } break; case 's': // Parse group number { getGroupNumber(); } break; case 'o': // Parse object name { getObjectName(); } break; default: { m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine ); } break; } } }
Mesh* MeshManager::parseOBJ(string filename, char* buffer, int lenght){ // logInf("parse OBJ file with name %s lenght %i", filename.c_str(),lenght); //logInf("buffer:\n%s",buffer); elementOffsetOBJ = 0; resultMesh = new Mesh(filename, getNewId()); int idSubMesh = 0; SubMesh* auxSubMesh = new SubMesh(idSubMesh); int i = 0; while (buffer[i] != '\0') { switch (buffer[i]){ case 'v': // Parse a vertex texture coordinate ++i; if (buffer[i] == ' '){ // Read in vertex definition getVector3(&(auxSubMesh->vertices), buffer, &i); } else if (buffer[i] == 't'){ // Read in texture coordinate (2D) i++; getVector2(&(auxSubMesh->textureCoord), buffer, &i); } else if (buffer[i] == 'n'){ // Read in normal vector definition i++; getVector3(&(auxSubMesh->normals), buffer, &i); } break; case 'f': // Parse a face i++; getFace(&(auxSubMesh->elements), buffer, &i); //skipLine(buffer, &i); break; case '#': // Parse a comment //getComment(); skipLine(buffer, &i); break; case 'u': // Parse a material desc. setter //getMaterialDesc(); skipLine(buffer, &i); break; case 'm': // Parse a material library //getMaterialLib(); skipLine(buffer, &i); break; case 'g': // Parse group name //getGroupName(); skipLine(buffer, &i); break; case 's': // Parse group number //getGroupNumber(); skipLine(buffer, &i); break; case 'o': // Parse object name //getObjectName(); if (idSubMesh != 0) { elementOffsetOBJ += auxSubMesh->vertices.size(); resultMesh->subMeshes.push_back(auxSubMesh); } idSubMesh++; auxSubMesh = new SubMesh(idSubMesh); skipLine(buffer, &i); break; default: skipLine(buffer, &i); break; } } resultMesh->subMeshes.push_back(auxSubMesh); for (int t = 0; t < resultMesh->subMeshes.size(); t++) { auxSubMesh = resultMesh->subMeshes.at(t); //logInf("calculating normals auxSubMesh->vertices.size() %lu", auxSubMesh->vertices.size()); //logInf("calculating normals auxSubMesh->elements.size() %lu", auxSubMesh->elements.size()); auxSubMesh->normals.resize(auxSubMesh->vertices.size(), glm::vec3(0.0, 0.0, 0.0)); vector<int> nb_seen; nb_seen.clear(); nb_seen.resize(auxSubMesh->vertices.size(), 0); for (int i = 0; i < auxSubMesh->elements.size(); i++) { int ia, ib, ic; glm::vec3 normal; int current; int v[3]; ia = auxSubMesh->elements.at(i).x; ib = auxSubMesh->elements.at(i).y; ic = auxSubMesh->elements.at(i).z; //logInf("a %i, b %i, c %i",ia,ib,ic); normal = glm::normalize(glm::cross( auxSubMesh->vertices.at(ib) - auxSubMesh->vertices.at(ia), auxSubMesh->vertices.at(ic) - auxSubMesh->vertices.at(ia))); v[0] = ia; v[1] = ib; v[2] = ic; for (int j = 0; j < 3; j++) { current = v[j]; //logInf("current %i", current); nb_seen[current]++; if(nb_seen[current] == 1){ auxSubMesh->normals[current] = normal; }else{ auxSubMesh->normals[current].x = auxSubMesh->normals[current].x * (1.0f - 1.0f/(float)nb_seen[current]) + normal.x * 1.0f/(float)nb_seen[current]; auxSubMesh->normals[current].y = auxSubMesh->normals[current].y * (1.0f - 1.0f/(float)nb_seen[current]) + normal.y * 1.0f/(float)nb_seen[current]; auxSubMesh->normals[current].z = auxSubMesh->normals[current].z * (1.0f - 1.0f/(float)nb_seen[current]) + normal.z * 1.0f/(float)nb_seen[current]; auxSubMesh->normals[current] = glm::normalize(auxSubMesh->normals[current]); } } } } return resultMesh; }
//------------------------------------------------------------------------- bool PULineAffectorTranslator::translateChildProperty( PUScriptCompiler* compiler, PUAbstractNode *node ) { PUPropertyAbstractNode* prop = reinterpret_cast<PUPropertyAbstractNode*>(node); PUAffector* af = static_cast<PUAffector*>(prop->parent->context); PULineAffector* affector = static_cast<PULineAffector*>(af); if (prop->name == token[TOKEN_MAX_DEVIATION]) { // Property: max_deviation if (passValidateProperty(compiler, prop, token[TOKEN_MAX_DEVIATION], VAL_REAL)) { float val = 0.0f; if(getFloat(*prop->values.front(), &val)) { affector->setMaxDeviation(val); return true; } } } else if (prop->name == token[TOKEN_LINE_AFF_MAX_DEVIATION]) { // Property: line_aff_max_deviation (deprecated and replaced by 'max_deviation') if (passValidateProperty(compiler, prop, token[TOKEN_LINE_AFF_MAX_DEVIATION], VAL_REAL)) { float val = 0.0f; if(getFloat(*prop->values.front(), &val)) { affector->setMaxDeviation(val); return true; } } } else if (prop->name == token[TOKEN_TIME_STEP]) { // Property: time_step if (passValidateProperty(compiler, prop, token[TOKEN_TIME_STEP], VAL_REAL)) { float val = 0.0f; if(getFloat(*prop->values.front(), &val)) { affector->setTimeStep(val); return true; } } } else if (prop->name == token[TOKEN_LINE_AFF_TIME_STEP]) { // Property: line_aff_time_step (deprecated and replaced by 'time_step') if (passValidateProperty(compiler, prop, token[TOKEN_LINE_AFF_TIME_STEP], VAL_REAL)) { float val = 0.0f; if(getFloat(*prop->values.front(), &val)) { affector->setTimeStep(val); return true; } } } else if (prop->name == token[TOKEN_END]) { // Property: end if (passValidateProperty(compiler, prop, token[TOKEN_END], VAL_VECTOR3)) { Vec3 val; if(getVector3(prop->values.begin(), prop->values.end(), &val)) { affector->setEnd(val); return true; } } } else if (prop->name == token[TOKEN_LINE_AFF_END]) { // Property: line_aff_end (deprecated and replaced by 'end') if (passValidateProperty(compiler, prop, token[TOKEN_LINE_AFF_END], VAL_VECTOR3)) { Vec3 val; if(getVector3(prop->values.begin(), prop->values.end(), &val)) { affector->setEnd(val); return true; } } } else if (prop->name == token[TOKEN_DRIFT]) { // Property: drift if (passValidateProperty(compiler, prop, token[TOKEN_DRIFT], VAL_REAL)) { float val = 0.0f; if(getFloat(*prop->values.front(), &val)) { affector->setDrift(val); return true; } } } else if (prop->name == token[TOKEN_LINE_AFF_DRIFT]) { // Property: line_aff_drift (deprecated and replaced by 'drift') if (passValidateProperty(compiler, prop, token[TOKEN_LINE_AFF_DRIFT], VAL_REAL)) { float val = 0.0f; if(getFloat(*prop->values.front(), &val)) { affector->setDrift(val); return true; } } } return false; }
//------------------------------------------------------------------------- bool PUParticle3DVortexAffectorTranslator::translateChildProperty( PUScriptCompiler* compiler, PUAbstractNode *node ) { PUPropertyAbstractNode* prop = reinterpret_cast<PUPropertyAbstractNode*>(node); PUParticle3DAffector* af = static_cast<PUParticle3DAffector*>(prop->parent->context); PUParticle3DVortexAffector* affector = static_cast<PUParticle3DVortexAffector*>(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; }
//------------------------------------------------------------------------- bool PUGeometryRotatorTranslator::translateChildProperty( PUScriptCompiler* compiler, PUAbstractNode *node ) { PUPropertyAbstractNode* prop = reinterpret_cast<PUPropertyAbstractNode*>(node); PUAffector* af = static_cast<PUAffector*>(prop->parent->context); PUGeometryRotator* affector = static_cast<PUGeometryRotator*>(af); if (prop->name == token[TOKEN_USE_OWN_ROTATION]) { // Property: use_own_rotation if (passValidateProperty(compiler, prop, token[TOKEN_USE_OWN_ROTATION], VAL_BOOL)) { bool val; if(getBoolean(*prop->values.front(), &val)) { affector->setUseOwnRotationSpeed(val); return true; } } } else if (prop->name == token[TOKEN_GEOMROT_USE_OWN_ROTATION]) { // Property: geom_rot_use_own_rotation (deprecated and replaced by 'use_own_rotation') if (passValidateProperty(compiler, prop, token[TOKEN_GEOMROT_USE_OWN_ROTATION], VAL_BOOL)) { bool val; if(getBoolean(*prop->values.front(), &val)) { affector->setUseOwnRotationSpeed(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_GEOMROT_ROTATION_SPEED]) { // Property: geom_rot_rotation_speed (deprecated and replaced by 'rotation_speed') if (passValidateProperty(compiler, prop, token[TOKEN_GEOMROT_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_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->setRotationAxis(val); return true; } } } else if (prop->name == token[TOKEN_GEOMROT_ROTATION_AXIS]) { // Property: geom_rot_axis (deprecated and replaced by 'rotation_axis') if (passValidateProperty(compiler, prop, token[TOKEN_GEOMROT_ROTATION_AXIS], VAL_VECTOR3)) { Vec3 val; if(getVector3(prop->values.begin(), prop->values.end(), &val)) { affector->setRotationAxis(val); return true; } } } return false; }
void NIFStream::getVector3s(osg::Vec3Array* vec, size_t size) { vec->reserve(size); for(size_t i = 0;i < size;i++) vec->push_back(getVector3()); }
//------------------------------------------------------------------------- void SystemTranslator::translate(ScriptCompiler* compiler, const AbstractNodePtr &node) { ObjectAbstractNode* obj = reinterpret_cast<ObjectAbstractNode*>(node.get()); if(obj->name.empty()) { compiler->addError(ScriptCompiler::CE_OBJECTNAMEEXPECTED, obj->file, obj->line); return; } // Create a particle system with the given name mSystem = ParticleSystemManager::getSingletonPtr()->createParticleSystemTemplate(obj->name, compiler->getResourceGroup()); if (!mSystem) { compiler->addError(ScriptCompiler::CE_INVALIDPARAMETERS, obj->file, obj->line); return; } obj->context = Any(mSystem); for(AbstractNodeList::iterator i = obj->children.begin(); i != obj->children.end(); ++i) { if((*i)->type == ANT_PROPERTY) { PropertyAbstractNode* prop = reinterpret_cast<PropertyAbstractNode*>((*i).get()); if (prop->name == token[TOKEN_PS_ITERATION_INTERVAL]) { // Property: iteration_interval if (passValidateProperty(compiler, prop, token[TOKEN_PS_ITERATION_INTERVAL], VAL_REAL)) { Real val = 0.0f; if(getReal(prop->values.front(), &val)) { mSystem->setIterationInterval(val); } } } else if (prop->name == token[TOKEN_PS_NONVIS_UPDATE_TIMEOUT]) { // Property: nonvisible_update_timeout if (passValidateProperty(compiler, prop, token[TOKEN_PS_NONVIS_UPDATE_TIMEOUT], VAL_REAL)) { Real val = 0.0f; if(getReal(prop->values.front(), &val)) { mSystem->setNonVisibleUpdateTimeout(val); } } } else if (prop->name == token[TOKEN_PS_FIXED_TIMEOUT]) { // Property: fixed_timeout if (passValidateProperty(compiler, prop, token[TOKEN_PS_FIXED_TIMEOUT], VAL_REAL)) { Real val = 0.0f; if(getReal(prop->values.front(), &val)) { mSystem->setFixedTimeout(val); } } } else if (prop->name == token[TOKEN_PS_LOD_DISTANCES]) { // Property: lod_distances if (passValidatePropertyNoValues(compiler, prop, token[TOKEN_PS_LOD_DISTANCES])) { for(AbstractNodeList::iterator j = prop->values.begin(); j != prop->values.end(); ++j) { Real val = 0.0f; if(getReal(*j, &val)) { mSystem->addLodDistance(val); } else { compiler->addError(ScriptCompiler::CE_NUMBEREXPECTED, prop->file, prop->line, "PU Compiler: lod_distances expects only numbers as arguments"); } } } } else if (prop->name == token[TOKEN_PS_MAIN_CAMERA_NAME]) { // Property: main_camera_name if (passValidateProperty(compiler, prop, token[TOKEN_PS_MAIN_CAMERA_NAME], VAL_STRING)) { String val; if(getString(prop->values.front(), &val)) { mSystem->setMainCameraName(val); } } } else if (prop->name == token[TOKEN_PS_SMOOTH_LOD]) { // Property: smooth_lod if (passValidateProperty(compiler, prop, token[TOKEN_PS_SMOOTH_LOD], VAL_BOOL)) { bool val; if(getBoolean(prop->values.front(), &val)) { mSystem->setSmoothLod(val); } } } else if (prop->name == token[TOKEN_PS_FAST_FORWARD]) { // Property: fast_forward if (passValidateProperty(compiler, prop, token[TOKEN_PS_SCALE], VAL_VECTOR2)) { Vector2 val; if(getVector2(prop->values.begin(), prop->values.end(), &val)) { mSystem->setFastForward(val.x, val.y); } } } else if (prop->name == token[TOKEN_PS_SCALE]) { // Property: scale if (passValidateProperty(compiler, prop, token[TOKEN_PS_SCALE], VAL_VECTOR3)) { Vector3 val; if(getVector3(prop->values.begin(), prop->values.end(), &val)) { mSystem->setScale(val); } } } else if (prop->name == token[TOKEN_PS_SCALE_VELOCITY]) { // Property: scale_velocity if (passValidateProperty(compiler, prop, token[TOKEN_PS_ITERATION_INTERVAL], VAL_REAL)) { Real val = 0.0f; if(getReal(prop->values.front(), &val)) { mSystem->setScaleVelocity(val); } } } else if (prop->name == token[TOKEN_PS_SCALE_TIME]) { // Property: scale_time if (passValidateProperty(compiler, prop, token[TOKEN_PS_SCALE_TIME], VAL_REAL)) { Real val = 0.0f; if(getReal(prop->values.front(), &val)) { mSystem->setScaleTime(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)) { mSystem->setKeepLocal(val); } } } else if (prop->name == token[TOKEN_PS_TIGHT_BOUNDING_BOX]) { // Property: tight_bounding_box if (passValidateProperty(compiler, prop, token[TOKEN_PS_TIGHT_BOUNDING_BOX], VAL_BOOL)) { bool val; if(getBoolean(prop->values.front(), &val)) { mSystem->setTightBoundingBox(val); } } } else if (prop->name == token[TOKEN_PS_CATEGORY]) { // Property: category if (passValidateProperty(compiler, prop, token[TOKEN_PS_CATEGORY], VAL_STRING)) { String val; if(getString(prop->values.front(), &val)) { mSystem->setCategory(val); } } } else if (prop->name == token[TOKEN_USE_ALIAS]) { // Property: use_alias // The alias can only be a technique if (passValidateProperty(compiler, prop, token[TOKEN_USE_ALIAS], VAL_STRING)) { String val; if(getString(prop->values.front(), &val)) { IAlias* alias = ParticleSystemManager::getSingletonPtr()->getAlias(val); if (alias->getAliasType() == IAlias::AT_TECHNIQUE) { ParticleTechnique* technique = static_cast<ParticleTechnique*>(alias); ParticleTechnique* newTechnique = ParticleSystemManager::getSingletonPtr()->cloneTechnique(technique); mSystem->addTechnique(newTechnique); } } } } else { errorUnexpectedProperty(compiler, prop); } } else if((*i)->type == ANT_OBJECT) { processNode(compiler, *i); } else { errorUnexpectedToken(compiler, *i); } } }
// ------------------------------------------------------------------- // File parsing method. void ObjFileParser::parseFile() { if (m_DataIt == m_DataItEnd) return; while (m_DataIt != m_DataItEnd) { switch (*m_DataIt) { case 'v': // Parse a vertex texture coordinate { ++m_DataIt; if (*m_DataIt == ' ' || *m_DataIt == '\t') { // read in vertex definition getVector3(m_pModel->m_Vertices); } else if (*m_DataIt == 't') { // read in texture coordinate ( 2D or 3D ) ++m_DataIt; getVector( m_pModel->m_TextureCoord ); } else if (*m_DataIt == 'n') { // Read in normal vector definition ++m_DataIt; getVector3( m_pModel->m_Normals ); } } break; case 'p': // Parse a face, line or point statement case 'l': case 'f': { getFace(*m_DataIt == 'f' ? aiPrimitiveType_POLYGON : (*m_DataIt == 'l' ? aiPrimitiveType_LINE : aiPrimitiveType_POINT)); } break; case '#': // Parse a comment { getComment(); } break; case 'u': // Parse a material desc. setter { getMaterialDesc(); } break; case 'm': // Parse a material library or merging group ('mg') { if (*(m_DataIt + 1) == 'g') getGroupNumberAndResolution(); else getMaterialLib(); } break; case 'g': // Parse group name { getGroupName(); } break; case 's': // Parse group number { getGroupNumber(); } break; case 'o': // Parse object name { getObjectName(); } break; default: { m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine ); } break; } } }
//------------------------------------------------------------------------- bool PULineEmitterTranslator::translateChildProperty( PUScriptCompiler* compiler, PUAbstractNode *node ) { PUPropertyAbstractNode* prop = reinterpret_cast<PUPropertyAbstractNode*>(node); PUEmitter* em = static_cast<PUEmitter*>(prop->parent->context); PULineEmitter* emitter = static_cast<PULineEmitter*>(em); if (prop->name == token[TOKEN_END]) { // Property: end if (passValidateProperty(compiler, prop, token[TOKEN_END], VAL_VECTOR3)) { Vec3 val; if(getVector3(prop->values.begin(), prop->values.end(), &val)) { emitter->setEnd(val); return true; } } } else if (prop->name == token[TOKEN_LINE_EMIT_END]) { // Property: line_em_end (deprecated and replaced by 'end') if (passValidateProperty(compiler, prop, token[TOKEN_LINE_EMIT_END], VAL_VECTOR3)) { Vec3 val; if(getVector3(prop->values.begin(), prop->values.end(), &val)) { emitter->setEnd(val); return true; } } } else if (prop->name == token[TOKEN_MAX_INCREMENT]) { // Property: max_increment if (passValidateProperty(compiler, prop, token[TOKEN_MAX_INCREMENT], VAL_REAL)) { float val = 0.0f; if(getFloat(*prop->values.front(), &val)) { emitter->setMaxIncrement(val); return true; } } } else if (prop->name == token[TOKEN_LINE_EMIT_MAX_INCREMENT]) { // Property: line_em_max_increment (de[recated and replaced by 'max_increment') if (passValidateProperty(compiler, prop, token[TOKEN_LINE_EMIT_MAX_INCREMENT], VAL_REAL)) { float val = 0.0f; if(getFloat(*prop->values.front(), &val)) { emitter->setMaxIncrement(val); return true; } } } else if (prop->name == token[TOKEN_MIN_INCREMENT]) { // Property: min_increment if (passValidateProperty(compiler, prop, token[TOKEN_MIN_INCREMENT], VAL_REAL)) { float val = 0.0f; if(getFloat(*prop->values.front(), &val)) { emitter->setMinIncrement(val); return true; } } } else if (prop->name == token[TOKEN_LINE_EMIT_MIN_INCREMENT]) { // Property: line_em_min_increment (deprecated and replaced by 'min_increment') if (passValidateProperty(compiler, prop, token[TOKEN_LINE_EMIT_MIN_INCREMENT], VAL_REAL)) { float val = 0.0f; if(getFloat(*prop->values.front(), &val)) { emitter->setMinIncrement(val); return true; } } } else if (prop->name == token[TOKEN_MAX_DEVIATION]) { // Property: max_deviation if (passValidateProperty(compiler, prop, token[TOKEN_MAX_DEVIATION], VAL_REAL)) { float val = 0.0f; if(getFloat(*prop->values.front(), &val)) { emitter->setMaxDeviation(val); return true; } } } else if (prop->name == token[TOKEN_LINE_EMIT_MAX_DEVIATION]) { // Property: line_em_max_deviation (deprecated and replaced by 'max_deviation') if (passValidateProperty(compiler, prop, token[TOKEN_LINE_EMIT_MAX_DEVIATION], VAL_REAL)) { float val = 0.0f; if(getFloat(*prop->values.front(), &val)) { emitter->setMaxDeviation(val); return true; } } } return false; }
//----------------------------------------------------------------------- bool SceneDecoratorExternTranslator::translateChildProperty(ScriptCompiler* compiler, const AbstractNodePtr &node) { PropertyAbstractNode* prop = reinterpret_cast<PropertyAbstractNode*>(node.get()); Extern* ex = any_cast<Extern*>(prop->parent->context); SceneDecoratorExtern* externObject = static_cast<SceneDecoratorExtern*>(ex); if (prop->name == token[TOKEN_MESH_NAME]) { // Property: mesh_name if (passValidateProperty(compiler, prop, token[TOKEN_MESH_NAME], VAL_STRING)) { String val; if(getString(prop->values.front(), &val)) { externObject->setMeshName(val); return true; } } } else if (prop->name == token[TOKEN_SCENE_MESH_NAME]) { // Property: scene_mesh_name (deprecated and replaced by mesh_name) if (passValidateProperty(compiler, prop, token[TOKEN_SCENE_MESH_NAME], VAL_STRING)) { String val; if(getString(prop->values.front(), &val)) { externObject->setMeshName(val); return true; } } } else if (prop->name == token[TOKEN_MATERIAL]) { // Property: material if (passValidateProperty(compiler, prop, token[TOKEN_MATERIAL], VAL_STRING)) { String val; if(getString(prop->values.front(), &val)) { externObject->setMaterialName(val); return true; } } } else if (prop->name == token[TOKEN_SCENE_MATERIAL_NAME]) { // Property: scene_material_name (deprecated and replaced by 'material') if (passValidateProperty(compiler, prop, token[TOKEN_SCENE_MATERIAL_NAME], VAL_STRING)) { String val; if(getString(prop->values.front(), &val)) { externObject->setMaterialName(val); return true; } } } else if (prop->name == token[TOKEN_SCENE_SCALE]) { // Property: scene_node_scale if (passValidateProperty(compiler, prop, token[TOKEN_SCENE_SCALE], VAL_VECTOR3)) { Vector3 val; if(getVector3(prop->values.begin(), prop->values.end(), &val)) { externObject->setScale(val); return true; } } } else if (prop->name == token[TOKEN_SCENE_POSITION]) { // Property: scene_node_position if (passValidateProperty(compiler, prop, token[TOKEN_SCENE_POSITION], VAL_VECTOR3)) { Vector3 val; if(getVector3(prop->values.begin(), prop->values.end(), &val)) { externObject->setPosition(val); return true; } } } return false; }
//------------------------------------------------------------------------- bool PUForceFieldAffectorTranslator::translateChildProperty( PUScriptCompiler* compiler, PUAbstractNode *node ) { PUPropertyAbstractNode* prop = reinterpret_cast<PUPropertyAbstractNode*>(node); PUAffector* af = static_cast<PUAffector*>(prop->parent->context); PUForceFieldAffector* affector = static_cast<PUForceFieldAffector*>(af); if (prop->name == token[TOKEN_FORCEFIELD_TYPE]) { // Property: forcefield_type if (passValidateProperty(compiler, prop, token[TOKEN_FORCEFIELD_TYPE], VAL_STRING)) { std::string val; if(getString(*prop->values.front(), &val)) { affector->suppressGeneration(true); if (val == token[TOKEN_REALTIME]) { affector->setForceFieldType(PUForceField::FF_REALTIME_CALC); return true; } else if (val == token[TOKEN_MATRIX]) { affector->setForceFieldType(PUForceField::FF_MATRIX_CALC); return true; } affector->suppressGeneration(false); } } } else if (prop->name == token[TOKEN_DELTA]) { // Property: delta if (passValidateProperty(compiler, prop, token[TOKEN_DELTA], VAL_REAL)) { float val = 0.0f; if(getFloat(*prop->values.front(), &val)) { affector->suppressGeneration(true); affector->setDelta(val); affector->suppressGeneration(false); return true; } } } else if (prop->name == token[TOKEN_FORCE]) { // Property: force if (passValidateProperty(compiler, prop, token[TOKEN_FORCE], VAL_REAL)) { float val = 0.0f; if(getFloat(*prop->values.front(), &val)) { affector->suppressGeneration(true); affector->setScaleForce(val); affector->suppressGeneration(false); return true; } } } else if (prop->name == token[TOKEN_OCTAVES]) { // Property: octaves if (passValidateProperty(compiler, prop, token[TOKEN_OCTAVES], VAL_UINT)) { unsigned int val = 0; if(getUInt(*prop->values.front(), &val)) { affector->suppressGeneration(true); affector->setOctaves(val); affector->suppressGeneration(false); return true; } } } else if (prop->name == token[TOKEN_FREQUENCY]) { // Property: frequency if (passValidateProperty(compiler, prop, token[TOKEN_FREQUENCY], VAL_REAL)) { float val = 0.0f; if(getFloat(*prop->values.front(), &val)) { affector->suppressGeneration(true); affector->setFrequency(val); affector->suppressGeneration(false); return true; } } } else if (prop->name == token[TOKEN_AMPLITUDE]) { // Property: amplitude if (passValidateProperty(compiler, prop, token[TOKEN_AMPLITUDE], VAL_REAL)) { float val = 0.0f; if(getFloat(*prop->values.front(), &val)) { affector->suppressGeneration(true); affector->setAmplitude(val); affector->suppressGeneration(false); return true; } } } else if (prop->name == token[TOKEN_PERSISTENCE]) { // Property: persistence if (passValidateProperty(compiler, prop, token[TOKEN_PERSISTENCE], VAL_REAL)) { float val = 0.0f; if(getFloat(*prop->values.front(), &val)) { affector->suppressGeneration(true); affector->setPersistence(val); affector->suppressGeneration(false); return true; } } } else if (prop->name == token[TOKEN_FORCEFIELDSIZE]) { // Property: forcefield_size if (passValidateProperty(compiler, prop, token[TOKEN_FORCEFIELDSIZE], VAL_UINT)) { unsigned int val = 0; if(getUInt(*prop->values.front(), &val)) { affector->suppressGeneration(true); affector->setForceFieldSize(val); affector->suppressGeneration(false); return true; } } } else if (prop->name == token[TOKEN_WORLDSIZE]) { // Property: worldsize if (passValidateProperty(compiler, prop, token[TOKEN_WORLDSIZE], VAL_VECTOR3)) { Vec3 val; if(getVector3(prop->values.begin(), prop->values.end(), &val)) { affector->suppressGeneration(true); affector->setWorldSize(val); affector->suppressGeneration(false); return true; } } } else if (prop->name == token[TOKEN_IGNORE_NEGATIVE_X]) { // Property: ignore_negative_x if (passValidateProperty(compiler, prop, token[TOKEN_IGNORE_NEGATIVE_X], VAL_BOOL)) { bool val; if(getBoolean(*prop->values.front(), &val)) { affector->suppressGeneration(true); affector->setIgnoreNegativeX(val); affector->suppressGeneration(false); return true; } } } else if (prop->name == token[TOKEN_IGNORE_NEGATIVE_Y]) { // Property: ignore_negative_y if (passValidateProperty(compiler, prop, token[TOKEN_IGNORE_NEGATIVE_Y], VAL_BOOL)) { bool val; if(getBoolean(*prop->values.front(), &val)) { affector->suppressGeneration(true); affector->setIgnoreNegativeY(val); affector->suppressGeneration(false); return true; } } } else if (prop->name == token[TOKEN_IGNORE_NEGATIVE_Z]) { // Property: ignore_negative_z if (passValidateProperty(compiler, prop, token[TOKEN_IGNORE_NEGATIVE_Z], VAL_BOOL)) { bool val; if(getBoolean(*prop->values.front(), &val)) { affector->suppressGeneration(true); affector->setIgnoreNegativeZ(val); affector->suppressGeneration(false); return true; } } } else if (prop->name == token[TOKEN_MOVEMENT]) { // Property: movement if (passValidateProperty(compiler, prop, token[TOKEN_MOVEMENT], VAL_VECTOR3)) { Vec3 val; if(getVector3(prop->values.begin(), prop->values.end(), &val)) { affector->suppressGeneration(true); affector->setMovement(val); affector->suppressGeneration(false); return true; } } } else if (prop->name == token[TOKEN_MOVEMENT_FREQUENCY]) { // Property: movement_frequency if (passValidateProperty(compiler, prop, token[TOKEN_MOVEMENT_FREQUENCY], VAL_REAL)) { float val = 0.0f; if(getFloat(*prop->values.front(), &val)) { affector->suppressGeneration(true); affector->setMovementFrequency(val); affector->suppressGeneration(false); return true; } } } return false; }
// ------------------------------------------------------------------- void ObjFileParser::parseFile() { if (m_DataIt == m_DataItEnd) return; while (m_DataIt != m_DataItEnd) { switch (*m_DataIt) { case 'v': // Parse a vertex texture coordinate { ++m_DataIt; if (*m_DataIt == ' ') { // Read in vertex definition getVector3(m_pModel->m_Vertices); } else if (*m_DataIt == 't') { // Read in texture coordinate (2D) ++m_DataIt; getVector2(m_pModel->m_TextureCoord); } else if (*m_DataIt == 'n') { // Read in normal vector definition ++m_DataIt; getVector3( m_pModel->m_Normals ); } } break; case 'f': // Parse a face { getFace(); } break; case '#': // Parse a comment { getComment(); } break; case 'u': // Parse a material desc. setter { getMaterialDesc(); } break; case 'm': // Parse a material library { getMaterialLib(); } break; case 'g': // Parse group name { getGroupName(); } break; case 's': // Parse group number { getGroupNumber(); } break; case 'o': // Parse object name { getObjectName(); } break; default: { m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine ); } break; } } }
//----------------------------------------------------------------------- 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; }
void PUParticleSystem3DTranslator::translate(PUScriptCompiler* compiler, PUAbstractNode *node) { PUObjectAbstractNode* obj = reinterpret_cast<PUObjectAbstractNode*>(node); if(obj->name.empty()) { return; } //// Create a particle system with the given name //_system = PUParticleSystem3D::create(); //PUParticleSystem3DBuilder::Instance()->puParticleSystem3DList.push_back(_system); //if (!mSystem) //{ // return; //} obj->context = _system; _system->setName(obj->name); 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_PS_ITERATION_INTERVAL]) // { // // Property: iteration_interval // if (passValidateProperty(compiler, prop, token[TOKEN_PS_ITERATION_INTERVAL], VAL_REAL)) // { // Real val = 0.0f; // if(getReal(prop->values.front(), &val)) // { // mSystem->setIterationInterval(val); // } // } // } // else if (prop->name == token[TOKEN_PS_NONVIS_UPDATE_TIMEOUT]) // { // // Property: nonvisible_update_timeout // if (passValidateProperty(compiler, prop, token[TOKEN_PS_NONVIS_UPDATE_TIMEOUT], VAL_REAL)) // { // Real val = 0.0f; // if(getReal(prop->values.front(), &val)) // { // mSystem->setNonVisibleUpdateTimeout(val); // } // } // } // else if (prop->name == token[TOKEN_PS_FIXED_TIMEOUT]) // { // // Property: fixed_timeout // if (passValidateProperty(compiler, prop, token[TOKEN_PS_FIXED_TIMEOUT], VAL_REAL)) // { // Real val = 0.0f; // if(getReal(prop->values.front(), &val)) // { // mSystem->setFixedTimeout(val); // } // } // } // else if (prop->name == token[TOKEN_PS_LOD_DISTANCES]) // { // // Property: lod_distances // if (passValidatePropertyNoValues(compiler, prop, token[TOKEN_PS_LOD_DISTANCES])) // { // for(PUAbstractNodeList::iterator j = prop->values.begin(); j != prop->values.end(); ++j) // { // Real val = 0.0f; // if(getReal(*j, &val)) // { // mSystem->addLodDistance(val); // } // else // { // compiler->addError(PUScriptCompiler::CE_NUMBEREXPECTED, prop->file, prop->line, // "PU Compiler: lod_distances expects only numbers as arguments"); // } // } // } // } // else if (prop->name == token[TOKEN_PS_MAIN_CAMERA_NAME]) // { // // Property: main_camera_name // if (passValidateProperty(compiler, prop, token[TOKEN_PS_MAIN_CAMERA_NAME], VAL_STRING)) // { // String val; // if(getString(prop->values.front(), &val)) // { // mSystem->setMainCameraName(val); // } // } // } // else if (prop->name == token[TOKEN_PS_SMOOTH_LOD]) // { // // Property: smooth_lod // if (passValidateProperty(compiler, prop, token[TOKEN_PS_SMOOTH_LOD], VAL_BOOL)) // { // bool val; // if(getBoolean(prop->values.front(), &val)) // { // mSystem->setSmoothLod(val); // } // } // } // else if (prop->name == token[TOKEN_PS_FAST_FORWARD]) // { // // Property: fast_forward // if (passValidateProperty(compiler, prop, token[TOKEN_PS_SCALE], VAL_VECTOR2)) // { // Vector2 val; // if(getVector2(prop->values.begin(), prop->values.end(), &val)) // { // mSystem->setFastForward(val.x, val.y); // } // } // } if (prop->name == token[TOKEN_PS_SCALE]) { // Property: scale if (passValidateProperty(compiler, prop, token[TOKEN_PS_SCALE], VAL_VECTOR3)) { Vec3 val; if(getVector3(prop->values.begin(), prop->values.end(), &val)) { _system->setScaleX(val.x); _system->setScaleY(val.y); _system->setScaleZ(val.z); } } } // else if (prop->name == token[TOKEN_PS_SCALE_VELOCITY]) // { // // Property: scale_velocity // if (passValidateProperty(compiler, prop, token[TOKEN_PS_ITERATION_INTERVAL], VAL_REAL)) // { // Real val = 0.0f; // if(getReal(prop->values.front(), &val)) // { // mSystem->setScaleVelocity(val); // } // } // } // else if (prop->name == token[TOKEN_PS_SCALE_TIME]) // { // // Property: scale_time // if (passValidateProperty(compiler, prop, token[TOKEN_PS_SCALE_TIME], VAL_REAL)) // { // Real val = 0.0f; // if(getReal(prop->values.front(), &val)) // { // mSystem->setScaleTime(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)) { _system->setKeepLocal(val); } } } // else if (prop->name == token[TOKEN_PS_TIGHT_BOUNDING_BOX]) // { // // Property: tight_bounding_box // if (passValidateProperty(compiler, prop, token[TOKEN_PS_TIGHT_BOUNDING_BOX], VAL_BOOL)) // { // bool val; // if(getBoolean(prop->values.front(), &val)) // { // mSystem->setTightBoundingBox(val); // } // } // } // else if (prop->name == token[TOKEN_PS_CATEGORY]) // { // // Property: category // if (passValidateProperty(compiler, prop, token[TOKEN_PS_CATEGORY], VAL_STRING)) // { // String val; // if(getString(prop->values.front(), &val)) // { // mSystem->setCategory(val); // } // } // } // else if (prop->name == token[TOKEN_USE_ALIAS]) // { // // Property: use_alias // // The alias can only be a technique // if (passValidateProperty(compiler, prop, token[TOKEN_USE_ALIAS], VAL_STRING)) // { // String val; // if(getString(prop->values.front(), &val)) // { // IAlias* alias = ParticleSystemManager::getSingletonPtr()->getAlias(val); // if (alias->getAliasType() == IAlias::AT_TECHNIQUE) // { // ParticleTechnique* technique = static_cast<ParticleTechnique*>(alias); // ParticleTechnique* newTechnique = ParticleSystemManager::getSingletonPtr()->cloneTechnique(technique); // mSystem->addTechnique(newTechnique); // } // } // } // } // else // { // errorUnexpectedProperty(compiler, prop); // } } else if((*i)->type == ANT_OBJECT) { processNode(compiler, *i); } else { errorUnexpectedToken(compiler, *i); } } }
//------------------------------------------------------------------------- void PUAffectorTranslator::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 affector // 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 //ParticleAffectorFactory* particleAffectorFactory = ParticleSystemManager::getSingletonPtr()->getAffectorFactory(type); //if (!particleAffectorFactory) //{ // compiler->addError(ScriptCompiler::CE_INVALIDPARAMETERS, obj->file, obj->line); // return; //} PUScriptTranslator *particleAffectorTranlator = PUAffectorManager::Instance()->getTranslator(type); if (!particleAffectorTranlator) return; //// Create the affector //mAffector = ParticleSystemManager::getSingletonPtr()->createAffector(type); //if (!mAffector) //{ // compiler->addError(ScriptCompiler::CE_INVALIDPARAMETERS, obj->file, obj->line); // return; //} _affector = PUAffectorManager::Instance()->createAffector(type); if (!_affector) return; _affector->setAffectorType(type); if (parent && parent->context) { PUParticleSystem3D* system = static_cast<PUParticleSystem3D*>(parent->context); system->addAffector(_affector); } // The first value is the (optional) name std::string name; if(!obj->values.empty()) { getString(*obj->values.front(), &name); _affector->setName(name); } // Set it in the context obj->context = _affector; // 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)) { _affector->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)) { //mAffector->position = val; //mAffector->originalPosition = val; _affector->setLocalPosition(val); } } } else if (prop->name == token[TOKEN_AFFECTOR_MASS]) { if (passValidateProperty(compiler, prop, token[TOKEN_AFFECTOR_MASS], VAL_REAL)) { float val = 0.0f; if(getFloat(*prop->values.front(), &val)) { _affector->setMass(val); } } } else if (prop->name == token[TOKEN_AFFECTOR_SPECIALISATION]) { if (passValidateProperty(compiler, prop, token[TOKEN_AFFECTOR_SPECIALISATION], VAL_STRING)) { std::string val; if(getString(*prop->values.front(), &val)) { if (val == token[TOKEN_AFFECTOR_SPEC_DEFAULT]) { _affector->setAffectSpecialisation(PUAffector::AFSP_DEFAULT); } else if (val == token[TOKEN_AFFECTOR_SPEC_TTL_INCREASE]) { _affector->setAffectSpecialisation(PUAffector::AFSP_TTL_INCREASE); } else if (val == token[TOKEN_AFFECTOR_SPEC_TTL_DECREASE]) { _affector->setAffectSpecialisation(PUAffector::AFSP_TTL_DECREASE); } } } } else if (prop->name == token[TOKEN_AFFECTOR_EXCLUDE_EMITTER]) { if (passValidatePropertyNoValues(compiler, prop, token[TOKEN_AFFECTOR_EXCLUDE_EMITTER])) { for(PUAbstractNodeList::iterator j = prop->values.begin(); j != prop->values.end(); ++j) { std::string val; if(getString(**j, &val)) { _affector->addEmitterToExclude(val); } } } } else if (particleAffectorTranlator->translateChildProperty(compiler, *i)) { // Parsed the property by another translator; do nothing } else { errorUnexpectedProperty(compiler, prop); } } else if((*i)->type == ANT_OBJECT) { if (particleAffectorTranlator->translateChildObject(compiler, *i)) { // Parsed the object by another translator; do nothing } else { processNode(compiler, *i); } } else { errorUnexpectedToken(compiler, *i); } } }
Vector3 Sound::getPosition() { return getVector3(AL_POSITION); }
//----------------------------------------------------------------------- bool MeshSurfaceEmitterTranslator::translateChildProperty(Ogre::ScriptCompiler* compiler, const Ogre::AbstractNodePtr &node) { Ogre::PropertyAbstractNode* prop = reinterpret_cast<Ogre::PropertyAbstractNode*>(node.get()); ParticleEmitter* em = Ogre::any_cast<ParticleEmitter*>(prop->parent->context); MeshSurfaceEmitter* emitter = static_cast<MeshSurfaceEmitter*>(em); if (prop->name == token[TOKEN_MESH_NAME]) { // Property: mesh_name if (passValidateProperty(compiler, prop, token[TOKEN_MESH_NAME], VAL_STRING)) { Ogre::String val; if(getString(prop->values.front(), &val)) { emitter->setMeshName(val); return true; } } } else if (prop->name == token[TOKEN_MESH_SURFACE_NAME]) { // Property: mesh_surface_mesh_name (deprecated and replaced by mesh_name) if (passValidateProperty(compiler, prop, token[TOKEN_MESH_SURFACE_NAME], VAL_STRING)) { Ogre::String val; if(getString(prop->values.front(), &val)) { emitter->setMeshName(val); return true; } } } else if (prop->name == token[TOKEN_MESH_SURFACE_DISTRIBUTION]) { // Property: mesh_surface_distribution if (passValidateProperty(compiler, prop, token[TOKEN_MESH_SURFACE_DISTRIBUTION], VAL_STRING)) { Ogre::String val; if(getString(prop->values.front(), &val)) { if (val == token[TOKEN_MESH_SURFACE_EDGE]) { emitter->setDistribution(MeshInfo::MSD_EDGE); return true; } else if (val == token[TOKEN_MESH_SURFACE_HETEROGENEOUS_1]) { emitter->setDistribution(MeshInfo::MSD_HETEROGENEOUS_1); return true; } else if (val == token[TOKEN_MESH_SURFACE_HETEROGENEOUS_2]) { emitter->setDistribution(MeshInfo::MSD_HETEROGENEOUS_2); return true; } else if (val == token[TOKEN_MESH_SURFACE_HOMOGENEOUS]) { emitter->setDistribution(MeshInfo::MSD_HOMOGENEOUS); return true; } else if (val == token[TOKEN_MESH_SURFACE_HOMOGENEOUS]) { emitter->setDistribution(MeshInfo::MSD_HOMOGENEOUS); return true; } } } } else if (prop->name == token[TOKEN_MESH_SURFACE_MESH_SCALE]) { // Property: mesh_surface_scale if (passValidateProperty(compiler, prop, token[TOKEN_MESH_SURFACE_MESH_SCALE], VAL_VECTOR3)) { Ogre::Vector3 val; if(getVector3(prop->values.begin(), prop->values.end(), &val)) { emitter->setScale(val); return true; } } } return false; }
//----------------------------------------------------------------------- bool CircleEmitterTranslator::translateChildProperty(ScriptCompiler* compiler, const AbstractNodePtr &node) { PropertyAbstractNode* prop = reinterpret_cast<PropertyAbstractNode*>(node.get()); ParticleEmitter* em = any_cast<ParticleEmitter*>(prop->parent->context); CircleEmitter* emitter = static_cast<CircleEmitter*>(em); if (prop->name == token[TOKEN_RADIUS]) { // Property: radius if (passValidateProperty(compiler, prop, token[TOKEN_RADIUS], VAL_REAL)) { Real val = 0.0f; if(getReal(prop->values.front(), &val)) { emitter->setRadius(val); return true; } } } else if (prop->name == token[TOKEN_CIRCLE_RADIUS]) { // Property: circle_em_radius (deprecated and replaced by radius) if (passValidateProperty(compiler, prop, token[TOKEN_CIRCLE_RADIUS], VAL_REAL)) { Real val = 0.0f; if(getReal(prop->values.front(), &val)) { emitter->setRadius(val); return true; } } } else if (prop->name == token[TOKEN_STEP]) { // Property: step if (passValidateProperty(compiler, prop, token[TOKEN_STEP], VAL_REAL)) { Real val = 0.0f; if(getReal(prop->values.front(), &val)) { emitter->setStep(val); return true; } } } else if (prop->name == token[TOKEN_CIRCLE_STEP]) { // Property: circle_em_step (deprecated and replaced by 'step') if (passValidateProperty(compiler, prop, token[TOKEN_CIRCLE_STEP], VAL_REAL)) { Real val = 0.0f; if(getReal(prop->values.front(), &val)) { emitter->setStep(val); return true; } } } else if (prop->name == token[TOKEN_ANGLE]) { // Property: angle if (passValidateProperty(compiler, prop, token[TOKEN_ANGLE], VAL_REAL)) { Real val = 0.0f; if(getReal(prop->values.front(), &val)) { emitter->setCircleAngle(val); return true; } } } else if (prop->name == token[TOKEN_CIRCLE_ANGLE]) { // Property: circle_em_angle if (passValidateProperty(compiler, prop, token[TOKEN_CIRCLE_ANGLE], VAL_REAL)) { Real val = 0.0f; if(getReal(prop->values.front(), &val)) { emitter->setCircleAngle(val); return true; } } } else if (prop->name == token[TOKEN_EMIT_RANDOM]) { // Property: emit_random if (passValidateProperty(compiler, prop, token[TOKEN_EMIT_RANDOM], VAL_BOOL)) { bool val; if(getBoolean(prop->values.front(), &val)) { emitter->setRandom(val); return true; } } } else if (prop->name == token[TOKEN_CIRCLE_RANDOM]) { // Property: circle_em_random (deprecated and replaced by 'emit_random')) if (passValidateProperty(compiler, prop, token[TOKEN_CIRCLE_RANDOM], VAL_BOOL)) { bool val; if(getBoolean(prop->values.front(), &val)) { emitter->setRandom(val); return true; } } } else if (prop->name == token[TOKEN_NORMAL]) { // Property: normal { Vector3 val; if(getVector3(prop->values.begin(), prop->values.end(), &val)) { emitter->setNormal(val); return true; } } } else if (prop->name == token[TOKEN_CIRCLE_NORMAL]) { // Property: circle_em_normal (deprecated and replaced by 'normal') { Vector3 val; if(getVector3(prop->values.begin(), prop->values.end(), &val)) { emitter->setNormal(val); return true; } } } return false; }
//------------------------------------------------------------------------- bool PUBaseForceAffectorTranslator::translateChildProperty( PUScriptCompiler* compiler, PUAbstractNode *node ) { PUPropertyAbstractNode* prop = reinterpret_cast<PUPropertyAbstractNode*>(node); PUAffector* af = static_cast<PUAffector*>(prop->parent->context); PUBaseForceAffector* affector = static_cast<PUBaseForceAffector*>(af); if (prop->name == token[TOKEN_FORCE_VECTOR]) { if (passValidateProperty(compiler, prop, token[TOKEN_FORCE_VECTOR], VAL_VECTOR3)) { Vec3 val; if(getVector3(prop->values.begin(), prop->values.end(), &val)) { affector->setForceVector(val); return true; } } } else if (prop->name == token[TOKEN_FORCE_AFF_VECTOR]) { if (passValidateProperty(compiler, prop, token[TOKEN_FORCE_AFF_VECTOR], VAL_VECTOR3)) { Vec3 val; if(getVector3(prop->values.begin(), prop->values.end(), &val)) { affector->setForceVector(val); return true; } } } else if (prop->name == token[TOKEN_FORCE_APPLICATION]) { if (passValidateProperty(compiler, prop, token[TOKEN_FORCE_APPLICATION], VAL_STRING)) { std::string val; if(getString(*prop->values.front(), &val)) { if (val == token[TOKEN_FORCE_ADD]) { affector->setForceApplication(PUBaseForceAffector::FA_ADD); return true; } else if (val == token[TOKEN_FORCE_AVERAGE]) { affector->setForceApplication(PUBaseForceAffector::FA_AVERAGE); return true; } } } } else if (prop->name == token[TOKEN_FORCE_AFF_APPLICATION]) { if (passValidateProperty(compiler, prop, token[TOKEN_FORCE_AFF_APPLICATION], VAL_STRING)) { std::string val; if(getString(*prop->values.front(), &val)) { if (val == token[TOKEN_FORCE_ADD]) { affector->setForceApplication(PUBaseForceAffector::FA_ADD); return true; } else if (val == token[TOKEN_FORCE_AVERAGE]) { affector->setForceApplication(PUBaseForceAffector::FA_AVERAGE); return true; } } } } return false; }
Vector3 Sound::getDirection() { return getVector3(AL_DIRECTION); }
Vector3 Sound::getVelocity() { return getVector3(AL_VELOCITY); }
void PUTechniqueTranslator::translate(PUScriptCompiler* compiler, PUAbstractNode *node) { PUObjectAbstractNode* obj = reinterpret_cast<PUObjectAbstractNode*>(node); PUObjectAbstractNode* parent = obj->parent ? reinterpret_cast<PUObjectAbstractNode*>(obj->parent) : 0; // Create the technique _system = PUParticleSystem3D::create(); //mTechnique = ParticleSystemManager::getSingletonPtr()->createTechnique(); //if (!mTechnique) //{ // compiler->addError(ScriptCompiler::CE_INVALIDPARAMETERS, obj->file, obj->line); // return; //} if (parent && parent->context) { PUParticleSystem3D* system = static_cast<PUParticleSystem3D*>(parent->context); system->addChild(_system); } //else //{ // // It is an alias // mTechnique->setAliasName(parent->name); // PU 1.4 // ParticleSystemManager::getSingletonPtr()->addAlias(mTechnique); //} _system->setName(obj->name); obj->context = _system; // Add this to the context, because it is needed for the underlying emitters, affectors, ... // Get the name of the technique //if(!obj->name.empty()) // mTechnique->setName(obj->name); 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)) { _system->setEnabled(val); } } } else if (prop->name == token[TOKEN_POSITION]) { // Property: positon if (passValidateProperty(compiler, prop, token[TOKEN_POSITION], VAL_VECTOR3)) { Vec3 val; if(getVector3(prop->values.begin(), prop->values.end(), &val)) { _system->setPosition3D(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)) { _system->setKeepLocal(val); } } } else if (prop->name == token[TOKEN_TECH_VISUAL_PARTICLE_QUOTA]) { // Property: visual_particle_quota if (passValidateProperty(compiler, prop, token[TOKEN_TECH_VISUAL_PARTICLE_QUOTA], VAL_UINT)) { unsigned int val = 0; if(getUInt(*prop->values.front(), &val)) { _system->setParticleQuota(val); } } } else if (prop->name == token[TOKEN_TECH_EMITTED_EMITTER_QUOTA]) { // Property: emitted_emitter_quota if (passValidateProperty(compiler, prop, token[TOKEN_TECH_EMITTED_EMITTER_QUOTA], VAL_UINT)) { unsigned int val = 0; if(getUInt(*prop->values.front(), &val)) { _system->setEmittedEmitterQuota(val); } } } else if (prop->name == token[TOKEN_TECH_EMITTED_AFFECTOR_QUOTA]) { //// Property: emitted_affector_quota //if (passValidateProperty(compiler, prop, token[TOKEN_TECH_EMITTED_AFFECTOR_QUOTA], VAL_UINT)) //{ // uint val = 0; // if(getUInt(prop->values.front(), &val)) // { // mTechnique->setEmittedAffectorQuota(val); // } //} } else if (prop->name == token[TOKEN_TECH_EMITTED_TECHNIQUE_QUOTA]) { // Property: emitted_technique_quota if (passValidateProperty(compiler, prop, token[TOKEN_TECH_EMITTED_TECHNIQUE_QUOTA], VAL_UINT)) { unsigned int val = 0; if(getUInt(*prop->values.front(), &val)) { _system->setEmittedSystemQuota(val); } } } else if (prop->name == token[TOKEN_TECH_EMITTED_SYSTEM_QUOTA]) { //// Property: emitted_system_quota //if (passValidateProperty(compiler, prop, token[TOKEN_TECH_EMITTED_SYSTEM_QUOTA], VAL_UINT)) //{ // uint val = 0; // if(getUInt(prop->values.front(), &val)) // { // mTechnique->setEmittedSystemQuota(val); // } //} } else if (prop->name == token[TOKEN_MATERIAL]) { // Property: material if (passValidateProperty(compiler, prop, token[TOKEN_MATERIAL], VAL_STRING)) { std::string val; if(getString(*prop->values.front(), &val)) { _system->setMaterialName(val); PUMaterial *material = PUMaterialCache::Instance()->getMaterial(val); if (material){ _system->setBlendFunc(material->blendFunc); } } } } else if (prop->name == token[TOKEN_TECH_LOD_INDEX]) { //// Property: lod_index //if (passValidateProperty(compiler, prop, token[TOKEN_TECH_LOD_INDEX], VAL_UINT)) //{ // uint val = 0; // if(getUInt(prop->values.front(), &val)) // { // mTechnique->setLodIndex(val); // } //} } else if (prop->name == token[TOKEN_TECH_DEFAULT_PARTICLE_WIDTH]) { // Property: default_particle_width if (passValidateProperty(compiler, prop, token[TOKEN_TECH_DEFAULT_PARTICLE_WIDTH], VAL_REAL)) { float val = 0.0f; if(getFloat(*prop->values.front(), &val)) { _system->setDefaultWidth(val); } } } else if (prop->name == token[TOKEN_TECH_DEFAULT_PARTICLE_HEIGHT]) { // Property: default_particle_height if (passValidateProperty(compiler, prop, token[TOKEN_TECH_DEFAULT_PARTICLE_HEIGHT], VAL_REAL)) { float val = 0.0f; if(getFloat(*prop->values.front(), &val)) { _system->setDefaultHeight(val); } } } else if (prop->name == token[TOKEN_TECH_DEFAULT_PARTICLE_DEPTH]) { // Property: default_particle_depth if (passValidateProperty(compiler, prop, token[TOKEN_TECH_DEFAULT_PARTICLE_DEPTH], VAL_REAL)) { float val = 0.0f; if(getFloat(*prop->values.front(), &val)) { _system->setDefaultDepth(val); } } } else if (prop->name == token[TOKEN_TECH_SPHASHING_CELL_DIMENSION]) { //// Property: spatial_hashing_cell_dimension //if (passValidateProperty(compiler, prop, token[TOKEN_TECH_SPHASHING_CELL_DIMENSION], VAL_UINT)) //{ // unsigned int val = 0; // if(getUInt(prop->values.front(), &val)) // { // mTechnique->setSpatialHashingCellDimension(val); // } //} } else if (prop->name == token[TOKEN_TECH_SPHASHING_CELL_OVERLAP]) { //// Property: spatial_hashing_cell_overlap //if (passValidateProperty(compiler, prop, token[TOKEN_TECH_SPHASHING_CELL_OVERLAP], VAL_UINT)) //{ // unsigned int val = 0; // if(getUInt(prop->values.front(), &val)) // { // mTechnique->setSpatialHashingCellOverlap(val); // } //} } else if (prop->name == token[TOKEN_TECH_SPHASHING_SIZE]) { //// Property: spatial_hashtable_size //if (passValidateProperty(compiler, prop, token[TOKEN_TECH_SPHASHING_SIZE], VAL_UINT)) //{ // unsigned int val = 0; // if(getUInt(prop->values.front(), &val)) // { // mTechnique->setSpatialHashTableSize(val); // } //} } else if (prop->name == token[TOKEN_TECH_SPHASHING_UPDATE_INTERVAL]) { //// Property: spatial_hashing_update_interval //if (passValidateProperty(compiler, prop, token[TOKEN_TECH_SPHASHING_UPDATE_INTERVAL], VAL_REAL)) //{ // float val = 0.0f; // if(getReal(prop->values.front(), &val)) // { // mTechnique->setSpatialHashingInterval(val); // } //} } else if (prop->name == token[TOKEN_TECH_MAX_VELOCITY]) { // Property: max_velocity if (passValidateProperty(compiler, prop, token[TOKEN_TECH_MAX_VELOCITY], VAL_REAL)) { float val = 0.0f; if(getFloat(*prop->values.front(), &val)) { _system->setMaxVelocity(val); } } } else if (prop->name == token[TOKEN_USE_ALIAS]) { //// Property: use_alias //if (passValidateProperty(compiler, prop, token[TOKEN_USE_ALIAS], VAL_STRING)) //{ // String val; // if(getString(prop->values.front(), &val)) // { // IAlias* alias = ParticleSystemManager::getSingletonPtr()->getAlias(val); // switch (alias->getAliasType()) // { // case IAlias::AT_RENDERER: // { // ParticleRenderer* renderer = static_cast<ParticleRenderer*>(alias); // ParticleRenderer* newRenderer = ParticleSystemManager::getSingletonPtr()->cloneRenderer(renderer); // mTechnique->setRenderer(newRenderer); // } // break; // // case IAlias::AT_EMITTER: // { // ParticleEmitter* emitter = static_cast<ParticleEmitter*>(alias); // ParticleEmitter* newEmitter = ParticleSystemManager::getSingletonPtr()->cloneEmitter(emitter); // mTechnique->addEmitter(newEmitter); // } // break; // // case IAlias::AT_AFFECTOR: // { // ParticleAffector* affector = static_cast<ParticleAffector*>(alias); // ParticleAffector* newAffector = ParticleSystemManager::getSingletonPtr()->cloneAffector(affector); // mTechnique->addAffector(newAffector); // } // break; // // case IAlias::AT_OBSERVER: // { // ParticleObserver* observer = static_cast<ParticleObserver*>(alias); // ParticleObserver* newObserver = ParticleSystemManager::getSingletonPtr()->cloneObserver(observer); // mTechnique->addObserver(newObserver); // } // break; // // case IAlias::AT_EXTERN: // { // Extern* externObject = static_cast<Extern*>(alias); // Extern* newExternObject = ParticleSystemManager::getSingletonPtr()->cloneExtern(externObject); // mTechnique->addExtern(newExternObject); // } // break; // // case IAlias::AT_BEHAVIOUR: // { // ParticleBehaviour* behaviour = static_cast<ParticleBehaviour*>(alias); // ParticleBehaviour* newBehaviour = ParticleSystemManager::getSingletonPtr()->cloneBehaviour(behaviour); // mTechnique->_addBehaviourTemplate(newBehaviour); // } // break; // } // } //} } else { errorUnexpectedProperty(compiler, prop); } } else if((*i)->type == ANT_OBJECT) { //ObjectAbstractNode* child = reinterpret_cast<ObjectAbstractNode*>((*i).get()); //if (child->cls == token[TOKEN_CAMERA_DEPENDENCY]) //{ // // Property: camera_dependency // CameraDependency* cameraDependency = PU_NEW_T(CameraDependency, MEMCATEGORY_SCRIPTING)(); // child->context = Any(cameraDependency); // CameraDependencyTranslator cameraDependencyTranslator; // cameraDependencyTranslator.translate(compiler, *i); // Real threshold = cameraDependency->getThreshold(); // bool increase = cameraDependency->isIncrease(); // if (child->name == token[TOKEN_TECH_DEFAULT_PARTICLE_WIDTH]) // { // mTechnique->setWidthCameraDependency(threshold * threshold, increase); // } // else if (child->name == token[TOKEN_TECH_DEFAULT_PARTICLE_HEIGHT]) // { // mTechnique->setHeightCameraDependency(threshold * threshold, increase); // } // else if (child->name == token[TOKEN_TECH_DEFAULT_PARTICLE_DEPTH]) // { // mTechnique->setDepthCameraDependency(threshold * threshold, increase); // } // // Delete the camera dependency // PU_DELETE_T(cameraDependency, CameraDependency, MEMCATEGORY_SCRIPTING); //} //else { processNode(compiler, *i); } } else { errorUnexpectedToken(compiler, *i); } } }