void CSceneManager::ChangeScene() { Safe_Delete(m_pCurScene); CScene* pScene = NULL; switch(m_eNextScene) { case STYPE_INIT: pScene = new CInitScene; break; case STYPE_EDIT: pScene = new CEditorScene; break; case STYPE_MAIN1: pScene = new CMainGameScene; break; } if(FAILED(pScene->Init())) { Safe_Delete(pScene); return; } m_pCurScene = pScene; m_pNextScene = NULL; }
void CSceneManager::CreateScene(const eSCENE_TYPE& eScene) { CScene* pScene = NULL; switch(eScene) { case STYPE_INIT: pScene = new CInitScene; break; case STYPE_EDIT: pScene = new CEditorScene; break; case STYPE_MAIN1: pScene = new CMainGameScene; break; } if(FAILED(pScene->Init())) { Safe_Delete(pScene); return; } if(m_pCurScene) { Safe_Delete(m_pCurScene); m_pCurScene = pScene; } else { m_pCurScene = pScene; } }
bool CSceneControl::IsPrecedentScene(void){ // シーンあるんやろな? CScene* lpScene = m_vSceneFrame.m_lpScene; if (lpScene == NULL) return false; return lpScene->IsPrecedentScene(); }
VOID CObject_Map::SetPosition(const fVector3& fvPosition) { //找到该物体所处的网格 CScene* pActiveScene = (CScene*)CWorldManager::GetMe()->GetActiveScene(); if(pActiveScene) { //当前有激活场景 m_ivGridPos.x = (INT)pActiveScene->GetZoneX(fvPosition.x); m_ivGridPos.y = (INT)pActiveScene->GetZoneZ(fvPosition.z); //是否是UI模型 if(!GetFakeObjectFlag()) { //如果已经有注册过的网格,首先反注册 if(m_pZone) m_pZone->UnRegisterObject(this); //注册到新网格上 CZone* pZone = pActiveScene->GetZone(m_ivGridPos.x, m_ivGridPos.y); if(!pZone || pZone == m_pZone) return; pZone->RegisterObject(this); } } CObject::SetPosition( fvPosition ); }
void CUnit::update() { CAnimationObject::update(); CScene *scene = CScene::sharedScene(); CLandscape *landscape = scene->getLandscape(); pos[2] = landscape->getHeight(pos[0],pos[1]); if(currState==NULL) return; if(currState!=nextState) { if(currState->end()) { currState = nextState; currState->start(); } } else { currState->update(); } }
void CMessageBoxScene::ExitSceneOnOkCb(int result, void* usr) { if (result) // ok { CScene* self = (CScene*)(usr); self->ExitScene(); // ending } }
void CMessageBoxScene::CloseWinOnOkCb(int result, void* usr) { if (result) //ok { CScene* self = (CScene*)(usr); self->GetEngine()->CloseWin(); // ending everything } }
// 计算从开始点到结束点的路径 2006-4-17 BOOL CPath::CreateMovePath(const fVector2& fvCurrent, const fVector2& fvTarget) { KLU_Log("Begin CreateMovePath : %f,%f,%f,%f", fvCurrent.x, fvCurrent.y, fvTarget.x, fvTarget.y); m_vPosStack.clear(); CScene* pActiveScene = (CScene*)CWorldManager::GetMe()->GetActiveScene(); if( pActiveScene == NULL ) return FALSE; if( FALSE == pActiveScene->IsValidPosition(fvCurrent) ) KLThrow("CPath::CreateMovePath() current position is invalid : %f,%f", fvCurrent.x, fvCurrent.y); if( FALSE == pActiveScene->IsValidPosition(fvTarget) ) KLThrow("CPath::CreateMovePath() target position is invalid : %f,%f", fvTarget.x, fvTarget.y); bool find = pActiveScene->mPathFinder->findPath(fvCurrent.x, fvCurrent.y, fvTarget.x, fvTarget.y); int pathCount = 0; if (find) { size_t count = pActiveScene->mPathFinder->getNumPathPoints(); pathCount = static_cast<int>(count); KLU_Log("CreateMovePath : %f,%f,%f,%f,%d,%s", fvCurrent.x, fvCurrent.y, fvTarget.x, fvTarget.y, pathCount, find ? "find" : "not find"); if (count > 16) { KLU_Log("CreateMovePath : %f,%f,%f,%f,%d,path unit > 16", fvCurrent.x, fvCurrent.y, fvTarget.x, fvTarget.y, pathCount); } for (size_t i=0; i<count-1; ++i) { const PathLib::ResultPoint& point1 = pActiveScene->mPathFinder->getResultPoint(i); const PathLib::ResultPoint& point2 = pActiveScene->mPathFinder->getResultPoint(i+1); PathUnit pathUnit; pathUnit.fvStart.x = point1.x; pathUnit.fvStart.y = point1.y; pathUnit.fvTarget.x = point2.x; pathUnit.fvTarget.y = point2.y; m_vPosStack.push_back(pathUnit); } } return find; }
BOOL CSceneManager::OnUpdate( UINT32 dwTick ) { for(SceneMap::iterator itor = m_mapSceneList.begin(); itor != m_mapSceneList.end(); ++itor) { CScene *pScene = itor->second; pScene->OnUpdate(dwTick); } return TRUE; }
void CMyCamera::RenderPass( int32 i_iPass ) { if( i_iPass == -1 || i_iPass == ePass_Lighting ) { CScene *pScene = pGetParent()->pGetParent()->pGetScene(); uint32 iNumLights = pScene->iGetNumLights(); for( uint32 i = 0; i < iNumLights; ++i ) { pScene->SetCurrentLight( i ); pScene->Render( ePass_Lighting ); } } }
CBillboard::CBillboard(Logic::CEntity * entity) { assert(entity); CScene * scene = entity->getMap()->getScene(); _billboardset = scene->getSceneMgr()->createBillboardSet(); Logic::MAttachBillboard * m = new Logic::MAttachBillboard(); m->setBillboardset(this); entity->emitMessage(m); Ogre::Billboard* billboard; billboard = _billboardset->createBillboard(0.0f,0.0f,0.0f); }
CSceneManager::~CSceneManager() { SceneMap::iterator itor = m_mapSceneList.begin(); for(; itor != m_mapSceneList.end(); ++itor) { CScene *pScene = itor->second; if(pScene != NULL) { pScene->Uninit(); delete pScene; pScene = NULL; } } }
// // 但前点是否在不可行走区域之内 // BOOL CPath::IsPointInUnreachRegion(const fVector2& fvTarget) { CScene* pActiveScene = (CScene*)CWorldManager::GetMe()->GetActiveScene(); if( pActiveScene == NULL ) return FALSE; //检测坐标是否非法 if( FALSE == pActiveScene->IsValidPosition(fvTarget) ) // KLThrow("CPath::IsPointInUnreachRegion() target position is invalid : %f,%f", fvTarget.x, fvTarget.y); // 不抛异常,如果目标点非法,直接返回true return TRUE; unsigned int id; return pActiveScene->mPathFinder->isPointInRegion(fvTarget.x, fvTarget.y, id, 1); }
void PlayAnimation() { MSG main_msg; g_StartTime = 0; ZeroMemory(&main_msg, sizeof(main_msg)); while (main_msg.message != WM_QUIT) { if (::PeekMessage(&main_msg, NULL, 0, 0, PM_NOREMOVE)) { if (::GetMessage(&main_msg, NULL, 0, 0)) { ::TranslateMessage(&main_msg); ::DispatchMessage(&main_msg); } } if (!g_StartTime) g_StartTime = GetTickCount(); float time = (float)(GetTickCount() - g_StartTime)/1000.0f; if (time>=(g_Scene.dwFrameStop-g_Scene.dwFrameStart+1)/33.3f) g_StartTime = GetTickCount(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); g_Scene.RenderFrame( 33.3f*time ); SwapBuf(); } }
CRenderingCore::CRenderingCore() { this->m_iPixelX = XRES; this->m_iPixelY = YRES; this->m_pcamCurrent = g_objScene.GetCamera(); this->m_iSupersampleDepth = 2; }
BOOL CSceneManager::OnCommandHandle(UINT16 wCommandID, UINT64 u64ConnID, CBufferHelper *pBufferHelper) { BOOL bHandled = TRUE; switch(wCommandID) { case CMD_SVR_CREATE_SCENE_REQ: { OnCmdCreateSceneReq(wCommandID, u64ConnID, pBufferHelper); } break; case CMD_DISCONNECT_NOTIFY: { } break; default: { bHandled = FALSE; } break; } if(bHandled) //消息己经被处理 { return TRUE; } PacketHeader *pPacketHeader = pBufferHelper->GetPacketHeader(); if(pPacketHeader == NULL) { ASSERT_FAIELD; return FALSE; } CScene *pScene = GetSceneByID(pPacketHeader->dwSceneID); if(pScene == NULL) { ASSERT_FAIELD; return FALSE; } pScene->OnCommandHandle(wCommandID, u64ConnID, pBufferHelper); return TRUE; }
BOOL CSceneManager::CreateScene( UINT32 dwSceneID ) { CScene *pScene = new CScene; if(!pScene->Init(dwSceneID, -1000, 1000, -1000, 1000)) { ASSERT_FAIELD; delete pScene; return FALSE; } m_mapSceneList.insert(std::make_pair(dwSceneID, pScene)); return TRUE; }
void BackLayer::keyBackClicked() { CScene *scene = CSceneManager::sharedSceneManager()->getCurrScene(); if (CGuideManager::getInstance()->getIsRunGuide()) return; const string &name = scene->getClassName(); if (!m_backTip) { if (LayerManager::instance()->getLayerCount()==0&&name=="CMainScene") { //平台推出 if(GamePlatformMgr->ExitPlatform()) { return; } m_backTip = CPopTip::create(); m_backTip->addContentTip(GETLANGSTR(5)); m_backTip->setTouchEnabled(true); m_backTip->setTouchPriority(-100); m_backTip->setButtonLisener(this,ccw_click_selector(BackLayer::onExitGame)); scene->addChild(m_backTip,10,1); return; } else if(LayerManager::instance()->getLayerCount()==0&&name=="BattleScene") { CCNotificationCenter::sharedNotificationCenter()->postNotification(MsgReturnLayer); } else if (LayerManager::instance()->getLayerCount()==0&&name=="LoginScene") { m_backTip = CPopTip::create(); m_backTip->addContentTip(GETLANGSTR(5)); m_backTip->setTouchEnabled(true); m_backTip->setTouchPriority(-100); m_backTip->setButtonLisener(this,ccw_click_selector(BackLayer::onExitGame)); scene->addChild(m_backTip, 999, 1); } else { LayerManager::instance()->pop(); LayerManager::instance()->pop(); } } }
bool CScriptParser::send() { bool bRet = false; MyParserType* parser = &m_RDParser; do { MATCH1(TokenType::SE); MATCH1(TokenType::LINEEND); CScene* pScene = new CScene; pScene->SetData(m_scene); g_ScriptDB.m_sceneMap[pScene->m_nID] = pScene; bRet = true; } while (false); return bRet; }
//--------------------------------------------------------------------------- void CRenderWidget::notifySceneChanged() { mScene.clear(); if (Globals::getCurrentScene()) { // Make background this->setBackgroundBrush(QBrush(QPixmap(Globals::getProjectPath() + "/backgrounds/01.jpg"))); // We rebuild the scene out of the new elements. CScene* scene = Globals::getCurrentScene(); scene->addAllElementsToScene(&mScene); } else { mScene.addText("Veuillez ouvrir ou créer un nouveau niveau."); }// }
bool CLevel::Initialise(int _iWidth, int _iHeight, int _iNumScenes) { m_iNumScenes = _iNumScenes; m_pScenes = new CScene[m_iNumScenes]; std::vector<CSprite*> vSprites; CSprite* bkgSprite = new CSprite(); bkgSprite->Initialise(IDB_BITMAP2, IDB_BITMAP3); bkgSprite->SetX(400); bkgSprite->SetY(300); vSprites.push_back(bkgSprite); CScene cNewScene = CScene(); cNewScene.Initialise(1, vSprites); m_pScenes[0] = cNewScene; return false; }
// protected functions: CColor CRenderingCore::Sample(float x, float y, int curDepth) { CColor colArray[5]; CColor finalCol; int colCount = 1; double dXFraction; double dYFraction; /******************************************************************* STRATEGY: 1. First compute the color for the central pixel. 2. Check if we have to dive further into the oversampling recursion. 3. Average the colors. 4. Return the color. *******************************************************************/ // 1. /*********************************************************** SUB_STEPS: 1.1. Calculate the x and y fractions. 1.2. Get the corresponding ray from the camera. 1.3. Test the scene to see which object intersects the ray. 1.4. Query the object for teh color of the point. ***********************************************************/ // 1.1. dYFraction = (double)y / (double)m_iPixelY; dXFraction = (double)x / (double)m_iPixelX; // 1.2. CRay ray = m_pcamCurrent->GetRay(dXFraction, dYFraction); // 1.3. CIntersectionInfo hitInfo = g_objScene.TestRayForClosest(ray); // 1.4. colArray[0] = hitInfo.GetShape()->ShadePoint(hitInfo); // 2. if (curDepth < m_iSupersampleDepth) { colCount = 5; float inc = 1.0f / (float) pow(2.0f, (float)curDepth); colArray[1] = Sample (x + inc, y, curDepth + 1); colArray[2] = Sample (x - inc, y, curDepth + 1); colArray[3] = Sample (x, y + inc, curDepth + 1); colArray[4] = Sample (x, y - inc, curDepth + 1); } // 3. finalCol = CColor::Average(colArray, colCount); // 4. return finalCol; }
//-------------------------------------------------------------------------------------- // Release D3D11 resources created in OnD3D11CreateDevice //-------------------------------------------------------------------------------------- void CALLBACK OnD3D11DestroyDevice(void* /*pUserContext*/) { g_DialogResourceManager.OnD3D11DestroyDevice(); g_D3DSettingsDlg.OnD3D11DestroyDevice(); DXUTGetGlobalResourceCache().OnDestroyDevice(); SAFE_DELETE(g_pTxtHelper); g_Scene.OnD3D11DestroyDevice(); g_OIT.OnD3D11DestroyDevice(); }
//// OnShow() //// void CArkanoidController::OnShow() try { #if DEBUG==1 time_t startT = time(NULL); exceptPrintFile << asctime(localtime(&startT))<< " < << <<< <<<< <<<<< <<<<<< GAME START {i.e. `OnShow()` started working} >>>>>> >>>>> >>>> >>> >> >" << std::endl; #endif m_fSceneHeight = CRender::GetInst().GetHeight()/*768*/; m_fSceneWidth = CRender::GetInst().GetWidth()/*1024*/; CScene *sc = m_scene; //@@ ?: д/ более простой изменяемости?? (а надо ли? - может просто `m_scene` использовать) m_pPad = sc->FindPictureObject(PIC_SC01_PADDLE); //#OUTDATED (Видимо не нужен): g_pBall = sc->FindPictureObject(PIC_SC01_BALL); ///@@@ Видимо не нужен //Готовлю array-входн.пар-р для C-tor'а CBallsManager. //Вынес этот код сюда, чтобы уйти от зависимости класса CBallsManager .. { //.. от кол-ва видов шариков и конкретных их объектов. std::vector<CPictureObject*> vpBallPicObjs; vpBallPicObjs.push_back(sc->FindPictureObject(PIC_SC01_BALL)); vpBallPicObjs.push_back(sc->FindPictureObject(PIC_SC01_BALL2)); vpBallPicObjs.push_back(sc->FindPictureObject(PIC_SC01_BALL3)); vpBallPicObjs.push_back(sc->FindPictureObject(PIC_SC01_BALL4)); //Создаю менеджер шариков: m_pBallsMngr = new CBallsManager(vpBallPicObjs); //conditional delete is in D-tor. } //Создаю менеджер кирпичей: m_pBricksMngr = new /*_BRICK_MNGR*/CBricksManager(/*12*/NUMBER_OF_BRICKS); ///@@ Передаю маг.числом, НО не держу лишнюю глоб.переменную. Верно? //Это что? Типа БРИКС_ОН_ЛВЛ ? (вроде да, therefore заменил `12` на NUMBER_OF_BRICKS) //#OUTDATED (метод уже перекочевал в CBall и вызывается в C-tor'e): //InitBallHitChckPntsArr(); //#OUTDATED: InitOfBallsPictObjects(sc); //инициализирую массив CPict.Object'ов шариков //#OUTDATED: CPictureObject* pOriBall = sc->FindPictureObject(PIC_SC01_BALL); ///@@@ может вынести в глоб. vars (тем более, если его, как и oriBrick не задейтсвовать в самой игре m_fPaddleY1 = m_fSceneHeight - m_fBOTTOM_GAP - (u32)m_pPad->GetSize().y; //#COMPILER(Warning) `(u32)` m_fCurrPaddleY = m_fPaddleY1; //#OUTDATED: g_fMaxDltYWithPad = m_pPad->GetCenter().y - pOriBall->GetCenter().y; //if(ball[i]..->GetPos().y > g_fPaddleY+g_fMaxDltYWithPad) .. // //.. то больше не просчитывать IsHit() с Pad'ом. std::srand((int)time(NULL)); //для того, чтобы rand() выдавал не одно и то же //#OUTDATED: _BALL::InitFewPixelsShift(); //OLD: Инициализирую таблицу 1-(2-3..)-пиксельных смещений шарика при контакте. //@@ перенёс вызов в C-tor шарика (в условный блок, исполняемый только при cre. 1го шарика) InitNewGame(sc); }
void CUIComboObjListTile::initObject(CScene& scene) { m_pScene=&scene; m_ListBoxObject.RemoveAllItems(); static const int nNullTile = 255; m_ListBoxObject.AddItem(L"NULL",(LPVOID)nNullTile); CTerrain::MAP_TILES& tiles =((CTerrain*)(scene.getTerrainData()))->GetTiles(); for (CTerrain::MAP_TILES::iterator it=tiles.begin(); it!=tiles.end(); it++) { m_ListBoxObject.AddItem(s2ws(it->second).c_str(),(LPVOID)it->first); } }
EXCPTN_CATCH //// OnRender() //// void CArkanoidController::OnRender(vector2 _scroll) ///@@@ Быть может нужно как-то исп-ть этот пар-р: Warning C4100: '_scroll' : unreferenced formal parameter 330 try { LOG_INFO("CArkanoidController::OnRender"); vector2 pos = CCursorController::GetInst().GetCursorPos(); CScene *sc = m_scene; ///@@@ /*+см.в кажд.методе эту же строку*/ зачем каждый рендер создавать этот ptr заново? Может его передавать пар-ром, или сделать static'ом? Хотя ск.вс., т.к. m_scene - это, должно быть, верхняя (активная) (хотя написано в доках, что это материнская сцена). Ну короче м/у рендерами может она видимо измениься. Поэтому обновляем. ?? ////Вызываю метод, отыгрывающий анимацию уничтожения в 1й проход и удаляющий объект во второй //for (char i=m_vpBricks.size()-1; i>=0; --i) //Костыли: переносил это в OnUpdate() - не помогло //{ // if (m_vpBricks[i]->m_state == CBrick::DSTR_ST || m_vpBricks[i]->m_state == CBrick::DSTR_EN) // DelBrick(i, sc); //} ProcessWinLostState(sc); ///@@@ #TODO: кажд.рендер прогоняем эти проверки. Быть может заменить проверкой единств-го флага "Что-то изменилось с game_state'ом". И только if `true`, то гонять этот метод? Print("SCORE: ", m_uGameScore, 15,m_fSceneWidth-100, 240,10,240,100); #if DEBUG==1 CPictureObject* ball1 = sc->FindPictureObject(PIC_SC01_BALL); //dbgPrint("rndmAng1 = ", dbgTmp0, 10,10, 255,10,255); if (!m_pBallsMngr->IsBallsEmpty()) DbgPrint("currBallFi = ", m_pBallsMngr->GetBallFi(0)/*m_vBalls[0]->GetFi()*/, 10,200, 255,10,255); ///@@: Тут подчёркивание - /*возможно*/НЕ ошибка КОМП-ра, /*т.к.*/то, что я объявил френдом метод, ДАЁТ ДОСТУП К ЗАКРЫТЫМ ДАННЫМ _ВНУТРИ_ ф-ции, НО НЕ В СПИСКЕ ЕЁ ПАР-РОВ! DbgPrint("currMouse X : Y = ", pos.x, pos.y, " : ", 25,10, 10,10,10); DbgPrint("ball1->GetPos().x : .y ", ball1->GetPos().x, ball1->GetPos().y, " : ", 300); //dbgPrint("rand()%... : ", dbgTmp6, 355,10, 50,50,1); #endif //Костыли: перенёс сюда из OnUpdate() //Провека коллизий и пересчёт траекторий ///@@ Stoped_here 2014/09/16 m_pBallsMngr->ProcessIsHit(m_pPad, m_pBricksMngr->GetLavBricksPtr(), m_fSceneWidth, m_GameState); }
//*************************************************************** // 全描画 //*************************************************************** void CScene::DrawAll(LPDIRECT3DDEVICE9 pDevice) { //ポインタ宣言 CScene *pScene; for(int nCount = 0 ; nCount < MAX_LIST ; nCount++) { pScene = m_apTop[nCount]; while(pScene) { //次のオブジェクトへのポインタを保存 CScene *pSceneNext = pScene->m_pNext; //更新 pScene->Draw(pDevice); //次のオブジェクトを代入 pScene = pSceneNext; } } }
// *************************************************************************** void UTransform::getLastParentClusters(std::vector<CCluster*> &clusters) const { CTransform *object = getObjectPtr(); CScene *scene = object->getOwnerScene(); // look in the list of parent of the transform object and extract the CCluster parents if (scene == NULL) return; CClipTrav &clipTrav= scene->getClipTrav(); uint num= object->clipGetNumParents(); for(uint i=0;i<num;i++) { CCluster *pcluster = dynamic_cast<CCluster*>(object->clipGetParent(i)); if (pcluster != NULL) clusters.push_back(pcluster); } // If the object is link to a QuadCluster, add the RootCluster to the list CTransformShape *trShp= dynamic_cast<CTransformShape*>( object ); if( trShp && trShp->isLinkToQuadCluster() ) clusters.push_back(clipTrav.RootCluster); }
//*************************************************************** // ステートの終了処理 //*************************************************************** void CScene::UninitAll(void) { //ポインタ宣言 CScene *pScene; for(int nCount = 0 ; nCount < MAX_LIST - 1 ; nCount++) { pScene = m_apTop[nCount]; //全てのリストを解放するまで繰り返す while(pScene) { //次のオブジェクトへのポインタを保存 CScene *pSceneNext = pScene->m_pNext; //更新 pScene->Release(); //次のオブジェクトを代入 pScene = pSceneNext; } } }
//-------------------------------------------------------------------------------------- // Create any D3D11 resources that aren't dependent on the back buffer //-------------------------------------------------------------------------------------- HRESULT CALLBACK OnD3D11CreateDevice(ID3D11Device* pd3dDevice, const DXGI_SURFACE_DESC* /*pBackBufferSurfaceDesc*/, void* /*pUserContext*/) { HRESULT hr; ID3D11DeviceContext* pd3dImmediateContext = DXUTGetD3D11DeviceContext(); V_RETURN(g_DialogResourceManager.OnD3D11CreateDevice(pd3dDevice, pd3dImmediateContext)); V_RETURN(g_D3DSettingsDlg.OnD3D11CreateDevice(pd3dDevice)); g_pTxtHelper = new CDXUTTextHelper(pd3dDevice, pd3dImmediateContext, &g_DialogResourceManager, 15); V_RETURN(g_Scene.OnD3D11CreateDevice(pd3dDevice)); // Setup the camera XMVECTOR vecEye = XMVectorSet(0.0f, 0.5f, -3.0f, 0); XMVECTOR vecAt = XMVectorSet(0.0f, 0.0f, 0.0f, 0); g_Camera.SetViewParams(vecEye, vecAt); g_OIT.OnD3D11CreateDevice(pd3dDevice); return S_OK; }