diff --git a/Utils/MapEdit/LayerTile.cpp b/Utils/MapEdit/LayerTile.cpp new file mode 100644 index 000000000..c48011417 --- /dev/null +++ b/Utils/MapEdit/LayerTile.cpp @@ -0,0 +1,221 @@ +/******************/ +/*** Layer Tile ***/ +/******************/ + + +#include "stdafx.h" +#include "gl3d.h" +#include +#include +#include +#include "GLEnabledView.h" + +#include "MapEditDoc.h" +#include "MapEditView.h" + +#include "Core.h" +#include "Layer.h" +#include "LayerTile.h" +#include "Utils.h" + + +/*****************************************************************************/ +/*****************************************************************************/ +/*****************************************************************************/ +// New Layer +CLayerTile::CLayerTile(char *_Name,int Width,int Height,float ZDiv,BOOL Is3d) +{ + SetName(_Name); + Map.SetSize(Width,Height); + ZPosDiv=ZDiv; + Render3dFlag=Is3d; +} + +/*****************************************************************************/ +// Load Layer +CLayerTile::CLayerTile(char *_Name) +{ + ASSERT(1); +} + +/*****************************************************************************/ +CLayerTile::~CLayerTile() +{ +} + +/*****************************************************************************/ +/*****************************************************************************/ +/*****************************************************************************/ +void CLayerTile::Render(CCore *Core,Vec &MapPos,BOOL Is3d) +{ + if (Is3d && Render3dFlag) + { + glEnable(GL_DEPTH_TEST); + Render3d(Core,MapPos); + glDisable(GL_DEPTH_TEST); + } + else + { + Render2d(Core,MapPos); + } +} + +/*****************************************************************************/ +void CLayerTile::Render2d(CCore *Core,Vec &MapPos) +{ +float XYDiv=GetLayerZPosDiv(); +int MapW=Map.GetWidth(); +int MapH=Map.GetHeight(); +float StartX=MapPos.x/XYDiv; +float StartY=MapPos.y/XYDiv; +CTexCache &TexCache=Core->GetTexCache(); + + glColor3f(0.5,0.5,0.5); + glMatrixMode(GL_MODELVIEW); + + for (int YLoop=0; YLoopGetTile(ThisElem.Bank,ThisElem.Tile); + + glLoadIdentity(); // Slow way, but good to go for the mo + glTranslatef(StartX+XLoop,StartY-YLoop,MapPos.z); +// ThisTile.Render(); +int c=(XLoop+YLoop)&1; + glColor3f(c,1,1); + glBegin(GL_QUADS); + BuildGLQuad(0,1,0,1,0); + glEnd(); + + } + } +} + +/*****************************************************************************/ +void CLayerTile::Render3d(CCore *Core,Vec &MapPos) +{ +float XYDiv=GetLayerZPosDiv(); +int MapW=Map.GetWidth(); +int MapH=Map.GetHeight(); +float StartX=MapPos.x/XYDiv; +float StartY=MapPos.y/XYDiv; +CTexCache &TexCache=Core->GetTexCache(); + + glColor3f(0.5,0.5,0.5); + glMatrixMode(GL_MODELVIEW); + + for (int YLoop=0; YLoopGetTile(ThisElem.Bank,ThisElem.Tile); + + glLoadIdentity(); // Slow way, but good to go for the mo + glTranslatef(StartX+XLoop,StartY-YLoop,MapPos.z); + ThisTile.Render(); + } + } + +} + +/*****************************************************************************/ +void CLayerTile::RenderGrid(CCore *Core,Vec &MapPos) +{ +float XYDiv=GetLayerZPosDiv(); +int MapW=Map.GetWidth(); +int MapH=Map.GetHeight(); +float StartX=MapPos.x/XYDiv; +float StartY=MapPos.y/XYDiv; +float OverVal=0.5; + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(StartX,StartY,MapPos.z); + glDisable(GL_TEXTURE_2D); + + glBegin(GL_LINES); + glNormal3f( 1,1,1); + glColor3ub(255,255,255); + + for (int YLoop=0; YLoopGetCursorPos(); + +float XYDiv=GetLayerZPosDiv(); +int MapW=Map.GetWidth(); +int MapH=Map.GetHeight(); +float StartX=MapPos.x/XYDiv; +float StartY=MapPos.y/XYDiv; + + glGetIntegerv(GL_VIEWPORT, Viewport); + glSelectBuffer (SELECT_BUFFER_SIZE, SelectBuffer ); + glRenderMode (GL_SELECT); + + glInitNames(); + glPushName(-1); + + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + gluPickMatrix( MousePos.x ,(Viewport[3]-MousePos.y),5.0,5.0,Viewport); + View->SetupPersMatrix(); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(StartX,StartY,MapPos.z); + + for (int YLoop=0; YLoop