/******************/ /*** Layer Core ***/ /******************/ #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 "Utils.h" /*****************************************************************************/ /*****************************************************************************/ /*****************************************************************************/ CLayer::CLayer() { } /*****************************************************************************/ CLayer::~CLayer() { } /*****************************************************************************/ void CLayer::Render(CCore *Core,Vec &MapPos,BOOL Is3d) { Render2d(Core,MapPos); } /*****************************************************************************/ void CLayer::Render2d(CCore *Core,Vec &MapPos) { float XYDiv=GetLayerZPosDiv(); return; int Width=Map.GetWidth(); int Height=Map.GetHeight(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(MapPos.x/XYDiv,MapPos.y/XYDiv,MapPos.z); glBegin(GL_QUADS); BuildGLQuad(-1,Width+1,-1,0,0); // Bottom BuildGLQuad(-1,Width+1,Height+1,Height,0); // Top BuildGLQuad(-1,0,Height,0,0); // Left BuildGLQuad(Width,Width+1,Height,0,0); // Right glEnd(); } /*****************************************************************************/ void CLayer::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(); 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 CLayer::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