#include #include #include Section::Section(tFont* pFont, const char* szName) : _pDebugFont(pFont), _pLineShader(NULL), _autoReset(true) { assert(szName); int i; Reset(szName); _pLineShader = p3d::device->NewShader(/*p3d::pddi, */"simple"); _pLineShader->AddRef(); _pLineShader->SetInt(PDDI_SP_BLENDMODE, PDDI_BLEND_ALPHA); //Allocate string primitives for the 3d strings for(i=0;iAddRef(); P3D_UNICODE string[256]; char emptyString[] = "Empty String"; p3d::AsciiToUnicode(emptyString, string, strlen(emptyString)); _pText[i]._pText = new tTextString(_pDebugFont, string); _pText[i]._pText->AddRef(); } else { _pText[i]._pText = NULL; } } } Section::~Section() { for(int i=0;iSetString(string); p->SetColour(colour); p->SetScale(20.0f); //Fudge factor to make font appear about 1 meter high _pText[_NumText]._Pos = pos; _NumText++; } } void Section::AddScreenLine(const rmt::Vector &a, const rmt::Vector &b, tColour colour) { if(_NumScreenLines < MaxScreenLines) { _ScreenLines[_NumScreenLines]._a = a; _ScreenLines[_NumScreenLines]._b = b; _ScreenLines[_NumScreenLines]._Colour = colour; _NumScreenLines++; } } void Section::AddScreenText(const char* szName, tColour colour ) { assert(szName); ScreenText &pST = _pScreenText[_NumScreenText]; if(_NumScreenTextEnableStatsOverlay(0==strcmp(_szName, "pddi")); //Stream out world space lines if(_NumLines > 0) { pStream = p3d::pddi->BeginPrims(_pLineShader, PDDI_PRIM_LINES, PDDI_V_C, _NumLines*2); if(pStream) { for(i=0; i<_NumLines; i++) { Line &l = _Lines[i]; pddiVector A(l._a.x, l._a.y, l._a.z); pddiVector B(l._b.x, l._b.y, l._b.z); pStream->Vertex(&A,l._Colour); pStream->Vertex(&B,l._Colour); } } p3d::pddi->EndPrims(pStream); } //Draw all the world space vector text for(i=0;i<_NumText;i++) { p3d::stack->Push(); p3d::stack->Translate(_pText[i]._Pos); _pText[i]._pText->Display(); p3d::stack->Pop(); } //Draw screen space lines { //Setup the matrix stack p3d::stack->Push(); p3d::pddi->EnableZBuffer(false); p3d::stack->LoadIdentity(); p3d::stack->Scale((float)p3d::display->GetWidth(),(float)p3d::display->GetHeight(),1); p3d::pddi->SetProjectionMode(PDDI_PROJECTION_DEVICE); //Stream out lines if(_NumScreenLines > 0) { pStream = p3d::pddi->BeginPrims(_pLineShader, PDDI_PRIM_LINES, PDDI_V_C, _NumScreenLines*2); if(pStream) { for(i=0; i<_NumScreenLines; i++) { Line &l = _ScreenLines[i]; pddiVector A(l._a.x, l._a.y, 1); pddiVector B(l._b.x, l._b.y, 1); pStream->Vertex(&A,l._Colour); pStream->Vertex(&B,l._Colour); } } p3d::pddi->EndPrims(pStream); } //Restore the old stack p3d::pddi->SetProjectionMode(PDDI_PROJECTION_PERSPECTIVE); p3d::pddi->EnableZBuffer(true); p3d::stack->Pop(); } //Draw all the screen text p3d::stack->Push(); p3d::stack->LoadIdentity(); int height = p3d::display->GetHeight(); int width = p3d::display->GetWidth(); for(i=0;i<_NumScreenText;i++) { ScreenText &pST = _pScreenText[i]; if(pST._pText) { p3d::pddi->DrawString(pST._pText, (int)(pST._Pos.x*width), (int)(pST._Pos.y*height), pST._Colour); } } p3d::stack->Pop(); }