SBSPSS/Utils/MapEdit/Layer.cpp

110 lines
2.4 KiB
C++
Raw Normal View History

2000-09-25 17:43:52 +02:00
/******************/
/*** Layer Core ***/
/******************/
#include "stdafx.h"
#include "gl3d.h"
#include <gl\gl.h>
#include <gl\glu.h>
#include <gl\glut.h>
//#include "GLEnabledView.h"
//#include "MapEditDoc.h"
//#include "MapEditView.h"
2000-11-02 16:46:17 +01:00
#include "Core.h"
2000-09-25 17:43:52 +02:00
#include "Layer.h"
#include "Utils.h"
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
2000-11-02 16:46:17 +01:00
CLayer::CLayer(CCore *_Core)
2000-09-25 17:43:52 +02:00
{
}
2000-10-25 20:28:44 +02:00
2000-09-25 17:43:52 +02:00
/*****************************************************************************/
CLayer::~CLayer()
{
}
2000-11-02 16:46:17 +01:00
/*****************************************************************************/
void CLayer::InitLayer(CCore *_Core)
{
int Width=Map.GetWidth();
int Height=Map.GetHeight();
Core=_Core;
TRACE3("%i x %i = %i\t",Width,Height,Width*Height);
}
2000-09-25 17:43:52 +02:00
/*****************************************************************************/
2000-10-25 23:00:54 +02:00
void CLayer::Render(Vec &MapPos,BOOL Is3d)
2000-09-25 17:43:52 +02:00
{
2000-10-25 23:00:54 +02:00
if (Is3d && CanRender3d())
Render3d(MapPos);
else
Render2d(MapPos);
}
2000-09-25 17:43:52 +02:00
2000-10-25 23:00:54 +02:00
/*****************************************************************************/
void CLayer::Render2d(Vec &MapPos)
{
float XYDiv=GetLayerZPosDiv();
2000-10-27 20:18:30 +02:00
return;
2000-11-02 16:46:17 +01:00
int Width=Map.GetWidth();
int Height=Map.GetHeight();
2000-10-25 23:00:54 +02:00
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(MapPos.x/XYDiv,MapPos.y/XYDiv,MapPos.z);
2000-10-27 20:18:30 +02:00
2000-10-25 23:00:54 +02:00
glBegin(GL_QUADS);
SetTestColor();
2000-11-02 16:46:17 +01:00
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
2000-10-25 23:00:54 +02:00
glEnd();
2000-10-27 20:18:30 +02:00
2000-10-25 23:00:54 +02:00
}
/*****************************************************************************/
2000-10-27 20:18:30 +02:00
float asd=0;
2000-10-25 23:00:54 +02:00
void CLayer::Render3d(Vec &MapPos)
{
2000-10-25 20:28:44 +02:00
float XYDiv=GetLayerZPosDiv();
2000-11-02 16:46:17 +01:00
float X,Y;
int XX=0;
int YY=0;
2000-09-25 17:43:52 +02:00
glMatrixMode(GL_MODELVIEW);
2000-10-30 22:16:48 +01:00
2000-11-02 16:46:17 +01:00
Y=MapPos.y;
for (YY=0; YY<3; YY++)
{
X=MapPos.x;
for (XX=0; XX<3; XX++)
{
glLoadIdentity();
glTranslatef(X/XYDiv,Y/XYDiv,MapPos.z);
// glRotatef(asd,0,1,0);
// asd+=0.5;
// glCallList(Core->GetTile(0,2));
glCallList(Core->GetTile(0,XX+(YY*3)));
X+=1.0f;
}
Y+=1.0f;
}
2000-09-25 17:43:52 +02:00
}
2000-10-25 23:00:54 +02:00
2000-09-25 17:43:52 +02:00
/*****************************************************************************/
/*****************************************************************************/