Implemented grid toggle in the model editor
This commit is contained in:
parent
5fbdfc8298
commit
200918671b
|
@ -5,7 +5,8 @@ CModelEditorViewport::CModelEditorViewport(QWidget *pParent)
|
||||||
: CBasicViewport(pParent),
|
: CBasicViewport(pParent),
|
||||||
mMode(eDrawMesh),
|
mMode(eDrawMesh),
|
||||||
mpActiveMaterial(nullptr),
|
mpActiveMaterial(nullptr),
|
||||||
mpModelNode(nullptr)
|
mpModelNode(nullptr),
|
||||||
|
mGridEnabled(true)
|
||||||
{
|
{
|
||||||
mpRenderer = new CRenderer();
|
mpRenderer = new CRenderer();
|
||||||
mpRenderer->SetViewportSize(width(), height());
|
mpRenderer->SetViewportSize(width(), height());
|
||||||
|
@ -42,17 +43,27 @@ void CModelEditorViewport::SetClearColor(CColor color)
|
||||||
mpRenderer->SetClearColor(color);
|
mpRenderer->SetClearColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CModelEditorViewport::SetGridEnabled(bool Enable)
|
||||||
|
{
|
||||||
|
mGridEnabled = Enable;
|
||||||
|
}
|
||||||
|
|
||||||
void CModelEditorViewport::Paint()
|
void CModelEditorViewport::Paint()
|
||||||
{
|
{
|
||||||
mpRenderer->BeginFrame();
|
mpRenderer->BeginFrame();
|
||||||
mCamera.LoadMatrices();
|
mCamera.LoadMatrices();
|
||||||
|
|
||||||
if (!mpModelNode->Model())
|
if (!mpModelNode->Model())
|
||||||
|
{
|
||||||
|
if (mGridEnabled)
|
||||||
CDrawUtil::DrawGrid();
|
CDrawUtil::DrawGrid();
|
||||||
|
}
|
||||||
|
|
||||||
else if (mMode == eDrawMesh)
|
else if (mMode == eDrawMesh)
|
||||||
{
|
{
|
||||||
|
if (mGridEnabled)
|
||||||
CDrawUtil::DrawGrid();
|
CDrawUtil::DrawGrid();
|
||||||
|
|
||||||
mpModelNode->AddToRenderer(mpRenderer, mViewInfo);
|
mpModelNode->AddToRenderer(mpRenderer, mViewInfo);
|
||||||
mpRenderer->RenderBuckets(mViewInfo);
|
mpRenderer->RenderBuckets(mViewInfo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ private:
|
||||||
CModelNode *mpModelNode;
|
CModelNode *mpModelNode;
|
||||||
CMaterial *mpActiveMaterial;
|
CMaterial *mpActiveMaterial;
|
||||||
CRenderer *mpRenderer;
|
CRenderer *mpRenderer;
|
||||||
|
bool mGridEnabled;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CModelEditorViewport(QWidget *pParent = 0);
|
CModelEditorViewport(QWidget *pParent = 0);
|
||||||
|
@ -24,6 +25,7 @@ public:
|
||||||
void SetActiveMaterial(CMaterial *pMat);
|
void SetActiveMaterial(CMaterial *pMat);
|
||||||
void SetDrawMode(EDrawMode mode);
|
void SetDrawMode(EDrawMode mode);
|
||||||
void SetClearColor(CColor color);
|
void SetClearColor(CColor color);
|
||||||
|
void SetGridEnabled(bool Enable);
|
||||||
void Paint();
|
void Paint();
|
||||||
void OnResize();
|
void OnResize();
|
||||||
};
|
};
|
||||||
|
|
|
@ -884,3 +884,8 @@ void CModelEditorWindow::on_actionConvert_DDS_to_TXTR_triggered()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CModelEditorWindow::on_ToggleGridButton_toggled(bool checked)
|
||||||
|
{
|
||||||
|
ui->Viewport->SetGridEnabled(checked);
|
||||||
|
}
|
||||||
|
|
|
@ -119,6 +119,8 @@ private slots:
|
||||||
|
|
||||||
void on_actionConvert_DDS_to_TXTR_triggered();
|
void on_actionConvert_DDS_to_TXTR_triggered();
|
||||||
|
|
||||||
|
void on_ToggleGridButton_toggled(bool checked);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void Closed();
|
void Closed();
|
||||||
};
|
};
|
||||||
|
|
|
@ -2140,7 +2140,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,0,0,0,0,0,0,0,0">
|
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,0,0,0,0,0,0,0">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>50</number>
|
<number>50</number>
|
||||||
</property>
|
</property>
|
||||||
|
@ -2167,7 +2167,7 @@
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton_2">
|
<widget class="QPushButton" name="ToggleGridButton">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Grid</string>
|
<string>Grid</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -2195,38 +2195,6 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pushButton">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Selection Tint</string>
|
|
||||||
</property>
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">border: none;</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="../Icons.qrc">
|
|
||||||
<normaloff>:/icons/Highlight.png</normaloff>:/icons/Highlight.png</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="iconSize">
|
|
||||||
<size>
|
|
||||||
<width>32</width>
|
|
||||||
<height>32</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="checked">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="flat">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="CameraModeButton">
|
<widget class="QPushButton" name="CameraModeButton">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
|
@ -2418,6 +2386,19 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QToolBar" name="toolBar">
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>toolBar</string>
|
||||||
|
</property>
|
||||||
|
<attribute name="toolBarArea">
|
||||||
|
<enum>TopToolBarArea</enum>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="toolBarBreak">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
<addaction name="actionOpen"/>
|
||||||
|
<addaction name="actionSave"/>
|
||||||
|
</widget>
|
||||||
<widget class="QMenuBar" name="menubar">
|
<widget class="QMenuBar" name="menubar">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
|
@ -2445,27 +2426,8 @@
|
||||||
<addaction name="actionConvert_to_DDS"/>
|
<addaction name="actionConvert_to_DDS"/>
|
||||||
<addaction name="actionConvert_DDS_to_TXTR"/>
|
<addaction name="actionConvert_DDS_to_TXTR"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuWindow">
|
|
||||||
<property name="title">
|
|
||||||
<string>Window</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<addaction name="menuFile"/>
|
<addaction name="menuFile"/>
|
||||||
<addaction name="menuTextures"/>
|
<addaction name="menuTextures"/>
|
||||||
<addaction name="menuWindow"/>
|
|
||||||
</widget>
|
|
||||||
<widget class="QToolBar" name="toolBar">
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>toolBar</string>
|
|
||||||
</property>
|
|
||||||
<attribute name="toolBarArea">
|
|
||||||
<enum>TopToolBarArea</enum>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="toolBarBreak">
|
|
||||||
<bool>false</bool>
|
|
||||||
</attribute>
|
|
||||||
<addaction name="actionOpen"/>
|
|
||||||
<addaction name="actionSave"/>
|
|
||||||
</widget>
|
</widget>
|
||||||
<action name="actionOpen">
|
<action name="actionOpen">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|
Loading…
Reference in New Issue