Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Material Preview Renders a scene #1336

Open
wants to merge 15 commits into
base: development
Choose a base branch
from
Prev Previous commit
Next Next commit
everything working, however hacky
removed middle mouse button interaction from material preview.... because why!
  • Loading branch information
marauder2k7 committed Jan 24, 2025
commit 9f26794401b530c15cb3ee6a131def2c51912368
53 changes: 0 additions & 53 deletions Engine/source/T3D/guiMaterialPreview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,28 +154,6 @@ void GuiMaterialPreview::setLightTranslate(S32 modifier, F32 xstep, F32 ystep)
GuiMaterialPreview::mFakeSun->setDirection(relativeLightDirection);
}

// This is for panning the viewport camera.
void GuiMaterialPreview::setTranslate(S32 modifier, F32 xstep, F32 ystep)
{
F32 transstep = (modifier & SI_SHIFT ? mTransStep : (mTransStep*mTranMult));

F32 nominalDistance = 20.0;
Point3F vec = mCameraPos;
vec -= mOrbitPos;
transstep *= vec.len() / nominalDistance;

if (modifier & SI_PRIMARY_CTRL)
{
mOrbitRelPos.x += ( xstep * transstep );
mOrbitRelPos.y += ( ystep * transstep );
}
else
{
mOrbitRelPos.x += ( xstep * transstep );
mOrbitRelPos.z += ( ystep * transstep );
}
}

// Left Click
void GuiMaterialPreview::onMouseDown(const GuiEvent &event)
{
Expand Down Expand Up @@ -249,37 +227,6 @@ bool GuiMaterialPreview::onMouseWheelDown(const GuiEvent &event)
return true;
}

// Mouse Wheel Click
void GuiMaterialPreview::onMiddleMouseDown(const GuiEvent &event)
{
if (!mActive || !mVisible || !mAwake)
{
return;
}
mMouseState = Panning;
mLastMousePoint = event.mousePoint;
mouseLock();
}

// Mouse Wheel Click Release
void GuiMaterialPreview::onMiddleMouseUp(const GuiEvent &event)
{
mouseUnlock();
mMouseState = None;
}

// Mouse Wheel Click Drag
void GuiMaterialPreview::onMiddleMouseDragged(const GuiEvent &event)
{
if (mMouseState != Panning)
{
return;
}
Point2I delta = event.mousePoint - mLastMousePoint;
mLastMousePoint = event.mousePoint;
setTranslate(event.modifier, delta.x, delta.y);
}

// This is used to set the model we want to view in the control object.
void GuiMaterialPreview::setObjectModel(const char* modelName)
{
Expand Down
8 changes: 1 addition & 7 deletions Engine/source/T3D/guiMaterialPreview.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,7 @@ class GuiMaterialPreview : public GuiTSCtrl
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);

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<ImageAsset
AssetName="rogland_clear_night_4k_image"
imageFile="@assetFile=rogland_clear_night_4k.hdr"
isHDRImage="true"/>
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,15 @@ function MaterialEditorGui::open(%this)

//Sift through the RootGroup and find all loaded material items.
MaterialEditorGui.updateAllFields();

// this is a hacky piece of shit script, but it means that updates will continue.
matEd_previewObjectView.setModel("ToolsModule:cubepreview");
matEd_previewObjectView.setModel("ToolsModule:spherepreview");
matEd_previewObjectView.setModel("ToolsModule:pyramidpreview");
matEd_previewObjectView.setModel("ToolsModule:cylinderpreview");
matEd_previewObjectView.setModel("ToolsModule:toruspreview");
matEd_previewObjectView.setModel("ToolsModule:torusknotpreview");

MaterialEditorGui.updatePreviewObject();

// If no selected object; go to material mode. And edit the last selected material
Expand Down