Unit1.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include <tchar.h>
  4. #pragma hdrstop
  5. #include "Unit1.h"
  6. //---------------------------------------------------------------------------
  7. #pragma package(smart_init)
  8. #pragma link "GLBaseClasses"
  9. #pragma link "GLCoordinates"
  10. #pragma link "GLCrossPlatform"
  11. #pragma link "GLGeomObjects"
  12. #pragma link "GLObjects"
  13. #pragma link "GLScene"
  14. #pragma link "GLWin32Viewer"
  15. #pragma resource "*.dfm"
  16. TForm1 *Form1;
  17. //---------------------------------------------------------------------------
  18. __fastcall TForm1::TForm1(TComponent* Owner)
  19. : TForm(Owner)
  20. {
  21. }
  22. //---------------------------------------------------------------------------
  23. void __fastcall TForm1::GLSceneViewer1MouseMove(TObject *Sender, TShiftState Shift,
  24. int X, int Y)
  25. {
  26. TGLCustomSceneObject *pick;
  27. // find what's under the mouse
  28. pick = (TGLCustomSceneObject *) GLSceneViewer1->Buffer->GetPickedObject(X, Y);
  29. // if it has changed since last MouseMove...
  30. if (pick != oldPick)
  31. {
  32. // ...turn to black previous "hot" object...
  33. if (oldPick)
  34. oldPick->Material->FrontProperties->Emission->Color = clrBlack;
  35. // ...and heat up the new selection...
  36. if (pick)
  37. pick->Material->FrontProperties->Emission->Color = clrRed;
  38. // ...and don't forget it !
  39. oldPick = pick;
  40. }
  41. }
  42. //---------------------------------------------------------------------------
  43. void __fastcall TForm1::GLSceneViewer1MouseDown(TObject *Sender, TMouseButton Button,
  44. TShiftState Shift, int X, int Y)
  45. {
  46. TGLCustomSceneObject *pick;
  47. // if an object is picked...
  48. pick = (TGLCustomSceneObject *) GLSceneViewer1->Buffer->GetPickedObject(X, Y);
  49. if (pick)
  50. // ...turn it to yellow and show its name
  51. pick->Material->FrontProperties->Emission->Color = clrYellow;
  52. ShowMessage("You clicked the "+pick->Name);
  53. }
  54. //---------------------------------------------------------------------------