void CSelectScene::Update() { m_cursor.Update(); (*GetKeyDevice()).GetDeviceState( sizeof(diks), // パラメータ バッファサイズ &diks); if (GAMEPAD(CGamepad)->GetConnected()) { if (GAMEPAD(CGamepad)->isButtonsTrg(GAMEPAD_A)) { STAGEMANEGER->SelectStage(1); SINSTANCE(CSceneManager)->ChangeScene(SCENE::GAME); } } else { if (KEYDOWN(diks, DIK_A)) { STAGEMANEGER->SelectStage(1); SINSTANCE(CSceneManager)->ChangeScene(SCENE::GAME); } } GAMEPAD(CGamepad)->UpdateControllerState(); }
void CScore::Update() { if (m_player == NULL) { m_player = (SINSTANCE(CObjectManager)->FindGameObject<CPlayer>(_T("TEST3D"))); } if (m_number == NULL) { m_number =(SINSTANCE(CObjectManager)->FindGameObject<CNumber>(_T("Number"))); } if (m_player != NULL&&m_number!=NULL){ //CNumber* pNumber = SINSTANCE(CObjectManager)->FindGameObject<CNumber>(_T("ResultNumber")); score = ENEMY_BONUS * m_player->GetBusterEnemyNum(); m_number->SetValue(score); } }
void CUpFloor::Initialize(D3DXVECTOR3 pos, D3DXQUATERNION rot, D3DXVECTOR3 scale) { strcpy(m_pFileName, "image/down_block.x"); C3DImage::Initialize(); m_transform.position = pos; StartPos = m_transform.position; m_transform.scale = scale; m_transform.angle = rot; if (scale.z != 1.0f){ this->Build(D3DXVECTOR3(1.5f * scale.x, 0.3f * scale.y, 1.75f * scale.z), m_transform.position); } else{ this->Build(D3DXVECTOR3(1.5f * scale.x, 0.3f * scale.y, 1.0f * scale.z), m_transform.position); } m_player = SINSTANCE(CObjectManager)->FindGameObject<CPlayer>(_T("TEST3D")); m_rigidBody->setActivationState(DISABLE_DEACTIVATION); SetAlive(true); m_IamFlgKeeper = false; C3DImage::SetImage(); }
void Update() { //SceneManagerのupdate g_bulletPhysics.Update(); //物理エンジン更新 SINSTANCE(CSceneManager)->UpdateScene(); }
void CCBManager::NonActivate(){ for (int idx = 0; idx < CHOCO_NUM; idx++){ m_Choco[idx].SetAlive(false); SINSTANCE(CShadowRender)->DeleteObject(&m_Choco[idx]); } SetAlive(false); }
void Initialize() { graphicsDevice().InitD3d(hWnd); GetKeyDevice().Initialize(hWnd); //SceneManagerのinitialize g_bulletPhysics.InitPysics(); //物理エンジン初期化 SINSTANCE(CSceneManager)->InitializeScene(); gamen.Initialize(); RT.Create(BACKWINDOW_WIDTH, BACKWINDOW_HEIGHT, 1, D3DFMT_A8R8G8B8, D3DFMT_D16, D3DMULTISAMPLE_NONE, 0); BR.Create(true); }
/*! * @brief 作成。 */ void CDofRender::Create() { int w = SINSTANCE(CRenderContext)->GetWindowWidth(); int h = SINSTANCE(CRenderContext)->GetWindowHeight(); //レンダリングターゲットを作成。 //深度情報抽出用 (*graphicsDevice()).CreateDepthStencilSurface(w, h, D3DFMT_D16, D3DMULTISAMPLE_NONE, 0, TRUE, &m_DepthSamplingTarget, NULL); (*graphicsDevice()).CreateTexture(w, h, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &m_pDepthSamplingTexture, NULL); m_pDepthSamplingTexture->GetSurfaceLevel(0, &m_DepthSamplingTarget); //横ブラー用。 (*graphicsDevice()).CreateDepthStencilSurface(w, h, D3DFMT_D16, D3DMULTISAMPLE_NONE, 0, TRUE, &m_RenderTarget[0], NULL); (*graphicsDevice()).CreateTexture(w, h, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &m_pBlurTexture[0], NULL); m_pBlurTexture[0]->GetSurfaceLevel(0, &m_RenderTarget[0]); //縦ブラー用。 (*graphicsDevice()).CreateDepthStencilSurface(w, h, D3DFMT_D16, D3DMULTISAMPLE_NONE, 0, TRUE, &m_RenderTarget[1], NULL); (*graphicsDevice()).CreateTexture(w, h, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &m_pBlurTexture[1], NULL); m_pBlurTexture[1]->GetSurfaceLevel(0, &m_RenderTarget[1]); m_pEffect = SINSTANCE(CEffect)->LoadEffect(_T("Shader/DepthOfField.hlsl")); m_FarNear = D3DXVECTOR2(100.0f, 1.0f); m_isEnable = true; };
void CUpFloor::Build(const D3DXVECTOR3& size, const D3DXVECTOR3& pos){ //この引数に渡すのはボックスhalfsizeなので、0.5倍する。 m_collisionShape = new btBoxShape(btVector3(size.x*0.5f, size.y*0.5f, size.z*0.5f)); btTransform groundTransform; groundTransform.setIdentity(); groundTransform.setOrigin(btVector3(pos.x, pos.y, pos.z)); groundTransform.setRotation(btQuaternion(m_transform.angle.x, m_transform.angle.y, m_transform.angle.z, m_transform.angle.w)); float mass = 0.0f; //using motionstate is optional, it provides interpolation capabilities, and only synchronizes 'active' objects m_myMotionState = new btDefaultMotionState(groundTransform); btRigidBody::btRigidBodyConstructionInfo rbInfo(mass, m_myMotionState, m_collisionShape, btVector3(0, 0, 0)); m_rigidBody = new btRigidBody(rbInfo); //m_rigidBody->setUserIndex(1); //ワールドに追加。 SINSTANCE(CObjectManager)->FindGameObject<CBulletPhysics>(_T("BulletPhysics"))->AddRigidBody(m_rigidBody); }
void Draw() { //(*graphicsDevice()).Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); (*graphicsDevice()).Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(255, 255, 255), 1.0f, 0); (*graphicsDevice()).BeginScene(); (*graphicsDevice()).GetViewport(&m_viewport); (*graphicsDevice()).GetRenderTarget(0, &m_Backbuffer); (*graphicsDevice()).GetDepthStencilSurface(&m_BackZ); (*graphicsDevice()).SetRenderTarget(0, RT.GetSurfaceDx()); (*graphicsDevice()).SetDepthStencilSurface(RT.GetDepthSurfaceDx()); //(*graphicsDevice()).Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); (*graphicsDevice()).Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(255, 255, 255), 1.0f, 0); D3DVIEWPORT9 viewport = { 0, 0, BACKWINDOW_WIDTH, BACKWINDOW_HEIGHT, 0.0f, 1.0f }; (*graphicsDevice()).SetViewport(&viewport); (*graphicsDevice()).SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); SINSTANCE(CSceneManager)->DrawScene(); (*graphicsDevice()).SetRenderTarget(0, m_Backbuffer); (*graphicsDevice()).SetDepthStencilSurface(m_BackZ); (*graphicsDevice()).SetViewport(&m_viewport); (*graphicsDevice()).SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW); gamen.SetTex(RT.GetTexture()); static float a=0,b=0; // a+=0.5f*1.5; //b += 1; gamen.Draw(D3DXVECTOR3(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2, 1.0f), D3DXVECTOR3(WINDOW_WIDTH - (WINDOW_WIDTH / 100)*b, WINDOW_HEIGHT - (WINDOW_HEIGHT / 100)*b, 0.0f), a); BR.Render(); (*graphicsDevice()).EndScene(); (*graphicsDevice()).Present(NULL, NULL, NULL, NULL); }
/*! * @brief 描画。 */ void CDofRender::Draw(LPDIRECT3DTEXTURE9 tex) { if (m_isEnable) { UpdateWeight(200.0f); LPDIRECT3DSURFACE9 RenderingTarget; LPDIRECT3DSURFACE9 m_SavedMapZ; // もとのレンダリングターゲットを保存 (*graphicsDevice()).GetRenderTarget(0, &RenderingTarget); (*graphicsDevice()).GetDepthStencilSurface(&m_SavedMapZ); m_Primitive = SINSTANCE(CRenderContext)->GetPrimitive(); // 深度情報抽出 { (*graphicsDevice()).SetRenderTarget(0, m_DepthSamplingTarget); (*graphicsDevice()).Clear(0, nullptr, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0, 1.0f, 0); vector<OBJECT_DATA*> Objects = SINSTANCE(CObjectManager)->GetObjectList(); int size = Objects.size(); for (PRIORTY priorty = PRIORTY::PLAYER; priorty < PRIORTY::OBJECT2D; priorty = static_cast<PRIORTY>(priorty + 1)){ // 優先度の高いものから更新 for (int idx = 0; idx < size; idx++){ if (Objects[idx]->object->GetAlive()){ if (Objects[idx]->priority == priorty){ Objects[idx]->object->DrawDepth(m_pEffect,m_FarNear); //static_cast<C3DImage*>(Objects[idx]->object)->DrawDepth(); //if (/*アニメーションするか*/){ // //(*graphicsDevice()).DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); //} //else{ // //(*graphicsDevice()).DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); //} } } } } } int w = SINSTANCE(CRenderContext)->GetWindowWidth(); int h = SINSTANCE(CRenderContext)->GetWindowHeight(); //XBlur { (*graphicsDevice()).SetRenderTarget(0, m_RenderTarget[0]); //(*graphicsDevice()).Clear(0, nullptr, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0, 1.0f, 0); m_pEffect->SetTechnique("XBlur"); m_pEffect->Begin(NULL, D3DXFX_DONOTSAVESHADERSTATE); m_pEffect->BeginPass(0); float size[2] = { static_cast<float>(w), static_cast<float>(h) }; float offset[] = { 16.0f / static_cast<float>(w), 0.0f }; m_pEffect->SetValue("g_TexSize", size, sizeof(size)); m_pEffect->SetValue("g_offset", offset, sizeof(offset)); m_pEffect->SetValue("g_weight", m_weights, sizeof(m_weights)); m_pEffect->SetTexture("g_blur", tex); m_pEffect->CommitChanges(); (*graphicsDevice()).SetVertexDeclaration(m_Primitive->GetVertexDecl()); (*graphicsDevice()).SetStreamSource(0, m_Primitive->GetVertexBuffer(), 0, sizeof(SShapeVertex_PT)); (*graphicsDevice()).SetIndices(m_Primitive->GetIndexBuffer()); (*graphicsDevice()).DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); m_pEffect->EndPass(); m_pEffect->End(); } //YBlur { (*graphicsDevice()).SetRenderTarget(0, m_RenderTarget[1]); //(*graphicsDevice()).Clear(0, nullptr, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0, 1.0f, 0); m_pEffect->SetTechnique("YBlur"); m_pEffect->Begin(NULL, D3DXFX_DONOTSAVESHADERSTATE); m_pEffect->BeginPass(0); float size[2] = { static_cast<float>(w), static_cast<float>(h) }; float offset[] = { 0.0f, 16.0f / static_cast<float>(h) }; m_pEffect->SetValue("g_TexSize", size, sizeof(size)); m_pEffect->SetValue("g_offset", offset, sizeof(offset)); m_pEffect->SetValue("g_weight", m_weights, sizeof(m_weights)); m_pEffect->SetTexture("g_blur", m_pBlurTexture[0]); m_pEffect->CommitChanges(); (*graphicsDevice()).SetVertexDeclaration(m_Primitive->GetVertexDecl()); (*graphicsDevice()).SetStreamSource(0, m_Primitive->GetVertexBuffer(), 0, sizeof(SShapeVertex_PT)); (*graphicsDevice()).SetIndices(m_Primitive->GetIndexBuffer()); (*graphicsDevice()).DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); m_pEffect->EndPass(); m_pEffect->End(); } { float offset[] = { 0.5f / static_cast<float>(w), 0.5f / static_cast<float>(h) }; //戻す。 (*graphicsDevice()).SetRenderTarget(0, RenderingTarget); (*graphicsDevice()).SetDepthStencilSurface(m_SavedMapZ); //深度情報を参照して合成。 m_pEffect->SetTechnique("Final"); m_pEffect->Begin(NULL, D3DXFX_DONOTSAVESHADERSTATE); m_pEffect->BeginPass(0); m_pEffect->SetTexture("g_Texture", tex); m_pEffect->SetTexture("g_DepthSample", m_pDepthSamplingTexture); m_pEffect->SetTexture("g_blur", m_pBlurTexture[1]); m_pEffect->SetValue("g_offset", offset, sizeof(offset)); m_pEffect->CommitChanges(); (*graphicsDevice()).SetVertexDeclaration(m_Primitive->GetVertexDecl()); (*graphicsDevice()).SetStreamSource(0, m_Primitive->GetVertexBuffer(), 0, sizeof(SShapeVertex_PT)); (*graphicsDevice()).SetIndices(m_Primitive->GetIndexBuffer()); (*graphicsDevice()).DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); m_pEffect->EndPass(); m_pEffect->End(); } } };
void CStage9::Update() { m_Player.Died(playerpos_stage9); if (m_goal.GetGoal() != true) { if (GAMEPAD(CGamepad)->GetConnected()) { ExecuteChangeCamera(ARRAYSIZE(collision9InfoTable2D), ARRAYSIZE(collision9InfoTable3D)); } else { if (!(GAMEFLG->Getflg())) { if (GetAsyncKeyState(VK_RIGHT) & 0x8000) { m_camera.RotTransversal(-0.05f); } if (GetAsyncKeyState(VK_LEFT) & 0x8000) { m_camera.RotTransversal(0.05f); } } if (GetAsyncKeyState(VK_Q) & 0x8000) { GAMEFLG->Set2D(); m_camera.Set2DProj(); } if (GetAsyncKeyState(VK_W) & 0x8000) { GAMEFLG->Set3D(); m_camera.Set3DProj(); } } m_camera.Update(); m_Player.Update();//プレイヤー CStage::Update(); D3DXVECTOR3 lightPos = m_Player.GetPosition() + D3DXVECTOR3(2.0f, 5.0f, 2.0f); g_Shadow.SetLightPosition(lightPos); D3DXVECTOR3 lightDir = m_Player.GetPosition() - lightPos; D3DXVec3Normalize(&lightDir, &lightDir); g_Shadow.SetLightDirection(lightDir); m_Ground9.Update();//地面 m_gimmick.Update(); m_pointa.Update();//ポインタ m_GameCursor.Update();//ゲームカーソル m_GCursorWind.Update();//ゲームカーソルかぜ m_Back1.Update(); m_GameCursor3D.Update();//ゲームカーソル3D //レイカーソルに値をセット m_Ray.Update(m_GameCursor.GetPosition(), m_camera.GetViewMatrix(), m_camera.GetProjectionMatrix()); m_goal.Update(); } else if (m_goal.GetGoal() == true) { CStage::StopStageAudio(); m_Player.StopRunAudio(); m_Player.StopJumpAudio(); m_goal.SetGoalAudio(); m_pointa.SetDraw(false); m_Player.Update(); m_goal.Update(); m_Player.SetState(CPlayer::StateGoal); GoalCount++; if (GoalCount >= 300) { m_goal.StopGoalAudio(); Remove3DRigidBody(ARRAYSIZE(collision9InfoTable3D)); Remove2DRigidBody(ARRAYSIZE(collision9InfoTable2D)); dl.SetData(0); SINSTANCE(CSceneManager)->ChangeScene(SCENE::RESULT); } } GAMEPAD(CGamepad)->UpdateControllerState(); }
void CEnemyBullet::Initialize(){ m_enemybullet = SINSTANCE(CObjectManager)->GenerationObject<Bullet>(_T("EnemyBullet"), PRIORTY::BULLET, false); m_enemybullet->Initialize(); m_Range = 20.0f; }
void CCBManager::Update() { //チョコボールを生成していく。 const float deltaTime = 1.0f / 60.0f; m_timer += deltaTime; if (m_interval < m_timer){ int createCount = 0; while ( m_numCreate < CHOCO_NUM ){ if (createCount == 10){ break; } float rate = 100.0f / (rand() % 100 + 1); rate /= 50.0f; if (rand() % 2){ rate *= -1.0f; } D3DXVECTOR3 pos(GetStartPosition()); pos.x += rate; pos.z += fabsf(rate); pos.y += rate; D3DXVECTOR3 Epos(GetEndPosition()); Epos.x += rate; Epos.z += fabsf(rate); Epos.y += rate; m_Choco[m_numCreate].Initialize(pos, Epos); //if (m_IsFirst){ // D3DXMESHCONTAINER_DERIVED* pMeshContainer = static_cast<D3DXMESHCONTAINER_DERIVED*>(m_Choco[m_numCreate].GetImage()->pModel->GetFrameRoot()->pMeshContainer); // LPDIRECT3DVERTEXBUFFER9 buffer; // pMeshContainer->MeshData.pMesh->GetVertexBuffer(&buffer)/*->GetBufferPointer()*/; // VOID* pVertices; // buffer->Lock(0, sizeof(buffer), (void**)&pVertices, 0); // D3DVERTEXBUFFER_DESC desc; // buffer->GetDesc(&desc); // int stride = D3DXGetFVFVertexSize(desc.FVF); // char* p = (char*)pVertices; // int offset = -1; // D3DVERTEXELEMENT9 pDecl[MAX_FVF_DECL_SIZE]; // memset(pDecl, -1, sizeof(pDecl)); // pMeshContainer->MeshData.pMesh->GetDeclaration(pDecl); // for (int idx = 0; idx < MAX_FVF_DECL_SIZE; idx++){ // if (pDecl[idx].Stream == 255){ // //終わり // break; // } // if (pDecl[idx].Usage == D3DDECLUSAGE_BINORMAL){ // offset = pDecl[idx].Offset; // } // } // for (int vertNo = 0; vertNo < pMeshContainer->MeshData.pMesh->GetNumVertices(); vertNo++){ // D3DXVECTOR3* pBinomal = (D3DXVECTOR3*)&p[offset]; // pBinomal->x = // p += stride; // } // // // //buffer // //m_pVertexBuffer-> // //memcpy(pVertices, buffer, sizeof(buffer)); // //pVertices // buffer->Unlock(); // (*graphicsDevice()).CreateVertexBuffer(sizeof(buffer), 0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &m_pVertexBuffer, nullptr); // m_IsFirst = false; //} SINSTANCE(CShadowRender)->Entry(&m_Choco[m_numCreate]); createCount++; m_numCreate++; } } for (int i = 0; i < m_numCreate; i++) { m_Choco[i].Update(); } }