void CameraAction::activate() { Action::activate(); GetG().m_camera.setSmoothCameraDuration( (float)m_duration / 1000.0f ); switch ( m_type ) { case 0: GetG().m_camera.setAttachPos( &GetWorldManager().getCurWorld()->getHeroPos() ); GetG().m_camera.begin( CAMERA_SMOOTH_ATTACH ); break; case 1: { ArnSceneGraph* arnSceneGraph = GetWorldManager().getCurWorld()->getArnSceneGraphPt(); ArnCamera* arnCam = static_cast<ArnCamera*>( arnSceneGraph->getSceneRoot()->getNodeByName( m_arnCamNodeName ) ); GetG().m_camera.setExternalCamera( arnCam ); GetG().m_camera.begin( CAMERA_EXTERNAL ); } break; } // CameraAction is 'very' instantaneous, so deactivate() is called // immediately after activate(). deactivate(); }
int ShadedSurfaceLayer::DrawTriangle(float x1, float y1, float z1, int c1, float x2, float y2, float z2, int c2, float x3, float y3, float z3, int c3) const { int retval = NVN_NOERR; float ux, uy, uz; float vx, vy, vz; ux = x2 - x1; vx = x3 - x1; uy = y2 - y1; vy = y3 - y1; uz = z2 - z1; vz = z3 - z1; glNormal3f(uy*vz - uz*vy, uz*vx - ux*vz, ux*vy - uy*vx); glColor4ub(GetR(c1), GetG(c1), GetB(c1), GetA(c1)); glVertex3f(x1, y1, z1); glColor4ub(GetR(c2), GetG(c2), GetB(c2), GetA(c2)); glVertex3f(x2, y2, z2); glColor4ub(GetR(c3), GetG(c3), GetB(c3), GetA(c3)); glVertex3f(x3, y3, z3); }
void EpLight::frameMove( FLOAT fElapsedTime ) { // 스테이트는 기본적으로 LIGHT_NORMAL이고, 아래 과정에서 끝나지 않은 작업이 있으면 변할 수 있음. // 의도는 위와 같았으나 현재 기본으로 LIGHT_FADE 스테이트임. m_eLightState = LIGHT_NORMAL; if ( m_fDelay > 0.0f ) m_fDelay -= fElapsedTime; else { m_fDelay = 0.0f; updateFadeBrightness( fElapsedTime ); updateFlicker( fElapsedTime ); } switch ( m_eLightState ) { case LIGHT_FADE: ArnRgbaAssign(m_light.Ambient, m_cAmbient * m_fBrightness); ArnRgbaAssign(m_light.Diffuse, m_cDiffuse * m_fBrightness); ArnRgbaAssign(m_light.Specular, m_cSpecular * m_fBrightness); break; case LIGHT_FLICKER: if ( m_fBrightness < 0.3f ) m_fBrightness = 0.3f; ArnRgbaAssign(m_light.Ambient, m_cFlickerAmbient * m_fBrightness); ArnRgbaAssign(m_light.Diffuse, m_cFlickerDiffuse * m_fBrightness); ArnRgbaAssign(m_light.Specular, m_cFlickerSpecular * m_fBrightness); break; case LIGHT_NORMAL: ArnRgbaAssign(m_light.Ambient, m_cAmbient * m_fBrightness); ArnRgbaAssign(m_light.Diffuse, m_cDiffuse * m_fBrightness); ArnRgbaAssign(m_light.Specular, m_cSpecular * m_fBrightness); break; } m_vDir = *GetG().m_camera.GetLookAtPt() - *GetG().m_camera.GetEyePt(); m_vPos = *GetG().m_camera.GetEyePt(); float vDirLen = ArnVec3Length( &m_vDir ); if ( vDirLen < 1e-5 || vDirLen > 1e6 ) m_light.Direction = ArnConsts::ARNVEC3_Z; else ArnVec3Normalize((ArnVec3*)&m_light.Direction, &m_vDir); m_light.Position = m_vPos; m_bLightValueDirty = true; /*printf( "%f\n", m_fFadeTimer ); if ( m_bInFading ) printf( "true\n" ); else printf ( "false\n" );*/ }
HRESULT World::frameRender(IDirect3DDevice9* pd3dDevice, double dTime, float fElapsedTime) { EpCamera& camera = GetG().m_camera; HRESULT hr = S_OK; ////////////////////////////////////////////////////////////////////////// // Perspective Rendering Phase pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE ); // TODO - Lighting D3DXMATRIX v, p, w; D3DXVECTOR3 eye(0, 0, -50), at(0, 0, 0), up(0, 1, 0); D3DXMatrixPerspectiveFovLH(&p, ArnToRadian(45.0), 1.0f, 0.0f, 1000.0f); D3DXMatrixLookAtRH(&v, &eye, &at, &up); D3DXMatrixIdentity(&w); pd3dDevice->SetTransform(D3DTS_VIEW, camera.GetViewMatrix()); pd3dDevice->SetTransform(D3DTS_PROJECTION, camera.GetProjMatrix()); ////////////////////////////////////////////////////////////////////////// // Aran lib rendering routine (CW) pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW); //pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW); pd3dDevice->SetFVF(ArnVertex::FVF); D3DPERF_BeginEvent(0, L"World render"); GetG().m_videoMan->renderMeshesOnly(m_modelSg->getSceneRoot()); D3DPERF_EndEvent(); ////////////////////////////////////////////////////////////////////////// // EP rendering routine (CCW) UnitSet::iterator it = m_unitSet.begin(); for ( ; it != m_unitSet.end(); ++it ) { if ( !(*it)->getRemoveFlag() ) { if ( (*it)->getType() != UT_UNITBASE ) { // Locally created instance. Almost by script file. (*it)->frameRender( pd3dDevice, dTime, fElapsedTime ); } else { // Remotely created instance by RakNet ReplicaManager. pd3dDevice->SetTransform( D3DTS_WORLD, (D3DMATRIX*)&((*it)->getLocalXformRaw()) ); pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW); g_bst[BST_TEAPOT]->DrawSubset( 0 ); } } } DialogList::iterator itDialog = m_scriptedDialog.begin(); for ( ; itDialog != m_scriptedDialog.end(); ++itDialog ) { (*itDialog)->frameRender(pd3dDevice, dTime, fElapsedTime); } WorldStateManager& wsm = WorldStateManager::getSingleton(); wsm.getCurState()->frameRender(pd3dDevice, dTime, fElapsedTime); return hr; }
/** * Write the table index for the next \a iLength pixels, starting from the \a iCount offset. * @param oBase Base image to encode. * @param iCount Current index in the image. * @param iLength Number of pixels to process. * @param pDest Destination to write to. */ static void WriteTableIndex(const Image32bpp &oBase, uint32 iCount, int iLength, Output *pDest) { while (iLength > 0) { uint32 iColour = oBase.Get(iCount); iCount++; uint8 biggest = GetR(iColour); if (biggest < GetG(iColour)) biggest = GetG(iColour); if (biggest < GetB(iColour)) biggest = GetB(iColour); pDest->Uint8(biggest); iLength--; } }
HRESULT SkillObject::frameRender ( IDirect3DDevice9* pd3dDevice, double dTime, float fElapsedTime ) { HRESULT f = 0; D3DPERF_BeginEvent( 0, L"SkillObject Render" ); HRESULT hr = S_OK; ArnMatrix mWorld; ArnMatrixIdentity( &mWorld ); UINT iPass, cPasses; if ( SUCCEEDED(g_bombShader->setMainTechnique()) ) { ArnMatrix arnvm, arnpm; memcpy(arnvm.m, GetG().m_camera.GetViewMatrix()->m, sizeof(float)*16); memcpy(arnpm.m, GetG().m_camera.GetProjMatrix()->m, sizeof(float)*16); V( g_bombShader->setWorldViewProj( dTime, fElapsedTime, &getLocalXform(), &arnvm, &arnpm) ); V( g_bombShader->begin( &cPasses, 0 ) ); for( iPass = 0; iPass < cPasses; iPass++ ) { V( g_bombShader->beginPass( iPass ) ); // TODO Mesh pointing should be done here? not OnResetDevice? if ( getMesh() == 0 ) { setMesh( g_bst[ m_bst ] ); } f = getMesh()->DrawSubset( 0 ); V( g_bombShader->endPass() ); } V( g_bombShader->end() ); } else { // TODO Mesh pointing should be done here? not OnResetDevice? if ( getMesh() == 0 ) { setMesh( g_bst[ m_bst ] ); } pd3dDevice->SetTransform(D3DTS_WORLD, (const D3DXMATRIX*)getLocalXform().m); f = getMesh()->DrawSubset( 0 ); } D3DPERF_EndEvent(); return f; }
HRESULT World::init() { HRESULT hr = S_OK; if ( GetG().m_videoMan->GetDev() ) loadWorldModel(); char command[128]; StringCchPrintfA( command, 128, "%s::init 0x%p", m_worldName.c_str(), this ); GetScriptManager().execute( command ); if ( !m_sound ) { m_sound = new Sound; m_sound->init(); } else throw std::runtime_error( "Sound should not be init twice or more" ); // 'enter' function implemented in the script file defines which characters are exist in this world char scriptCommand[128]; StringCchPrintfA( scriptCommand, 128, "%s::enter", m_worldName.c_str() ); GetScriptManager().execute( scriptCommand ); // Hero and enemies are defined afterwards // CAUTION To be set by RakNet ReplicaManager assert( m_heroUnit ); m_curDialog = 0; return hr; }
HRESULT World::onResetDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext ) { OutputDebugString( _T( " - INFO: World::onResetDevice called.\n" ) ); loadWorldModel(); ArnLightData& light = GetG().m_light; // These cause the scene more brighter when onResetDevice() is called, i.e., resizing the window. // Why is these four lines are needed? /* setupLight(); pd3dDevice->SetLight(0, &light); pd3dDevice->LightEnable(0, TRUE); pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE ); */ UnitSet::iterator it = m_unitSet.begin(); for ( ; it != m_unitSet.end(); ++it ) { (*it)->onResetDevice( pd3dDevice, pBackBufferSurfaceDesc, pUserContext ); } if ( m_curDialog ) m_curDialog->updateDialogPosition(); return S_OK; }
bool Collinear(const leda::node v) { const mesh_t& G = GetG(); const point_t& v0 = G[G.source(g.P0.e)]; const point_t& v1 = G[G.source(g.P1.e)]; return leda::collinear(v0, v1, G[v]); }
bool InHPos(const leda::node v, const leda::node w) { const mesh_t& G = GetG(); const point_t& v0 = G[G.source(g.P0.e)]; const point_t& v1 = G[G.source(g.P1.e)]; return 0 < leda::orientation(v0, v1, G[v], G[w]); }
void Dialog::updateDialogPosition() { const UINT dialogPaneM_H = 200; const UINT dialogPaneM_W = 200; const UINT dialogPaneN_H = 60; const UINT dialogPaneN_W = 150; const UINT dialogPaneM_S = 20; const UINT dialogPaneN_S = 16; m_contentRect.top = GetG().m_scrHeight - dialogPaneM_H + dialogPaneM_S; m_contentRect.left = dialogPaneM_S; m_contentRect.right = dialogPaneM_W - dialogPaneM_S; m_contentRect.bottom = GetG().m_scrHeight - dialogPaneM_S; m_nameRect.top = (GetG().m_scrHeight - dialogPaneM_H) - dialogPaneN_H + dialogPaneN_S; m_nameRect.left = dialogPaneN_S; m_nameRect.right = dialogPaneN_W - dialogPaneN_S; m_nameRect.bottom = (GetG().m_scrHeight - dialogPaneM_H) - dialogPaneN_S; }
VOID World::enter() { GetG().m_camera.setAttachPos( &getHeroPos() ); GetG().m_camera.begin( CAMERA_ATTACH ); /*ArnVec3 eye( getHero()->getPos().x, getHero()->getPos().y, getHero()->getPos().z - 30.0f ); ArnVec3 at( getHero()->getPos().x, getHero()->getPos().y, getHero()->getPos().z - 1.0f ); ArnVec3 up( 0.0f, 1.0f, 0.0f ); GetG().m_camera.setViewParamsWithUp( &eye, &at, &up );*/ //GetEpLight().setFadeDuration( 1.0f ); GetEpLight().setBrightness( 0.0f ); //GetEpLight().fadeInLightForcedDelayed( 2.0f ); UnitSet::iterator it = m_unitSet.begin(); for ( ; it != m_unitSet.end(); ++it ) { (*it)->updateArnMesh(); } }
HRESULT Dialog::frameRender( IDirect3DDevice9* pd3dDevice, double dTime, float fElapsedTime ) { if ( m_bInit ) { pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE); pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW); pd3dDevice->SetTransform(D3DTS_VIEW, (const D3DXMATRIX*)GetG().g_fixedViewMat.m); pd3dDevice->SetTransform(D3DTS_PROJECTION, (const D3DXMATRIX*)GetG().g_orthoProjMat.m); D3DMATERIAL9 material; D3DCOLORVALUE cv, cv2; cv.a = 0.3f; cv.r = 0.1f; cv.g = 0.1f; cv.b = 0.1f; cv2.a = 0.3f; cv2.r = 1.0f; cv2.g = 0.1f; cv2.b = 0.3f; material.Ambient = cv; material.Diffuse = cv2; material.Emissive = cv; material.Power = 1.0f; material.Specular = cv2; pd3dDevice->SetMaterial(&material); //drawFixedText(scrWidth, scrHeight); pd3dDevice->SetRenderState(D3DRS_ZENABLE, FALSE); if( m_bTalking ) { D3DPERF_BeginEvent(0x12345678, L"Draw Dialog Pane"); //m_contentPic.draw(); //m_namePic.draw(); D3DPERF_EndEvent(); printDialog(); printName(); } pd3dDevice->SetRenderState(D3DRS_ZENABLE, TRUE); } return S_OK; }
/** * Write the RGB colour for the next \a iLength pixels, starting from the \a iCount offset. * @param oBase Base image to encode. * @param iCount Current index in the image. * @param iLength Number of pixels to process. * @param pDest Destination to write to. */ static void WriteColour(const Image32bpp &oBase, uint32 iCount, int iLength, Output *pDest) { while (iLength > 0) { uint32 iColour = oBase.Get(iCount); iCount++; pDest->Uint8(GetR(iColour)); pDest->Uint8(GetG(iColour)); pDest->Uint8(GetB(iColour)); iLength--; } }
Color::operator RGBA() const { RGBA color; if(IsNullInstance()) Zero(color); else { color.r = GetR(); color.g = GetG(); color.b = GetB(); color.a = 255; } return color; }
void Color::Jsonize(JsonIO& jio) { int r, g, b; if(IsNullInstance()) { r = g = b = Null; } else { r = GetR(); g = GetG(); b = GetB(); } jio("red", r)("green", g)("blue", b); if(IsNull(r)) *this = Null; else *this = Color(r, g, b); }
void UpdateActiveEdge() { const mesh_t& G = GetG(); if(!g.geom_activeEdge) { g.geom_activeEdge = NB::CreateMesh(); NB::SetMeshName(g.geom_activeEdge, "active edge"); NB::SetMeshRenderMode(g.geom_activeEdge, NB::RM_EDGES); } mesh_t& mesh = NB::GetGraph(g.geom_activeEdge); mesh.clear(); leda::node v0 = mesh.new_node(), v1 = mesh.new_node(); mesh.set_position(v0, G.position_of(G.source(g.activeEdge))); mesh.set_position(v1, G.position_of(G.target(g.activeEdge))); mesh.set_reversal(mesh.new_edge(v0, v1), mesh.new_edge(v1, v0)); leda::edge e = mesh.first_adj_edge(v0); mesh.set_color(e, R::Color::Yellow); mesh.set_radius(e, 0.1f); }
void Color::Xmlize(XmlIO& xio) { int r, g, b; if(IsNullInstance()) { r = g = b = Null; } else { r = GetR(); g = GetG(); b = GetB(); } xio .Attr("red", r) .Attr("green", g) .Attr("blue", b) ; if(IsNull(r)) *this = Null; else *this = Color(r, g, b); }
void CVisualizerStatic::Draw() { const char STR[] = "0CC-FamiTracker"; // // // const size_t COUNT = std::size(STR); static long long t = 0; const auto FixRGB = [] (int x) { return MakeRGB(GetB(x), GetG(x), GetR(x)); }; const COLORREF Back[] = { FixRGB(FTEnv.GetSettings()->Appearance.iColBackground), FixRGB(FTEnv.GetSettings()->Appearance.iColBackgroundHilite), FixRGB(FTEnv.GetSettings()->Appearance.iColBackgroundHilite2), }; const COLORREF Color = FixRGB(FTEnv.GetSettings()->Appearance.iColPatternText); const COLORREF Shadow = BlendColors(Color, 1, Back[0], 2); for (int y = m_iHeight - 1; y >= 0; --y) for (int x = m_iWidth - 1; x >= 0; --x) { int Dist = (abs(x - m_iWidth / 2) + abs(y - m_iHeight / 2) - t / 5) % 12; if (Dist < 0) Dist += 12; m_pBlitBuffer[y * m_iWidth + x] = Back[Dist / 4]; } for (size_t i = 0; i < COUNT; ++i) { double Phase = .07 * t - .9 * i; double x = sin(Phase) * 2. + m_iWidth + 11. * i - .4 * t; double y = sin(Phase) * 7.; const double MAX = m_iWidth + 120.; if (x < 0) { x = fmod(x, MAX); if (x < -40.) x += MAX; } DrawChar(STR[i], static_cast<int>(x) + 1, static_cast<int>(m_iHeight / 2. - 3.5 - y) + 1, Shadow); DrawChar(STR[i], static_cast<int>(x), static_cast<int>(m_iHeight / 2. - 3.5 - y), Color); } ++t; }
int EpCameraSetShake( int b ) { GetG().m_camera.setShake( b?true:false ); return 0; }
int AStarPathFind::PathFind(int nStartX, int nStartY, int nEndX, int nEndY, std::list<Point>& oListPath) { if (m_poMapConf == NULL) { return -1; } nStartX = XMath::Max(0, XMath::Min(nStartX, (int)m_poMapConf->nPixelWidth - 1)); nStartY = XMath::Max(0, XMath::Min(nStartY, (int)m_poMapConf->nPixelHeight - 1)); nEndX = XMath::Max(0, XMath::Min(nEndX, (int)m_poMapConf->nPixelWidth - 1)); nEndY = XMath::Max(0, XMath::Min(nEndY , (int)m_poMapConf->nPixelHeight - 1)); int nSX = nStartX / gnUnitWidth; int nSY = nStartY / gnUnitHeight; int nEX = nEndX / gnUnitWidth; int nEY = nEndY / gnUnitHeight; if (nSX == nEX && nSY == nEY) { return -2; } if (!CanWalk(nSX, nSY) || !CanWalk(nEX, nEY)) { return -3; } m_uSearchVersion++; ASTAR_NODE* pNode = GetNode(nSX, nSY); ASTAR_NODE* pEnd = GetNode(nEX, nEY); if (pNode == NULL || pEnd == NULL) { return -4; } m_OpenedList.Clear(); pNode->bOpened = true; m_OpenedList.Push(pNode); static int tDir[8][2] = { { -1, 1 }, { -1, 0 }, { -1, -1 }, { 0, 1 }, { 0, -1 }, { 1, 1 }, { 1, 0 }, { 1, -1 } }; while (!pEnd->bClosed && m_OpenedList.Size() > 0) { pNode = m_OpenedList.Min(); m_OpenedList.Remove(pNode); pNode->bOpened = false; pNode->bClosed = true; ASTAR_NODE* pTmpNode = NULL; for (int i = 0; i < 8; i++) { int nX = pNode->nX + tDir[i][0]; int nY = pNode->nY + tDir[i][1]; pTmpNode = GetNode(nX, nY); if (pTmpNode == NULL || !CanWalk(nX, nY)) { continue; } if (!CanDiagonalWalk(pNode, pTmpNode)) { continue; } int nG = pNode->nG + GetG(pNode->nX, pNode->nY, pTmpNode->nX, pTmpNode->nY); int nH = GetH(pTmpNode->nX, pTmpNode->nY, pEnd->nX, pEnd->nY); int nF = nG + nH; if (pTmpNode->bOpened || pTmpNode->bClosed) { if (pTmpNode->nKey > nF) { pTmpNode->nG = nG; pTmpNode->nH = nH; pTmpNode->nKey = nF; pTmpNode->pParent = pNode; if (pTmpNode->bOpened) { m_OpenedList.Update(pTmpNode); } } } else { pTmpNode->nG = nG; pTmpNode->nH = nH; pTmpNode->nKey = nF; pTmpNode->pParent = pNode; m_OpenedList.Push(pTmpNode); pTmpNode->bOpened = true; } } } if (!pEnd->bClosed) { return -5; } m_oTmpListPath.clear(); ASTAR_NODE* pTarNode = pNode; //XLog(LEVEL_DEBUG,"Robot path0:"); while (pTarNode != NULL) { ASTAR_POINT oASPos; oASPos.nX = pTarNode->nX; oASPos.nY = pTarNode->nY; //XLog(LEVEL_DEBUG, "[%d,%d] ", oASPos.nX, 35 - oASPos.nY); m_oTmpListPath.push_front(oASPos); pTarNode = pTarNode->pParent; } //XLog(LEVEL_DEBUG,"\n"); if (m_oTmpListPath.size() > 2) { Floyd(m_oTmpListPath); } ASLITER iter = m_oTmpListPath.begin(); ASLITER iter_end = m_oTmpListPath.end(); //XLog(LEVEL_DEBUG,"Robot path1:"); for (; iter != iter_end; iter++) { ASTAR_POINT& oPos = *iter; int nPosX = (int)((oPos.nX + 0.5f) * gnUnitWidth); int nPosY = (int)((oPos.nY + 0.5f) * gnUnitHeight); oListPath.push_back(Point(nPosX, nPosY)); //XLog(LEVEL_DEBUG,"[%d,%d](%d,%d) ", nPosX, nPosY, oPos.nX, 35-oPos.nY); } //XLog(LEVEL_DEBUG,"\n"); return 0; }
void CppDiffieHellman::Init() { _p_int = CryptoPP::Integer(reinterpret_cast<byte *>(GetP().data()), GetP().count()); _q_int = CryptoPP::Integer(reinterpret_cast<byte *>(GetQ().data()), GetQ().count()); _g_int = CryptoPP::Integer(reinterpret_cast<byte *>(GetG().data()), GetG().count()); }
HRESULT World::handleMessages(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { m_pic.handleMessages(hWnd, uMsg, wParam, lParam); if ( m_sound ) m_sound->handleMessages(hWnd, uMsg, wParam, lParam); bool bTalking = false; DialogList::iterator itDialog = m_scriptedDialog.begin(); for ( ; itDialog != m_scriptedDialog.end(); ++itDialog ) { (*itDialog)->handleMessages( hWnd, uMsg, wParam, lParam ); bTalking |= (*itDialog)->isTalking(); } UnitSet::iterator it = m_unitSet.begin(); for ( ; it != m_unitSet.end(); ++it ) { if ( (*it)->getType() == UT_HERO && GetWorldStateManager().curStateEnum() == GAME_WORLD_STATE_FIELD ) { if ( !bTalking ) { (*it)->handleMessages(hWnd, uMsg, wParam, lParam); } else getHero()->clearKey(); } } if (uMsg == WM_KEYDOWN) { if (wParam == VK_ESCAPE) { if ( GetWorldStateManager().curStateEnum() != GAME_WORLD_STATE_BATTLE ) GetWorldStateManager().setNextState(GAME_WORLD_STATE_MENU); } if (wParam == 'P') { printf("이녀석의 x 위치 : %d\n", m_heroUnit->getTilePosX()); printf("이녀석의 y 위치 : %d\n", m_heroUnit->getTilePosY()); } } if (uMsg == WM_KEYUP) { if (wParam == VK_RETURN) { if ( !m_curDialog ) startTileDefinedDialogIfExist(); if ( m_curDialog ) proceedCurDialog(); } if (wParam == VK_END) { forceCloseCurDialog(); } } switch ( uMsg ) { case WM_KEYDOWN: switch ( wParam ) { case 'C': ////////////////////////////////////////////////////////////////////////// // External camera test EpCamera& rCamera = GetG().m_camera; const ArnVec3& vHeroPos = getHeroPos(); static bool bExtCam = true; if ( bExtCam ) { rCamera.setExternalCamera( static_cast<ArnCamera*>(m_modelSg->getSceneRoot()->getNodeByName( "Camera" )) ); rCamera.begin( CAMERA_EXTERNAL ); } else { rCamera.setAttachPos( &vHeroPos ); rCamera.setSmoothCameraDuration( 1.0f ); rCamera.begin( CAMERA_SMOOTH_ATTACH ); } bExtCam = !bExtCam; ////////////////////////////////////////////////////////////////////////// break; } break; case WM_KEYUP: break; } if ( GetWorldStateManager().getCurState() ) GetWorldStateManager().getCurState()->handleMessages(hWnd, uMsg, wParam, lParam); return S_OK; }
HRESULT World::frameMove( double dTime, float fElapsedTime ) { EpCamera& camera = GetG().m_camera; HRESULT hr = S_OK; if ( m_bNotEntered ) { enter(); m_bNotEntered = false; } m_pic.frameMove(fElapsedTime); m_avatar.frameMove(fElapsedTime); //camera.frameMove(fElapsedTime); if ( m_sound ) m_sound->UpdateAudio(); DialogList::iterator itDialog = m_scriptedDialog.begin(); for ( ; itDialog != m_scriptedDialog.end(); ++itDialog ) { (*itDialog)->frameMove( dTime, fElapsedTime ); } //GetG().m_camera.frameMove( fElapsedTime ); m_sampleTeapotMeshRot += fElapsedTime * D3DXToRadian(35); // 35 degrees per second GetWorldStateManager().transit( dTime ); GetWorldStateManager().getCurState()->frameMove(dTime, fElapsedTime); m_modelSg->getSceneRoot()->update(dTime, fElapsedTime); WCHAR msg[128]; StringCchPrintf( msg, 128, L"Hero Pos : (%.2f, %.2f, %.2f)\n", m_heroUnit->getPos().x, m_heroUnit->getPos().y, m_heroUnit->getPos().z ); g_debugBuffer.append( msg ); StringCchPrintf( msg, 128, L"Hero TilePos : (%d, %d)\n", m_heroUnit->getTilePosX(), m_heroUnit->getTilePosY() ); g_debugBuffer.append( msg ); ArnVec3 diff = m_heroUnit->getPos() - *GetG().m_camera.GetEyePt(); StringCchPrintf( msg, 128, L"Hero - Camera Pos : (%.4f, %.4f, %.4f)\n", diff.x, diff.y, diff.z ); g_debugBuffer.append( msg ); if ( D3DXVec2Length( (const D3DXVECTOR2*)&diff ) > 0.001f) { // Check for camera and character move inconsistency when field state //DebugBreak(); } if ( ((Hero*)getHeroUnit())->isEncounterEnemy() && GetWorldStateManager().curStateEnum() != GAME_WORLD_STATE_BATTLE ) battleEventCheck(); wannaTalkingEventCheck(); // Incidents update IncidentList::iterator itInc = m_incidents.begin(); for ( ; itInc != m_incidents.end(); ++itInc ) { (*itInc)->update( dTime, fElapsedTime ); } UnitSet::iterator it2 = m_unitSet.begin(); for ( ; it2 != m_unitSet.end(); ++it2 ) { (*it2)->frameMove( dTime, fElapsedTime ); // TODO: // Any registered units will not be deallocated automatically // until the world destructed. } return hr; }