void FEDebuggerInfo::Draw() { const float kWidthInterval = CoordinateInfo::sWidth / kGridWidth; const float kLengthInterval = CoordinateInfo::sLength / kGridLength; for(int i = 0; i < kGridWidth - 1; ++i) { Vec2 vPos1(-CoordinateInfo::sLength / 2.f, -CoordinateInfo::sWidth / 2.f + kWidthInterval * (i + 1)); Vec2 vPos2( CoordinateInfo::sLength / 2.f, -CoordinateInfo::sWidth / 2.f + kWidthInterval * (i + 1)); Vec2 vScreenPos1 = CoordinateInfo::WorldToScreen(vPos1); Vec2 vScreenPos2 = CoordinateInfo::WorldToScreen(vPos2); g_poSROU->DrawLine(vScreenPos1.x, vScreenPos1.y, vScreenPos2.x, vScreenPos2.y, D_Color(128, 128, 128), 1.f); } for(int i = 0; i < kGridLength - 1; ++i) { Vec2 vPos1(-CoordinateInfo::sLength / 2.f + kLengthInterval * (i + 1), CoordinateInfo::sWidth / 2.f); Vec2 vPos2(-CoordinateInfo::sLength / 2.f + kLengthInterval * (i + 1), -CoordinateInfo::sWidth / 2.f); Vec2 vScreenPos1 = CoordinateInfo::WorldToScreen(vPos1); Vec2 vScreenPos2 = CoordinateInfo::WorldToScreen(vPos2); g_poSROU->DrawLine(vScreenPos1.x, vScreenPos1.y, vScreenPos2.x, vScreenPos2.y, D_Color(128, 128, 128), 1.f); } if(m_SelectedPosition >= 0) { s32 realPos = m_SelectedPosition; if(CoordinateInfo::sAwayView) { s32 column = (kGridLength - 1) - m_SelectedPosition / kGridWidth; s32 row = (kGridWidth - 1) - m_SelectedPosition % kGridWidth; realPos = column * kGridWidth + row; } Vec2 indicatorPos(CoordinateInfo::sLength / 2.f - (realPos / kGridWidth + 1) * kLengthInterval, CoordinateInfo::sWidth / 2.f - (realPos % kGridWidth) * kWidthInterval); Vec2 indicatorScreenPos = CoordinateInfo::WorldToScreen(indicatorPos); Char indicator[4]; _itoa(m_SelectedPosition, indicator, 10); D_Color clr = Math::Blend(D_Color(128, 128, 128), D_Color(255, 255, 255), Math::Clamp(m_Turn / kOneTurnTime, 0.f, 1.f)); g_poSROU->DrawStringEx( indicatorScreenPos.x, indicatorScreenPos.y, kLengthInterval * CoordinateInfo::GetPixelPerMeter(), kWidthInterval * CoordinateInfo::GetPixelPerMeter(), 5.f * CoordinateInfo::GetPixelPerMeter(), indicator, NULL, clr); } }
// Since the modelviewmatrix is updated in the update, and flowgraph is updated in the preupdate, we need this postupdate virtual void OnPostUpdate(float fDeltaTime) { int invMouseY = gEnv->pRenderer->GetHeight() - m_mouseY; Vec3 vPos0(0,0,0); gEnv->pRenderer->UnProjectFromScreen((float)m_mouseX, (float)invMouseY, 0, &vPos0.x, &vPos0.y, &vPos0.z); Vec3 vPos1(0,0,0); gEnv->pRenderer->UnProjectFromScreen((float)m_mouseX, (float)invMouseY, 1, &vPos1.x, &vPos1.y, &vPos1.z); Vec3 vDir = vPos1 - vPos0; vDir.Normalize(); ray_hit hit; const unsigned int flags = rwi_stop_at_pierceable|rwi_colltype_any; IPhysicalEntity** pSkipEnts = NULL; int numSkipped = 0; int containerId = GetPortInt(&m_actInfo, EIP_EntitiesToIgnore); if(containerId != 0) { IFlowSystemContainerPtr container = gEnv->pFlowSystem->GetContainer(containerId); numSkipped = container->GetItemCount(); pSkipEnts = new IPhysicalEntity*[numSkipped]; for (int i = 0; i < numSkipped; i++) { EntityId id; container->GetItem(i).GetValueWithConversion(id); pSkipEnts[i] = gEnv->pEntitySystem->GetEntity(id)->GetPhysics(); } } if (gEnv->pPhysicalWorld && gEnv->pPhysicalWorld->RayWorldIntersection(vPos0, vDir * gEnv->p3DEngine->GetMaxViewDistance(), m_rayTypeFilter, flags, &hit, 1, pSkipEnts, numSkipped)) { ActivateOutput(&m_actInfo, EOP_HitPos, hit.pt); ActivateOutput(&m_actInfo, EOP_HitNormal, hit.n); if(hit.pCollider) { if(IEntity *pEntity = gEnv->pEntitySystem->GetEntityFromPhysics(hit.pCollider)) { ActivateOutput(&m_actInfo, EOP_EntityId, pEntity->GetId()); } } } if(pSkipEnts) delete [] pSkipEnts; }