From de289b442231c79388371704a9d9e11fcb2169f8 Mon Sep 17 00:00:00 2001 From: Daveo Date: Wed, 25 Oct 2000 21:00:54 +0000 Subject: [PATCH] --- Utils/MapEdit/Core.cpp | 43 ++++++++++++------------- Utils/MapEdit/Layer.cpp | 68 +++++++++++++++++++++++++++++++++++++-- Utils/MapEdit/Layer.h | 5 ++- Utils/MapEdit/MapEdit.dsp | 2 +- Utils/MapEdit/utils.cpp | 13 +++++++- Utils/MapEdit/utils.h | 1 + 6 files changed, 104 insertions(+), 28 deletions(-) diff --git a/Utils/MapEdit/Core.cpp b/Utils/MapEdit/Core.cpp index d234730b3..e4bca2f48 100644 --- a/Utils/MapEdit/Core.cpp +++ b/Utils/MapEdit/Core.cpp @@ -21,6 +21,7 @@ #include "LayerAction.h" #include "LayerFore.h" +BOOL Test3dFlag=TRUE; /*****************************************************************************/ /*****************************************************************************/ @@ -44,11 +45,10 @@ CCore::~CCore() void CCore::Init(CMapEditView *Wnd) { ParentWindow=Wnd; - +// glDisable(GL_DEPTH_TEST); ActiveLayer=0; MapPos.x=MapPos.y=MapPos.z=0; - - + UpdateView(0,0,0); } /*****************************************************************************/ @@ -59,7 +59,11 @@ void CCore::Render() for (int i=0;iRender(MapPos); + if (i==LAYER_TYPE_ACTION) + glEnable(GL_DEPTH_TEST); + + Layers[i]->Render(MapPos,Test3dFlag); + glDisable(GL_DEPTH_TEST); } } @@ -78,19 +82,19 @@ void CCore::UpdateView(float XOfs,float YOfs,float ZOfs) /*****************************************************************************/ void CCore::LButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag) { -// if (!(nFlags & (MK_MBUTTON | MK_RBUTTON))) Layers[ActiveLayer].MouseMsg(nFlags,point); } /*****************************************************************************/ void CCore::MButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag) { -// if (!(nFlags & (MK_LBUTTON | MK_RBUTTON))) Layers[ActiveLayer].MouseMsg(nFlags,point); + LastMousePos=point; } /*****************************************************************************/ void CCore::RButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag) { -// if (!(nFlags & (MK_LBUTTON | MK_MBUTTON))) Layers[ActiveLayer].MouseMsg(nFlags,point); +// Test3dFlag=!Test3dFlag; + UpdateView(0,0,0); } /*****************************************************************************/ @@ -111,18 +115,19 @@ float YOfs=0; // check if active doc if (theApp.GetCurrent()!=ParentWindow->GetDocument()) return; -// Layers[ActiveLayer].MouseMsg(nFlags,point); -/* -// Handle Movement CurrentMousePos=point; + +// Handle Drag Movement + if (nFlags & MK_MBUTTON) { float XS,YS; RECT ThisRect; ParentWindow->GetWindowRect(&ThisRect); - - XS=MapPos.z/((ThisRect.right-ThisRect.left)); - YS=MapPos.z/((ThisRect.bottom-ThisRect.top)); + XS=MapPos.z*Layers[ActiveLayer]->GetLayerZPos(); + YS=MapPos.z*Layers[ActiveLayer]->GetLayerZPos(); + XS/=((ThisRect.right-ThisRect.left)); + YS/=((ThisRect.bottom-ThisRect.top)); XOfs=LastMousePos.x-CurrentMousePos.x; YOfs=LastMousePos.y-CurrentMousePos.y; @@ -131,19 +136,11 @@ float YOfs=0; XOfs*=XS; YOfs*=YS; -// TRACE2("Move %i %i,",ThisRect.left,ThisRect.top); -// TRACE2("Move %i %i \n",ThisRect.right,ThisRect.bottom); + TRACE2("Move %i %i \n",point.x,point.y); + UpdateView(+XOfs,-YOfs,0); } - UpdateView(-XOfs,-YOfs,0); -// if (nFlags & MK_LBUTTON) LButtonControl(nFlags,point,TRUE); -// if (nFlags & MK_RBUTTON) RButtonControl(nFlags,point,TRUE); - TRACE2("Move %i %i \n",point.x,point.y); -*/ - MapPos.x+=0.01f; - UpdateView(0.01f,0,0); -//Render(); } /*****************************************************************************/ diff --git a/Utils/MapEdit/Layer.cpp b/Utils/MapEdit/Layer.cpp index 644bd6e78..3fcf2808c 100644 --- a/Utils/MapEdit/Layer.cpp +++ b/Utils/MapEdit/Layer.cpp @@ -16,6 +16,44 @@ #include "Layer.h" #include "Utils.h" +/* +Core Functionality + +Layers + Gfx Layers + Background Layer + Mid Layer + Action Layer + Fore Layer +Tile Bank + Tile Set + Core + GUI + +Map Data + Core + +Project + Load Project + Save Project + +Output + PSX Data + Map Data + Level Data + Tile Data + Tile Blocks + Textures + AGB Data + Map Data + Level Data + Tile Data + Textures + +Edit Functions + Paint + Tile Mirror +*/ /*****************************************************************************/ /*****************************************************************************/ @@ -30,10 +68,35 @@ CLayer::~CLayer() } /*****************************************************************************/ -void CLayer::Render(Vec &MapPos) +void CLayer::Render(Vec &MapPos,BOOL Is3d) { - TRACE1("%s\n",GetName()); + if (Is3d && CanRender3d()) + Render3d(MapPos); + else + Render2d(MapPos); +} +/*****************************************************************************/ +void CLayer::Render2d(Vec &MapPos) +{ +float XYDiv=GetLayerZPosDiv(); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(MapPos.x/XYDiv,MapPos.y/XYDiv,MapPos.z); + + glBegin(GL_QUADS); + SetTestColor(); + BuildGLQuad(-1,LayerWidth+1,-1,0,0); // Bottom + BuildGLQuad(-1,LayerWidth+1,LayerHeight+1,LayerHeight,0); // Top + BuildGLQuad(-1,0,LayerHeight,0,0); // Left + BuildGLQuad(LayerWidth,LayerWidth+1,LayerHeight,0,0); // Right + glEnd(); +} + +/*****************************************************************************/ +void CLayer::Render3d(Vec &MapPos) +{ float ZOfs=GetLayerZPos(); float XYDiv=GetLayerZPosDiv(); @@ -50,5 +113,6 @@ float XYDiv=GetLayerZPosDiv(); glEnd(); } + /*****************************************************************************/ /*****************************************************************************/ diff --git a/Utils/MapEdit/Layer.h b/Utils/MapEdit/Layer.h index b32834cdb..247671534 100644 --- a/Utils/MapEdit/Layer.h +++ b/Utils/MapEdit/Layer.h @@ -31,10 +31,13 @@ public: // Virtual virtual void Init()=0; virtual char *GetName()=0; -virtual void Render(Vec &MapPos); +virtual void Render(Vec &MapPos,BOOL Is3d); +virtual void Render2d(Vec &MapPos); +virtual void Render3d(Vec &MapPos); virtual float GetLayerZPosDiv()=0; virtual float GetLayerZPos()=0; +virtual BOOL CanRender3d()=0; virtual void SetTestColor()=0; // Control diff --git a/Utils/MapEdit/MapEdit.dsp b/Utils/MapEdit/MapEdit.dsp index c1de3f5bb..41ebca837 100644 --- a/Utils/MapEdit/MapEdit.dsp +++ b/Utils/MapEdit/MapEdit.dsp @@ -68,7 +68,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR /Yu"stdafx.h" /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" /d "_AFXDLL" diff --git a/Utils/MapEdit/utils.cpp b/Utils/MapEdit/utils.cpp index a007304a6..b166a968e 100644 --- a/Utils/MapEdit/utils.cpp +++ b/Utils/MapEdit/utils.cpp @@ -101,6 +101,17 @@ void BuildGLBoxNoNormals(float XMin,float XMax,float YMin,float YMax,float ZMin, glVertex3f( XMax, YMax, ZMax); glVertex3f( XMax, YMax, ZMin); } -/**************************************************************************************/ + +/**************************************************************************************/ +void BuildGLQuad(float XMin,float XMax,float YMin,float YMax,float Z) +{ + // Front Face + glNormal3f( 0.0f, 0.0f, 1.0f); + glVertex3f( XMin, YMin, Z); + glVertex3f( XMax, YMin, Z); + glVertex3f( XMax, YMax, Z); + glVertex3f( XMin, YMax, Z); +} + /**************************************************************************************/ /**************************************************************************************/ diff --git a/Utils/MapEdit/utils.h b/Utils/MapEdit/utils.h index a05c8f6ed..be8fbd715 100644 --- a/Utils/MapEdit/utils.h +++ b/Utils/MapEdit/utils.h @@ -10,6 +10,7 @@ void DbgMsg(const char * pszFmt,...); void BuildGLBox(float XMin,float XMax,float YMin,float YMax,float ZMin,float ZMax); void BuildGLBoxNoNormals(float XMin,float XMax,float YMin,float YMax,float ZMin,float ZMax); +void BuildGLQuad(float XMin,float XMax,float YMin,float YMax,float Z); /**************************************************************************************/