00001
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #pragma once
00034
00035 #include "../System/Builder/K3dTextureBuild.h"
00036 #include "../MathCore/K3dVector3.h"
00037 #include "../MathCore/K3dVector4.h"
00038 #include "../MathCore/K3dMatrix.h"
00039 #include "../Geometry/K3dCameraObj.h"
00040 #include "../System/GameData/K3dGameData.h"
00041 #include "K3dBmpFontObj.h"
00042 #include "../Script/K3dLua.h"
00043 #include "../System/K3dTimer.h"
00044
00045 class K3dFontBmp
00046 {
00047 K3dGameData *m_pGameData;
00048
00049 struct TDraw
00050 {
00051 char str[256];
00052 K3dVector3 kColor;
00053 };
00054 int m_iNumDraw;
00055 TDraw m_atDraw[64];
00056
00057
00058 GLuint m_uiTextureId;
00059 GLuint m_uiBase;
00060 bool m_bNewFrame;
00061 int m_iNumLines;
00062 int m_iLine;
00063 float m_fFirstLine;
00064 float m_afLine[64];
00065 float m_fSpace;
00066 float m_fRow;
00067 bool m_bDraw;
00068 bool m_bDrawFps;
00069 K3dVector3 m_kCamera;
00070 bool m_bDrawCamPos;
00071 bool m_bDrawNumFaces;
00072 int m_iFps;
00073 int m_iFpsTmp;
00074 int m_iFrame;
00075
00077 void Print ( const char *_strIn, K3dVector3 _kColor );
00079 void DrawFps();
00081 void DrawCameraPosition();
00083 void DrawNumFaces();
00084
00085
00086 public:
00087 K3dFontBmp ( K3dGameData *_pGameData );
00088 ~K3dFontBmp ( void );
00089 void LoadBmpFonts();
00090
00093 void SetFrame ( const bool _bFrame )
00094 {
00095 m_bNewFrame = _bFrame;
00096 }
00099 bool GetFrame()
00100 {
00101 return m_bNewFrame;
00102 }
00103
00106 void SetNumLines ( const int _iNumLines )
00107 {
00108 m_iNumLines = _iNumLines;
00109 }
00112 int GetNumLines()
00113 {
00114 return m_iNumLines;
00115 }
00116
00119 void SetFirstLine ( const float _fFirstLine )
00120 {
00121 m_fFirstLine = _fFirstLine;
00122 }
00125 float GetFirstLine()
00126 {
00127 return m_fFirstLine;
00128 }
00129
00132 void SetSpace ( const float _fSpace )
00133 {
00134 m_fSpace = _fSpace;
00135 }
00138 float GetSpace()
00139 {
00140 return m_fSpace;
00141 }
00142
00145 void SetRow ( const float _fRow )
00146 {
00147 m_fRow = _fRow;
00148 }
00151 float GetRow()
00152 {
00153 return m_fRow;
00154 }
00155
00158 void SetDrawFps ( const bool _bDrawFps )
00159 {
00160 cout << "void K3dFontBmp::SetDrawFps()" << endl;
00161 m_bDrawFps = _bDrawFps;
00162 }
00165 bool GetDrawFps()
00166 {
00167 return m_bDrawFps;
00168 }
00169
00173 void SetCamera ( K3dVector3 _kCamera )
00174 {
00175 m_kCamera = _kCamera;
00176 }
00177
00180 void SetDrawCamPos ( const bool _bDrawCamPos )
00181 {
00182 cout << "void K3dFontBmp::SetDrawCamPos(const bool _bDrawCamPos)" << endl;
00183 m_bDrawCamPos = _bDrawCamPos;
00184 }
00187 bool GetDrawCamPos()
00188 {
00189 return m_bDrawCamPos;
00190 }
00191
00194 void SetDrawNumFaces ( const bool _bDrawNumFaces )
00195 {
00196 cout << "void K3dFontBmp::SetDrawNumFaces(const bool _bDrawNumFaces)" << endl;
00197 m_bDrawNumFaces = _bDrawNumFaces;
00198 }
00200 bool GetDrawNumFaces()
00201 {
00202 return m_bDrawNumFaces;
00203 }
00204
00205
00206
00207 void InitFontBmp();
00208 void Reset();
00209 void Destroy();
00210 void DeleteFontBmp();
00211 void DrawFontBmp();
00212
00213
00215 void DrawValue ( const char *_strComment );
00217 void DrawValue ( const char *_strComment, const K3dVector3 _kVec );
00219 void DrawValue ( const char *_strComment, const K3dVector4 _kVec );
00221 void DrawValue ( const char *_strComment, const float _fVal );
00223 void DrawValue ( const char *_strComment, const int _iVal );
00225 void DrawValue ( const K3dMatrix _kMat );
00227 void ResetLines()
00228 {
00229 m_iLine = m_iNumLines;
00230 }
00231
00233
00235 void LoadTexture ( const K3dString &_strFileName );
00237 void CreateDisplayLists ( bool _bItalic );
00239 void ResetValues()
00240 {
00241 ResetLines();
00242 m_bNewFrame = true;
00243 }
00244
00245 };
00246
00249
00250
00251
00252
00253
00254
00255
00257 inline void K3dFontBmp::LoadTexture ( const K3dString &_strFileName )
00258 {
00259 cout << "void K3dFontBmp::LoadTexture()" << endl;
00260
00261
00262 cout << "void K3dFontBmp::LoadTexture() -- CreateTexture -- OK" << endl;
00263 }
00264
00265
00267 inline void K3dFontBmp::DrawCameraPosition()
00268 {
00269 K3dVector3 kColor;
00270 char acString[20];
00271
00272 TTextureOption *ptOption = m_pGameData->GetTextureOption();
00273
00274 if ( ptOption->bMultitexture )
00275 {
00276
00277
00278
00279
00280
00281
00282
00283
00284 }
00285 else
00286 {
00287
00288 }
00289
00290
00291 int iCamId = m_pGameData->GetActiveCamId();
00292 if ( iCamId>=0 )
00293 {
00294
00295 K3dCameraObj *pCamera = m_pGameData->GetCameraObjSP().Get ( iCamId );
00296 if ( !pCamera )
00297 {
00298 cerr << "void K3dFontBmp::DrawCameraPosition() -- Error - Pointer to camera object is NULL!!" << endl;
00299 return;
00300 }
00301 kColor.Set ( 0,1,0 );
00302 snprintf ( acString, 20, "%s%f", "Cam X: ", pCamera->GetCameraPos() [0] );
00303 Print ( acString, kColor );
00304 snprintf ( acString, 20, "%s%f", "Cam Y: ", pCamera->GetCameraPos() [1] );
00305 Print ( acString, kColor );
00306 snprintf ( acString, 20, "%s%f", "Cam Z: ", pCamera->GetCameraPos() [2] );
00307 Print ( acString, kColor );
00308 }
00309 }
00310
00312 inline void K3dFontBmp::DrawNumFaces()
00313 {
00314 int iNum = 0;
00315 K3dVector3 kColor;
00316 char acString[20];
00317
00318 TTextureOption *ptOption = m_pGameData->GetTextureOption();
00319
00320 if ( ptOption->bMultitexture )
00321 {
00322
00323
00324
00325
00326
00327
00328
00329
00330 }
00331 else
00332 {
00333 iNum = m_pGameData->NumDrawTriangles();
00334 kColor.Set ( 0,1,0 );
00335 snprintf ( acString, 20, "%s%i", "Triangles: ", iNum );
00336 Print ( acString, kColor );
00337 }
00338 }
00339
00343 inline void K3dFontBmp::DrawValue ( const char *_strComment, const K3dVector3 _kVec )
00344 {
00345 K3dVector3 kColor;
00346 char acString[200];
00347 TTextureOption *ptOption = m_pGameData->GetTextureOption();
00348 if ( ptOption->bMultitexture )
00349 {
00350
00351
00352
00353
00354
00355
00356
00357
00358 }
00359 else
00360 {
00361
00362 }
00363 kColor.Set ( 0,1,1 );
00364 snprintf ( acString, 200, "%s %f %f %f", _strComment, _kVec.GetX(), _kVec.GetY(), _kVec.GetZ() );
00365 Print ( acString, kColor );
00366 }
00367
00371 inline void K3dFontBmp::DrawValue ( const char *_strComment, K3dVector4 _kVec )
00372 {
00373 K3dVector3 kColor;
00374 char acString[200];
00375 float *pV;
00376 K3dVector4 kV;
00377
00378 kV = _kVec;
00379
00380 pV = kV.GetVector();
00381
00382 TTextureOption *ptOption = m_pGameData->GetTextureOption();
00383
00384 if ( ptOption->bMultitexture )
00385 {
00386
00387
00388
00389
00390
00391
00392
00393
00394 }
00395 else
00396 {
00397
00398 }
00399 kColor.Set ( 0,1,1 );
00400 snprintf ( acString, 200, "%s %f %f %f %f", _strComment, pV[0], pV[1], pV[2], pV[3] );
00401 Print ( acString, kColor );
00402 }
00403
00405 inline void K3dFontBmp::DrawValue ( const char *_strComment, const float _fVal )
00406 {
00407 K3dVector3 kColor;
00408 char acString[200];
00409
00410 TTextureOption *ptOption = m_pGameData->GetTextureOption();
00411
00412 if ( ptOption->bMultitexture )
00413 {
00414
00415
00416
00417
00418
00419
00420
00421
00422 }
00423 else
00424 {
00425
00426 }
00427 kColor.Set ( 0,1,1 );
00428 snprintf ( acString, 200, "%s %f", _strComment , _fVal );
00429 Print ( acString, kColor );
00430 }
00431
00432
00433 inline void K3dFontBmp::DrawValue ( const char *_strComment, const int _iVal )
00434 {
00435 K3dVector3 kColor;
00436 char acString[200];
00437
00438 TTextureOption *ptOption = m_pGameData->GetTextureOption();
00439
00440 if ( ptOption->bMultitexture )
00441 {
00442
00443
00444
00445
00446
00447
00448
00449
00450 }
00451 else
00452 {
00453
00454 }
00455 kColor.Set ( 0,1,1 );
00456 snprintf ( acString, 200, "%s %i", _strComment , _iVal );
00457 Print ( acString, kColor );
00458 }
00459
00460
00461 inline void K3dFontBmp::DrawValue ( const K3dMatrix _kMat )
00462 {
00463 K3dVector3 kColor;
00464 char acString[200];
00465 float *pM;
00466 K3dMatrix kM;
00467
00468 kM = _kMat;
00469 pM = kM.GetMatrix();
00470
00471 TTextureOption *ptOption = m_pGameData->GetTextureOption();
00472
00473 if ( ptOption->bMultitexture )
00474 {
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484 }
00485 else
00486 {
00487
00488 }
00489
00490 kColor.Set ( 0,1,1 );
00491 snprintf ( acString, 200, "%f %f %f %f", pM[0], pM[1], pM[2], pM[3] );
00492 Print ( acString, kColor );
00493 snprintf ( acString, 200, "%f %f %f %f", pM[4], pM[5], pM[6], pM[7] );
00494 Print ( acString, kColor );
00495 snprintf ( acString, 200, "%f %f %f %f", pM[8], pM[9], pM[10], pM[11] );
00496 Print ( acString, kColor );
00497 snprintf ( acString, 200, "%f %f %f %f", pM[12], pM[13], pM[14], pM[15] );
00498 Print ( acString, kColor );
00499 }
00500