void DiEditorManager::SaveAll(const DiString& fxFileName) { DiFxTokensParser parser; shared_ptr<DiXMLFile> xmlfile(new DiXMLFile()); DiXMLElement root = xmlfile->CreateRoot("Effects"); mRootObject->TraversalChildren([&](size_t id, DiBaseEditorObj* obj){ if(obj->GetType() == "ParticleSystem") { auto psObj = dynamic_cast<DiParticleSystemObj*>(obj); DiParticleSystemPtr ps = psObj->GetParticleSystem(); auto nd = root.CreateChild("ParticleSystem"); parser.WriteSystem(ps, nd); } else if(obj->GetType() == "ReferenceModel") { auto refmdObj = dynamic_cast<DiRefModelObj*>(obj); refmdObj->Save(root); } }); xmlfile->Save(fxFileName); SetCurrentFileName(fxFileName); }
void SceneEditorSceneUpdateManager::StepSceneNode(SceneNode &node, double deltaTimeInSeconds, SceneCullingManager &cullingManager) { // We need to orientate any sprites to face the camera. auto metadata = node.GetComponent<EditorMetadataComponent>(); if (metadata != nullptr) { if (metadata->IsUsingSprite()) { metadata->UpdateSpriteTransform(this->cameraNode); } // If we have dynamics or proximity component, we should update the wireframe meshes. if (metadata->IsSelected()) { if (node.HasComponent<DynamicsComponent>()) { metadata->UpdateCollisionShapeMeshGeometry(this->cameraNode); } if (node.HasComponent<ProximityComponent>()) { metadata->UpdateProximityShapeMeshGeometry(this->cameraNode); } } } if (!this->isSceneUpdatesPaused) { if (this->isEnabled) { DefaultSceneUpdateManager::StepSceneNode(node, deltaTimeInSeconds, cullingManager); } else { // If the particles are being updated, we should do that now. if (this->isParticlesEnabled) { auto particleSystemComponent = node.GetComponent<ParticleSystemComponent>(); if (particleSystemComponent != nullptr) { if (particleSystemComponent->IsPlayingOnStartup()) // Prevents particles from playing in-editor when not playing on startup. Unlikely deseriable. { auto particleSystem = particleSystemComponent->GetParticleSystem(); if (particleSystem != nullptr) { particleSystem->Update(deltaTimeInSeconds); cullingManager.UpdateParticleSystemAABB(node); } } } } } } }
void DiEditorManager::SetCurrentSelection(DiBaseEditorObj* sel) { if (mCurrentSel != sel) { mCurrentSel = sel; SetGizmoMode(mGlobalGizmoMode); auto psParent = mCurrentSel->LookForParent("ParticleSystem"); if(!psParent) return; auto psObj = dynamic_cast<DiParticleSystemObj*>(psParent); mSelectingFx = psObj->GetParticleSystem(); DI_DEBUG("Change selecting ps to [name = %s]", mSelectingFx->GetName().c_str()); } }