diff --git a/Utils/MapEdit/Core.cpp b/Utils/MapEdit/Core.cpp index e4bca2f48..19be44d46 100644 --- a/Utils/MapEdit/Core.cpp +++ b/Utils/MapEdit/Core.cpp @@ -21,7 +21,9 @@ #include "LayerAction.h" #include "LayerFore.h" + BOOL Test3dFlag=TRUE; +GLint TestTile; /*****************************************************************************/ /*****************************************************************************/ @@ -45,12 +47,15 @@ CCore::~CCore() void CCore::Init(CMapEditView *Wnd) { ParentWindow=Wnd; -// glDisable(GL_DEPTH_TEST); ActiveLayer=0; MapPos.x=MapPos.y=MapPos.z=0; UpdateView(0,0,0); + CTileSet NewSet("c:/SpongeBob/graphics/test.gin"); + TileSet.push_back(NewSet); } + + /*****************************************************************************/ /*****************************************************************************/ /*****************************************************************************/ diff --git a/Utils/MapEdit/Core.h b/Utils/MapEdit/Core.h index a46e6c7c2..b7caed5ce 100644 --- a/Utils/MapEdit/Core.h +++ b/Utils/MapEdit/Core.h @@ -10,6 +10,8 @@ #include "Layer.h" #include "LayerBack.h" +#include "TileSet.h" + /*****************************************************************************/ enum MOUSE_MODE @@ -49,13 +51,15 @@ public: private: - CMapEditView *ParentWindow; - MOUSE_MODE MouseMode; - CPoint CurrentMousePos,LastMousePos; - Vec MapPos; + CMapEditView *ParentWindow; + MOUSE_MODE MouseMode; + CPoint CurrentMousePos,LastMousePos; + Vec MapPos; - CLayer *Layers[LAYER_TYPE_MAX]; - int ActiveLayer; + CLayer *Layers[LAYER_TYPE_MAX]; + int ActiveLayer; + + std::vector TileSet; }; diff --git a/Utils/MapEdit/Layer.cpp b/Utils/MapEdit/Layer.cpp index 3fcf2808c..18266c62d 100644 --- a/Utils/MapEdit/Layer.cpp +++ b/Utils/MapEdit/Layer.cpp @@ -77,6 +77,8 @@ void CLayer::Render(Vec &MapPos,BOOL Is3d) } /*****************************************************************************/ +extern GLint TestTile; + void CLayer::Render2d(Vec &MapPos) { float XYDiv=GetLayerZPosDiv(); @@ -84,7 +86,7 @@ float XYDiv=GetLayerZPosDiv(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(MapPos.x/XYDiv,MapPos.y/XYDiv,MapPos.z); - +/* glBegin(GL_QUADS); SetTestColor(); BuildGLQuad(-1,LayerWidth+1,-1,0,0); // Bottom @@ -92,6 +94,8 @@ float XYDiv=GetLayerZPosDiv(); BuildGLQuad(-1,0,LayerHeight,0,0); // Left BuildGLQuad(LayerWidth,LayerWidth+1,LayerHeight,0,0); // Right glEnd(); +*/ + glCallList(TestTile); } /*****************************************************************************/ diff --git a/Utils/MapEdit/MapEdit.clw b/Utils/MapEdit/MapEdit.clw index a19e20190..d9f54837a 100644 --- a/Utils/MapEdit/MapEdit.clw +++ b/Utils/MapEdit/MapEdit.clw @@ -21,8 +21,8 @@ Class8=CMapEditView ResourceCount=4 Resource1=IDR_MAPEDITYPE (English (U.S.)) Resource2=IDD_ABOUTBOX (English (U.S.)) -Resource3=IDR_MAINFRAME (English (U.S.)) -Resource4=IDD_LAYERBAR (English (U.S.)) +Resource3=IDD_LAYERBAR (English (U.S.)) +Resource4=IDR_MAINFRAME (English (U.S.)) [CLS:CChildFrame] Type=0 diff --git a/Utils/MapEdit/MapEdit.dsp b/Utils/MapEdit/MapEdit.dsp index 41ebca837..9c20dfefd 100644 --- a/Utils/MapEdit/MapEdit.dsp +++ b/Utils/MapEdit/MapEdit.dsp @@ -68,7 +68,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # 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 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 MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" /d "_AFXDLL" @@ -78,7 +78,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # 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 @@ -143,6 +143,14 @@ SOURCE=.\Core.h # End 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 # End Source File # Begin Source File @@ -192,7 +200,7 @@ SOURCE=.\StdAfx.cpp # End Group # Begin Group "Header Files" -# PROP Default_Filter "h;hpp;hxx;hm;inl" +# PROP Default_Filter "" # Begin Source File SOURCE=.\ChildFrm.h diff --git a/Utils/MapEdit/MapEdit.dsw b/Utils/MapEdit/MapEdit.dsw index 8115d5e1f..3a30889af 100644 --- a/Utils/MapEdit/MapEdit.dsw +++ b/Utils/MapEdit/MapEdit.dsw @@ -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> Package=<5> @@ -11,6 +27,9 @@ Package=<5> Package=<4> {{{ + Begin Project Dependency + Project_Dep_Name GinLib + End Project Dependency }}} ############################################################################### diff --git a/Utils/MapEdit/TileSet.cpp b/Utils/MapEdit/TileSet.cpp new file mode 100644 index 000000000..d5650c25f --- /dev/null +++ b/Utils/MapEdit/TileSet.cpp @@ -0,0 +1,98 @@ +/*********************/ +/*** TileSet Stuph ***/ +/*********************/ + +#include "stdafx.h" +#include "gl3d.h" +#include +#include +#include +#include + +#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 const &Tex=Scene.GetTexNames(); + + for (i=0;i const &TriList=ThisNode.GetTris(); +std::vectorconst &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 +#include +#include +#include + + +/*****************************************************************************/ +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 Tile; + +}; + +/*****************************************************************************/ +#endif \ No newline at end of file diff --git a/Utils/MapEdit/utils.cpp b/Utils/MapEdit/utils.cpp index b166a968e..1f3a302c3 100644 --- a/Utils/MapEdit/utils.cpp +++ b/Utils/MapEdit/utils.cpp @@ -8,6 +8,7 @@ #include #include #include "GLEnabledView.h" +#include "maths.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; +} + +/**************************************************************************************/ +/**************************************************************************************/ +/**************************************************************************************/ diff --git a/Utils/MapEdit/utils.h b/Utils/MapEdit/utils.h index be8fbd715..30ce39306 100644 --- a/Utils/MapEdit/utils.h +++ b/Utils/MapEdit/utils.h @@ -5,6 +5,8 @@ #ifndef __UTILS_HEADER__ #define __UTILS_HEADER__ +#include "maths.h" + /**************************************************************************************/ 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 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 \ No newline at end of file