void CParticleEditor::pause(CWorkspaceNode &node) { if (!isRunning(&node)) return; nlassert(node.isLoaded()); node.getPSModel()->enableAutoGetEllapsedTime(false); node.getPSModel()->setEllapsedTime(0.f); }
void CParticleEditor::play(CWorkspaceNode &node) { if (isRunning(&node)) return; // NB : node must be stopped, no check is done nlassert(node.isLoaded()); // if node not started, start it node.memorizeState(); // enable the system to take the right date from the scene node.getPSModel()->enableAutoGetEllapsedTime(true); node.getPSPointer()->setSystemDate(0.f); node.getPSPointer()->reactivateSound(); node.getPSModel()->activateEmitters(true); if (node.getPSPointer()->getAutoCountFlag()) { if (node.getResetAutoCountFlag()) { // reset particle size arrays node.getPSPointer()->matchArraySize(); } resetAutoCount(&node, false); } // Set speed playback particle system node.getPSModel()->setEllapsedTimeRatio(_Speed); }
void CParticleEditor::stop(CWorkspaceNode &node) { if (!isRunning(&node)) return; nlassert(node.isLoaded()); node.restoreState(); node.getPSModel()->enableAutoGetEllapsedTime(false); node.getPSModel()->setEllapsedTime(0.f); node.getPSModel()->activateEmitters(true); node.getPSPointer()->stopSound(); }
NL3D::CParticleSystemModel *CParticleEditor::getModelFromPS(NL3D::CParticleSystem *ps) const { if (!ps) return NULL; CWorkspaceNode *node = _PW->getNodeFromPS(ps); if (!node) return NULL; return node->getPSModel(); }
void CParticleEditor::setSpeed(float value) { _Speed = value; if (!isRunning()) return; TPWNodeItr itr = _PW->getNodeList().begin(); while(itr != _PW->getNodeList().end()) { CWorkspaceNode *node = (*itr); if (node->isLoaded()) node->getPSModel()->setEllapsedTimeRatio(value); itr++; } }
void CParticleEditor::update() { if (!_ActiveNode) return; if (_PW == NULL) return; NL3D::CParticleSystem *currPS = _ActiveNode->getPSPointer(); // compute BBox if (_DisplayBBox) { if (_AutoUpdateBBox) { NLMISC::CAABBox currBBox; currPS->forceComputeBBox(currBBox); if (_EmptyBBox) { _EmptyBBox = false; _CurrBBox = currBBox; } else { _CurrBBox = NLMISC::CAABBox::computeAABBoxUnion(currBBox, _CurrBBox); } currPS->setPrecomputedBBox(_CurrBBox); } } // auto repeat feature if (_AutoRepeat) { if (isRunning()) { bool allFXFinished = true; bool fxStarted = false; TPWNodeItr itr = _PlayingNodes.begin(); while(itr != _PlayingNodes.end()) { CWorkspaceNode *node = (*itr); if (node->isLoaded()) { if (isRunning(node)) { fxStarted = true; if (node->getPSPointer()->getSystemDate() <= node->getPSPointer()->evalDuration()) { allFXFinished = false; break; } else { if (node->getPSPointer()->getCurrNumParticles() != 0) { allFXFinished = false; break; } } } } itr++; } if (fxStarted && allFXFinished) restartAllFX(); } } // draw PSmodel TPWNodeItr itr = _PW->getNodeList().begin(); while(itr != _PW->getNodeList().end()) { CWorkspaceNode *node = (*itr); if (node->isLoaded()) { if (node == _ActiveNode) node->getPSModel()->enableDisplayTools(!isRunning(node) || _DisplayHelpers); else node->getPSModel()->enableDisplayTools(false); // hide / show the node if (_State == State::RunningMultiple || _State == State::PausedMultiple) { if (isRunning(node)) node->getPSModel()->show(); else node->getPSModel()->hide(); } else { if (node == _ActiveNode) node->getPSModel()->show(); else node->getPSModel()->hide(); } } itr++; } }