reworked for new wfobj interface
git-svn-id: svn://anubis/dwscr/trunk@122 5bef9df8-b654-44bb-925b-0ff18baa8f8c
This commit is contained in:
parent
e2e552e338
commit
580597f389
@ -1,13 +1,7 @@
|
|||||||
|
|
||||||
#include <map>
|
|
||||||
#include <string>
|
|
||||||
#include "LoadFile.h"
|
#include "LoadFile.h"
|
||||||
|
|
||||||
typedef struct {
|
using namespace std;
|
||||||
const char * filename;
|
|
||||||
unsigned char * data;
|
|
||||||
int length;
|
|
||||||
} fileref_t;
|
|
||||||
|
|
||||||
/* The data section is generated by a perl script. The contents of the
|
/* The data section is generated by a perl script. The contents of the
|
||||||
* included file are part of this logical program unit, which is why it
|
* included file are part of this logical program unit, which is why it
|
||||||
@ -15,28 +9,33 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
#include "LoadFile-gen.inc"
|
#include "LoadFile-gen.inc"
|
||||||
|
|
||||||
const static int numFiles = sizeof(LoadFileData)/sizeof(fileref_t);
|
LoadFile::LoadFile()
|
||||||
|
|
||||||
static std::map< std::string, fileref_t * > * LoadFileMap = NULL;
|
|
||||||
|
|
||||||
void * LoadFile(const char * filename, unsigned int * length)
|
|
||||||
{
|
{
|
||||||
if (LoadFileMap == NULL)
|
for (unsigned int i = 0;
|
||||||
|
i < sizeof(LoadFileData)/sizeof(LoadFileData[0]);
|
||||||
|
i++)
|
||||||
{
|
{
|
||||||
LoadFileMap = new std::map< std::string, fileref_t * >();
|
m_filemap[LoadFileData[i].filename] = &LoadFileData[i];
|
||||||
for (int i = 0; i < numFiles; i++)
|
|
||||||
{
|
|
||||||
(*LoadFileMap)[std::string(LoadFileData[i].filename)] = &LoadFileData[i];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
std::map< std::string, fileref_t * >::iterator it =
|
|
||||||
LoadFileMap->find(std::string(filename));
|
FileLoader::Buffer LoadFile::load(const FileLoader::Path & path)
|
||||||
|
{
|
||||||
if (it == LoadFileMap->end())
|
map<string, fileref_t *>::iterator it = m_filemap.find(path.shortPath);
|
||||||
return NULL;
|
|
||||||
|
if (it == m_filemap.end())
|
||||||
*length = it->second->length;
|
return Buffer(0);
|
||||||
return it->second->data;
|
|
||||||
|
return Buffer((char *) it->second->data, it->second->length);
|
||||||
|
}
|
||||||
|
|
||||||
|
int LoadFile::getSize(const FileLoader::Path & path)
|
||||||
|
{
|
||||||
|
map<string, fileref_t *>::iterator it = m_filemap.find(path.shortPath);
|
||||||
|
|
||||||
|
if (it == m_filemap.end())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return it->second->length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,2 +1,25 @@
|
|||||||
|
|
||||||
void * LoadFile(const char * filename, unsigned int * length);
|
#ifndef LOADFILE_H
|
||||||
|
#define LOADFILE_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
#include "FileLoader/FileLoader.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const char * filename;
|
||||||
|
unsigned char * data;
|
||||||
|
int length;
|
||||||
|
} fileref_t;
|
||||||
|
|
||||||
|
class LoadFile : public FileLoader
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LoadFile();
|
||||||
|
int getSize(const Path & path);
|
||||||
|
Buffer load(const Path & path);
|
||||||
|
protected:
|
||||||
|
std::map< std::string, fileref_t * > m_filemap;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
6
Makefile
6
Makefile
@ -12,6 +12,12 @@ else
|
|||||||
WINDOWS := 1
|
WINDOWS := 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(WINDOWS),1)
|
||||||
|
export CPPFLAGS += -I"$(shell cd)"
|
||||||
|
else
|
||||||
|
export CPPFLAGS += -I"$(shell pwd)"
|
||||||
|
endif
|
||||||
|
|
||||||
OBJS = dwscr.o wfobj/WFObj.o LoadFile/LoadFile.o ss/ss.a
|
OBJS = dwscr.o wfobj/WFObj.o LoadFile/LoadFile.o ss/ss.a
|
||||||
TARGET = dwscr
|
TARGET = dwscr
|
||||||
export CXXFLAGS := -O2 -Wall
|
export CXXFLAGS := -O2 -Wall
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#ifndef WITHOUT_ODE
|
#ifndef WITHOUT_ODE
|
||||||
#include <ode/ode.h>
|
#include <ode/ode.h>
|
||||||
#endif
|
#endif
|
||||||
#include "../wfobj/WFObj.hh"
|
#include "../wfobj/WFObj.h"
|
||||||
#include "LogoBox.h"
|
#include "LogoBox.h"
|
||||||
#include "../LoadFile/LoadFile.h"
|
#include "../LoadFile/LoadFile.h"
|
||||||
|
|
||||||
@ -21,6 +21,7 @@ using namespace std;
|
|||||||
static GLuint _logoList = 0;
|
static GLuint _logoList = 0;
|
||||||
static float _logoAABB[6];
|
static float _logoAABB[6];
|
||||||
static GLuint _drawList;
|
static GLuint _drawList;
|
||||||
|
static LoadFile loadFile;
|
||||||
|
|
||||||
/* construct a LogoBox object
|
/* construct a LogoBox object
|
||||||
* The first time the constructor is called it loads the
|
* The first time the constructor is called it loads the
|
||||||
@ -38,8 +39,8 @@ LogoBox::LogoBox()
|
|||||||
{
|
{
|
||||||
if (_logoList == 0)
|
if (_logoList == 0)
|
||||||
{
|
{
|
||||||
WFObj obj;
|
WFObj obj(loadFile);
|
||||||
if (obj.load("dwlogo.obj", NULL, &LoadFile))
|
if (obj.load(FileLoader::Path("", "dwlogo.obj")))
|
||||||
{
|
{
|
||||||
_logoList = obj.render(false);
|
_logoList = obj.render(false);
|
||||||
const float * aabb = obj.getAABB();
|
const float * aabb = obj.getAABB();
|
||||||
|
40
ss/SSMode.cc
40
ss/SSMode.cc
@ -27,25 +27,25 @@ void SSMode::update()
|
|||||||
|
|
||||||
/* push an OpenGL matrix onto the matrix stack for a given
|
/* push an OpenGL matrix onto the matrix stack for a given
|
||||||
* ODE body position and rotation */
|
* ODE body position and rotation */
|
||||||
void SSMode::pushTransform(const float pos[3], const float R[12])
|
void SSMode::pushTransform(const dReal pos[3], const dReal R[12])
|
||||||
{
|
{
|
||||||
GLfloat matrix[16];
|
GLfloat matrix[16];
|
||||||
matrix[0] = R[0];
|
matrix[0] = R[0];
|
||||||
matrix[1] = R[4];
|
matrix[1] = R[4];
|
||||||
matrix[2] = R[8];
|
matrix[2] = R[8];
|
||||||
matrix[3] = 0;
|
matrix[3] = 0;
|
||||||
matrix[4] = R[1];
|
matrix[4] = R[1];
|
||||||
matrix[5] = R[5];
|
matrix[5] = R[5];
|
||||||
matrix[6] = R[9];
|
matrix[6] = R[9];
|
||||||
matrix[7] = 0;
|
matrix[7] = 0;
|
||||||
matrix[8] = R[2];
|
matrix[8] = R[2];
|
||||||
matrix[9] = R[6];
|
matrix[9] = R[6];
|
||||||
matrix[10] = R[10];
|
matrix[10] = R[10];
|
||||||
matrix[11] = 0;
|
matrix[11] = 0;
|
||||||
matrix[12] = pos[0];
|
matrix[12] = pos[0];
|
||||||
matrix[13] = pos[1];
|
matrix[13] = pos[1];
|
||||||
matrix[14] = pos[2];
|
matrix[14] = pos[2];
|
||||||
matrix[15] = 1;
|
matrix[15] = 1;
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glMultMatrixf(matrix);
|
glMultMatrixf(matrix);
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
|
#include <ode/ode.h>
|
||||||
|
|
||||||
class SSMain;
|
class SSMain;
|
||||||
|
|
||||||
@ -20,7 +21,7 @@ public:
|
|||||||
SSMode(SSMain * _SSMain);
|
SSMode(SSMain * _SSMain);
|
||||||
virtual ~SSMode();
|
virtual ~SSMode();
|
||||||
virtual void update();
|
virtual void update();
|
||||||
void pushTransform(const float pos[3], const float R[12]);
|
void pushTransform(const dReal pos[3], const dReal R[12]);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SSMain * m_SSMain;
|
SSMain * m_SSMain;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user