123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- //-----------------------------------------------------------------------------
- // Copyright (c) 2012 GarageGames, LLC
- //
- // Permission is hereby granted, free of charge, to any person obtaining a copy
- // of this software and associated documentation files (the "Software"), to
- // deal in the Software without restriction, including without limitation the
- // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- // sell copies of the Software, and to permit persons to whom the Software is
- // furnished to do so, subject to the following conditions:
- //
- // The above copyright notice and this permission notice shall be included in
- // all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- // IN THE SOFTWARE.
- //-----------------------------------------------------------------------------
- // Original header:
- // GuiMaterialPreview Control for Material Editor Written by Travis Vroman of Gaslight Studios
- // Updated 2-14-09
- // Portions based off Constructor viewport code.
- #ifndef _GUIMATERIALPREVIEW_H_
- #define _GUIMATERIALPREVIEW_H_
- #include "gui/3d/guiTSControl.h"
- #include "ts/tsShapeInstance.h"
- class LightInfo;
- class GuiMaterialPreview : public GuiTSCtrl
- {
- private:
- typedef GuiTSCtrl Parent;
- protected:
- enum MouseState
- {
- None,
- Rotating,
- Zooming,
- Panning,
- MovingLight
- };
- MouseState mMouseState;
- TSShapeInstance* mModel;
- TSShapeInstance* mMountedModel;
- U32 mSkinTag;
- // For Camera Panning.
- F32 mTransStep; //*** Amount of translation with each mouse move
- F32 mTranMult; //*** With a modifier, how much faster to translate
- // For light translation.
- F32 mLightTransStep;
- F32 mLightTranMult;
- Point3F mCameraPos;
- MatrixF mCameraMatrix;
- EulerF mCameraRot;
- Point3F mOrbitPos;
- Point3F mOrbitRelPos;
- Point3F mCameraTransform;
- TSThread * runThread;
- S32 lastRenderTime;
- Point2I mLastMousePoint;
- LightInfo* mFakeSun;
- public:
- bool onWake();
- void onMouseEnter(const GuiEvent &event);
- void onMouseLeave(const GuiEvent &event);
- void onMouseDown(const GuiEvent &event);
- void onMouseUp(const GuiEvent &event);
- void onMouseDragged(const GuiEvent &event);
- void onRightMouseDown(const GuiEvent &event);
- void onRightMouseUp(const GuiEvent &event);
- void onRightMouseDragged(const GuiEvent &event);
- bool onMouseWheelUp(const GuiEvent &event);
- bool onMouseWheelDown(const GuiEvent &event);
- void onMiddleMouseUp(const GuiEvent &event);
- void onMiddleMouseDown(const GuiEvent &event);
- void onMiddleMouseDragged(const GuiEvent &event);
-
- // For Camera Panning.
- void setTranslate(S32 modifier, F32 xstep, F32 ystep);
-
- // For Light Translation.
- void setLightTranslate(S32 modifier, F32 xstep, F32 ystep);
-
- // For changing the light color.
- void setLightColor( F32 r, F32 g, F32 b );
-
- // For changing the ambient light color.
- void setAmbientLightColor( F32 r, F32 g, F32 b );
- void setObjectModel(const char * modelName);
- void deleteModel();
- void resetViewport();
- void setOrbitDistance(F32 distance);
- bool processCameraQuery(CameraQuery *query);
- void renderWorld(const RectI &updateRect);
- DECLARE_CONOBJECT(GuiMaterialPreview);
- DECLARE_CATEGORY( "Gui Editor" );
- GuiMaterialPreview();
- ~GuiMaterialPreview();
- private:
- F32 mMaxOrbitDist;
- F32 mMinOrbitDist;
- F32 mOrbitDist;
- };
- #endif
|