This commit is contained in:
parent
3d8fc3912c
commit
a44030464c
10 changed files with 183 additions and 59 deletions
|
@ -50,7 +50,7 @@ void CCore::Init(CMapEditView *Wnd)
|
|||
ActiveLayer=0;
|
||||
MapPos.x=MapPos.y=MapPos.z=0;
|
||||
UpdateView(0,0,0);
|
||||
CTileSet NewSet("c:/SpongeBob/graphics/test.gin");
|
||||
CTileSet NewSet("c:/temp/test.gin",this);
|
||||
TileSet.push_back(NewSet);
|
||||
}
|
||||
|
||||
|
@ -70,6 +70,7 @@ void CCore::Render()
|
|||
Layers[i]->Render(MapPos,Test3dFlag);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
}
|
||||
ParentWindow->Invalidate();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "Layer.h"
|
||||
#include "LayerBack.h"
|
||||
|
||||
#include "TexCache.h"
|
||||
#include "TileSet.h"
|
||||
|
||||
|
||||
|
@ -60,6 +61,7 @@ private:
|
|||
int ActiveLayer;
|
||||
|
||||
std::vector<CTileSet> TileSet;
|
||||
CTexCache TexCache;
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -82,11 +82,11 @@ extern GLint TestTile;
|
|||
void CLayer::Render2d(Vec &MapPos)
|
||||
{
|
||||
float XYDiv=GetLayerZPosDiv();
|
||||
|
||||
return;
|
||||
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
|
||||
|
@ -94,11 +94,12 @@ float XYDiv=GetLayerZPosDiv();
|
|||
BuildGLQuad(-1,0,LayerHeight,0,0); // Left
|
||||
BuildGLQuad(LayerWidth,LayerWidth+1,LayerHeight,0,0); // Right
|
||||
glEnd();
|
||||
*/
|
||||
glCallList(TestTile);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
float asd=0;
|
||||
void CLayer::Render3d(Vec &MapPos)
|
||||
{
|
||||
float ZOfs=GetLayerZPos();
|
||||
|
@ -107,7 +108,9 @@ float XYDiv=GetLayerZPosDiv();
|
|||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(MapPos.x/XYDiv,MapPos.y/XYDiv,MapPos.z-ZOfs);
|
||||
|
||||
glRotatef(asd,0,1,0);
|
||||
asd+=0.5;
|
||||
/*
|
||||
glBegin(GL_QUADS);
|
||||
SetTestColor();
|
||||
BuildGLBox(-1,LayerWidth+1,-1,0,0,0+1); // Bottom
|
||||
|
@ -115,6 +118,8 @@ float XYDiv=GetLayerZPosDiv();
|
|||
BuildGLBox(-1,0,LayerHeight,0,0,0+1); // Left
|
||||
BuildGLBox(LayerWidth,LayerWidth+1,LayerHeight,0,0,0+1); // Right
|
||||
glEnd();
|
||||
*/
|
||||
glCallList(TestTile);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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 win32lib.lib ginlib.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /libpath:"..\ginlib\debug\\" /libpath:"..\GlibDev\glib\LIB\win32lib\debug\\"
|
||||
# ADD LINK32 opengl32.lib glu32.lib win32lib.lib ginlib.lib glaux.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /libpath:"..\ginlib\debug\\" /libpath:"..\GlibDev\glib\LIB\win32lib\debug\\"
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
@ -143,6 +143,22 @@ SOURCE=.\Core.h
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\TexCache.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\TexCache.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Tile.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Tile.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\TileSet.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
39
Utils/MapEdit/TexCache.cpp
Normal file
39
Utils/MapEdit/TexCache.cpp
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*********************/
|
||||
/*** Texture Cache ***/
|
||||
/*********************/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "gl3d.h"
|
||||
#include <gl\gl.h>
|
||||
#include <gl\glu.h>
|
||||
#include <gl\glut.h>
|
||||
#include <Vector>
|
||||
|
||||
#include "TexCache.h"
|
||||
#include "utils.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
int CTexCache::ProcessTexture(char *TexName)
|
||||
{
|
||||
// TRACE3("%i %s\t%i Tris\n",Id,ThisNode.GetName(),TriCount);
|
||||
int ListSize=TexList.size();
|
||||
|
||||
// Check if Tex exists
|
||||
for (int Count=0;Count<ListSize;Count++)
|
||||
{
|
||||
if (strcmp(TexName,TexList[Count].Name))
|
||||
{
|
||||
return(TexList[Count].TexID);
|
||||
}
|
||||
}
|
||||
sTex NewTex;
|
||||
strcpy(NewTex.Name,TexName);
|
||||
LoadGLTexture(TexName,NewTex.TexID);
|
||||
TexList.push_back(NewTex);
|
||||
|
||||
return(NewTex.TexID);
|
||||
//
|
||||
}
|
||||
|
37
Utils/MapEdit/TexCache.h
Normal file
37
Utils/MapEdit/TexCache.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*********************/
|
||||
/*** Texture Cache ***/
|
||||
/*********************/
|
||||
|
||||
#ifndef __TEXCACHE_HEADER__
|
||||
#define __TEXCACHE_HEADER__
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "gl3d.h"
|
||||
#include <gl\gl.h>
|
||||
#include <gl\glu.h>
|
||||
#include <gl\glut.h>
|
||||
#include <Vector>
|
||||
|
||||
struct sTex
|
||||
{
|
||||
char Name[256];
|
||||
GLuint TexID;
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
class CTexCache
|
||||
{
|
||||
public:
|
||||
|
||||
int ProcessTexture(char *TexName);
|
||||
int AddTexture(char *TexName);
|
||||
|
||||
|
||||
std::vector<sTex> TexList;
|
||||
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
#endif
|
|
@ -17,10 +17,10 @@
|
|||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
CTileSet::CTileSet(char *_Filename)
|
||||
CTileSet::CTileSet(char *_Filename,CCore *Core)
|
||||
{
|
||||
strcpy(Filename,_Filename);
|
||||
Load();
|
||||
Load(Core);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -33,18 +33,23 @@ CTileSet::~CTileSet()
|
|||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
int CTileSet::Load()
|
||||
int CTileSet::Load(CCore *Core)
|
||||
{
|
||||
CScene Scene;
|
||||
|
||||
Scene.Load(Filename);
|
||||
|
||||
int NodeCount=Scene.GetSceneNodeCount();
|
||||
CNode &ThisNode=Scene.GetSceneNode(0);
|
||||
int ChildCount=ThisNode.GetPruneChildCount();
|
||||
|
||||
for (int i=1;i<NodeCount;i++)
|
||||
for (int Child=0; Child<ChildCount; Child++)
|
||||
{
|
||||
AddTileToSet(Scene,i);
|
||||
CTile NewTile;
|
||||
NewTile.Load(Core,Scene,ThisNode.PruneChildList[Child]);
|
||||
Tile.push_back(NewTile);
|
||||
// AddTileToSet(Scene,ThisNode.PruneChildList[Child]);
|
||||
}
|
||||
|
||||
/*
|
||||
std::vector<GString> const &Tex=Scene.GetTexNames();
|
||||
|
||||
|
@ -57,42 +62,3 @@ std::vector<GString> const &Tex=Scene.GetTexNames();
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -12,22 +12,26 @@
|
|||
#include <gl\glut.h>
|
||||
#include <Vector>
|
||||
|
||||
#include "TexCache.h"
|
||||
#include "Tile.h"
|
||||
//#include "GinTex.h"
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
class CScene;
|
||||
class CNode;
|
||||
/*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
class CCore;
|
||||
class CTileSet
|
||||
{
|
||||
public:
|
||||
CTileSet(char *Filename);
|
||||
CTileSet(char *Filename,CCore *Core);
|
||||
~CTileSet();
|
||||
|
||||
int Load();
|
||||
void AddTileToSet(CScene &ThisScene,int Id);
|
||||
int Load(CCore *Core);
|
||||
|
||||
private:
|
||||
char Filename[256];
|
||||
std::vector<GLint> Tile;
|
||||
std::vector<CTile> Tile;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -3,10 +3,13 @@
|
|||
/*************/
|
||||
|
||||
#include "stdafx.h"
|
||||
//#include <windows.h> // Header File For Windows
|
||||
//#include <stdio.h> // Header File For Standard Input/Output
|
||||
#include "gl3d.h"
|
||||
#include <gl\gl.h>
|
||||
#include <gl\glu.h>
|
||||
#include <gl\glut.h>
|
||||
#include <gl\glaux.h> // Header File For The Glaux Library
|
||||
#include "GLEnabledView.h"
|
||||
#include "maths.h"
|
||||
|
||||
|
@ -155,3 +158,52 @@ TVECTOR Out;
|
|||
/**************************************************************************************/
|
||||
/**************************************************************************************/
|
||||
/**************************************************************************************/
|
||||
AUX_RGBImageRec *LoadBMP(char *Filename)
|
||||
{
|
||||
FILE *File=NULL;
|
||||
|
||||
File=fopen(Filename,"r");
|
||||
|
||||
if (File)
|
||||
{
|
||||
fclose(File);
|
||||
return auxDIBImageLoad(Filename);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**************************************************************************************/
|
||||
int LoadGLTexture(char *FileName, GLuint &Text)
|
||||
{
|
||||
AUX_RGBImageRec *TextureImage[1];
|
||||
int Status=FALSE;
|
||||
|
||||
memset(TextureImage,0,sizeof(void *)*1); // Init Buffer
|
||||
|
||||
// Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
|
||||
if (TextureImage[0]=LoadBMP(FileName))
|
||||
{
|
||||
Status=TRUE; // Set The Status To TRUE
|
||||
|
||||
glGenTextures(1, &Text); // Create The Texture
|
||||
|
||||
// Typical Texture Generation Using Data From The Bitmap
|
||||
glBindTexture(GL_TEXTURE_2D, Text);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
|
||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
|
||||
}
|
||||
|
||||
if (TextureImage[0]) // If Texture Exists
|
||||
{
|
||||
if (TextureImage[0]->data) // If Texture Image Exists
|
||||
{
|
||||
free(TextureImage[0]->data); // Free The Texture Image Memory
|
||||
}
|
||||
|
||||
free(TextureImage[0]); // Free The Image Structure
|
||||
}
|
||||
|
||||
return Status; // Return The Status
|
||||
}
|
||||
|
|
|
@ -10,9 +10,11 @@
|
|||
|
||||
/**************************************************************************************/
|
||||
void DbgMsg(const char * pszFmt,...);
|
||||
|
||||
void BuildGLBox(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);
|
||||
int LoadGLTexture(char *FileName, GLuint &Text);
|
||||
|
||||
void TNormalise(TVECTOR &V);
|
||||
TVECTOR TCrossProduct(TVECTOR const &V0,TVECTOR const &V1,const TVECTOR &V2 );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue