mirror of
https://github.com/leozide/leocad
synced 2025-01-28 19:58:12 +01:00
Removed calls to GL matrix stack.
This commit is contained in:
parent
75f093f96d
commit
0cf0f497e9
8 changed files with 87 additions and 162 deletions
|
@ -460,13 +460,12 @@ void Camera::CopyPosition(const Camera* camera)
|
|||
mUpVector = camera->mUpVector;
|
||||
}
|
||||
|
||||
void Camera::Render(float fLineWidth)
|
||||
void Camera::Render(const lcMatrix44& ViewMatrix, float LineWidth)
|
||||
{
|
||||
lcMatrix44 ViewWorld = lcMatrix44AffineInverse(mWorldView);
|
||||
|
||||
// Draw camera.
|
||||
glPushMatrix();
|
||||
glMultMatrixf(ViewWorld);
|
||||
glLoadMatrixf(lcMul(ViewWorld, ViewMatrix));
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
float verts[34][3] =
|
||||
|
@ -508,8 +507,6 @@ void Camera::Render(float fLineWidth)
|
|||
glDrawArrays(GL_LINES, 0, 24);
|
||||
glDrawArrays(GL_LINE_STRIP, 24, 10);
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
lcMatrix44 TargetMat = ViewWorld;
|
||||
float box[24][3] =
|
||||
{
|
||||
|
@ -528,7 +525,6 @@ void Camera::Render(float fLineWidth)
|
|||
};
|
||||
/*
|
||||
// Draw ortho target.
|
||||
glPushMatrix();
|
||||
TargetMat.SetTranslation(mOrthoTarget);
|
||||
glMultMatrixf(TargetMat);
|
||||
|
||||
|
@ -538,12 +534,10 @@ void Camera::Render(float fLineWidth)
|
|||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, 0, box);
|
||||
glDrawArrays(GL_LINES, 0, 24);
|
||||
glPopMatrix();
|
||||
*/
|
||||
// Draw target.
|
||||
glPushMatrix();
|
||||
TargetMat.SetTranslation(mTargetPosition);
|
||||
glMultMatrixf(TargetMat);
|
||||
glLoadMatrixf(lcMul(TargetMat, ViewMatrix));
|
||||
|
||||
if (IsTargetSelected())
|
||||
{
|
||||
|
@ -562,7 +556,8 @@ void Camera::Render(float fLineWidth)
|
|||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, 0, box);
|
||||
glDrawArrays(GL_LINES, 0, 24);
|
||||
glPopMatrix();
|
||||
|
||||
glLoadMatrixf(ViewMatrix);
|
||||
|
||||
lcVector3 Line[2] =
|
||||
{
|
||||
|
@ -577,8 +572,7 @@ void Camera::Render(float fLineWidth)
|
|||
|
||||
if (IsSelected())
|
||||
{
|
||||
glPushMatrix();
|
||||
glMultMatrixf(ViewWorld);
|
||||
glLoadMatrixf(lcMul(ViewWorld, ViewMatrix));
|
||||
|
||||
float Dist = lcLength(mTargetPosition - mPosition);
|
||||
lcMatrix44 Projection = lcMatrix44Perspective(m_fovy, 1.33f, 0.01f, Dist);
|
||||
|
@ -600,8 +594,6 @@ void Camera::Render(float fLineWidth)
|
|||
|
||||
glVertexPointer(3, GL_FLOAT, 0, ProjVerts);
|
||||
glDrawArrays(GL_LINES, 0, 16);
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
|
|
@ -143,7 +143,7 @@ public:
|
|||
|
||||
void UpdatePosition(unsigned short nTime);
|
||||
void CopyPosition(const Camera* camera);
|
||||
void Render(float fLineWidth);
|
||||
void Render(const lcMatrix44& ViewMatrix, float LineWidth);
|
||||
void LoadProjection(const lcProjection& projection);
|
||||
|
||||
void ZoomExtents(View* view, const lcVector3& Center, const lcVector3* Points, int NumPoints, unsigned short nTime, bool bAddKey);
|
||||
|
|
|
@ -291,39 +291,37 @@ void Light::UpdatePosition(unsigned short nTime)
|
|||
}
|
||||
}
|
||||
|
||||
void Light::Render(float fLineWidth)
|
||||
void Light::Render(const lcMatrix44& ViewMatrix, float LineWidth)
|
||||
{
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
if (m_pTarget != NULL)
|
||||
{
|
||||
glPushMatrix();
|
||||
|
||||
if (IsEyeSelected())
|
||||
{
|
||||
glLineWidth(fLineWidth*2);
|
||||
glLineWidth(LineWidth*2);
|
||||
if (m_nState & LC_LIGHT_FOCUSED)
|
||||
lcSetColorFocused();
|
||||
else
|
||||
lcSetColorSelected();
|
||||
RenderCone();
|
||||
glLineWidth(fLineWidth);
|
||||
RenderCone(ViewMatrix);
|
||||
glLineWidth(LineWidth);
|
||||
}
|
||||
else
|
||||
{
|
||||
lcSetColorLight();
|
||||
RenderCone();
|
||||
RenderCone(ViewMatrix);
|
||||
}
|
||||
|
||||
if (IsTargetSelected())
|
||||
{
|
||||
glLineWidth(fLineWidth*2);
|
||||
glLineWidth(LineWidth*2);
|
||||
if (m_nState & LC_LIGHT_TARGET_FOCUSED)
|
||||
lcSetColorFocused();
|
||||
else
|
||||
lcSetColorSelected();
|
||||
RenderTarget();
|
||||
glLineWidth(fLineWidth);
|
||||
glLineWidth(LineWidth);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -331,7 +329,7 @@ void Light::Render(float fLineWidth)
|
|||
RenderTarget();
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
glLoadMatrixf(ViewMatrix);
|
||||
|
||||
lcSetColorLight();
|
||||
|
||||
|
@ -342,7 +340,7 @@ void Light::Render(float fLineWidth)
|
|||
|
||||
if (IsSelected())
|
||||
{
|
||||
lcMatrix44 projection, modelview;
|
||||
lcMatrix44 ProjectionMatrix, LightMatrix;
|
||||
lcVector3 FrontVector(mTargetPosition - mPosition);
|
||||
lcVector3 UpVector(1, 1, 1);
|
||||
float Length = FrontVector.Length();
|
||||
|
@ -362,15 +360,11 @@ void Light::Render(float fLineWidth)
|
|||
UpVector[2] = -(UpVector[0] * FrontVector[0] + UpVector[1] * FrontVector[1]);
|
||||
}
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
modelview = lcMatrix44LookAt(mPosition, mTargetPosition, UpVector);
|
||||
modelview = lcMatrix44AffineInverse(modelview);
|
||||
glMultMatrixf(modelview);
|
||||
|
||||
projection = lcMatrix44Perspective(2*mSpotCutoff, 1.0f, 0.01f, Length);
|
||||
projection = lcMatrix44Inverse(projection);
|
||||
glMultMatrixf(projection);
|
||||
LightMatrix = lcMatrix44LookAt(mPosition, mTargetPosition, UpVector);
|
||||
LightMatrix = lcMatrix44AffineInverse(LightMatrix);
|
||||
ProjectionMatrix = lcMatrix44Perspective(2 * mSpotCutoff, 1.0f, 0.01f, Length);
|
||||
ProjectionMatrix = lcMatrix44Inverse(ProjectionMatrix);
|
||||
glLoadMatrixf(lcMul(ProjectionMatrix, lcMul(LightMatrix, ViewMatrix)));
|
||||
|
||||
// Draw the light cone.
|
||||
float Verts[16][3] =
|
||||
|
@ -396,14 +390,11 @@ void Light::Render(float fLineWidth)
|
|||
glVertexPointer(3, GL_FLOAT, 0, Verts);
|
||||
glDrawArrays(GL_LINE_LOOP, 0, 8);
|
||||
glDrawArrays(GL_LINES, 8, 8);
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
glPushMatrix();
|
||||
glTranslatef(mPosition[0], mPosition[1], mPosition[2]);
|
||||
glLoadMatrixf(lcMul(lcMatrix44Translation(mPosition), ViewMatrix));
|
||||
|
||||
if (IsEyeSelected())
|
||||
{
|
||||
|
@ -416,17 +407,13 @@ void Light::Render(float fLineWidth)
|
|||
lcSetColorLight();
|
||||
|
||||
RenderSphere();
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
}
|
||||
|
||||
void Light::RenderCone()
|
||||
void Light::RenderCone(const lcMatrix44& ViewMatrix)
|
||||
{
|
||||
glTranslatef(mPosition[0], mPosition[1], mPosition[2]);
|
||||
|
||||
lcVector3 FrontVector(mTargetPosition - mPosition);
|
||||
lcVector3 UpVector(1, 1, 1);
|
||||
float Length = FrontVector.Length();
|
||||
|
@ -446,11 +433,13 @@ void Light::RenderCone()
|
|||
UpVector[2] = -(UpVector[0] * FrontVector[0] + UpVector[1] * FrontVector[1]);
|
||||
}
|
||||
|
||||
lcMatrix44 mat = lcMatrix44LookAt(mPosition, mTargetPosition, UpVector);
|
||||
mat = lcMatrix44AffineInverse(mat);
|
||||
mat.SetTranslation(lcVector3(0, 0, 0));
|
||||
lcMatrix44 LightMatrix = lcMatrix44LookAt(mPosition, mTargetPosition, UpVector);
|
||||
LightMatrix = lcMatrix44AffineInverse(LightMatrix);
|
||||
LightMatrix.SetTranslation(lcVector3(0, 0, 0));
|
||||
|
||||
glMultMatrixf(mat);
|
||||
lcMatrix44 LightViewMatrix = lcMul(LightMatrix, lcMul(lcMatrix44Translation(mPosition), ViewMatrix));
|
||||
|
||||
glLoadMatrixf(LightViewMatrix);
|
||||
|
||||
float verts[16*3];
|
||||
for (int i = 0; i < 8; i++)
|
||||
|
@ -479,7 +468,7 @@ void Light::RenderCone()
|
|||
glVertexPointer(3, GL_FLOAT, 0, Lines);
|
||||
glDrawArrays(GL_LINE_LOOP, 0, 4);
|
||||
|
||||
glTranslatef(0, 0, -Length);
|
||||
glLoadMatrixf(lcMul(lcMatrix44Translation(lcVector3(0, 0, -Length)), LightViewMatrix));
|
||||
}
|
||||
|
||||
void Light::RenderTarget()
|
||||
|
|
|
@ -98,8 +98,8 @@ public:
|
|||
const char* GetName() const
|
||||
{ return m_strName; }
|
||||
|
||||
void Render(float fLineWidth);
|
||||
void RenderCone();
|
||||
void Render(const lcMatrix44& ViewMatrix, float LineWidth);
|
||||
void RenderCone(const lcMatrix44& ViewMatrix);
|
||||
void RenderTarget();
|
||||
void RenderSphere();
|
||||
|
||||
|
|
|
@ -1009,6 +1009,8 @@ void MinifigWizard::OnDraw()
|
|||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadMatrixf(Projection);
|
||||
|
||||
lcMatrix44 ViewMatrix;
|
||||
|
||||
if (m_AutoZoom)
|
||||
{
|
||||
lcVector3 Points[8] =
|
||||
|
@ -1028,8 +1030,7 @@ void MinifigWizard::OnDraw()
|
|||
lcMatrix44 ModelView = lcMatrix44LookAt(Eye, Center, lcVector3(0, 0, 1));
|
||||
Eye = lcZoomExtents(Eye, ModelView, Projection, Points, 8);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadMatrixf(lcMatrix44LookAt(Eye, Center, lcVector3(0, 0, 1)));
|
||||
ViewMatrix = lcMatrix44LookAt(Eye, Center, lcVector3(0, 0, 1));
|
||||
|
||||
// Update the new camera distance.
|
||||
lcVector3 d = Eye - Center;
|
||||
|
@ -1037,8 +1038,7 @@ void MinifigWizard::OnDraw()
|
|||
}
|
||||
else
|
||||
{
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadMatrixf(lcMatrix44LookAt(Eye * m_Distance, Center, lcVector3(0, 0, 1)));
|
||||
ViewMatrix = lcMatrix44LookAt(Eye * m_Distance, Center, lcVector3(0, 0, 1));
|
||||
}
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
@ -1046,6 +1046,7 @@ void MinifigWizard::OnDraw()
|
|||
glEnable(GL_POLYGON_OFFSET_FILL);
|
||||
glPolygonOffset(0.5f, 0.1f);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
float *bg = lcGetActiveProject()->GetBackgroundColor();
|
||||
glClearColor(bg[0], bg[1], bg[2], bg[3]);
|
||||
|
@ -1058,10 +1059,8 @@ void MinifigWizard::OnDraw()
|
|||
if (!mMinifig->Parts[PieceIdx])
|
||||
continue;
|
||||
|
||||
glPushMatrix();
|
||||
glMultMatrixf(mMinifig->Matrices[PieceIdx]);
|
||||
glLoadMatrixf(lcMul(mMinifig->Matrices[PieceIdx], ViewMatrix));
|
||||
mMinifig->Parts[PieceIdx]->RenderPiece(mMinifig->Colors[PieceIdx]);
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -521,37 +521,3 @@ void Piece::UpdatePosition(unsigned short nTime)
|
|||
mModelWorld = lcMatrix44FromAxisAngle(lcVector3(mRotation[0], mRotation[1], mRotation[2]), mRotation[3] * LC_DTOR);
|
||||
mModelWorld.SetTranslation(mPosition);
|
||||
}
|
||||
|
||||
void Piece::RenderBox(bool bHilite, float fLineWidth)
|
||||
{
|
||||
glPushMatrix();
|
||||
glMultMatrixf(mModelWorld);
|
||||
|
||||
if (bHilite && ((m_nState & LC_PIECE_SELECTED) != 0))
|
||||
{
|
||||
if (m_nState & LC_PIECE_FOCUSED)
|
||||
lcSetColorFocused();
|
||||
else
|
||||
lcSetColorSelected();
|
||||
glLineWidth(2*fLineWidth);
|
||||
glPushAttrib(GL_POLYGON_BIT);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
mPieceInfo->RenderBox();
|
||||
glPopAttrib();
|
||||
glLineWidth(fLineWidth);
|
||||
}
|
||||
else
|
||||
{
|
||||
lcSetColor(mColorIndex);
|
||||
mPieceInfo->RenderBox();
|
||||
}
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
void Piece::Render(bool bLighting, bool bEdges)
|
||||
{
|
||||
glPushMatrix();
|
||||
glMultMatrixf(mModelWorld);
|
||||
mPieceInfo->mMesh->Render(mColorIndex, (m_nState & LC_PIECE_SELECTED) != 0, (m_nState & LC_PIECE_FOCUSED) != 0);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
|
|
@ -83,9 +83,6 @@ public:
|
|||
unsigned char GetStepHide()
|
||||
{ return (unsigned char)m_nStepHide; }
|
||||
|
||||
void Render(bool bLighting, bool bEdges);
|
||||
void RenderBox(bool bHilite, float fLineWidth);
|
||||
|
||||
void SetColorCode(lcuint32 ColorCode)
|
||||
{
|
||||
mColorCode = ColorCode;
|
||||
|
|
|
@ -1546,7 +1546,10 @@ void Project::Render(View* view, bool ToMemory)
|
|||
RenderSceneObjects(view);
|
||||
|
||||
if (m_OverlayActive || ((m_nCurAction == LC_ACTION_SELECT) && (m_nTracking == LC_TRACK_LEFT) && (m_ActiveView == view)))
|
||||
{
|
||||
view->UpdateProjection();
|
||||
RenderOverlays(view);
|
||||
}
|
||||
|
||||
RenderViewports(view);
|
||||
}
|
||||
|
@ -1724,7 +1727,7 @@ void Project::RenderScenePieces(View* view)
|
|||
lcArray<Piece*> OpaquePieces(512);
|
||||
lcArray<lcTranslucentRenderSection> TranslucentSections(512);
|
||||
|
||||
const lcMatrix44& WorldView = view->mCamera->mWorldView;
|
||||
const lcMatrix44& ViewMatrix = view->mCamera->mWorldView;
|
||||
|
||||
for (Piece* pPiece = m_pPieces; pPiece; pPiece = pPiece->m_pNext)
|
||||
{
|
||||
|
@ -1739,7 +1742,7 @@ void Project::RenderScenePieces(View* view)
|
|||
|
||||
if ((Info->mFlags & LC_PIECE_HAS_TRANSLUCENT) || ((Info->mFlags & LC_PIECE_HAS_DEFAULT) && Translucent))
|
||||
{
|
||||
lcVector3 Pos = lcMul31(pPiece->mPosition, WorldView);
|
||||
lcVector3 Pos = lcMul31(pPiece->mPosition, ViewMatrix);
|
||||
|
||||
lcTranslucentRenderSection RenderSection;
|
||||
|
||||
|
@ -1764,8 +1767,7 @@ void Project::RenderScenePieces(View* view)
|
|||
Piece* piece = OpaquePieces[PieceIdx];
|
||||
lcMesh* Mesh = piece->mPieceInfo->mMesh;
|
||||
|
||||
glPushMatrix();
|
||||
glMultMatrixf(piece->mModelWorld);
|
||||
glLoadMatrixf(lcMul(piece->mModelWorld, ViewMatrix));
|
||||
|
||||
if (PreviousMesh != Mesh)
|
||||
{
|
||||
|
@ -1873,8 +1875,6 @@ void Project::RenderScenePieces(View* view)
|
|||
|
||||
glDrawElements(Section->PrimitiveType, Section->NumIndices, Mesh->mIndexType, ElementsOffset + Section->IndexOffset);
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
if (PreviousSelected)
|
||||
|
@ -1891,8 +1891,7 @@ void Project::RenderScenePieces(View* view)
|
|||
Piece* piece = TranslucentSections[PieceIdx].piece;
|
||||
lcMesh* Mesh = piece->mPieceInfo->mMesh;
|
||||
|
||||
glPushMatrix();
|
||||
glMultMatrixf(piece->mModelWorld);
|
||||
glLoadMatrixf(lcMul(piece->mModelWorld, ViewMatrix));
|
||||
|
||||
if (PreviousMesh != Mesh)
|
||||
{
|
||||
|
@ -1974,8 +1973,6 @@ void Project::RenderScenePieces(View* view)
|
|||
|
||||
glDrawElements(Section->PrimitiveType, Section->NumIndices, Mesh->mIndexType, ElementsOffset + Section->IndexOffset);
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
glDepthMask(GL_TRUE);
|
||||
|
@ -2013,6 +2010,7 @@ void Project::RenderScenePieces(View* view)
|
|||
void Project::RenderSceneObjects(View* view)
|
||||
{
|
||||
const lcPreferences& Preferences = lcGetPreferences();
|
||||
const lcMatrix44& ViewMatrix = view->mCamera->mWorldView;
|
||||
|
||||
#ifdef LC_DEBUG
|
||||
RenderDebugPrimitives();
|
||||
|
@ -2021,18 +2019,19 @@ void Project::RenderSceneObjects(View* view)
|
|||
// Draw cameras & lights
|
||||
if (m_nCurAction == LC_ACTION_INSERT || mDropPiece)
|
||||
{
|
||||
lcVector3 Pos;
|
||||
lcVector4 Rot;
|
||||
GetPieceInsertPosition(view, m_nDownX, m_nDownY, Pos, Rot);
|
||||
lcVector3 Position;
|
||||
lcVector4 Rotation;
|
||||
GetPieceInsertPosition(view, m_nDownX, m_nDownY, Position, Rotation);
|
||||
PieceInfo* PreviewPiece = mDropPiece ? mDropPiece : m_pCurPiece;
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(Pos[0], Pos[1], Pos[2]);
|
||||
glRotatef(Rot[3], Rot[0], Rot[1], Rot[2]);
|
||||
lcMatrix44 WorldMatrix = lcMatrix44FromAxisAngle(lcVector3(Rotation[0], Rotation[1], Rotation[2]), Rotation[3] * LC_DTOR);
|
||||
WorldMatrix.SetTranslation(Position);
|
||||
|
||||
glLoadMatrixf(lcMul(WorldMatrix, ViewMatrix));
|
||||
|
||||
glLineWidth(2 * Preferences.mLineWidth);
|
||||
PreviewPiece->RenderPiece(gMainWindow->mColorIndex);
|
||||
glLineWidth(Preferences.mLineWidth);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
if (Preferences.mLightingMode != LC_LIGHTING_FLAT)
|
||||
|
@ -2052,15 +2051,17 @@ void Project::RenderSceneObjects(View* view)
|
|||
if ((pCamera == view->mCamera) || !pCamera->IsVisible())
|
||||
continue;
|
||||
|
||||
pCamera->Render(Preferences.mLineWidth);
|
||||
pCamera->Render(ViewMatrix, Preferences.mLineWidth);
|
||||
}
|
||||
|
||||
for (Light* pLight = m_pLights; pLight; pLight = pLight->m_pNext)
|
||||
if (pLight->IsVisible ())
|
||||
pLight->Render(Preferences.mLineWidth);
|
||||
pLight->Render(ViewMatrix, Preferences.mLineWidth);
|
||||
|
||||
if (Preferences.mDrawGridStuds || Preferences.mDrawGridLines)
|
||||
{
|
||||
glLoadMatrixf(ViewMatrix);
|
||||
|
||||
const int Spacing = lcMax(Preferences.mGridLineSpacing, 1);
|
||||
int MinX = 0, MaxX = 0, MinY = 0, MaxY = 0;
|
||||
|
||||
|
@ -2233,11 +2234,9 @@ void Project::RenderSceneObjects(View* view)
|
|||
};
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glOrtho(0, view->mWidth, 0, view->mHeight, -50, 50);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glTranslatef(25.375f, 25.375f, 0.0f);
|
||||
|
||||
|
@ -2288,11 +2287,6 @@ void Project::RenderSceneObjects(View* view)
|
|||
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2392,6 +2386,7 @@ void Project::RenderOverlays(View* view)
|
|||
}
|
||||
|
||||
const float OverlayScale = view->m_OverlayScale;
|
||||
const lcMatrix44& ViewMatrix = view->mCamera->mWorldView;
|
||||
|
||||
if ((m_nCurAction == LC_ACTION_MOVE || m_nCurAction == LC_ACTION_SELECT) && (m_OverlayMode >= LC_OVERLAY_NONE && m_OverlayMode <= LC_OVERLAY_ROTATE_XYZ))
|
||||
{
|
||||
|
@ -2408,14 +2403,14 @@ void Project::RenderOverlays(View* view)
|
|||
|
||||
// Find the rotation from the focused piece if relative snap is enabled.
|
||||
Object* Focus = NULL;
|
||||
lcVector4 Rot(0, 0, 1, 0);
|
||||
lcVector4 Rotation(0, 0, 1, 0);
|
||||
|
||||
if ((m_nSnap & LC_DRAW_GLOBAL_SNAP) == 0)
|
||||
{
|
||||
Focus = GetFocusObject();
|
||||
|
||||
if ((Focus != NULL) && Focus->IsPiece())
|
||||
Rot = ((Piece*)Focus)->mRotation;
|
||||
Rotation = ((Piece*)Focus)->mRotation;
|
||||
else
|
||||
Focus = NULL;
|
||||
}
|
||||
|
@ -2423,21 +2418,21 @@ void Project::RenderOverlays(View* view)
|
|||
// Draw a quad if we're moving on a plane.
|
||||
if ((m_OverlayMode == LC_OVERLAY_MOVE_XY) || (m_OverlayMode == LC_OVERLAY_MOVE_XZ) || (m_OverlayMode == LC_OVERLAY_MOVE_YZ))
|
||||
{
|
||||
glPushMatrix();
|
||||
glTranslatef(m_OverlayCenter[0], m_OverlayCenter[1], m_OverlayCenter[2]);
|
||||
lcMatrix44 WorldViewMatrix = lcMul(lcMatrix44Translation(m_OverlayCenter), ViewMatrix);
|
||||
|
||||
if (Focus)
|
||||
glRotatef(Rot[3], Rot[0], Rot[1], Rot[2]);
|
||||
WorldViewMatrix = lcMul(lcMatrix44FromAxisAngle(lcVector3(Rotation[0], Rotation[1], Rotation[2]), Rotation[3] * LC_DTOR), WorldViewMatrix);
|
||||
|
||||
if (m_OverlayMode == LC_OVERLAY_MOVE_XZ)
|
||||
glRotatef(90.0f, 0.0f, 0.0f, -1.0f);
|
||||
WorldViewMatrix = lcMul(lcMatrix44RotationZ(-LC_PI / 2), WorldViewMatrix);
|
||||
else if (m_OverlayMode == LC_OVERLAY_MOVE_XY)
|
||||
glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
|
||||
WorldViewMatrix = lcMul(lcMatrix44RotationY(LC_PI / 2), WorldViewMatrix);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
glColor4f(0.8f, 0.8f, 0.0f, 0.3f);
|
||||
glLoadMatrixf(WorldViewMatrix);
|
||||
|
||||
float Verts[4][3] =
|
||||
{
|
||||
|
@ -2453,8 +2448,6 @@ void Project::RenderOverlays(View* view)
|
|||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
// Draw the arrows.
|
||||
|
@ -2482,16 +2475,17 @@ void Project::RenderOverlays(View* view)
|
|||
break;
|
||||
}
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(m_OverlayCenter[0], m_OverlayCenter[1], m_OverlayCenter[2]);
|
||||
lcMatrix44 WorldViewMatrix = lcMul(lcMatrix44Translation(m_OverlayCenter), ViewMatrix);
|
||||
|
||||
if (Focus)
|
||||
glRotatef(Rot[3], Rot[0], Rot[1], Rot[2]);
|
||||
WorldViewMatrix = lcMul(lcMatrix44FromAxisAngle(lcVector3(Rotation[0], Rotation[1], Rotation[2]), Rotation[3] * LC_DTOR), WorldViewMatrix);
|
||||
|
||||
if (i == 1)
|
||||
glMultMatrixf(lcMatrix44(lcVector4(0, 1, 0, 0), lcVector4(1, 0, 0, 0), lcVector4(0, 0, 1, 0), lcVector4(0, 0, 0, 1)));
|
||||
WorldViewMatrix = lcMul(lcMatrix44(lcVector4(0, 1, 0, 0), lcVector4(1, 0, 0, 0), lcVector4(0, 0, 1, 0), lcVector4(0, 0, 0, 1)), WorldViewMatrix);
|
||||
else if (i == 2)
|
||||
glMultMatrixf(lcMatrix44(lcVector4(0, 0, 1, 0), lcVector4(0, 1, 0, 0), lcVector4(1, 0, 0, 0), lcVector4(0, 0, 0, 1)));
|
||||
WorldViewMatrix = lcMul(lcMatrix44(lcVector4(0, 0, 1, 0), lcVector4(0, 1, 0, 0), lcVector4(1, 0, 0, 0), lcVector4(0, 0, 0, 1)), WorldViewMatrix);
|
||||
|
||||
glLoadMatrixf(WorldViewMatrix);
|
||||
|
||||
// Translation arrows.
|
||||
if (m_nTracking == LC_TRACK_NONE || (m_OverlayMode >= LC_OVERLAY_NONE && m_OverlayMode <= LC_OVERLAY_MOVE_XYZ))
|
||||
|
@ -2603,8 +2597,6 @@ void Project::RenderOverlays(View* view)
|
|||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
@ -2678,13 +2670,14 @@ void Project::RenderOverlays(View* view)
|
|||
|
||||
if (fabsf(Angle) >= fabsf(Step))
|
||||
{
|
||||
glPushMatrix();
|
||||
glTranslatef(m_OverlayCenter[0], m_OverlayCenter[1], m_OverlayCenter[2]);
|
||||
lcMatrix44 WorldViewMatrix = lcMul(lcMatrix44Translation(m_OverlayCenter), ViewMatrix);
|
||||
|
||||
if (Focus)
|
||||
glRotatef(Rot[3], Rot[0], Rot[1], Rot[2]);
|
||||
WorldViewMatrix = lcMul(lcMatrix44FromAxisAngle(lcVector3(Rot[0], Rot[1], Rot[2]), Rot[3] * LC_DTOR), WorldViewMatrix);
|
||||
|
||||
glRotatef(Rotation[0], Rotation[1], Rotation[2], Rotation[3]);
|
||||
WorldViewMatrix = lcMul(lcMatrix44FromAxisAngle(lcVector3(Rotation[1], Rotation[2], Rotation[3]), Rotation[0] * LC_DTOR), WorldViewMatrix);
|
||||
|
||||
glLoadMatrixf(WorldViewMatrix);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
|
@ -2731,13 +2724,9 @@ void Project::RenderOverlays(View* view)
|
|||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
lcMatrix44 Mat = lcMatrix44AffineInverse(Cam->mWorldView);
|
||||
Mat.SetTranslation(m_OverlayCenter);
|
||||
|
||||
|
@ -2758,6 +2747,7 @@ void Project::RenderOverlays(View* view)
|
|||
}
|
||||
|
||||
glColor4f(0.1f, 0.1f, 0.1f, 1.0f);
|
||||
glLoadMatrixf(ViewMatrix);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, 0, Verts);
|
||||
|
@ -2776,10 +2766,12 @@ void Project::RenderOverlays(View* view)
|
|||
ViewDir = lcMul30(ViewDir, RotMat);
|
||||
}
|
||||
|
||||
glTranslatef(m_OverlayCenter[0], m_OverlayCenter[1], m_OverlayCenter[2]);
|
||||
lcMatrix44 WorldViewMatrix = lcMul(lcMatrix44Translation(m_OverlayCenter), ViewMatrix);
|
||||
|
||||
if (Focus)
|
||||
glRotatef(Rot[3], Rot[0], Rot[1], Rot[2]);
|
||||
WorldViewMatrix = lcMul(lcMatrix44FromAxisAngle(lcVector3(Rot[0], Rot[1], Rot[2]), Rot[3] * LC_DTOR), WorldViewMatrix);
|
||||
|
||||
glLoadMatrixf(WorldViewMatrix);
|
||||
|
||||
// Draw each axis circle.
|
||||
for (int i = 0; i < 3; i++)
|
||||
|
@ -2845,8 +2837,6 @@ void Project::RenderOverlays(View* view)
|
|||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
// Draw tangent vector.
|
||||
if (m_nTracking != LC_TRACK_NONE)
|
||||
{
|
||||
|
@ -2878,13 +2868,14 @@ void Project::RenderOverlays(View* view)
|
|||
break;
|
||||
};
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(m_OverlayCenter[0], m_OverlayCenter[1], m_OverlayCenter[2]);
|
||||
lcMatrix44 WorldViewMatrix = lcMul(lcMatrix44Translation(m_OverlayCenter), ViewMatrix);
|
||||
|
||||
if (Focus)
|
||||
glRotatef(Rot[3], Rot[0], Rot[1], Rot[2]);
|
||||
WorldViewMatrix = lcMul(lcMatrix44FromAxisAngle(lcVector3(Rot[0], Rot[1], Rot[2]), Rot[3] * LC_DTOR), WorldViewMatrix);
|
||||
|
||||
glRotatef(Rotation[0], Rotation[1], Rotation[2], Rotation[3]);
|
||||
WorldViewMatrix = lcMul(lcMatrix44FromAxisAngle(lcVector3(Rotation[1], Rotation[2], Rotation[3]), Rotation[0] * LC_DTOR), WorldViewMatrix);
|
||||
|
||||
glLoadMatrixf(WorldViewMatrix);
|
||||
|
||||
glColor4f(0.8f, 0.8f, 0.0f, 1.0f);
|
||||
|
||||
|
@ -2911,8 +2902,6 @@ void Project::RenderOverlays(View* view)
|
|||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
// Draw text.
|
||||
int Viewport[4] = { 0, 0, view->mWidth, view->mHeight };
|
||||
float Aspect = (float)Viewport[2]/(float)Viewport[3];
|
||||
|
@ -2923,11 +2912,9 @@ void Project::RenderOverlays(View* view)
|
|||
lcVector3 ScreenPos = lcProjectPoint(m_OverlayCenter, ModelView, Projection, Viewport);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glOrtho(0, Viewport[2], 0, Viewport[3], -1, 1);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.375, 0.375, 0.0);
|
||||
|
||||
|
@ -2948,11 +2935,6 @@ void Project::RenderOverlays(View* view)
|
|||
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue