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