2000-09-22 17:11:29 +02:00
|
|
|
/***********************/
|
|
|
|
/*** Map Editor Core ***/
|
|
|
|
/***********************/
|
|
|
|
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
2000-09-22 23:19:46 +02:00
|
|
|
#include "gl3d.h"
|
|
|
|
#include <gl\gl.h>
|
|
|
|
#include <gl\glu.h>
|
|
|
|
#include <gl\glut.h>
|
|
|
|
#include "GLEnabledView.h"
|
|
|
|
|
2000-10-25 20:28:44 +02:00
|
|
|
#include "MapEdit.h"
|
2000-09-22 23:19:46 +02:00
|
|
|
#include "MapEditDoc.h"
|
|
|
|
#include "MapEditView.h"
|
|
|
|
|
2000-09-22 17:11:29 +02:00
|
|
|
#include "Core.h"
|
2000-09-25 17:43:52 +02:00
|
|
|
#include "Layer.h"
|
2000-10-25 20:28:44 +02:00
|
|
|
#include "LayerBack.h"
|
|
|
|
#include "LayerMid.h"
|
|
|
|
#include "LayerAction.h"
|
|
|
|
#include "LayerFore.h"
|
2000-09-22 17:11:29 +02:00
|
|
|
|
2000-10-25 23:00:54 +02:00
|
|
|
BOOL Test3dFlag=TRUE;
|
2000-09-22 23:19:46 +02:00
|
|
|
|
2000-09-22 17:11:29 +02:00
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
CCore::CCore()
|
|
|
|
{
|
2000-09-25 17:43:52 +02:00
|
|
|
MouseMode=MOUSE_MODE_NONE;
|
2000-10-25 20:28:44 +02:00
|
|
|
Layers[LAYER_TYPE_BACK]= new CLayerBack;
|
|
|
|
Layers[LAYER_TYPE_MID]= new CLayerMid;
|
|
|
|
Layers[LAYER_TYPE_ACTION]= new CLayerAction;
|
|
|
|
Layers[LAYER_TYPE_FORE]= new CLayerFore;
|
2000-09-22 17:11:29 +02:00
|
|
|
}
|
2000-09-25 17:43:52 +02:00
|
|
|
|
2000-09-22 17:11:29 +02:00
|
|
|
/*****************************************************************************/
|
|
|
|
CCore::~CCore()
|
|
|
|
{
|
2000-10-25 20:28:44 +02:00
|
|
|
for (int i=0; i<LAYER_TYPE_MAX; i++) delete Layers[i];
|
2000-09-22 17:11:29 +02:00
|
|
|
}
|
|
|
|
|
2000-09-22 23:19:46 +02:00
|
|
|
/*****************************************************************************/
|
|
|
|
void CCore::Init(CMapEditView *Wnd)
|
|
|
|
{
|
|
|
|
ParentWindow=Wnd;
|
2000-10-25 23:00:54 +02:00
|
|
|
// glDisable(GL_DEPTH_TEST);
|
2000-10-25 20:28:44 +02:00
|
|
|
ActiveLayer=0;
|
|
|
|
MapPos.x=MapPos.y=MapPos.z=0;
|
2000-10-25 23:00:54 +02:00
|
|
|
UpdateView(0,0,0);
|
2000-09-22 23:19:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
void CCore::Render()
|
|
|
|
{
|
2000-10-25 20:28:44 +02:00
|
|
|
|
|
|
|
for (int i=0;i<LAYER_TYPE_MAX;i++)
|
|
|
|
{
|
2000-10-25 23:00:54 +02:00
|
|
|
if (i==LAYER_TYPE_ACTION)
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
|
|
|
|
Layers[i]->Render(MapPos,Test3dFlag);
|
|
|
|
glDisable(GL_DEPTH_TEST);
|
2000-10-25 20:28:44 +02:00
|
|
|
}
|
2000-09-22 23:19:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
void CCore::UpdateView(float XOfs,float YOfs,float ZOfs)
|
|
|
|
{
|
2000-10-25 20:28:44 +02:00
|
|
|
MapPos=MapPos+Vec(XOfs,YOfs,ZOfs);
|
|
|
|
if (MapPos.z>-1) MapPos.z=-1;
|
2000-09-22 23:19:46 +02:00
|
|
|
|
2000-10-25 20:28:44 +02:00
|
|
|
ParentWindow->Invalidate();
|
2000-09-22 23:19:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*** Control *****************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
void CCore::LButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
void CCore::MButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag)
|
|
|
|
{
|
2000-10-25 23:00:54 +02:00
|
|
|
LastMousePos=point;
|
2000-09-22 23:19:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
void CCore::RButtonControl(UINT nFlags, CPoint &point,BOOL DownFlag)
|
|
|
|
{
|
2000-10-25 23:00:54 +02:00
|
|
|
// Test3dFlag=!Test3dFlag;
|
|
|
|
UpdateView(0,0,0);
|
2000-09-22 23:19:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
void CCore::MouseWheel(UINT nFlags, short zDelta, CPoint &pt)
|
|
|
|
{
|
2000-10-25 20:28:44 +02:00
|
|
|
if (zDelta>0)
|
|
|
|
UpdateView(0,0,1.0f);
|
|
|
|
else
|
|
|
|
UpdateView(0,0,-1.0f);
|
2000-09-22 23:19:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2000-10-25 20:28:44 +02:00
|
|
|
void CCore::MouseMove(UINT nFlags, CPoint &point)
|
2000-09-22 23:19:46 +02:00
|
|
|
{
|
|
|
|
float XOfs=0;
|
|
|
|
float YOfs=0;
|
|
|
|
|
2000-10-25 20:28:44 +02:00
|
|
|
// check if active doc
|
|
|
|
if (theApp.GetCurrent()!=ParentWindow->GetDocument()) return;
|
2000-09-22 23:19:46 +02:00
|
|
|
|
2000-10-25 20:28:44 +02:00
|
|
|
CurrentMousePos=point;
|
2000-10-25 23:00:54 +02:00
|
|
|
|
|
|
|
// Handle Drag Movement
|
|
|
|
if (nFlags & MK_MBUTTON)
|
2000-09-22 23:19:46 +02:00
|
|
|
{
|
|
|
|
float XS,YS;
|
|
|
|
RECT ThisRect;
|
|
|
|
|
|
|
|
ParentWindow->GetWindowRect(&ThisRect);
|
2000-10-25 23:00:54 +02:00
|
|
|
XS=MapPos.z*Layers[ActiveLayer]->GetLayerZPos();
|
|
|
|
YS=MapPos.z*Layers[ActiveLayer]->GetLayerZPos();
|
|
|
|
XS/=((ThisRect.right-ThisRect.left));
|
|
|
|
YS/=((ThisRect.bottom-ThisRect.top));
|
2000-09-22 23:19:46 +02:00
|
|
|
|
|
|
|
XOfs=LastMousePos.x-CurrentMousePos.x;
|
|
|
|
YOfs=LastMousePos.y-CurrentMousePos.y;
|
2000-09-25 17:43:52 +02:00
|
|
|
LastMousePos=CurrentMousePos;
|
2000-09-22 23:19:46 +02:00
|
|
|
|
|
|
|
XOfs*=XS;
|
|
|
|
YOfs*=YS;
|
2000-10-25 20:28:44 +02:00
|
|
|
|
2000-10-25 23:00:54 +02:00
|
|
|
TRACE2("Move %i %i \n",point.x,point.y);
|
|
|
|
UpdateView(+XOfs,-YOfs,0);
|
2000-09-22 23:19:46 +02:00
|
|
|
}
|
|
|
|
|
2000-10-25 20:28:44 +02:00
|
|
|
|
2000-09-22 23:19:46 +02:00
|
|
|
}
|
|
|
|
|
2000-09-22 17:11:29 +02:00
|
|
|
/*****************************************************************************/
|
|
|
|
/*** Layer Code **************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
void CCore::LayerSetActive(int i)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
int CCore::LayerGetActive()
|
|
|
|
{
|
|
|
|
return(ActiveLayer);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2000-10-25 20:28:44 +02:00
|
|
|
CLayer *CCore::LayerGet(int i)
|
2000-09-22 17:11:29 +02:00
|
|
|
{
|
|
|
|
return(Layers[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|