This commit is contained in:
parent
ee30817b75
commit
3d8fc3912c
10 changed files with 231 additions and 13 deletions
|
@ -21,7 +21,9 @@
|
||||||
#include "LayerAction.h"
|
#include "LayerAction.h"
|
||||||
#include "LayerFore.h"
|
#include "LayerFore.h"
|
||||||
|
|
||||||
|
|
||||||
BOOL Test3dFlag=TRUE;
|
BOOL Test3dFlag=TRUE;
|
||||||
|
GLint TestTile;
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -45,12 +47,15 @@ CCore::~CCore()
|
||||||
void CCore::Init(CMapEditView *Wnd)
|
void CCore::Init(CMapEditView *Wnd)
|
||||||
{
|
{
|
||||||
ParentWindow=Wnd;
|
ParentWindow=Wnd;
|
||||||
// glDisable(GL_DEPTH_TEST);
|
|
||||||
ActiveLayer=0;
|
ActiveLayer=0;
|
||||||
MapPos.x=MapPos.y=MapPos.z=0;
|
MapPos.x=MapPos.y=MapPos.z=0;
|
||||||
UpdateView(0,0,0);
|
UpdateView(0,0,0);
|
||||||
|
CTileSet NewSet("c:/SpongeBob/graphics/test.gin");
|
||||||
|
TileSet.push_back(NewSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
#include "Layer.h"
|
#include "Layer.h"
|
||||||
#include "LayerBack.h"
|
#include "LayerBack.h"
|
||||||
|
|
||||||
|
#include "TileSet.h"
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
enum MOUSE_MODE
|
enum MOUSE_MODE
|
||||||
|
@ -57,6 +59,8 @@ private:
|
||||||
CLayer *Layers[LAYER_TYPE_MAX];
|
CLayer *Layers[LAYER_TYPE_MAX];
|
||||||
int ActiveLayer;
|
int ActiveLayer;
|
||||||
|
|
||||||
|
std::vector<CTileSet> TileSet;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,8 @@ void CLayer::Render(Vec &MapPos,BOOL Is3d)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
extern GLint TestTile;
|
||||||
|
|
||||||
void CLayer::Render2d(Vec &MapPos)
|
void CLayer::Render2d(Vec &MapPos)
|
||||||
{
|
{
|
||||||
float XYDiv=GetLayerZPosDiv();
|
float XYDiv=GetLayerZPosDiv();
|
||||||
|
@ -84,7 +86,7 @@ float XYDiv=GetLayerZPosDiv();
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glTranslatef(MapPos.x/XYDiv,MapPos.y/XYDiv,MapPos.z);
|
glTranslatef(MapPos.x/XYDiv,MapPos.y/XYDiv,MapPos.z);
|
||||||
|
/*
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
SetTestColor();
|
SetTestColor();
|
||||||
BuildGLQuad(-1,LayerWidth+1,-1,0,0); // Bottom
|
BuildGLQuad(-1,LayerWidth+1,-1,0,0); // Bottom
|
||||||
|
@ -92,6 +94,8 @@ float XYDiv=GetLayerZPosDiv();
|
||||||
BuildGLQuad(-1,0,LayerHeight,0,0); // Left
|
BuildGLQuad(-1,0,LayerHeight,0,0); // Left
|
||||||
BuildGLQuad(LayerWidth,LayerWidth+1,LayerHeight,0,0); // Right
|
BuildGLQuad(LayerWidth,LayerWidth+1,LayerHeight,0,0); // Right
|
||||||
glEnd();
|
glEnd();
|
||||||
|
*/
|
||||||
|
glCallList(TestTile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -21,8 +21,8 @@ Class8=CMapEditView
|
||||||
ResourceCount=4
|
ResourceCount=4
|
||||||
Resource1=IDR_MAPEDITYPE (English (U.S.))
|
Resource1=IDR_MAPEDITYPE (English (U.S.))
|
||||||
Resource2=IDD_ABOUTBOX (English (U.S.))
|
Resource2=IDD_ABOUTBOX (English (U.S.))
|
||||||
Resource3=IDR_MAINFRAME (English (U.S.))
|
Resource3=IDD_LAYERBAR (English (U.S.))
|
||||||
Resource4=IDD_LAYERBAR (English (U.S.))
|
Resource4=IDR_MAINFRAME (English (U.S.))
|
||||||
|
|
||||||
[CLS:CChildFrame]
|
[CLS:CChildFrame]
|
||||||
Type=0
|
Type=0
|
||||||
|
|
|
@ -68,7 +68,7 @@ LINK32=link.exe
|
||||||
# PROP Ignore_Export_Lib 0
|
# PROP Ignore_Export_Lib 0
|
||||||
# PROP Target_Dir ""
|
# 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 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" /FR /Yu"stdafx.h" /FD /GZ /c
|
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\GinLib" /I "..\glibdev\glib\include" /I "..\glibdev\glib\include\pc" /I "..\ginlib" /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 BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||||
# ADD BASE RSC /l 0x809 /d "_DEBUG" /d "_AFXDLL"
|
# ADD BASE RSC /l 0x809 /d "_DEBUG" /d "_AFXDLL"
|
||||||
|
@ -78,7 +78,7 @@ BSC32=bscmake.exe
|
||||||
# ADD BSC32 /nologo
|
# ADD BSC32 /nologo
|
||||||
LINK32=link.exe
|
LINK32=link.exe
|
||||||
# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
||||||
# ADD LINK32 opengl32.lib glu32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
# ADD LINK32 opengl32.lib glu32.lib win32lib.lib ginlib.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /libpath:"..\ginlib\debug\\" /libpath:"..\GlibDev\glib\LIB\win32lib\debug\\"
|
||||||
|
|
||||||
!ENDIF
|
!ENDIF
|
||||||
|
|
||||||
|
@ -143,6 +143,14 @@ SOURCE=.\Core.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\TileSet.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\TileSet.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\utils.cpp
|
SOURCE=.\utils.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
@ -192,7 +200,7 @@ SOURCE=.\StdAfx.cpp
|
||||||
# End Group
|
# End Group
|
||||||
# Begin Group "Header Files"
|
# Begin Group "Header Files"
|
||||||
|
|
||||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
# PROP Default_Filter ""
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\ChildFrm.h
|
SOURCE=.\ChildFrm.h
|
||||||
|
|
|
@ -3,6 +3,22 @@ Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
Project: "GinLib"=..\GinLib\ginlib.dsp - Package Owner=<4>
|
||||||
|
|
||||||
|
Package=<5>
|
||||||
|
{{{
|
||||||
|
begin source code control
|
||||||
|
"$/Utils/GinLib", RICAAAAA
|
||||||
|
..\ginlib
|
||||||
|
end source code control
|
||||||
|
}}}
|
||||||
|
|
||||||
|
Package=<4>
|
||||||
|
{{{
|
||||||
|
}}}
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
Project: "MapEdit"=.\MapEdit.dsp - Package Owner=<4>
|
Project: "MapEdit"=.\MapEdit.dsp - Package Owner=<4>
|
||||||
|
|
||||||
Package=<5>
|
Package=<5>
|
||||||
|
@ -11,6 +27,9 @@ Package=<5>
|
||||||
|
|
||||||
Package=<4>
|
Package=<4>
|
||||||
{{{
|
{{{
|
||||||
|
Begin Project Dependency
|
||||||
|
Project_Dep_Name GinLib
|
||||||
|
End Project Dependency
|
||||||
}}}
|
}}}
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
98
Utils/MapEdit/TileSet.cpp
Normal file
98
Utils/MapEdit/TileSet.cpp
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
/*********************/
|
||||||
|
/*** TileSet Stuph ***/
|
||||||
|
/*********************/
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "gl3d.h"
|
||||||
|
#include <gl\gl.h>
|
||||||
|
#include <gl\glu.h>
|
||||||
|
#include <gl\glut.h>
|
||||||
|
#include <Vector>
|
||||||
|
|
||||||
|
#include "TileSet.h"
|
||||||
|
#include "GinTex.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
CTileSet::CTileSet(char *_Filename)
|
||||||
|
{
|
||||||
|
strcpy(Filename,_Filename);
|
||||||
|
Load();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
CTileSet::~CTileSet()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
int CTileSet::Load()
|
||||||
|
{
|
||||||
|
CScene Scene;
|
||||||
|
|
||||||
|
Scene.Load(Filename);
|
||||||
|
|
||||||
|
int NodeCount=Scene.GetSceneNodeCount();
|
||||||
|
|
||||||
|
for (int i=1;i<NodeCount;i++)
|
||||||
|
{
|
||||||
|
AddTileToSet(Scene,i);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
std::vector<GString> const &Tex=Scene.GetTexNames();
|
||||||
|
|
||||||
|
for (i=0;i<Tex.size();i++)
|
||||||
|
{
|
||||||
|
TRACE1("%s\n",Tex[i]);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
extern GLint TestTile;
|
||||||
|
void CTileSet::AddTileToSet(CScene &ThisScene,int Id)
|
||||||
|
{
|
||||||
|
CNode &ThisNode=ThisScene.GetNode(Id);
|
||||||
|
std::vector<sTri> const &TriList=ThisNode.GetTris();
|
||||||
|
std::vector<TVECTOR>const &VtxList=ThisNode.GetRelPts();
|
||||||
|
int TriCount=TriList.size();
|
||||||
|
GLint ThisTile;
|
||||||
|
|
||||||
|
ThisTile=glGenLists(1);
|
||||||
|
glNewList(ThisTile,GL_COMPILE);
|
||||||
|
glColor3f(0.5,0.5,0);
|
||||||
|
glBegin (GL_TRIANGLES);
|
||||||
|
|
||||||
|
TRACE3("%i %s\t%i Tris\n",Id,ThisNode.GetName(),TriCount);
|
||||||
|
|
||||||
|
for (int T=0; T<TriCount; T++)
|
||||||
|
{
|
||||||
|
sTri const &ThisTri=TriList[T];
|
||||||
|
TVECTOR Normal=TCrossProduct(VtxList[ThisTri.p[0]],VtxList[ThisTri.p[1]],VtxList[ThisTri.p[2]]);
|
||||||
|
glNormal3f( Normal.GetX(), Normal.GetZ(),Normal.GetY());
|
||||||
|
|
||||||
|
for (int P=0; P<3; P++)
|
||||||
|
{
|
||||||
|
TVECTOR const &ThisVtx=VtxList[ThisTri.p[P]];
|
||||||
|
|
||||||
|
glVertex3f( ThisVtx.GetX(), ThisVtx.GetZ(), ThisVtx.GetY());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
glEnd();
|
||||||
|
glEndList();
|
||||||
|
Tile.push_back(ThisTile);
|
||||||
|
TestTile=ThisTile;
|
||||||
|
}
|
35
Utils/MapEdit/TileSet.h
Normal file
35
Utils/MapEdit/TileSet.h
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*********************/
|
||||||
|
/*** TileSet Stuph ***/
|
||||||
|
/*********************/
|
||||||
|
|
||||||
|
#ifndef __TILESET_HEADER__
|
||||||
|
#define __TILESET_HEADER__
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "gl3d.h"
|
||||||
|
#include <gl\gl.h>
|
||||||
|
#include <gl\glu.h>
|
||||||
|
#include <gl\glut.h>
|
||||||
|
#include <Vector>
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
class CScene;
|
||||||
|
class CNode;
|
||||||
|
class CTileSet
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CTileSet(char *Filename);
|
||||||
|
~CTileSet();
|
||||||
|
|
||||||
|
int Load();
|
||||||
|
void AddTileToSet(CScene &ThisScene,int Id);
|
||||||
|
|
||||||
|
private:
|
||||||
|
char Filename[256];
|
||||||
|
std::vector<GLint> Tile;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
#endif
|
|
@ -8,6 +8,7 @@
|
||||||
#include <gl\glu.h>
|
#include <gl\glu.h>
|
||||||
#include <gl\glut.h>
|
#include <gl\glut.h>
|
||||||
#include "GLEnabledView.h"
|
#include "GLEnabledView.h"
|
||||||
|
#include "maths.h"
|
||||||
|
|
||||||
#include "Utils.H"
|
#include "Utils.H"
|
||||||
|
|
||||||
|
@ -115,3 +116,42 @@ void BuildGLQuad(float XMin,float XMax,float YMin,float YMax,float Z)
|
||||||
|
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
|
/**************************************************************************************/
|
||||||
|
void TNormalise(TVECTOR &V)
|
||||||
|
{
|
||||||
|
float SqMag = V.length2();// v.x * v.x + v.y * v.y + v.z * v.z;
|
||||||
|
|
||||||
|
if (SqMag> 0.001f)
|
||||||
|
{
|
||||||
|
float Mag = (float)sqrt( SqMag);
|
||||||
|
|
||||||
|
V/=Mag;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************************************************************************/
|
||||||
|
TVECTOR TCrossProduct(TVECTOR const &V0,TVECTOR const &V1,const TVECTOR &V2 )
|
||||||
|
{
|
||||||
|
TVECTOR DV1, DV2;
|
||||||
|
TVECTOR Out;
|
||||||
|
|
||||||
|
DV1.X() = V1.X() - V0.X();
|
||||||
|
DV1.Y() = V1.Y() - V0.Y();
|
||||||
|
DV1.Z() = V1.Z() - V0.Z();
|
||||||
|
|
||||||
|
DV2.X() = V2.X() - V0.X();
|
||||||
|
DV2.Y() = V2.Y() - V0.Y();
|
||||||
|
DV2.Z() = V2.Z() - V0.Z();
|
||||||
|
|
||||||
|
Out.SetX( (DV1.Z() * DV2.Y()) - (DV1.Y() * DV2.Z()) );
|
||||||
|
Out.SetY( (DV1.X() * DV2.Z()) - (DV1.Z() * DV2.X()) );
|
||||||
|
Out.SetZ( (DV1.Y() * DV2.X()) - (DV1.X() * DV2.Y()) );
|
||||||
|
|
||||||
|
TNormalise(Out);
|
||||||
|
return Out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************************************************************************/
|
||||||
|
/**************************************************************************************/
|
||||||
|
/**************************************************************************************/
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#ifndef __UTILS_HEADER__
|
#ifndef __UTILS_HEADER__
|
||||||
#define __UTILS_HEADER__
|
#define __UTILS_HEADER__
|
||||||
|
|
||||||
|
#include "maths.h"
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
void DbgMsg(const char * pszFmt,...);
|
void DbgMsg(const char * pszFmt,...);
|
||||||
|
@ -12,6 +14,9 @@ void BuildGLBox(float XMin,float XMax,float YMin,float YMax,float ZMin,float ZMa
|
||||||
void BuildGLBoxNoNormals(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);
|
void BuildGLQuad(float XMin,float XMax,float YMin,float YMax,float Z);
|
||||||
|
|
||||||
|
void TNormalise(TVECTOR &V);
|
||||||
|
TVECTOR TCrossProduct(TVECTOR const &V0,TVECTOR const &V1,const TVECTOR &V2 );
|
||||||
|
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Add table
Add a link
Reference in a new issue