guiMaterialPreview.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. // Original header:
  23. // GuiMaterialPreview Control for Material Editor Written by Travis Vroman of Gaslight Studios
  24. // Updated 2-14-09
  25. // Portions based off Constructor viewport code.
  26. #ifndef _GUIMATERIALPREVIEW_H_
  27. #define _GUIMATERIALPREVIEW_H_
  28. #include "gui/3d/guiTSControl.h"
  29. #include "ts/tsShapeInstance.h"
  30. class LightInfo;
  31. class GuiMaterialPreview : public GuiTSCtrl
  32. {
  33. private:
  34. typedef GuiTSCtrl Parent;
  35. protected:
  36. enum MouseState
  37. {
  38. None,
  39. Rotating,
  40. Zooming,
  41. Panning,
  42. MovingLight
  43. };
  44. MouseState mMouseState;
  45. TSShapeInstance* mModel;
  46. TSShapeInstance* mMountedModel;
  47. U32 mSkinTag;
  48. // For Camera Panning.
  49. F32 mTransStep; //*** Amount of translation with each mouse move
  50. F32 mTranMult; //*** With a modifier, how much faster to translate
  51. // For light translation.
  52. F32 mLightTransStep;
  53. F32 mLightTranMult;
  54. Point3F mCameraPos;
  55. MatrixF mCameraMatrix;
  56. EulerF mCameraRot;
  57. Point3F mOrbitPos;
  58. Point3F mOrbitRelPos;
  59. Point3F mCameraTransform;
  60. TSThread * runThread;
  61. S32 lastRenderTime;
  62. Point2I mLastMousePoint;
  63. LightInfo* mFakeSun;
  64. public:
  65. bool onWake();
  66. void onMouseEnter(const GuiEvent &event);
  67. void onMouseLeave(const GuiEvent &event);
  68. void onMouseDown(const GuiEvent &event);
  69. void onMouseUp(const GuiEvent &event);
  70. void onMouseDragged(const GuiEvent &event);
  71. void onRightMouseDown(const GuiEvent &event);
  72. void onRightMouseUp(const GuiEvent &event);
  73. void onRightMouseDragged(const GuiEvent &event);
  74. bool onMouseWheelUp(const GuiEvent &event);
  75. bool onMouseWheelDown(const GuiEvent &event);
  76. void onMiddleMouseUp(const GuiEvent &event);
  77. void onMiddleMouseDown(const GuiEvent &event);
  78. void onMiddleMouseDragged(const GuiEvent &event);
  79. // For Camera Panning.
  80. void setTranslate(S32 modifier, F32 xstep, F32 ystep);
  81. // For Light Translation.
  82. void setLightTranslate(S32 modifier, F32 xstep, F32 ystep);
  83. // For changing the light color.
  84. void setLightColor( F32 r, F32 g, F32 b );
  85. // For changing the ambient light color.
  86. void setAmbientLightColor( F32 r, F32 g, F32 b );
  87. void setObjectModel(const char * modelName);
  88. void deleteModel();
  89. void resetViewport();
  90. void setOrbitDistance(F32 distance);
  91. bool processCameraQuery(CameraQuery *query);
  92. void renderWorld(const RectI &updateRect);
  93. DECLARE_CONOBJECT(GuiMaterialPreview);
  94. DECLARE_CATEGORY( "Gui Editor" );
  95. GuiMaterialPreview();
  96. ~GuiMaterialPreview();
  97. private:
  98. F32 mMaxOrbitDist;
  99. F32 mMinOrbitDist;
  100. F32 mOrbitDist;
  101. };
  102. #endif