home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2006 March / Gamestar_82_2006-03_dvd.iso / DVDStar / Editace / quake4_sdkv10.exe / source / game / Icon.cpp < prev    next >
C/C++ Source or Header  |  2005-11-14  |  2KB  |  97 lines

  1. //----------------------------------------------------------------
  2. // Icon.cpp
  3. //
  4. // Copyright 2002-2004 Raven Software
  5. //----------------------------------------------------------------
  6.  
  7. #include "../idlib/precompiled.h"
  8. #pragma hdrstop
  9.  
  10. #include "Game_local.h"
  11. #include "Icon.h"
  12.  
  13. /*
  14. ===============
  15. rvIcon::rvIcon
  16. ===============
  17. */
  18. rvIcon::rvIcon() {
  19.     iconHandle    = -1;
  20. }
  21.  
  22. /*
  23. ===============
  24. rvIcon::~rvIcon
  25. ===============
  26. */
  27. rvIcon::~rvIcon() {
  28.     FreeIcon();
  29. }
  30.  
  31. /*
  32. ===============
  33. rvIcon::FreeIcon
  34. ===============
  35. */
  36. void rvIcon::FreeIcon( void ) {
  37.     if ( iconHandle != - 1 ) {
  38.         gameRenderWorld->FreeEntityDef( iconHandle );
  39.         iconHandle = -1;
  40.     }
  41. }
  42.  
  43. /*
  44. ===============
  45. rvIcon::CreateIcon
  46. ===============
  47. */
  48. qhandle_t rvIcon::CreateIcon( const char *mtr, int suppressViewID ) {
  49.     FreeIcon();
  50.  
  51.     memset( &renderEnt, 0, sizeof( renderEnt ) );
  52.     renderEnt.origin    = vec3_origin;
  53.     renderEnt.axis        = mat3_identity;
  54.     renderEnt.shaderParms[ SHADERPARM_RED ]                = 1.0f;
  55.     renderEnt.shaderParms[ SHADERPARM_GREEN ]            = 1.0f;
  56.     renderEnt.shaderParms[ SHADERPARM_BLUE ]            = 1.0f;
  57.     renderEnt.shaderParms[ SHADERPARM_ALPHA ]            = 1.0f;
  58.     renderEnt.shaderParms[ SHADERPARM_SPRITE_WIDTH ]    = 16.0f;
  59.     renderEnt.shaderParms[ SHADERPARM_SPRITE_HEIGHT ]    = 16.0f;
  60.     renderEnt.hModel = renderModelManager->FindModel( "_sprite" );
  61.     renderEnt.callback = NULL;
  62.     renderEnt.numJoints = 0;
  63.     renderEnt.joints = NULL;
  64.     renderEnt.customSkin = 0;
  65.     renderEnt.noShadow = true;
  66.     renderEnt.noSelfShadow = true;
  67.     renderEnt.customShader = declManager->FindMaterial( mtr );
  68.     renderEnt.referenceShader = 0;
  69.     renderEnt.bounds = renderEnt.hModel->Bounds( &renderEnt );
  70.     renderEnt.suppressSurfaceInViewID = suppressViewID;
  71.     
  72.     iconHandle = gameRenderWorld->AddEntityDef( &renderEnt );
  73.  
  74.     return iconHandle;
  75. }
  76.  
  77. /*
  78. ===============
  79. rvIcon::UpdateIcon
  80. ===============
  81. */
  82. void rvIcon::UpdateIcon( const idVec3 &origin, const idMat3 &axis ) {
  83.     assert( iconHandle >= 0 );
  84.  
  85.     renderEnt.origin = origin;
  86.     renderEnt.axis    = axis;
  87.     gameRenderWorld->UpdateEntityDef( iconHandle, &renderEnt );
  88. }
  89.  
  90. int rvIcon::GetWidth( void ) const {
  91.     return renderEnt.shaderParms[ SHADERPARM_SPRITE_WIDTH ];
  92. }
  93.  
  94. int rvIcon::GetHeight( void ) const {
  95.     return renderEnt.shaderParms[ SHADERPARM_SPRITE_HEIGHT ];
  96. }
  97.