Added rotation arrow for when billboards are selected

This commit is contained in:
parax0 2016-01-25 22:26:38 -07:00
parent 9a24a34bc6
commit 75091f718c
7 changed files with 37 additions and 13 deletions

Binary file not shown.

View File

@ -3,6 +3,7 @@
#include "Core/Render/CGraphics.h"
#include "Core/Render/CDrawUtil.h"
#include "Core/Resource/CGameArea.h"
#include "Core/Resource/CResCache.h"
#include <Common/AnimUtil.h>
#include <Math/CTransform4f.h>
@ -215,6 +216,12 @@ void CSceneNode::DrawBoundingBox() const
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)
{
u32 SurfaceCount = pModel->GetSurfaceCount();

View File

@ -74,6 +74,7 @@ public:
void BuildLightList(CGameArea *pArea);
void LoadLights(const SViewInfo& ViewInfo);
void DrawBoundingBox() const;
void DrawRotationArrow() const;
void AddSurfacesToRenderer(CRenderer *pRenderer, CModel *pModel, u32 MatSet, const SViewInfo& ViewInfo);
// Transform

View File

@ -197,15 +197,28 @@ void CScriptNode::Draw(FRenderOptions Options, int ComponentIndex, const SViewIn
void CScriptNode::DrawSelection()
{
glBlendFunc(GL_ONE, GL_ZERO);
LoadModelMatrix();
// Draw wireframe for models; billboards only get tinted
// Draw wireframe for models
if (UsesModel())
{
LoadModelMatrix();
CModel *pModel = (mpActiveModel ? mpActiveModel : CDrawUtil::GetCubeModel());
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)
{
CGraphics::sMVPBlock.ModelMatrix = CMatrix4f::skIdentity;
@ -503,7 +516,7 @@ void CScriptNode::CalculateTransform(CTransform4f& rOut) const
rOut.Scale(Scale * pTemp->PreviewScale());
}
if (UsesModel() && pTemp->RotationType() == CScriptTemplate::eRotationEnabled)
if (pTemp->RotationType() == CScriptTemplate::eRotationEnabled)
rOut.Rotate(AbsoluteRotation());
rOut.Translate(AbsolutePosition());

View File

@ -569,21 +569,21 @@ void CGizmo::SetMode(EGizmoMode mode)
{
case eTranslate:
mpCurrentParts = smTranslateModels;
mNumCurrentParts = 9;
mNumCurrentParts = CGIZMO_TRANSLATE_NUM;
mDeltaRotation = CQuaternion::skIdentity;
mDeltaScale = CVector3f::skOne;
break;
case eRotate:
mpCurrentParts = smRotateModels;
mNumCurrentParts = 5;
mNumCurrentParts = CGIZMO_ROTATE_NUM;
mDeltaTranslation = CVector3f::skZero;
mDeltaScale = CVector3f::skOne;
break;
case eScale:
mpCurrentParts = smScaleModels;
mNumCurrentParts = 10;
mNumCurrentParts = CGIZMO_SCALE_NUM;
mDeltaTranslation = CVector3f::skZero;
mDeltaRotation = CQuaternion::skIdentity;
break;
@ -730,6 +730,6 @@ void CGizmo::WrapCursor()
// ************ STATIC MEMBER INITIALIZATION ************
bool CGizmo::smModelsLoaded = false;
CGizmo::SModelPart CGizmo::smTranslateModels[9];
CGizmo::SModelPart CGizmo::smRotateModels[5];
CGizmo::SModelPart CGizmo::smScaleModels[10];
CGizmo::SModelPart CGizmo::smTranslateModels[CGIZMO_TRANSLATE_NUM];
CGizmo::SModelPart CGizmo::smRotateModels[CGIZMO_ROTATE_NUM];
CGizmo::SModelPart CGizmo::smScaleModels[CGIZMO_SCALE_NUM];

View File

@ -20,11 +20,13 @@
#define CGIZMO_TRANSLATE_POLY_XY 6
#define CGIZMO_TRANSLATE_POLY_XZ 7
#define CGIZMO_TRANSLATE_POLY_YZ 8
#define CGIZMO_TRANSLATE_NUM 9
#define CGIZMO_ROTATE_OUTLINE 0
#define CGIZMO_ROTATE_X 1
#define CGIZMO_ROTATE_Y 2
#define CGIZMO_ROTATE_Z 3
#define CGIZMO_ROTATE_XYZ 4
#define CGIZMO_ROTATE_NUM 5
#define CGIZMO_SCALE_X 0
#define CGIZMO_SCALE_Y 1
#define CGIZMO_SCALE_Z 2
@ -35,6 +37,7 @@
#define CGIZMO_SCALE_POLY_XZ 7
#define CGIZMO_SCALE_POLY_YZ 8
#define CGIZMO_SCALE_XYZ 9
#define CGIZMO_SCALE_NUM 10
class CGizmo : public IRenderable
{
@ -116,9 +119,9 @@ private:
// Static
static bool smModelsLoaded;
static SModelPart smTranslateModels[9];
static SModelPart smRotateModels[5];
static SModelPart smScaleModels[10];
static SModelPart smTranslateModels[CGIZMO_TRANSLATE_NUM];
static SModelPart smRotateModels[CGIZMO_ROTATE_NUM];
static SModelPart smScaleModels[CGIZMO_SCALE_NUM];
public:
CGizmo();

View File

@ -542,7 +542,7 @@ void CModelEditorWindow::UpdateMaterial(QColor Color)
if (mIgnoreSignals) return;
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)
{