void MLevel::changeCurrentScene(unsigned int id) { if(id == m_currentSceneId) return; MEngine * engine = MEngine::getInstance(); if(id < getScenesNumber()) { MScene * scene = getCurrentScene(); // onEndScene MGame * game = engine->getGame(); if(game) game->onEndScene(); // change scene setCurrentSceneId(id); scene = getCurrentScene(); // onBeginScene if(game) game->onBeginScene(); } }
void BaseScene::debugPrint(std::string output){ static Label* label = nullptr; static BaseScene *thisScene = nullptr; if(label == nullptr || thisScene != getCurrentScene()){ label = Label::createWithSystemFont(output, "Arial", 24, Size(E::visibleWidth, 48), TextHAlignment::LEFT, TextVAlignment::BOTTOM); label->setPosition(24, 24); label->setAnchorPoint(Vec2(0, 0)); label->enableShadow(Color4B(0, 0, 0, 128), Size(1, -1)); getCurrentScene()->addChild(label, 10000); thisScene = getCurrentScene(); } label->setString(output); };
void Director::getKeyState() { getCurrentScene()->clearKeys(); if (_keyList.size()) { for (vector<int>::iterator it = _keyList.begin(); it != _keyList.end(); it++) { if (GetAsyncKeyState((*it)) & 0x8000) { getCurrentScene()->onKeyPressedCallback((*it)); } } } int LBUTTONState = GetAsyncKeyState(VK_LBUTTON) & 0x8000; mouseEvent _event; if (LBUTTONState) { if (lastLBUTTONState) { _event.type = DRAG; } else { _event.type = DOWN; } } else { if (lastLBUTTONState) { _event.type = UP; } else { _event.type = MOVE; } } _event.point = POINT2Point(_mousepos); lastLBUTTONState = LBUTTONState; EventMsg msg; msg._event = _event; msg.name = "test"; raiseEvent(msg); raiseMouseEvent(_event); }
void TApp::autosave() { ToonzScene *scene = getCurrentScene()->getScene(); if (!getCurrentScene()->getDirtyFlag()) return; if (getCurrentTool()->isToolBusy()) { m_autosaveSuspended = true; return; } else m_autosaveSuspended = false; if (scene->isUntitled()) { DVGui::warning( tr("It is not possible to save automatically an untitled scene.")); return; } DVGui::ProgressDialog pb( "Autosaving scene..." + toQString(scene->getScenePath()), 0, 0, 1); pb.show(); IoCmd::saveScene(); pb.setValue(1); }
void TApp::onLevelColorStyleChanged() { onPaletteChanged(); TXshLevel *level = m_currentLevel->getLevel(); if (!level) return; TPalette *palette = getCurrentPalette()->getPalette(); TXshSimpleLevel *simpleLevel = level->getSimpleLevel(); if (simpleLevel && simpleLevel->getPalette() == palette) { notifyPaletteChanged(simpleLevel); } else { TLevelSet *levelSet = getCurrentScene()->getScene()->getLevelSet(); for (int i = 0; i < levelSet->getLevelCount(); i++) { if (levelSet->getLevel(i)) { simpleLevel = levelSet->getLevel(i)->getSimpleLevel(); if (simpleLevel && simpleLevel->getPalette() == palette) { notifyPaletteChanged(simpleLevel); } } } } }
void Scenery3d::setEnableScene(const bool enable) { if(enable && ! getCurrentScene().isValid) { //check if a default scene is set and load that QString id = getDefaultScenery3dID(); if(!id.isEmpty()) { if(!currentLoadScene.isValid) loadScenery3dByID(id); return; } else { flagEnabled = false; showMessage(q_("Please load a scene first!")); emit enableSceneChanged(false); } } if(enable!=flagEnabled) { flagEnabled=enable; if (renderer->getCubemapSize()==0) { //TODO FS: remove this? if (flagEnabled) { oldProjectionType= StelApp::getInstance().getCore()->getCurrentProjectionType(); StelApp::getInstance().getCore()->setCurrentProjectionType(StelCore::ProjectionPerspective); } else StelApp::getInstance().getCore()->setCurrentProjectionType(oldProjectionType); } emit enableSceneChanged(flagEnabled); } }
void MLevel::setCurrentSceneId(unsigned int id) { if(id == m_currentSceneId) { updateQueueDatas(); return; } // previous scene MScene * scene = getCurrentScene(); if(scene->getDataMode() == M_DATA_DYNAMIC || scene->getDataMode() == M_DATA_STREAM) { // meshs unsigned int i; unsigned int eSize = scene->getEntitiesNumber(); for(i=0; i<eSize; i++) { MOEntity * entity = scene->getEntityByIndex(i); MMesh * mesh = entity->getMesh(); if(mesh) { // textures unsigned int t; unsigned int tSize = mesh->getTexturesNumber(); for(t=0; t<tSize; t++) { MTextureRef * ref = mesh->getTexture(t)->getTextureRef(); decrDataRefScore(ref); } // armature anim { MArmatureAnimRef * ref = mesh->getArmatureAnimRef(); decrDataRefScore(ref); } // textures anim { MTexturesAnimRef * ref = mesh->getTexturesAnimRef(); decrDataRefScore(ref); } // materials anim { MMaterialsAnimRef * ref = mesh->getMaterialsAnimRef(); decrDataRefScore(ref); } } // mesh MMeshRef * ref = entity->getMeshRef(); decrDataRefScore(ref); } // sounds unsigned int sSize = scene->getSoundsNumber(); for(i=0; i<sSize; i++) { MOSound * sound = scene->getSoundByIndex(i); MSoundRef * ref = sound->getSoundRef(); decrDataRefScore(ref); } // clear queue data clearQueueDatas(); } // change current id m_currentSceneId = id; // next scene scene = getCurrentScene(); if(scene->getDataMode() == M_DATA_DYNAMIC || scene->getDataMode() == M_DATA_STREAM) { // meshs unsigned int i; unsigned int eSize = scene->getEntitiesNumber(); for(i=0; i<eSize; i++) { MOEntity * entity = scene->getEntityByIndex(i); MMesh * mesh = entity->getMesh(); if(mesh) { // textures unsigned int t; unsigned int tSize = mesh->getTexturesNumber(); for(t=0; t<tSize; t++) { MTextureRef * ref = mesh->getTexture(t)->getTextureRef(); incrDataRefScore(ref); } // armature anim { MArmatureAnimRef * ref = mesh->getArmatureAnimRef(); incrDataRefScore(ref); } // textures anim { MTexturesAnimRef * ref = mesh->getTexturesAnimRef(); incrDataRefScore(ref); } // materials anim { MMaterialsAnimRef * ref = mesh->getMaterialsAnimRef(); incrDataRefScore(ref); } } // mesh MMeshRef * ref = entity->getMeshRef(); incrDataRefScore(ref); } // sounds unsigned int sSize = scene->getSoundsNumber(); for(i=0; i<sSize; i++) { MOSound * sound = scene->getSoundByIndex(i); MSoundRef * ref = sound->getSoundRef(); incrDataRefScore(ref); } } // updateQueueData updateQueueDatas(); }
bool NxuPhysicsExport::Write(NxJoint *j,const char *userProperties,const char *id) { bool ret = false; NxSceneDesc *current = getCurrentScene(); CustomCopy cc(mCollection,current); NxJointDesc *joint = 0; switch ( j->getType() ) { case NX_JOINT_PRISMATIC: if ( 1 ) { ::NxPrismaticJointDesc d1; NxPrismaticJoint *sj = j->isPrismaticJoint(); sj->saveToDesc(d1); addActor( d1.actor[0] ); addActor( d1.actor[1] ); NxPrismaticJointDesc *desc = new NxPrismaticJointDesc; desc->copyFrom(d1,cc); joint = static_cast<NxJointDesc *>(desc); } break; case NX_JOINT_REVOLUTE: if ( 1 ) { ::NxRevoluteJointDesc d1; NxRevoluteJoint *sj = j->isRevoluteJoint(); sj->saveToDesc(d1); addActor( d1.actor[0] ); addActor( d1.actor[1] ); NxRevoluteJointDesc *desc = new NxRevoluteJointDesc; desc->copyFrom(d1,cc); joint = static_cast<NxJointDesc *>(desc); } break; case NX_JOINT_CYLINDRICAL: if ( 1 ) { ::NxCylindricalJointDesc d1; NxCylindricalJoint *sj = j->isCylindricalJoint(); sj->saveToDesc(d1); addActor( d1.actor[0] ); addActor( d1.actor[1] ); NxCylindricalJointDesc *desc = new NxCylindricalJointDesc; desc->copyFrom(d1,cc); joint = static_cast<NxJointDesc *>(desc); } break; case NX_JOINT_SPHERICAL: if ( 1 ) { ::NxSphericalJointDesc d1; NxSphericalJoint *sj = j->isSphericalJoint(); sj->saveToDesc(d1); addActor( d1.actor[0] ); addActor( d1.actor[1] ); NxSphericalJointDesc *desc = new NxSphericalJointDesc; desc->copyFrom(d1,cc); joint = static_cast<NxJointDesc *>(desc); } break; case NX_JOINT_POINT_ON_LINE: if ( 1 ) { ::NxPointOnLineJointDesc d1; NxPointOnLineJoint *sj = j->isPointOnLineJoint(); sj->saveToDesc(d1); addActor( d1.actor[0] ); addActor( d1.actor[1] ); NxPointOnLineJointDesc *desc = new NxPointOnLineJointDesc; desc->copyFrom(d1,cc); joint = static_cast<NxJointDesc *>(desc); } break; case NX_JOINT_POINT_IN_PLANE: if ( 1 ) { ::NxPointInPlaneJointDesc d1; NxPointInPlaneJoint *sj = j->isPointInPlaneJoint(); sj->saveToDesc(d1); addActor( d1.actor[0] ); addActor( d1.actor[1] ); NxPointInPlaneJointDesc *desc = new NxPointInPlaneJointDesc; desc->copyFrom(d1,cc); joint = static_cast<NxJointDesc *>(desc); } break; case NX_JOINT_DISTANCE: if ( 1 ) { ::NxDistanceJointDesc d1; NxDistanceJoint *sj = j->isDistanceJoint(); sj->saveToDesc(d1); addActor( d1.actor[0] ); addActor( d1.actor[1] ); NxDistanceJointDesc *desc = new NxDistanceJointDesc; desc->copyFrom(d1,cc); joint = static_cast<NxJointDesc *>(desc); } break; case NX_JOINT_PULLEY: if ( 1 ) { ::NxPulleyJointDesc d1; NxPulleyJoint *sj = j->isPulleyJoint(); sj->saveToDesc(d1); addActor( d1.actor[0] ); addActor( d1.actor[1] ); NxPulleyJointDesc *desc = new NxPulleyJointDesc; desc->copyFrom(d1,cc); joint = static_cast<NxJointDesc *>(desc); } break; case NX_JOINT_FIXED: if ( 1 ) { ::NxFixedJointDesc d1; NxFixedJoint *sj = j->isFixedJoint(); sj->saveToDesc(d1); addActor( d1.actor[0] ); addActor( d1.actor[1] ); NxFixedJointDesc *desc = new NxFixedJointDesc; desc->copyFrom(d1,cc); joint = static_cast<NxJointDesc *>(desc); } break; case NX_JOINT_D6: if ( 1 ) { ::NxD6JointDesc d1; NxD6Joint *sj = j->isD6Joint(); sj->saveToDesc(d1); addActor( d1.actor[0] ); addActor( d1.actor[1] ); NxD6JointDesc *desc = new NxD6JointDesc; desc->copyFrom(d1,cc); joint = static_cast<NxJointDesc *>(desc); } break; default: break; } //Add Limits // in addition, we also have to write out its limit planes! j->resetLimitPlaneIterator(); if (j->hasMoreLimitPlanes()) { // write limit point joint->mOnActor2 = j->getLimitPoint(joint->mPlaneLimitPoint); NxArray< NxPlaneInfoDesc *> plist; // write the plane normals while (j->hasMoreLimitPlanes()) { NxPlaneInfoDesc *pInfo = new NxPlaneInfoDesc(); #if NX_SDK_VERSION_NUMBER >= 272 j->getNextLimitPlane(pInfo->mPlaneNormal, pInfo->mPlaneD, &pInfo->restitution); #else j->getNextLimitPlane(pInfo->mPlaneNormal, pInfo->mPlaneD); #endif plist.push_back(pInfo); } if ( plist.size() ) { for (int i=plist.size()-1; i>=0; i--) { NxPlaneInfoDesc *p = plist[i]; joint->mPlaneInfo.pushBack(p); } } } if ( joint ) { if ( id ) { joint->mId = id; } else { char scratch[512]; sprintf(scratch,"Joint_%d", current->mJoints.size()); joint->mId = getGlobalString(scratch); joint->mUserProperties = getGlobalString(userProperties); } current->mJoints.push_back(joint); ret = true; } return ret; }
void Director::raiseMouseEvent(mouseEvent _event) { getCurrentScene()->processMouseEvent(_event); }