mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-05-30 03:01:32 +00:00
Added rotation arrow for when billboards are selected
This commit is contained in:
parent
9a24a34bc6
commit
75091f718c
BIN
resources/RotationArrow.cmdl
Normal file
BIN
resources/RotationArrow.cmdl
Normal file
Binary file not shown.
@ -3,6 +3,7 @@
|
|||||||
#include "Core/Render/CGraphics.h"
|
#include "Core/Render/CGraphics.h"
|
||||||
#include "Core/Render/CDrawUtil.h"
|
#include "Core/Render/CDrawUtil.h"
|
||||||
#include "Core/Resource/CGameArea.h"
|
#include "Core/Resource/CGameArea.h"
|
||||||
|
#include "Core/Resource/CResCache.h"
|
||||||
#include <Common/AnimUtil.h>
|
#include <Common/AnimUtil.h>
|
||||||
#include <Math/CTransform4f.h>
|
#include <Math/CTransform4f.h>
|
||||||
|
|
||||||
@ -215,6 +216,12 @@ void CSceneNode::DrawBoundingBox() const
|
|||||||
CDrawUtil::DrawWireCube(AABox(), CColor::skWhite);
|
CDrawUtil::DrawWireCube(AABox(), CColor::skWhite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSceneNode::DrawRotationArrow() const
|
||||||
|
{
|
||||||
|
static TResPtr<CModel> spArrowModel = gResCache.GetResource("../resources/RotationArrow.cmdl");
|
||||||
|
spArrowModel->Draw(eNoRenderOptions, 0);
|
||||||
|
}
|
||||||
|
|
||||||
void CSceneNode::AddSurfacesToRenderer(CRenderer *pRenderer, CModel *pModel, u32 MatSet, const SViewInfo& rkViewInfo)
|
void CSceneNode::AddSurfacesToRenderer(CRenderer *pRenderer, CModel *pModel, u32 MatSet, const SViewInfo& rkViewInfo)
|
||||||
{
|
{
|
||||||
u32 SurfaceCount = pModel->GetSurfaceCount();
|
u32 SurfaceCount = pModel->GetSurfaceCount();
|
||||||
|
@ -74,6 +74,7 @@ public:
|
|||||||
void BuildLightList(CGameArea *pArea);
|
void BuildLightList(CGameArea *pArea);
|
||||||
void LoadLights(const SViewInfo& ViewInfo);
|
void LoadLights(const SViewInfo& ViewInfo);
|
||||||
void DrawBoundingBox() const;
|
void DrawBoundingBox() const;
|
||||||
|
void DrawRotationArrow() const;
|
||||||
void AddSurfacesToRenderer(CRenderer *pRenderer, CModel *pModel, u32 MatSet, const SViewInfo& ViewInfo);
|
void AddSurfacesToRenderer(CRenderer *pRenderer, CModel *pModel, u32 MatSet, const SViewInfo& ViewInfo);
|
||||||
|
|
||||||
// Transform
|
// Transform
|
||||||
|
@ -197,15 +197,28 @@ void CScriptNode::Draw(FRenderOptions Options, int ComponentIndex, const SViewIn
|
|||||||
void CScriptNode::DrawSelection()
|
void CScriptNode::DrawSelection()
|
||||||
{
|
{
|
||||||
glBlendFunc(GL_ONE, GL_ZERO);
|
glBlendFunc(GL_ONE, GL_ZERO);
|
||||||
|
LoadModelMatrix();
|
||||||
|
|
||||||
// Draw wireframe for models; billboards only get tinted
|
// Draw wireframe for models
|
||||||
if (UsesModel())
|
if (UsesModel())
|
||||||
{
|
{
|
||||||
LoadModelMatrix();
|
|
||||||
CModel *pModel = (mpActiveModel ? mpActiveModel : CDrawUtil::GetCubeModel());
|
CModel *pModel = (mpActiveModel ? mpActiveModel : CDrawUtil::GetCubeModel());
|
||||||
pModel->DrawWireframe(eNoRenderOptions, WireframeColor());
|
pModel->DrawWireframe(eNoRenderOptions, WireframeColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Draw rotation arrow for billboards
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Create model matrix that doesn't take scaling into account, and draw
|
||||||
|
CTransform4f Transform;
|
||||||
|
Transform.Rotate(AbsoluteRotation());
|
||||||
|
Transform.Translate(AbsolutePosition());
|
||||||
|
CGraphics::sMVPBlock.ModelMatrix = Transform.ToMatrix4f();
|
||||||
|
CGraphics::UpdateMVPBlock();
|
||||||
|
|
||||||
|
DrawRotationArrow();
|
||||||
|
}
|
||||||
|
|
||||||
if (mpInstance)
|
if (mpInstance)
|
||||||
{
|
{
|
||||||
CGraphics::sMVPBlock.ModelMatrix = CMatrix4f::skIdentity;
|
CGraphics::sMVPBlock.ModelMatrix = CMatrix4f::skIdentity;
|
||||||
@ -503,7 +516,7 @@ void CScriptNode::CalculateTransform(CTransform4f& rOut) const
|
|||||||
rOut.Scale(Scale * pTemp->PreviewScale());
|
rOut.Scale(Scale * pTemp->PreviewScale());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UsesModel() && pTemp->RotationType() == CScriptTemplate::eRotationEnabled)
|
if (pTemp->RotationType() == CScriptTemplate::eRotationEnabled)
|
||||||
rOut.Rotate(AbsoluteRotation());
|
rOut.Rotate(AbsoluteRotation());
|
||||||
|
|
||||||
rOut.Translate(AbsolutePosition());
|
rOut.Translate(AbsolutePosition());
|
||||||
|
@ -569,21 +569,21 @@ void CGizmo::SetMode(EGizmoMode mode)
|
|||||||
{
|
{
|
||||||
case eTranslate:
|
case eTranslate:
|
||||||
mpCurrentParts = smTranslateModels;
|
mpCurrentParts = smTranslateModels;
|
||||||
mNumCurrentParts = 9;
|
mNumCurrentParts = CGIZMO_TRANSLATE_NUM;
|
||||||
mDeltaRotation = CQuaternion::skIdentity;
|
mDeltaRotation = CQuaternion::skIdentity;
|
||||||
mDeltaScale = CVector3f::skOne;
|
mDeltaScale = CVector3f::skOne;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case eRotate:
|
case eRotate:
|
||||||
mpCurrentParts = smRotateModels;
|
mpCurrentParts = smRotateModels;
|
||||||
mNumCurrentParts = 5;
|
mNumCurrentParts = CGIZMO_ROTATE_NUM;
|
||||||
mDeltaTranslation = CVector3f::skZero;
|
mDeltaTranslation = CVector3f::skZero;
|
||||||
mDeltaScale = CVector3f::skOne;
|
mDeltaScale = CVector3f::skOne;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case eScale:
|
case eScale:
|
||||||
mpCurrentParts = smScaleModels;
|
mpCurrentParts = smScaleModels;
|
||||||
mNumCurrentParts = 10;
|
mNumCurrentParts = CGIZMO_SCALE_NUM;
|
||||||
mDeltaTranslation = CVector3f::skZero;
|
mDeltaTranslation = CVector3f::skZero;
|
||||||
mDeltaRotation = CQuaternion::skIdentity;
|
mDeltaRotation = CQuaternion::skIdentity;
|
||||||
break;
|
break;
|
||||||
@ -730,6 +730,6 @@ void CGizmo::WrapCursor()
|
|||||||
|
|
||||||
// ************ STATIC MEMBER INITIALIZATION ************
|
// ************ STATIC MEMBER INITIALIZATION ************
|
||||||
bool CGizmo::smModelsLoaded = false;
|
bool CGizmo::smModelsLoaded = false;
|
||||||
CGizmo::SModelPart CGizmo::smTranslateModels[9];
|
CGizmo::SModelPart CGizmo::smTranslateModels[CGIZMO_TRANSLATE_NUM];
|
||||||
CGizmo::SModelPart CGizmo::smRotateModels[5];
|
CGizmo::SModelPart CGizmo::smRotateModels[CGIZMO_ROTATE_NUM];
|
||||||
CGizmo::SModelPart CGizmo::smScaleModels[10];
|
CGizmo::SModelPart CGizmo::smScaleModels[CGIZMO_SCALE_NUM];
|
||||||
|
@ -20,11 +20,13 @@
|
|||||||
#define CGIZMO_TRANSLATE_POLY_XY 6
|
#define CGIZMO_TRANSLATE_POLY_XY 6
|
||||||
#define CGIZMO_TRANSLATE_POLY_XZ 7
|
#define CGIZMO_TRANSLATE_POLY_XZ 7
|
||||||
#define CGIZMO_TRANSLATE_POLY_YZ 8
|
#define CGIZMO_TRANSLATE_POLY_YZ 8
|
||||||
|
#define CGIZMO_TRANSLATE_NUM 9
|
||||||
#define CGIZMO_ROTATE_OUTLINE 0
|
#define CGIZMO_ROTATE_OUTLINE 0
|
||||||
#define CGIZMO_ROTATE_X 1
|
#define CGIZMO_ROTATE_X 1
|
||||||
#define CGIZMO_ROTATE_Y 2
|
#define CGIZMO_ROTATE_Y 2
|
||||||
#define CGIZMO_ROTATE_Z 3
|
#define CGIZMO_ROTATE_Z 3
|
||||||
#define CGIZMO_ROTATE_XYZ 4
|
#define CGIZMO_ROTATE_XYZ 4
|
||||||
|
#define CGIZMO_ROTATE_NUM 5
|
||||||
#define CGIZMO_SCALE_X 0
|
#define CGIZMO_SCALE_X 0
|
||||||
#define CGIZMO_SCALE_Y 1
|
#define CGIZMO_SCALE_Y 1
|
||||||
#define CGIZMO_SCALE_Z 2
|
#define CGIZMO_SCALE_Z 2
|
||||||
@ -35,6 +37,7 @@
|
|||||||
#define CGIZMO_SCALE_POLY_XZ 7
|
#define CGIZMO_SCALE_POLY_XZ 7
|
||||||
#define CGIZMO_SCALE_POLY_YZ 8
|
#define CGIZMO_SCALE_POLY_YZ 8
|
||||||
#define CGIZMO_SCALE_XYZ 9
|
#define CGIZMO_SCALE_XYZ 9
|
||||||
|
#define CGIZMO_SCALE_NUM 10
|
||||||
|
|
||||||
class CGizmo : public IRenderable
|
class CGizmo : public IRenderable
|
||||||
{
|
{
|
||||||
@ -116,9 +119,9 @@ private:
|
|||||||
|
|
||||||
// Static
|
// Static
|
||||||
static bool smModelsLoaded;
|
static bool smModelsLoaded;
|
||||||
static SModelPart smTranslateModels[9];
|
static SModelPart smTranslateModels[CGIZMO_TRANSLATE_NUM];
|
||||||
static SModelPart smRotateModels[5];
|
static SModelPart smRotateModels[CGIZMO_ROTATE_NUM];
|
||||||
static SModelPart smScaleModels[10];
|
static SModelPart smScaleModels[CGIZMO_SCALE_NUM];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CGizmo();
|
CGizmo();
|
||||||
|
@ -542,7 +542,7 @@ void CModelEditorWindow::UpdateMaterial(QColor Color)
|
|||||||
if (mIgnoreSignals) return;
|
if (mIgnoreSignals) return;
|
||||||
|
|
||||||
EModelEditorWidget Widget = (EModelEditorWidget) sender()->property("ModelEditorWidgetType").toInt();
|
EModelEditorWidget Widget = (EModelEditorWidget) sender()->property("ModelEditorWidgetType").toInt();
|
||||||
CColor KColor((u8) Color.red(), (u8) Color.green(), (u8) Color.blue(), (u8) Color.alpha());
|
CColor KColor(Color.red() / 255.f, Color.green() / 255.f, Color.blue() / 255.f, Color.alpha() / 255.f);
|
||||||
|
|
||||||
switch (Widget)
|
switch (Widget)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user