Torque3D/Engine/source/T3D/guiMaterialPreview.h
JeffR f3cad0d77e Converts the ad-hoc design of the Material Editor to utilize the same inspector interface as most everything else does.
- Overhauls the material editor to simplify and streamline the logic behind it since the inspector does most of the work
- Tweak a few order positions of materialdefinition fields to work better
- Sets AO, Rough and Metal channel fields to use an enum type for human readability
- Updates the MaterialPreview gui control to work with assetIds
- MatEd now supports setting of parent material to inherit from
- Creating a new material now can prompt selecting an existing material to inherit from
- Can now edit the mapTo value of a material in the matEd
- New standalone Composite Texture Editor window for convering AO, Roughness and Metalness maps in a material to an ORMMap
- Can also star the creation of a composite texture via RMB context menu in AB on an image asset
- Moved logic of CubemapEditor from MatEd to it's own stuff
- Made ImageAsset fields now be more clear when they have nothing assigned, and also have a clear button to empty the field's value so it's consistent across the board
- Reorganized the layout of the gui and image files for the MatEd to be easier to navigate
- MaterialEditor now overlays the EditorGUI instead of being forcefully embedded in it, allowing easy editing of the MatEd Gui via the Gui editor
2025-08-03 12:03:02 -05:00

135 lines
4.2 KiB
C++

//-----------------------------------------------------------------------------
// 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 "assets/ShapeAsset.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;
DECLARE_SHAPEASSET_REFACTOR(GuiMaterialPreview, Model)
DECLARE_SHAPEASSET_REFACTOR(GuiMaterialPreview, MountedModel)
TSShapeInstance* mModelInstance;
TSShapeInstance* mMountedModelInstance;
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;
void renderSunDirection() const;
public:
bool onWake() override;
void onMouseEnter(const GuiEvent &event) override;
void onMouseLeave(const GuiEvent &event) override;
void onMouseDown(const GuiEvent &event) override;
void onMouseUp(const GuiEvent &event) override;
void onMouseDragged(const GuiEvent &event) override;
void onRightMouseDown(const GuiEvent &event) override;
void onRightMouseUp(const GuiEvent &event) override;
void onRightMouseDragged(const GuiEvent &event) override;
bool onMouseWheelUp(const GuiEvent &event) override;
bool onMouseWheelDown(const GuiEvent &event) override;
void onMiddleMouseUp(const GuiEvent &event) override;
void onMiddleMouseDown(const GuiEvent &event) override;
void onMiddleMouseDragged(const GuiEvent &event) override;
// 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) override;
void renderWorld(const RectI &updateRect) override;
DECLARE_CONOBJECT(GuiMaterialPreview);
DECLARE_CATEGORY( "Gui Editor" );
GuiMaterialPreview();
~GuiMaterialPreview();
private:
F32 mMaxOrbitDist;
F32 mMinOrbitDist;
F32 mOrbitDist;
};
#endif