# HG changeset patch # User koryspansel # Date 1315587447 25200 # Node ID 817a7b518fbbd6aae42bc1910db6b5d336cfec66 # Parent 88b5c4d51c68dd8e149bde7ae872db9c750463b8 Fix up dialog buttons diff -r 88b5c4d51c68 -r 817a7b518fbb Assets/Maps/map03.def --- a/Assets/Maps/map03.def Thu Sep 08 11:55:35 2011 -0700 +++ b/Assets/Maps/map03.def Fri Sep 09 09:57:27 2011 -0700 @@ -21,7 +21,7 @@ 0,1 0,1 0,1 -1,2 +0,1 0,1 0,1 @@ -30,12 +30,12 @@ 0,1 1,2 0,1 -1,2 +0,1 0,1 0,1 0,1 -0,1 +1,2 0,1 1,2 0,1 @@ -44,7 +44,7 @@ 0,1 0,1 0,1 -0,1 +1,2 0,1 0,1 0,1 diff -r 88b5c4d51c68 -r 817a7b518fbb LightClone/Source/Controller.cpp --- a/LightClone/Source/Controller.cpp Thu Sep 08 11:55:35 2011 -0700 +++ b/LightClone/Source/Controller.cpp Fri Sep 09 09:57:27 2011 -0700 @@ -103,13 +103,13 @@ if(pModel->kInputManager.IsKeyDown(DIK_NEXT)) { - pView->UpdateCameraDistance(-0.1f); + pView->UpdateCameraDistance(0.1f); } else if(pModel->kInputManager.IsKeyDown(DIK_PRIOR)) { - pView->UpdateCameraDistance(0.1f); + pView->UpdateCameraDistance(-0.1f); } #endif @@ -238,6 +238,14 @@ { if(i == 0) { + if(pModel->nSimulationState == SimulationState_Active) + { + pModel->ResetEnvironment(); + pModel->ResetBot(); + + pModel->nSimulationState = SimulationState_Idle; + } + pModel->nGameState = GameState_LoadMap; } } @@ -248,6 +256,14 @@ if(nSelection == DialogButton_A) { + if(pModel->nSimulationState == SimulationState_Active) + { + pModel->ResetEnvironment(); + pModel->ResetBot(); + + pModel->nSimulationState = SimulationState_Idle; + } + pModel->nGameState = GameState_LoadMap; } */ diff -r 88b5c4d51c68 -r 817a7b518fbb LightClone/Source/Core.cpp --- a/LightClone/Source/Core.cpp Thu Sep 08 11:55:35 2011 -0700 +++ b/LightClone/Source/Core.cpp Fri Sep 09 09:57:27 2011 -0700 @@ -88,13 +88,42 @@ */ void ComputePickRay(float fScreenX, float fScreenY, const D3DVIEWPORT9& kViewport, const D3DXMATRIX& kProjection, const D3DXMATRIX& kView, D3DXVECTOR3* pOrigin, D3DXVECTOR3* pDirection) { - const float fX = +(2.0f * (fScreenX / kViewport.Width) - 1.0f) / kProjection._11; - const float fY = -(2.0f * (fScreenY / kViewport.Height) - 1.0f) / kProjection._22; - const float fZ = 1.0f; + const float fHalfSizeX = 0.5f * kViewport.Width; + const float fHalfSizeY = 0.5f * kViewport.Height; + const float fAspect = fHalfSizeX / fHalfSizeY; + const float fViewAngle = D3DX_PI / 4.0f; + const float fNear = 1.0f; + const float fFar = 1024.0f; + + const float fX = tanf(0.5f * fViewAngle) * (fScreenX / fHalfSizeX - 1.0f) / fAspect; + const float fY = tanf(0.5f * fViewAngle) * (1.0f - fScreenY / fHalfSizeY); + + //const float fX = +(2.0f * (fScreenX / kViewport.Width) - 1.0f) / kProjection._11; + //const float fY = -(2.0f * (fScreenY / kViewport.Height) - 1.0f) / kProjection._22; + //const float fZ = 1.0f; D3DXMATRIX kInverseView; D3DXMatrixInverse(&kInverseView, NULL, &kView); + D3DXVECTOR3 kPointA(fNear * fX, fNear * fY, fNear); + D3DXVECTOR3 kPointB(fFar * fX, fFar * fY, fFar); + + D3DXVECTOR3 kWorldA; + D3DXVec3TransformCoord(&kWorldA, &kPointA, &kInverseView); + + D3DXVECTOR3 kWorldB; + D3DXVec3TransformCoord(&kWorldB, &kPointB, &kInverseView); + + if(pOrigin) + *pOrigin = kWorldA; + + if(pDirection) + { + D3DXVec3Normalize(pDirection, &(kWorldB - kWorldA)); + //*pDirection = kWorldB - kWorldA; + } + + /* if(pOrigin) { pOrigin->x = kInverseView._41; @@ -108,6 +137,7 @@ pDirection->y = fX * kInverseView._12 + fY * kInverseView._22 + fZ * kInverseView._32; pDirection->z = fX * kInverseView._13 + fY * kInverseView._23 + fZ * kInverseView._33; } + */ } /* @@ -125,10 +155,10 @@ D3DXVECTOR3 kDelta; D3DXVec3Subtract(&kDelta, &kCameraOrigin, &kPlaneOrigin); - D3DXVec3Normalize(&kDelta, &kDelta); - float fD = D3DXVec3Dot(&kPlaneNormal, &kCameraDirection); - float fT = fD != 0.0f ? D3DXVec3Dot(&kPlaneNormal, &kDelta) / fD : 0.0f; + //float fD = D3DXVec3Dot(&kPlaneNormal, &kCameraDirection); + //float fT = fD != 0.0f ? D3DXVec3Dot(&kPlaneNormal, &kDelta) / fD : 0.0f; + const float fT = -D3DXVec3Dot(&kPlaneNormal, &kDelta) / D3DXVec3Dot(&kPlaneNormal, &kCameraDirection); return kCameraOrigin + fT * kCameraDirection; } \ No newline at end of file diff -r 88b5c4d51c68 -r 817a7b518fbb LightClone/Source/Interface.cpp --- a/LightClone/Source/Interface.cpp Thu Sep 08 11:55:35 2011 -0700 +++ b/LightClone/Source/Interface.cpp Fri Sep 09 09:57:27 2011 -0700 @@ -223,56 +223,59 @@ */ void Interface::Render(RenderContext& kContext, Model* pModel) { - kContext.SetupCamera2D(pEffect); - - uint32 nPasses = 0; + if(pModel->nGameState != GameState_Exit) + { + kContext.SetupCamera2D(pEffect); - pEffect->SetTechnique(pEffect->GetTechnique(0)); - pEffect->Begin(&nPasses, 0); - pEffect->BeginPass(0); + uint32 nPasses = 0; + + pEffect->SetTechnique(pEffect->GetTechnique(0)); + pEffect->Begin(&nPasses, 0); + pEffect->BeginPass(0); - RenderBackground(kContext, pModel); - RenderToolbar(kContext, pModel); - RenderMain(kContext, pModel); - RenderFunctions(kContext, pModel); - RenderControls(kContext, pModel); + RenderBackground(kContext, pModel); + RenderToolbar(kContext, pModel); + RenderMain(kContext, pModel); + RenderFunctions(kContext, pModel); + RenderControls(kContext, pModel); - if(pModel->nGameState == GameState_Active) - { - } - else + if(pModel->nGameState == GameState_Active) + { + } + else - if(pModel->nGameState == GameState_Complete) - { - char kMessage[256]; - sprintf_s(kMessage, "Congratulations!\nYou have completed level %d", pModel->nCurrentLevel); + if(pModel->nGameState == GameState_Complete) + { + char kMessage[256]; + sprintf_s(kMessage, "Congratulations!\nYou have completed level %d", pModel->nCurrentLevel); - RenderDialog(kContext, pModel, kMessage, "Ok"); - //RenderLevelDialog(kContext, pModel); - } - else + RenderDialog(kContext, pModel, kMessage, "Ok"); + //RenderLevelDialog(kContext, pModel); + } + else + + if(pModel->nGameState == GameState_Over) + { + const char* pMessage = "Congratulations!\nYou have won the game!"; - if(pModel->nGameState == GameState_Over) - { - const char* pMessage = "Congratulations!\nYou have won the game!"; + RenderDialog(kContext, pModel, pMessage, "Ok"); + //RenderGameOverDialog(kContext, pModel); + } + else + + if(pModel->nGameState == GameState_Confirm) + { + const char* pMessage = "Are you sure you want to quit the game?"; - RenderDialog(kContext, pModel, pMessage, "Ok"); - //RenderGameOverDialog(kContext, pModel); + RenderDialog(kContext, pModel, pMessage, "Yes", "No"); + //RenderConfirmExitDialog(kContext, pModel); + } + + RenderCursor(kContext, pModel); + + pEffect->EndPass(); + pEffect->End(); } - else - - if(pModel->nGameState == GameState_Confirm) - { - const char* pMessage = "Are you sure you want to quit the game?"; - - RenderDialog(kContext, pModel, pMessage, "Yes", "No"); - //RenderConfirmExitDialog(kContext, pModel); - } - - RenderCursor(kContext, pModel); - - pEffect->EndPass(); - pEffect->End(); } /* @@ -513,162 +516,79 @@ } /* - * RenderLevelDialog - */ -void Interface::RenderLevelDialog(RenderContext& kContext, Model* pModel) -{ - const D3DXVECTOR4 kColorVector(1.0f, 1.0f, 1.0f, 1.0f); - - D3DSURFACE_DESC kDescriptor; - pDialog1Texture->GetLevelDesc(0, &kDescriptor); - - const float fSizeX = (float)kDescriptor.Width; - const float fSizeY = (float)kDescriptor.Height; - - D3DXMATRIX kScale; - D3DXMatrixScaling(&kScale, fSizeX, fSizeY, 1.0f); - - D3DXMATRIX kTranslate; - D3DXMatrixTranslation(&kTranslate, -0.5f * fSizeX, 0.5f * fSizeY, 0.0f); - - D3DXMATRIX kWorldMatrix; - D3DXMatrixMultiply(&kWorldMatrix, &kScale, &kTranslate); - - pEffect->SetMatrix(pEffect->GetParameterByName(NULL, "kWorld"), &kWorldMatrix); - pEffect->SetVector(pEffect->GetParameterByName(NULL, "kColor"), &kColorVector); - pEffect->SetTexture(pEffect->GetParameterByName(NULL, "kTexture"), pDialog1Texture); - pEffect->CommitChanges(); - - kContext.DrawTriangles(Vertex::Quad::Declaration, pVertexBuffer, sizeof(Vertex::Quad), TrianglesPerFace); - - RECT kRectangle; - - kRectangle.left = ScreenSizeX / 2; - kRectangle.top = ScreenSizeY / 2 - 24; - kRectangle.right = ScreenSizeX / 2; - kRectangle.bottom = ScreenSizeY / 2 - 24; - - char kMessage[256]; - sprintf_s(kMessage, "Congratulations!\nYou have completed level %d", pModel->nCurrentLevel); - - pFont->DrawTextA(NULL, kMessage, -1, &kRectangle, DT_CENTER | DT_VCENTER | DT_CALCRECT, D3DCOLOR_XRGB(0, 0, 0)); - pFont->DrawTextA(NULL, kMessage, -1, &kRectangle, DT_CENTER | DT_VCENTER, D3DCOLOR_XRGB(0, 0, 0)); -} - -/* - * RenderGameOverDialog - */ -void Interface::RenderGameOverDialog(RenderContext& kContext, Model* pModel) -{ - const D3DXVECTOR4 kColorVector(1.0f, 1.0f, 1.0f, 1.0f); - - D3DSURFACE_DESC kDescriptor; - pDialog1Texture->GetLevelDesc(0, &kDescriptor); - - const float fSizeX = (float)kDescriptor.Width; - const float fSizeY = (float)kDescriptor.Height; - - D3DXMATRIX kScale; - D3DXMatrixScaling(&kScale, fSizeX, fSizeY, 1.0f); - - D3DXMATRIX kTranslate; - D3DXMatrixTranslation(&kTranslate, -0.5f * fSizeX, 0.5f * fSizeY, 0.0f); - - D3DXMATRIX kWorldMatrix; - D3DXMatrixMultiply(&kWorldMatrix, &kScale, &kTranslate); - - pEffect->SetMatrix(pEffect->GetParameterByName(NULL, "kWorld"), &kWorldMatrix); - pEffect->SetVector(pEffect->GetParameterByName(NULL, "kColor"), &kColorVector); - pEffect->SetTexture(pEffect->GetParameterByName(NULL, "kTexture"), pDialog1Texture); - pEffect->CommitChanges(); - - kContext.DrawTriangles(Vertex::Quad::Declaration, pVertexBuffer, sizeof(Vertex::Quad), TrianglesPerFace); - - RECT kRectangle; - - kRectangle.left = ScreenSizeX / 2; - kRectangle.top = ScreenSizeY / 2 - 24; - kRectangle.right = ScreenSizeX / 2; - kRectangle.bottom = ScreenSizeY / 2 - 24; - - const char* pMessage = "Congratulations!\nYou have won the game!"; - - pFont->DrawTextA(NULL, pMessage, -1, &kRectangle, DT_CENTER | DT_VCENTER | DT_CALCRECT, D3DCOLOR_XRGB(0, 0, 0)); - pFont->DrawTextA(NULL, pMessage, -1, &kRectangle, DT_CENTER | DT_VCENTER, D3DCOLOR_XRGB(0, 0, 0)); -} - -/* - * RenderConfirmExitDialog - */ -void Interface::RenderConfirmExitDialog(RenderContext& kContext, Model* pModel) -{ - const D3DXVECTOR4 kColorVector(1.0f, 1.0f, 1.0f, 1.0f); - - D3DSURFACE_DESC kDescriptor; - pDialog1Texture->GetLevelDesc(0, &kDescriptor); - - const float fSizeX = (float)kDescriptor.Width; - const float fSizeY = (float)kDescriptor.Height; - - D3DXMATRIX kScale; - D3DXMatrixScaling(&kScale, fSizeX, fSizeY, 1.0f); - - D3DXMATRIX kTranslate; - D3DXMatrixTranslation(&kTranslate, -0.5f * fSizeX, 0.5f * fSizeY, 0.0f); - - D3DXMATRIX kWorldMatrix; - D3DXMatrixMultiply(&kWorldMatrix, &kScale, &kTranslate); - - pEffect->SetMatrix(pEffect->GetParameterByName(NULL, "kWorld"), &kWorldMatrix); - pEffect->SetVector(pEffect->GetParameterByName(NULL, "kColor"), &kColorVector); - pEffect->SetTexture(pEffect->GetParameterByName(NULL, "kTexture"), pDialog1Texture); - pEffect->CommitChanges(); - - kContext.DrawTriangles(Vertex::Quad::Declaration, pVertexBuffer, sizeof(Vertex::Quad), TrianglesPerFace); - - RECT kRectangle; - - kRectangle.left = ScreenSizeX / 2; - kRectangle.top = ScreenSizeY / 2 - 24; - kRectangle.right = ScreenSizeX / 2; - kRectangle.bottom = ScreenSizeY / 2 - 24; - - const char* pMessage = "Are you sure you want to quit the game?"; - - pFont->DrawTextA(NULL, pMessage, -1, &kRectangle, DT_CENTER | DT_VCENTER | DT_CALCRECT, D3DCOLOR_XRGB(0, 0, 0)); - pFont->DrawTextA(NULL, pMessage, -1, &kRectangle, DT_CENTER | DT_VCENTER, D3DCOLOR_XRGB(0, 0, 0)); -} - -/* * RenderDialog */ void Interface::RenderDialog(RenderContext& kContext, Model* pModel, const char* pMessage, const char* pChoiceA, const char* pChoiceB) +//void Interface::RenderDialog(RenderContext& kContext, const Dialog& kDialog) { if(pMessage && pChoiceA) { - IDirect3DTexture9* pTexture = pChoiceB ? pDialog2Texture : pDialog1Texture; + IDirect3DTexture9* pDialogTexture = pChoiceB ? pDialog2Texture : pDialog1Texture; D3DSURFACE_DESC kDescriptor; - pTexture->GetLevelDesc(0, &kDescriptor); + pDialogTexture->GetLevelDesc(0, &kDescriptor); const float fSizeX = (float)kDescriptor.Width; const float fSizeY = (float)kDescriptor.Height; - D3DXMATRIX kScale; - D3DXMatrixScaling(&kScale, fSizeX, fSizeY, 1.0f); + { + D3DXMATRIX kScale; + D3DXMatrixScaling(&kScale, fSizeX, fSizeY, 1.0f); + + D3DXMATRIX kTranslate; + D3DXMatrixTranslation(&kTranslate, -0.5f * fSizeX, 0.5f * fSizeY, 0.0f); + + D3DXMATRIX kWorldMatrix; + D3DXMatrixMultiply(&kWorldMatrix, &kScale, &kTranslate); - D3DXMATRIX kTranslate; - D3DXMatrixTranslation(&kTranslate, -0.5f * fSizeX, 0.5f * fSizeY, 0.0f); + pEffect->SetMatrix(pEffect->GetParameterByName(NULL, "kWorld"), &kWorldMatrix); + pEffect->SetTexture(pEffect->GetParameterByName(NULL, "kTexture"), pDialogTexture); + pEffect->SetVector(pEffect->GetParameterByName(NULL, "kColor"), &D3DXVECTOR4(1.0f, 1.0f, 1.0f, 1.0f)); + pEffect->CommitChanges(); + + kContext.DrawTriangles(Vertex::Quad::Declaration, pVertexBuffer, sizeof(Vertex::Quad), TrianglesPerFace); + } + + /* + for(uint32 i = 0; i < kDialog.nButtonCount; ++i) + { + D3DXMATRIX kScale; + D3DXMatrixScaling(&kScale, fSizeX, fSizeY, 1.0f); + + D3DXMATRIX kTranslate; + D3DXMatrixTranslation(&kTranslate, -0.5f * fSizeX, 0.5f * fSizeY, 0.0f); - D3DXMATRIX kWorldMatrix; - D3DXMatrixMultiply(&kWorldMatrix, &kScale, &kTranslate); + D3DXMATRIX kWorldMatrix; + D3DXMatrixMultiply(&kWorldMatrix, &kScale, &kTranslate); + + pEffect->SetMatrix(pEffect->GetParameterByName(NULL, "kWorld"), &kWorldMatrix); + pEffect->SetTexture(pEffect->GetParameterByName(NULL, "kTexture"), pDialogTexture); + pEffect->SetVector(pEffect->GetParameterByName(NULL, "kColor"), &D3DXVECTOR4(1.0f, 1.0f, 1.0f, 1.0f)); + pEffect->CommitChanges(); + + kContext.DrawTriangles(Vertex::Quad::Declaration, pVertexBuffer, sizeof(Vertex::Quad), TrianglesPerFace); + } + */ - pEffect->SetMatrix(pEffect->GetParameterByName(NULL, "kWorld"), &kWorldMatrix); - pEffect->SetTexture(pEffect->GetParameterByName(NULL, "kTexture"), pTexture); - pEffect->SetVector(pEffect->GetParameterByName(NULL, "kColor"), &D3DXVECTOR4(1.0f, 1.0f, 1.0f, 1.0f)); - pEffect->CommitChanges(); + #if 0 + { + D3DXMATRIX kScale; + D3DXMatrixScaling(&kScale, pModel->kDialog1Bounds[0].Width, pModel->kDialog1Bounds[0].Height, 1.0f); + + D3DXMATRIX kTranslate; + D3DXMatrixTranslation(&kTranslate, -0.5f * ScreenSizeX + pModel->kDialog1Bounds[0].X, 0.5f * ScreenSizeY - pModel->kDialog1Bounds[0].Y, 0.0f); - kContext.DrawTriangles(Vertex::Quad::Declaration, pVertexBuffer, sizeof(Vertex::Quad), TrianglesPerFace); + D3DXMATRIX kWorldMatrix; + D3DXMatrixMultiply(&kWorldMatrix, &kScale, &kTranslate); + + pEffect->SetMatrix(pEffect->GetParameterByName(NULL, "kWorld"), &kWorldMatrix); + pEffect->SetTexture(pEffect->GetParameterByName(NULL, "kTexture"), pTexture); + pEffect->SetVector(pEffect->GetParameterByName(NULL, "kColor"), &D3DXVECTOR4(1.0f, 1.0f, 1.0f, 1.0f)); + pEffect->CommitChanges(); + + kContext.DrawTriangles(Vertex::Quad::Declaration, pVertexBuffer, sizeof(Vertex::Quad), TrianglesPerFace); + } + #endif RECT kRectangle; @@ -680,7 +600,16 @@ pFont->DrawTextA(NULL, pMessage, -1, &kRectangle, DT_CENTER | DT_VCENTER | DT_CALCRECT, D3DCOLOR_XRGB(0, 0, 0)); pFont->DrawTextA(NULL, pMessage, -1, &kRectangle, DT_CENTER | DT_VCENTER, D3DCOLOR_XRGB(0, 0, 0)); - //TODO: Render button text + kRectangle.left = (int32)pModel->kDialog1Bounds[0].X; + kRectangle.right = (int32)(pModel->kDialog1Bounds[0].X + pModel->kDialog1Bounds[0].Width); + kRectangle.top = (int32)pModel->kDialog1Bounds[0].Y; + kRectangle.bottom = (int32)(pModel->kDialog1Bounds[0].Y + pModel->kDialog1Bounds[0].Height); + + pFont->DrawTextA(NULL, pChoiceA, -1, &kRectangle, DT_CENTER | DT_VCENTER, D3DCOLOR_XRGB(0, 0, 0)); + + if(pChoiceB) + { + } } } diff -r 88b5c4d51c68 -r 817a7b518fbb LightClone/Source/Model.cpp --- a/LightClone/Source/Model.cpp Thu Sep 08 11:55:35 2011 -0700 +++ b/LightClone/Source/Model.cpp Fri Sep 09 09:57:27 2011 -0700 @@ -18,7 +18,7 @@ kArrowBounds[0] = Rectangle2(1206.0f + 0 * 16.0f, 473.0f + 0 * 54.0f, 16.0f, 16.0f); kArrowBounds[1] = Rectangle2(1206.0f + 2 * 16.0f, 473.0f + 0 * 54.0f, 16.0f, 16.0f); - kDialog1Bounds[0] = Rectangle2(1023.0f + 2.5f * 54.0f, 638.0f + 0 * 00.0f, 48.0f, 48.0f); + kDialog1Bounds[0] = Rectangle2(567.0f, 412.0f, 150.0f, 60.0f); kDialog2Bounds[0] = Rectangle2(1023.0f + 2.5f * 54.0f, 638.0f + 0 * 00.0f, 48.0f, 48.0f); kDialog2Bounds[1] = Rectangle2(1023.0f + 2.5f * 54.0f, 638.0f + 0 * 00.0f, 48.0f, 48.0f); @@ -68,15 +68,15 @@ */ bool Model::Load(const char* pName) { - if(pFunction) - { - delete[] pFunction; - pFunction = NULL; - } - ErrorCode eCode = kLoader.Load(pName); if(eCode == Error_Success) { + if(pFunction) + { + delete[] pFunction; + pFunction = NULL; + } + const Size& kSize = kLoader.GetSize(); eCode = kEnvironment.Initialize(kSize.X, kSize.Y); @@ -174,3 +174,13 @@ pFunction[i].Clear(); } } + +/* + * SetupDialog + */ +void Model::SetupDialog(const char* pMessage, const char* pChoiceA, uint32 nResultA, const char* pChoiceB, uint32 nResultB) +{ + kDialog.Reset("Some message"); + //kDialog.AddButton(DialogButton_Ok, "Ok", 0.0f, 0.0f, 0.0f, 0.0f); + kDialog.AddButton(nResultA, pMessageA, +} diff -r 88b5c4d51c68 -r 817a7b518fbb LightClone/Source/Model.h --- a/LightClone/Source/Model.h Thu Sep 08 11:55:35 2011 -0700 +++ b/LightClone/Source/Model.h Fri Sep 09 09:57:27 2011 -0700 @@ -183,6 +183,11 @@ * ResetCode */ void ClearCode(); + + /* + * SetupDialog + */ + void SetupDialog(const char* pMessage, const char* pChoiceA, uint32 nResultA, const char* pChoiceB = NULL, uint32 nResultB = 0); }; #endif //__MODEL_H__ diff -r 88b5c4d51c68 -r 817a7b518fbb LightClone/Source/View.cpp --- a/LightClone/Source/View.cpp Thu Sep 08 11:55:35 2011 -0700 +++ b/LightClone/Source/View.cpp Fri Sep 09 09:57:27 2011 -0700 @@ -286,7 +286,8 @@ const uint32 nSizeX = pEnvironment->GetWidth(); const uint32 nSizeY = pEnvironment->GetHeight(); - const D3DXVECTOR3 kTarget(0.5f * (nSizeX - 1) * kScale.x, 0.0f, 0.5f * (nSizeY - 1) * kScale.z); + //const D3DXVECTOR3 kTarget(0.5f * (nSizeX - 1) * kScale.x, 0.0f, 0.5f * (nSizeY - 1) * kScale.z); + const D3DXVECTOR3 kTarget(0.0f, 0.0f, 0.0f); kContext.SetupCamera3D(pBlockEffect, kCameraController.GetLocation(kTarget), kTarget); @@ -329,8 +330,12 @@ D3DVIEWPORT9 kViewport; kContext.GetViewport(&kViewport); - //D3DXVECTOR3 kCenterWorld(0.0f, 0.0f, 0.0f); - const D3DXVECTOR3& kCenterWorld = ComputeOrigin(0.5f * (ScreenSizeX - 304.0f), 0.5f * ScreenSizeY, kViewport, kProjection, kView); + D3DXVECTOR3 kCenterWorld(0.0f, 0.0f, 0.0f); + const float fMagicOffset = 400.0f; + //const D3DXVECTOR3& kCenterWorld = ComputeOrigin(0.5f * (ScreenSizeX - (304.0f + fMagicOffset)), 0.5f * ScreenSizeY, kViewport, kProjection, kView); + + const float fOffsetX = -0.5f * (nSizeX * kScale.x); + const float fOffsetZ = -0.5f * (nSizeY * kScale.z); for(uint32 nZ = 0; nZ < nSizeY; ++nZ) { @@ -349,7 +354,7 @@ for(uint32 i = 0; i < pEnvironment->GetAltitude(nX, nZ); ++i) { D3DXMATRIX kTranslateMatrix; - D3DXMatrixTranslation(&kTranslateMatrix, kCenterWorld.x + nX * kScale.x, i * kScale.y, kCenterWorld.z + nZ * kScale.z); + D3DXMatrixTranslation(&kTranslateMatrix, fOffsetX + (kCenterWorld.x + nX) * kScale.x, i * kScale.y, fOffsetZ + (kCenterWorld.z + nZ) * kScale.z); D3DXMATRIX kWorldMatrix; D3DXMatrixMultiply(&kWorldMatrix, &kScaleMatrix, &kTranslateMatrix); @@ -417,6 +422,9 @@ const D3DXVECTOR3& kPosition = pBot->GetWorldPosition(); const D3DXVECTOR3& kOrientation = pBot->GetWorldOrientation(); + const float fOffsetX = -0.5f * (pEnvironment->GetWidth() * pEnvironment->GetScale().x); + const float fOffsetZ = -0.5f * (pEnvironment->GetHeight() * pEnvironment->GetScale().z); + uint32 nPasses = 0; pBlockEffect->SetTechnique(pBlockEffect->GetTechnique(0)); @@ -427,7 +435,7 @@ D3DXMatrixScaling(&kScale, pBot->kSize.x, pBot->kSize.y, pBot->kSize.z); D3DXMATRIX kTranslate; - D3DXMatrixTranslation(&kTranslate, kPosition.x, kPosition.y, kPosition.z); + D3DXMatrixTranslation(&kTranslate, fOffsetX + kPosition.x, kPosition.y, fOffsetZ + kPosition.z); D3DXMATRIX kRotate; D3DXMatrixRotationY(&kRotate, kOrientation.y);