void ClientApplication::Proc() { LoadScene(SceneList::FIRST); //prepare the time system typedef std::chrono::steady_clock Clock; Clock::time_point simTime = Clock::now(); Clock::time_point realTime; //The main loop while(activeScene->GetNextScene() != SceneList::QUIT) { //switch scenes when necessary if (activeScene->GetNextScene() != SceneList::CONTINUE) { LoadScene(activeScene->GetNextScene()); continue; } //update the current time realTime = Clock::now(); //simulate game time while (simTime < realTime) { //call each user defined function activeScene->RunFrame(); //~60 FPS simTime += std::chrono::duration<int, std::milli>(16); } //draw the game to the screen activeScene->RenderFrame(); } UnloadScene(); }
//------------------------------------------------------------------------- // 切换Scene void EventBridge::__SwitchScene(int nTag) { FKCW_SceneExMgr_SceneExMgr* pSceneSystem = GetSceneSystem(); if (pSceneSystem == NULL) { return; } switch (nTag) { case eSubSceneType_Login: pSceneSystem->pushScene(LoadScene("CLoginScene") ); break; case eSubSceneType_Play: pSceneSystem->pushScene(LoadScene("CPlayTestScene") ); break; case eSubSceneType_Shop: pSceneSystem->pushScene(LoadScene("CShopTestScene") ); break; case eSubSceneType_Achie: pSceneSystem->pushScene(LoadScene("CAchieTestScene") ); break; default: break; } }
JNIEXPORT jint JNICALL Java_net_airtheva_assdroid_Native_LoadScene(JNIEnv* env, jclass thiz, jstring jPath) { std::string path; path.append(env->GetStringUTFChars(jPath, NULL)); uint sceneKey = LoadScene(&path); return sceneKey; }
bool FBXScene::Init(const char* fileName, Vector3& minPos, Vector3& maxPos) { // Create the entity that will hold the scene. mScene = FbxScene::Create(mSdkManager,""); if(!mScene) return false; // Cache Scene if ( !LoadCachedScene(fileName, this, minPos, maxPos) ) { std::stringstream ss; if ( !LoadScene(fileName, ss, minPos, maxPos) ) { return false; } CacheScene(fileName, this); } else { mFilename = fileName; } return true; }
int MySGLEngine::SetupScene() { glfwMakeContextCurrent(window); if ( LoadScene(scene1, scenefilename) != 0) return 1; // Set initial camera position scene1.camPosition.x = -50; scene1.camPosition.y = 30; scene1.camPosition.z = -40; scene1.camRotY = 0.00; // scene1.camRotY = 1.00; // scene1.objects.back().currentVel = glm::vec3(0.0,16.0,40.0); scene1.objects.back().currentVel = glm::vec3(0.0,0.0,0.0); for (auto &obj : scene1.objects) { obj.gravG = -9.81; obj.gravMass = 10.0*rand()/(float)RAND_MAX + 2.0; obj.physGrav = false; obj.doColl = false; } scene1.objects.back().doColl = true; scene1.objects.back().physGrav = false; scene1.objects.back().gravMass = 1000.0; return 0; }
bool AppDelegate::applicationDidFinishLaunching() { // initialize director auto director = Director::getInstance(); auto glview = director->getOpenGLView(); if(!glview) { glview = GLView::createWithRect("HelloTuiCpp", Rect(0, 0, 800, 480)); director->setOpenGLView(glview); } //glview->setDesignResolutionSize(size.width,size.height,ResolutionPolicy::NO_BORDER); // turn on display FPS director->setDisplayStats(true); director->setAnimationInterval(1.0 / 60); //regist scene ResoureMgr::getInstance()->registScene(); // use spriteframe to create component TuiManager::getInstance()->setUseSpriteFrame(true); // run CSceneManager::getInstance()->runWithScene(LoadScene("Welcome::Welcomeui")); return true; }
void HandleBarcode(){ //save if(barcode == 0) SaveScene(); //load else if(barcode == 1) LoadScene(); //add cube else if(barcode == 2){ OpenGLObject another_obj; another_obj.translate_object(0, objects.size()*10, 0); objects.push_back(another_obj); } //delete cube else if(barcode == 3){ //prompt them to make sure they're sure cout << "\n***ARE YOU SURE YOU WANT TO DELETE CURRENTLY SELECTED OBJECT?***\n\n"; string answer; cin >> answer; if(answer == "Yes" || answer == "yes" || answer == "y"){ //only let them do it if they have more than one cube on the screen if(objects.size() > 1){ for(int i=0; i < objects.size(); i++) objects[i].reset_colors(); control_mode = 0; mode = 0; objects.erase(objects.begin() + object_selection); object_selection = 0; } } }
void ShowPhoneui::event_menu_phone(Ref* pSender) { Node* node = (Node*)pSender; CCLOG("tag %d", node->getTag()); CSceneManager::getInstance()->replaceScene( CCSceneExTransitionFade::create(0.5f, LoadScene("Main::Mainui"))); }
bool gltfPackage::load (const std::string &fn) { assert( !_scene ) ; auto pMgr =fbxSdkMgr::Instance ()->fbxMgr () ; _scene.Reset (FbxScene::Create (pMgr, (gltfPackage::filename (fn)).c_str ())) ; assert( !!_scene ) ; bool bRet =LoadScene (fn) ; return (bRet) ; }
Scene_Mgr* Scene_Mgr::instance() { LoadScene(); if(_scene_mgr==NULL) _scene_mgr=new Scene_Mgr; return _scene_mgr; }
static void LoadFloor(DemoEntityManager* const scene, NewtonCollision* const sceneCollision) { NewtonWorld* const world = scene->GetNewton(); // add a flat plane dMatrix matrix (dGetIdentityMatrix()); DemoEntityManager::dListNode* const floorNode = LoadScene(scene, "flatPlane.ngd", matrix); DemoEntity* const entity = floorNode->GetInfo(); DemoMesh* const mesh = (DemoMesh*)entity->GetMesh(); dAssert (mesh->IsType(DemoMesh::GetRttiType())); NewtonCollision* const tree = NewtonCreateTreeCollision(world, 0); NewtonTreeCollisionBeginBuild(tree); dFloat* const vertex = mesh->m_vertex; for (DemoMesh::dListNode* node = mesh->GetFirst(); node; node = node->GetNext()){ DemoSubMesh* const subMesh = &node->GetInfo(); unsigned int* const indices = subMesh->m_indexes; int trianglesCount = subMesh->m_indexCount; for (int i = 0; i < trianglesCount; i += 3) { dVector face[3]; int index = indices[i + 0] * 3; face[0] = dVector (vertex[index + 0], vertex[index + 1], vertex[index + 2]); index = indices[i + 1] * 3; face[1] = dVector (vertex[index + 0], vertex[index + 1], vertex[index + 2]); index = indices[i + 2] * 3; face[2] = dVector (vertex[index + 0], vertex[index + 1], vertex[index + 2]); int matID = 0; //matID = matID == 2 ? 1 : 2 ; NewtonTreeCollisionAddFace(tree, 3, &face[0].m_x, sizeof (dVector), matID); } } NewtonTreeCollisionEndBuild (tree, 1); // add the collision tree to the collision scene void* const proxy = NewtonSceneCollisionAddSubCollision (sceneCollision, tree); // destroy the original tree collision NewtonDestroyCollision (tree); // set the parameter on the added collision share matrix = entity->GetCurrentMatrix(); NewtonCollision* const collisionTree = NewtonSceneCollisionGetCollisionFromNode (sceneCollision, proxy); NewtonSceneCollisionSetSubCollisionMatrix (sceneCollision, proxy, &matrix[0][0]); NewtonCollisionSetUserData(collisionTree, entity); // set the application level callback, for debug display #ifdef USE_STATIC_MESHES_DEBUG_COLLISION NewtonStaticCollisionSetDebugCallback (collisionTree, ShowMeshCollidingFaces); #endif }
CVCDFile::CVCDFile( CScene *scene, char const *filename ) : m_pOwner( scene ) { Q_strncpy( m_szName, filename, sizeof( m_szName ) ); m_pScene = LoadScene( filename ); LoadSoundsFromScene( m_pScene ); m_pszComments = NULL; }
bool RoadScene::init(){ if ( !CCLayer::init() ) { return false; } event=false; LoadScene(); return true; }
bool ofxFBXScene::load(string path){ bool lResult; // Prepare the FBX SDK. InitializeSdkObjects(lSdkManager, lScene); lResult = LoadScene(lSdkManager, lScene, ofToDataPath(path).c_str()); if(!lResult){ ofLogError("ofxFBXScene") << "An error occurred while loading the scene..."; }else if(lScene){ for (int i = 0; i < lScene->GetSrcObjectCount<FbxAnimStack>(); i++) { FbxAnimStack* lAnimStack = FbxCast<FbxAnimStack>(lScene->GetSrcObject<FbxAnimStack>(i)); int l; int nbAnimLayers = lAnimStack->GetMemberCount<FbxAnimLayer>(); /*for (l = 0; l < nbAnimLayers; l++) {*/ if(nbAnimLayers){ FbxAnimLayer* lAnimLayer = lAnimStack->GetMember<FbxAnimLayer>(0); //get root node of the fbx scene FbxNode* lRootNode = lScene->GetRootNode(); parseScene(lRootNode, lAnimLayer,NULL); } } list<ofxFBXCamera>::iterator itCameras; for(itCameras=camerasList.begin();itCameras!=camerasList.end();itCameras++){ cameras.push_back(&(*itCameras)); } list<ofxFBXMesh>::iterator itMeshes; for(itMeshes=meshesList.begin();itMeshes!=meshesList.end();itMeshes++){ meshes.push_back(&(*itMeshes)); } list<ofxFBXNode>::iterator itNulls; for(itNulls=nullsList.begin();itNulls!=nullsList.end();itNulls++){ nulls.push_back(&(*itNulls)); } list<ofxFBXLight>::iterator itLights; for(itLights=lightsList.begin();itLights!=lightsList.end();itLights++){ lights.push_back(&(*itLights)); } }else{ ofLogError("ofxFBXScene") << "Null scene..."; lResult = false; } //Destroy all objects created by the FBX SDK. //DestroySdkObjects(lSdkManager,false); return lResult; }
/*****************Scene**************************/ Scene::Scene() { m_triangles = NULL; LoadScene(); SetTriangle(); vector3 p1 = vector3( 0, 0, 0 ), p2 = vector3( 10, 10, 10 ); m_box = aabb( p1, p2 - p1 ); }
//------------------------------------------------------------ void PPC::LoadScenes( tixmlel_traits::in element, bool replace ) { string_traits::str childName; const TiXmlElement* childElement(0); while( XI::IterateChildElements( element, childElement ) ) { childName = childElement->Value(); if( childName == PK::SCENE ) LoadScene( childElement, replace ); } }
void StartNewScene(SCNHANDLE scene, int entry) { EndScene(); // Wrap up the last scene. if (TinselV2) { TouchMoverReels(); LockMem(scene); // Do CD change before PrimeScene } PrimeScene(); // Start up the standard stuff for the next scene. LoadScene(scene, entry); }
//-------------------------------------------------------- void CListControllerLayer::menuCallback(CCObject * pSender) { CCMenuItem* pMenuItem = (CCMenuItem *)(pSender); int nIdx = pMenuItem->getZOrder() - 10000; // 创建并执行子场景 string szSceneClassName = GetSceneClassName(static_cast<ENUM_TEST_SCENE_TYPE>(nIdx)); if ( szSceneClassName != "" ) { FKCOLORLOG( eConsolBKColor_Gray | eConsolTextColor_Red , "尝试创建 : %s", szSceneClassName.c_str() ); FKCW_SceneExMgr_SceneExMgr::sharedManager()->pushScene(LoadScene(szSceneClassName.c_str())); } }
void test(){ // Create the FBX SDK manager FbxManager* lSdkManager = FbxManager::Create(); // Create an IOSettings object. IOSROOT is defined in Fbxiosettingspath.h. FbxIOSettings * ios = FbxIOSettings::Create(lSdkManager, IOSROOT ); lSdkManager->SetIOSettings(ios); FbxScene* lScene = FbxScene::Create(lSdkManager,"myScene"); LoadScene(lSdkManager, lScene, ios, "sponza.fbx"); }
void MenuScene::onClick(CCObject* sender) { CCMenuItemFont* pFont = (CCMenuItemFont*) sender; switch( pFont->getTag() ) { case 1: { CCSceneManager::sharedManager()->pushScene( CCSceneExTransitionFade::create(1.0f, LoadScene("BasicSceneTest")) ); } break; } }
void VrScene::OneTimeInit( const char * launchIntent ) { LOG( "VrScene::OneTimeInit" ); app->GetStoragePaths().PushBackSearchPathIfValid(EST_SECONDARY_EXTERNAL_STORAGE, EFT_ROOT, "RetailMedia/", SearchPaths); app->GetStoragePaths().PushBackSearchPathIfValid(EST_SECONDARY_EXTERNAL_STORAGE, EFT_ROOT, "", SearchPaths); app->GetStoragePaths().PushBackSearchPathIfValid(EST_PRIMARY_EXTERNAL_STORAGE, EFT_ROOT, "RetailMedia/", SearchPaths); app->GetStoragePaths().PushBackSearchPathIfValid(EST_PRIMARY_EXTERNAL_STORAGE, EFT_ROOT, "", SearchPaths); // Check if we already loaded the model through an intent if ( !ModelLoaded ) { LoadScene( launchIntent ); } }
void GLMesh::Load(std::string filepath) { const aiScene *scene = importer.ReadFile(filepath, aiProcess_Triangulate | aiProcess_GenSmoothNormals | aiProcess_FlipUVs | aiProcess_FindDegenerates); bool result = false; if (scene) { LoadScene(scene); LoadMaterial(scene, filepath); } else { std::cerr << "GLMesh import error " << filepath << std::endl; } }
NS_WELCOME_BEGIN void Welcomeui::onLoadScene() { setAutoRemoveUnusedTexture(true); TuiManager::getInstance()->parseScene(this,"panel_welcome",PATH_WELCOME); this->runAction( Sequence::create( DelayTime::create(1.5f), CallFunc::create( [](){ CSceneManager::getInstance()->replaceScene( CCSceneExTransitionFade::create(0.5f, LoadScene("Main::Mainui"))); }), NULL)); }
bool initScene (std::string sceneName) { LoadScene(sceneName); // Init the scene sofa::simulation::getSimulation()->init(root.get()); // Test if root is not null if(!root) { ADD_FAILURE() << "Error in init for the scene: " << sceneName << std::endl; return false; } return true; }
void CLoadState::Begin() { // Load References SingletonPointer<CMainState> MainState; SingletonPointer<CMainMenuState> MenuState; Canvas = GUIManager->GetCanvas(); // Init Canvas Canvas->SetBackgroundColor(Gwen::Color(32, 48, 48)); Canvas->SetDrawBackground(true); // Top Label Gwen::Controls::Label * BigLabel = new Gwen::Controls::Label(Canvas); BigLabel->SetFont(GUIManager->GetLargeFont()); BigLabel->SetText(L"Loading..."); BigLabel->SetBounds(10, 10, 1590, 300); BigLabel->SetTextColor(Gwen::Color(255, 255, 255, 84)); GUIManager->Draw(0, true); Context->Window->SwapBuffers(); AddLabel(L"Initializing System..."); CGUIEventManager * Forwarder = new CGUIEventManager(GUIManager->GetCanvas(), Context->Window); AddLabel(L"Loading Scene Shaders..."); LoadShaders(); AddLabel(L"Loading Scene Objects..."); LoadScene(); AddLabel(L"Menu is Starting..."); if (GetConfirmation) { Gwen::Controls::Button * Button = new Gwen::Controls::Button(GUIManager->GetCanvas()); Button->SetBounds(250, 650, 250, 35); Button->SetText(L"Continue"); Button->onPress.Add(& Handler, & CLoadStateEventHandler::OnFinish); } else { OnFinish(); } }
//----------------------------------------------------------------------------- // Purpose: // Input : *filename - //----------------------------------------------------------------------------- void C_SceneEntity::LoadSceneFromFile( const char *filename ) { UnloadScene(); int sleepCount = 0; while ( scenefilecache->IsStillAsyncLoading( filename ) ) { ::Sleep( 10 ); ++sleepCount; if ( sleepCount > 10 ) { Assert( 0 ); break; } } m_pScene = LoadScene( filename ); }
void App::LoadSNBTerrain() { terrainload_ = true; g_ConfigFiles.push_back( L"Default_Config.txt"); g_TerrainDX11Render.SetQuadTreePreviewPos(10, 290, 200, 200); LoadScene(); // Setup the camera's view parameters D3DXVECTOR3 vecEye( 2643.75f, 2178.89f, 2627.14f ); D3DXVECTOR3 vecAt ( 2644.52f, 2178.71f, 2627.74f ); //D3DXVECTOR3 vecEye( 150.75f, 100.89f, 150.14f ); //D3DXVECTOR3 vecAt ( 151.52f, 100.71f, 150.74f ); //g_Camera.SetViewParams( &vecEye, &vecAt ); //g_Camera.SetRotateButtons(true, false, false); ActiveCam_->setFrom((float*)vecEye); ActiveCam_->setTo((float*)vecAt); ActiveCam_->setFOV(RAD2DEG(noMath::PI / 4)); ActiveCam_->setNear(CLIP_NEAR); ActiveCam_->setFar(CLIP_FAR); ActiveCam_->SetAspect(GetAspectRatio()); ActiveCam_->computeModelView(); ActiveCam_->ComputeProjection(); static bool bFirstTime = true; if( bFirstTime ) { InitTerrainRender(); bFirstTime = false; } g_TerrainDX11Render.OnD3D11CreateDevice( device, context ); //ResizeSNBTerrain(); D3DXCOLOR SunColor(1,1,1,1), AmbientLight(0,0,0,0); g_TerrainDX11Render.SetSunParams(g_vDirectionOnSun, SunColor, AmbientLight); g_TerrainDX11Render.EnableAdaptiveTriangulation(true); }
void CSceneManager::SwitchScene(const TString& strFileName) { SceneSwithNotify(); #ifdef DEVELOP_VERSION uint32_t uStartTimeMS = (uint32_t)(CTimeMeter::GetCurrUSec() / 1000); BEATS_PRINT("Start switch scene at time %u\n", uStartTimeMS); #endif BEATS_ASSERT(GetSwitchSceneState() == false); SetSwitchSceneState(true); uint32_t uNewSceneFileId = GetSceneFileId(strFileName); if (m_loadedScene.find(uNewSceneFileId) == m_loadedScene.end()) { LoadScene(strFileName); BEYONDENGINE_CHECK_HEAP; } SetCurrentScene(m_loadedScene[uNewSceneFileId]); SetSwitchSceneState(false); #ifdef DEVELOP_VERSION uint32_t uEndTimeMS = (uint32_t)(CTimeMeter::GetCurrUSec() / 1000); BEATS_PRINT("Finish switch scene at time %u, elapsed time :%u\n", uEndTimeMS, uEndTimeMS - uStartTimeMS); #endif }
void Init() { memset(&cam,0,sizeof(cam)); cam.up.b.z=1; cam.eye.b.y=-16; cam.eye.b.z=0; cam.fov=45; inittextureengine(); InitPrecalc(); //LoadScene(raw_copytest,©test,&texturelist,&lasttexture,&materiallist,&lastmaterial,SceneNum,PrecalcAnim); LoadScene(raw_alienprobe,&CNSlogo,&texturelist,&lasttexture,&materiallist,&lastmaterial,SceneNum,PrecalcAnim); status=0; while (status<=1) { PrecalcRotate(status); status+=0.005f; } glEnable(GL_LIGHTING); glEnable(GL_TEXTURE_2D); glColor4f(1,1,1,1); m_rotate(0.9f,1.0f,0.7f,radtheta,m); }
bool AppDelegate::applicationDidFinishLaunching() { // initialize director auto director = Director::getInstance(); auto glview = director->getOpenGLView(); if(!glview) { glview = GLView::create("Cpp Tests"); director->setOpenGLView(glview); } director->setDisplayStats(true); // set FPS. the default value is 1.0/60 if you don't call this director->setAnimationInterval(1.0 / 60); //pEGLView->setDesignResolutionSize(960, 640, kResolutionShowAll); REGISTER_SCENE_FUNC(MenuScene); REGISTER_SCENE_FUNC(BasicSceneTest); REGISTER_SCENE_FUNC(BasicUIScene); CSceneManager::getInstance()->runWithScene(LoadScene("MenuScene")); return true; }