camerapoint.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #include "../idlib/precompiled.h"
  2. #pragma hdrstop
  3. #include "Game_local.h"
  4. const idEventDef EV_setcamerapointvisibility( "setcamerapointvisibility", "d" );
  5. CLASS_DECLARATION( idEntity, idCameraPoint )
  6. EVENT( EV_setcamerapointvisibility, idCameraPoint::Event_setcamerapointvisibility)
  7. END_CLASS
  8. void idCameraPoint::Save( idSaveGame *savefile ) const
  9. {
  10. savefile->WriteBool(snapped);
  11. savefile->WriteObject(arrowModel);
  12. }
  13. void idCameraPoint::Restore( idRestoreGame *savefile )
  14. {
  15. savefile->ReadBool(snapped);
  16. savefile->ReadObject(reinterpret_cast<idClass *&>(arrowModel));
  17. }
  18. void idCameraPoint::Spawn( void )
  19. {
  20. this->GetPhysics()->SetContents(0);
  21. snapped = false;
  22. renderEntity.weaponDepthHack = true;
  23. idDict args;
  24. args.Clear();
  25. args.SetVector( "origin", this->GetPhysics()->GetOrigin() );
  26. args.Set( "model", "models/camerapoint_arrow/tris.ase" );
  27. args.SetInt( "solid", 0 );
  28. arrowModel = gameLocal.SpawnEntityType( idStaticEntity::Type, &args );
  29. arrowModel->GetRenderEntity()->weaponDepthHack = true;
  30. arrowModel->Bind(this, false);
  31. BecomeActive( TH_THINK );
  32. }
  33. void idCameraPoint::SetSnapped()
  34. {
  35. SetSkin(declManager->FindSkin("skins/camerapoint/dotted"));
  36. arrowModel->Hide();
  37. snapped = true;
  38. }
  39. void idCameraPoint::SetHover(int value)
  40. {
  41. if (value > 0)
  42. {
  43. SetSkin(declManager->FindSkin("skins/camerapoint/hover"));
  44. arrowModel->SetSkin(declManager->FindSkin("skins/camerapoint_arrow/green"));
  45. }
  46. else
  47. {
  48. SetSkin(declManager->FindSkin("skins/camerapoint/skin"));
  49. arrowModel->SetSkin(declManager->FindSkin("skins/camerapoint_arrow/skin"));
  50. }
  51. }
  52. void idCameraPoint::Event_setcamerapointvisibility( int value)
  53. {
  54. if (value <= 0)
  55. {
  56. //hide it.
  57. arrowModel->Hide();
  58. this->Hide();
  59. return;
  60. }
  61. //else, show it.
  62. this->Show();
  63. if (snapped)
  64. return;
  65. arrowModel->Show(); //but only show arrow if pic hasnt been snapped yet.
  66. }
  67. /*
  68. void idCameraPoint::Think( void )
  69. {
  70. //Present();
  71. }*/
  72. /*
  73. void idCameraPoint::Present( void )
  74. {
  75. //blink speed.
  76. if (!snapped && gameLocal.GetLocalPlayer()->isCasing)
  77. {
  78. if ((int)(gameLocal.time * 0.004) % 4 != 0)
  79. {
  80. int lineLength = 128;
  81. //idVec3 ang = this->GetPhysics()->GetAxis().ToAngles().ToForward();
  82. //gameRenderWorld->DebugCircle(idVec4(1,1,1,1), this->GetPhysics()->GetOrigin(), ang, 15, 9);
  83. float modifier = 8 * idMath::Sin(gameLocal.time * 0.008);
  84. gameRenderWorld->DebugArrow(idVec4(.8f, .8f, .8f, 1), this->GetPhysics()->GetOrigin() + idVec3(0,0, lineLength + modifier*4), this->GetPhysics()->GetOrigin() + idVec3(0,0,32 + modifier), 16);
  85. gameRenderWorld->DebugArrow(idVec4(.8f, .8f, .8f, 1), this->GetPhysics()->GetOrigin() + idVec3(0,0, -lineLength + modifier*4), this->GetPhysics()->GetOrigin() + idVec3(0,0,-32 - modifier), 16);
  86. }
  87. }
  88. idEntity::Present();
  89. }*/