anaglym/anaglym.h
Josh Holtrop f260d83d47 added Engine::createObject() factory method, using new OdeWorld::Object interface
git-svn-id: svn://anubis/anaglym/trunk@55 99a6e188-d820-4881-8870-2d33a10e2619
2009-10-08 04:12:09 +00:00

96 lines
2.6 KiB
C++

#ifndef ANAGLYM_H
#define ANAGLYM_H
#include <string>
#include <lua.hpp>
#include <map>
#include "Video.h"
#include "OdeWorld/OdeWorld.h"
#include "wfobj/WFObj.hh"
#define FILENAME_SAFE_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-"
class Engine
{
public:
class Object
{
public:
Object(bool is_static, OdeWorld & world, GLuint dl)
{
m_ode_object = world.createObject(is_static);
m_display_list = dl;
}
~Object()
{
delete m_ode_object;
}
void setPosition(double x, double y, double z)
{
m_ode_object->setPosition(x, y, z);
}
void getPosition(double * x, double * y, double * z)
{
m_ode_object->getPosition(x, y, z);
}
void loadPhy(const std::string & path)
{
m_ode_object->loadPhy(path);
}
void draw();
protected:
OdeWorld::Object * m_ode_object;
GLuint m_display_list;
};
Engine();
~Engine();
std::string locateResource(const std::string & shortname);
Video * getVideo() { return m_video; }
bool load(const char * program);
void run();
void reportErrors(int status);
OdeWorld & getWorld() { return m_world; }
int addObject(WFObj * obj, bool is_static);
Object * getObject(int id);
void doPhysics();
/* lua services */
int startFrame(lua_State * L);
int endFrame(lua_State * L);
int setCamera(lua_State * L);
protected:
static Uint32 updateCallback(Uint32 interval, void * param);
static SDL_Event userEvent;
Uint32 updateCallback(Uint32 interval);
void registerLibraries();
bool fileExists(const std::string & path);
void update();
Object * createObject(bool is_static, GLuint display_list)
{
return new Object(is_static, m_world, display_list);
}
lua_State * m_luaState;
Video * m_video;
std::string m_program_path;
OdeWorld m_world;
std::map<int, Object *> m_objects;
int m_next_object_index;
GLdouble m_eye[3];
GLdouble m_center[3];
GLdouble m_up[3];
bool m_drawing;
};
extern Engine * g_engine;
#endif