added initial support for reference objects
git-svn-id: svn://anubis/anaglym/trunk@241 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
9d9c16f3ad
commit
9058dcfefc
4
.todo
4
.todo
@ -1 +1,3 @@
|
|||||||
- support reference objects
|
change bowling demo to use reference objects
|
||||||
|
update documentation for loadModel*(), create*()
|
||||||
|
add documentation for motors
|
||||||
|
156
Engine.cc
156
Engine.cc
@ -262,19 +262,20 @@ bool Engine::fileExists(const string & path)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Engine::addObject(WFObj * obj, bool is_static, float scale)
|
int Engine::addObject(WFObj * obj, bool is_static, bool is_reference,
|
||||||
|
float scale)
|
||||||
{
|
{
|
||||||
int id = m_next_object_index++;
|
int id = m_next_object_index++;
|
||||||
Object * o = new Object(is_static, m_world, obj, scale);
|
Object * o = new Object(is_static, is_reference, m_world, obj, scale);
|
||||||
m_objects[id] = o;
|
m_objects[id] = o;
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Engine::addObject(bool is_static, OdeWorld::GeomType geom_type,
|
int Engine::addObject(bool is_static, bool is_reference,
|
||||||
refptr< vector<float> > args)
|
OdeWorld::GeomType geom_type, refptr< vector<float> > args)
|
||||||
{
|
{
|
||||||
int id = m_next_object_index++;
|
int id = m_next_object_index++;
|
||||||
Object * o = new Object(is_static, m_world, geom_type, args);
|
Object * o = new Object(is_static, is_reference, m_world, geom_type, args);
|
||||||
m_objects[id] = o;
|
m_objects[id] = o;
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@ -514,7 +515,8 @@ int Engine::clearEventHandler(lua_State * L)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Engine::loadModel(const string & name, bool static_data, float scale)
|
int Engine::loadModel(const string & name, bool is_static, bool is_reference,
|
||||||
|
float scale)
|
||||||
{
|
{
|
||||||
size_t pos = name.find_first_not_of(FILENAME_SAFE_CHARS);
|
size_t pos = name.find_first_not_of(FILENAME_SAFE_CHARS);
|
||||||
if (pos == string::npos)
|
if (pos == string::npos)
|
||||||
@ -526,7 +528,7 @@ int Engine::loadModel(const string & name, bool static_data, float scale)
|
|||||||
|
|
||||||
if (obj->load(model_path))
|
if (obj->load(model_path))
|
||||||
{
|
{
|
||||||
int id = addObject(obj, static_data, scale);
|
int id = addObject(obj, is_static, is_reference, scale);
|
||||||
Engine::Object * engine_obj = getObject(id);
|
Engine::Object * engine_obj = getObject(id);
|
||||||
if (engine_obj != NULL)
|
if (engine_obj != NULL)
|
||||||
{
|
{
|
||||||
@ -1074,10 +1076,21 @@ void Engine::drawObjects()
|
|||||||
|
|
||||||
/******** Engine::Object functions ********/
|
/******** Engine::Object functions ********/
|
||||||
|
|
||||||
Engine::Object::Object(bool is_static, OdeWorld & world, WFObj * obj,
|
/* used for objects loaded directly from model files */
|
||||||
float scale)
|
Engine::Object::Object(bool is_static, bool is_reference,
|
||||||
|
OdeWorld & world, WFObj * obj, float scale)
|
||||||
|
: m_world(world)
|
||||||
{
|
{
|
||||||
m_ode_object = world.createObject(is_static, scale);
|
m_is_reference = is_reference;
|
||||||
|
if (m_is_reference)
|
||||||
|
{
|
||||||
|
m_ode_object = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_ode_object = world.createObject(is_static, scale);
|
||||||
|
}
|
||||||
|
m_is_static = is_static;
|
||||||
m_display_list = obj->render();
|
m_display_list = obj->render();
|
||||||
const float * obj_aabb = obj->getAABB();
|
const float * obj_aabb = obj->getAABB();
|
||||||
for (int i = 0; i < 6; i++)
|
for (int i = 0; i < 6; i++)
|
||||||
@ -1090,18 +1103,27 @@ Engine::Object::Object(bool is_static, OdeWorld & world, WFObj * obj,
|
|||||||
m_is_managed = false;
|
m_is_managed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Engine::Object::Object(bool is_static, OdeWorld & world,
|
/* used for "managed" objects with one geom */
|
||||||
|
Engine::Object::Object(bool is_static, bool is_reference, OdeWorld & world,
|
||||||
OdeWorld::GeomType geom_type,
|
OdeWorld::GeomType geom_type,
|
||||||
refptr< std::vector<float> > args)
|
refptr< std::vector<float> > args)
|
||||||
|
: m_world(world)
|
||||||
{
|
{
|
||||||
|
m_is_reference = is_reference;
|
||||||
|
m_is_static = geom_type == OdeWorld::PLANE ? false : is_static;
|
||||||
m_is_visible = true;
|
m_is_visible = true;
|
||||||
m_scale = 1.0f;
|
m_scale = 1.0f;
|
||||||
m_is_scaled = false;
|
m_is_scaled = false;
|
||||||
m_display_list = 0;
|
m_display_list = 0;
|
||||||
m_display_list_refcnt = NULL;
|
m_display_list_refcnt = NULL;
|
||||||
m_ode_object = world.createObject(
|
if (m_is_reference)
|
||||||
geom_type == OdeWorld::PLANE ? false : is_static,
|
{
|
||||||
m_scale);
|
m_ode_object = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_ode_object = world.createObject(m_is_static, m_scale);
|
||||||
|
}
|
||||||
m_is_managed = true;
|
m_is_managed = true;
|
||||||
m_geom_type = geom_type;
|
m_geom_type = geom_type;
|
||||||
m_args = args;
|
m_args = args;
|
||||||
@ -1110,12 +1132,19 @@ Engine::Object::Object(bool is_static, OdeWorld & world,
|
|||||||
m_texture = 0;
|
m_texture = 0;
|
||||||
m_texture_scale = 1.0f;
|
m_texture_scale = 1.0f;
|
||||||
createManagedObject();
|
createManagedObject();
|
||||||
|
render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* used to clone objects */
|
||||||
Engine::Object::Object(const Engine::Object & orig)
|
Engine::Object::Object(const Engine::Object & orig)
|
||||||
|
: m_world(orig.m_world)
|
||||||
{
|
{
|
||||||
|
m_is_reference = false;
|
||||||
m_is_visible = orig.m_is_visible;
|
m_is_visible = orig.m_is_visible;
|
||||||
m_ode_object = new OdeWorld::Object(*orig.m_ode_object);
|
m_is_static = orig.m_is_static;
|
||||||
|
m_scale = orig.m_scale;
|
||||||
|
m_is_scaled = orig.m_is_scaled;
|
||||||
|
m_phy = orig.m_phy;
|
||||||
m_is_managed = orig.m_is_managed;
|
m_is_managed = orig.m_is_managed;
|
||||||
if (m_is_managed)
|
if (m_is_managed)
|
||||||
m_display_list = 0;
|
m_display_list = 0;
|
||||||
@ -1124,21 +1153,32 @@ Engine::Object::Object(const Engine::Object & orig)
|
|||||||
m_display_list_refcnt = orig.m_display_list_refcnt;
|
m_display_list_refcnt = orig.m_display_list_refcnt;
|
||||||
if (m_display_list_refcnt != NULL)
|
if (m_display_list_refcnt != NULL)
|
||||||
(*m_display_list_refcnt)++;
|
(*m_display_list_refcnt)++;
|
||||||
m_scale = orig.m_scale;
|
|
||||||
m_is_scaled = orig.m_is_scaled;
|
|
||||||
m_geom_type = orig.m_geom_type;
|
m_geom_type = orig.m_geom_type;
|
||||||
m_args = orig.m_args;
|
m_args = orig.m_args;
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
m_color[i] = orig.m_color[i];
|
m_color[i] = orig.m_color[i];
|
||||||
m_texture = orig.m_texture;
|
m_texture = orig.m_texture;
|
||||||
m_texture_scale = orig.m_texture_scale;
|
m_texture_scale = orig.m_texture_scale;
|
||||||
|
if (orig.m_is_reference)
|
||||||
|
{
|
||||||
|
m_ode_object = m_world.createObject(m_is_static, m_scale);
|
||||||
|
instantiatePhy();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_ode_object = new OdeWorld::Object(*orig.m_ode_object);
|
||||||
|
}
|
||||||
if (m_is_managed)
|
if (m_is_managed)
|
||||||
|
{
|
||||||
|
createManagedObject();
|
||||||
render();
|
render();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Engine::Object::~Object()
|
Engine::Object::~Object()
|
||||||
{
|
{
|
||||||
delete m_ode_object;
|
if (m_ode_object != NULL)
|
||||||
|
delete m_ode_object;
|
||||||
if (m_display_list_refcnt != NULL)
|
if (m_display_list_refcnt != NULL)
|
||||||
{
|
{
|
||||||
(*m_display_list_refcnt)--;
|
(*m_display_list_refcnt)--;
|
||||||
@ -1162,7 +1202,8 @@ void Engine::Object::createManagedObject()
|
|||||||
case OdeWorld::BOX: {
|
case OdeWorld::BOX: {
|
||||||
while (m_args->size() < 9)
|
while (m_args->size() < 9)
|
||||||
m_args->push_back(0);
|
m_args->push_back(0);
|
||||||
m_ode_object->addBox(m_args);
|
if (m_ode_object != NULL)
|
||||||
|
m_ode_object->addBox(m_args);
|
||||||
float aabb[6] = {-(*m_args)[0], -(*m_args)[1], -(*m_args)[2],
|
float aabb[6] = {-(*m_args)[0], -(*m_args)[1], -(*m_args)[2],
|
||||||
(*m_args)[0], (*m_args)[1], (*m_args)[2]};
|
(*m_args)[0], (*m_args)[1], (*m_args)[2]};
|
||||||
memcpy(m_aabb, aabb, sizeof(m_aabb));
|
memcpy(m_aabb, aabb, sizeof(m_aabb));
|
||||||
@ -1171,7 +1212,8 @@ void Engine::Object::createManagedObject()
|
|||||||
case OdeWorld::SPHERE: {
|
case OdeWorld::SPHERE: {
|
||||||
while (m_args->size() < 4)
|
while (m_args->size() < 4)
|
||||||
m_args->push_back(0);
|
m_args->push_back(0);
|
||||||
m_ode_object->addSphere(m_args);
|
if (m_ode_object != NULL)
|
||||||
|
m_ode_object->addSphere(m_args);
|
||||||
float aabb[6] = {-(*m_args)[0], -(*m_args)[0], -(*m_args)[0],
|
float aabb[6] = {-(*m_args)[0], -(*m_args)[0], -(*m_args)[0],
|
||||||
(*m_args)[0], (*m_args)[0], (*m_args)[0]};
|
(*m_args)[0], (*m_args)[0], (*m_args)[0]};
|
||||||
memcpy(m_aabb, aabb, sizeof(m_aabb));
|
memcpy(m_aabb, aabb, sizeof(m_aabb));
|
||||||
@ -1180,7 +1222,8 @@ void Engine::Object::createManagedObject()
|
|||||||
case OdeWorld::PLANE: {
|
case OdeWorld::PLANE: {
|
||||||
while (m_args->size() < 4 || m_args->size() == 5)
|
while (m_args->size() < 4 || m_args->size() == 5)
|
||||||
m_args->push_back(0);
|
m_args->push_back(0);
|
||||||
m_ode_object->addPlane(m_args);
|
if (m_ode_object != NULL)
|
||||||
|
m_ode_object->addPlane(m_args);
|
||||||
for (int i = 0; i < 6; i++)
|
for (int i = 0; i < 6; i++)
|
||||||
m_aabb[i] = 0.0f;
|
m_aabb[i] = 0.0f;
|
||||||
break;
|
break;
|
||||||
@ -1188,7 +1231,8 @@ void Engine::Object::createManagedObject()
|
|||||||
case OdeWorld::CYLINDER: {
|
case OdeWorld::CYLINDER: {
|
||||||
while (m_args->size() < 8)
|
while (m_args->size() < 8)
|
||||||
m_args->push_back(0);
|
m_args->push_back(0);
|
||||||
m_ode_object->addCylinder(m_args);
|
if (m_ode_object != NULL)
|
||||||
|
m_ode_object->addCylinder(m_args);
|
||||||
float aabb[6] = {-(*m_args)[0], -(*m_args)[0], -(*m_args)[1],
|
float aabb[6] = {-(*m_args)[0], -(*m_args)[0], -(*m_args)[1],
|
||||||
(*m_args)[0], (*m_args)[0], (*m_args)[1]};
|
(*m_args)[0], (*m_args)[0], (*m_args)[1]};
|
||||||
memcpy(m_aabb, aabb, sizeof(m_aabb));
|
memcpy(m_aabb, aabb, sizeof(m_aabb));
|
||||||
@ -1197,22 +1241,29 @@ void Engine::Object::createManagedObject()
|
|||||||
case OdeWorld::CAPSULE: {
|
case OdeWorld::CAPSULE: {
|
||||||
while (m_args->size() < 8)
|
while (m_args->size() < 8)
|
||||||
m_args->push_back(0);
|
m_args->push_back(0);
|
||||||
m_ode_object->addCapsule(m_args);
|
if (m_ode_object != NULL)
|
||||||
|
m_ode_object->addCapsule(m_args);
|
||||||
float aabb[6] = {-(*m_args)[0], -(*m_args)[0], -(*m_args)[1],
|
float aabb[6] = {-(*m_args)[0], -(*m_args)[0], -(*m_args)[1],
|
||||||
(*m_args)[0], (*m_args)[0], (*m_args)[1]};
|
(*m_args)[0], (*m_args)[0], (*m_args)[1]};
|
||||||
memcpy(m_aabb, aabb, sizeof(m_aabb));
|
memcpy(m_aabb, aabb, sizeof(m_aabb));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_ode_object->finalize();
|
if (m_ode_object != NULL)
|
||||||
render();
|
{
|
||||||
|
m_ode_object->finalize();
|
||||||
|
}
|
||||||
|
if (!m_is_reference)
|
||||||
|
{
|
||||||
|
render();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* render a managed object */
|
/* render a managed object */
|
||||||
/* prerequisite: m_args->size() is big enough */
|
/* prerequisite: m_args->size() is big enough */
|
||||||
void Engine::Object::render()
|
void Engine::Object::render()
|
||||||
{
|
{
|
||||||
if (!m_is_managed)
|
if (!m_is_managed || m_is_reference)
|
||||||
return;
|
return;
|
||||||
GLUquadric * quad = gluNewQuadric();
|
GLUquadric * quad = gluNewQuadric();
|
||||||
if (m_display_list <= 0)
|
if (m_display_list <= 0)
|
||||||
@ -1410,31 +1461,40 @@ void Engine::Object::render()
|
|||||||
|
|
||||||
void Engine::Object::loadPhy(FileLoader * fl, const FileLoader::Path & path)
|
void Engine::Object::loadPhy(FileLoader * fl, const FileLoader::Path & path)
|
||||||
{
|
{
|
||||||
PhyObj po;
|
m_phy = new PhyObj();
|
||||||
po.load(fl, path);
|
m_phy->load(fl, path);
|
||||||
for (int i = 0, sz = po.getNumGeoms(); i < sz; i++)
|
if (!m_is_managed)
|
||||||
|
instantiatePhy();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Engine::Object::instantiatePhy()
|
||||||
|
{
|
||||||
|
if (m_ode_object != NULL && !m_is_managed && !m_phy.isNull())
|
||||||
{
|
{
|
||||||
refptr<PhyObj::Geom> geom = po.getGeom(i);
|
for (int i = 0, sz = m_phy->getNumGeoms(); i < sz; i++)
|
||||||
refptr< vector<float> > args = geom->getArgs();
|
|
||||||
switch (geom->getType())
|
|
||||||
{
|
{
|
||||||
case PhyObj::BOX:
|
refptr<PhyObj::Geom> geom = m_phy->getGeom(i);
|
||||||
m_ode_object->addBox(args);
|
refptr< vector<float> > args = geom->getArgs();
|
||||||
break;
|
switch (geom->getType())
|
||||||
case PhyObj::SPHERE:
|
{
|
||||||
m_ode_object->addSphere(args);
|
case PhyObj::BOX:
|
||||||
break;
|
m_ode_object->addBox(args);
|
||||||
case PhyObj::CAPSULE:
|
break;
|
||||||
m_ode_object->addCapsule(args);
|
case PhyObj::SPHERE:
|
||||||
break;
|
m_ode_object->addSphere(args);
|
||||||
case PhyObj::PLANE:
|
break;
|
||||||
m_ode_object->addPlane(args);
|
case PhyObj::CAPSULE:
|
||||||
break;
|
m_ode_object->addCapsule(args);
|
||||||
default:
|
break;
|
||||||
break;
|
case PhyObj::PLANE:
|
||||||
|
m_ode_object->addPlane(args);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
m_ode_object->finalize();
|
||||||
}
|
}
|
||||||
m_ode_object->finalize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::Object::setTexture(GLuint tex)
|
void Engine::Object::setTexture(GLuint tex)
|
||||||
@ -1448,7 +1508,7 @@ void Engine::Object::setTexture(GLuint tex)
|
|||||||
|
|
||||||
void Engine::Object::draw()
|
void Engine::Object::draw()
|
||||||
{
|
{
|
||||||
if (m_is_visible)
|
if (!m_is_reference && m_is_visible);
|
||||||
{
|
{
|
||||||
checkGLError();
|
checkGLError();
|
||||||
const dReal * pos = m_ode_object->getPosition();
|
const dReal * pos = m_ode_object->getPosition();
|
||||||
|
23
Engine.h
23
Engine.h
@ -13,6 +13,7 @@
|
|||||||
#include "Video.h"
|
#include "Video.h"
|
||||||
#include "refptr/refptr.h"
|
#include "refptr/refptr.h"
|
||||||
#include "ftgl.h"
|
#include "ftgl.h"
|
||||||
|
#include "PhyObj/PhyObj.h"
|
||||||
|
|
||||||
class Engine
|
class Engine
|
||||||
{
|
{
|
||||||
@ -20,10 +21,11 @@ class Engine
|
|||||||
class Object
|
class Object
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Object(bool is_static, OdeWorld & world, WFObj * wfobj,
|
Object(bool is_static, bool is_reference,
|
||||||
|
OdeWorld & world, WFObj * wfobj,
|
||||||
float scale = 1.0f);
|
float scale = 1.0f);
|
||||||
Object(bool is_static, OdeWorld & world,
|
Object(bool is_static, bool is_reference,
|
||||||
OdeWorld::GeomType geom_type,
|
OdeWorld & world, OdeWorld::GeomType geom_type,
|
||||||
refptr< std::vector<float> > args);
|
refptr< std::vector<float> > args);
|
||||||
Object(const Object & orig);
|
Object(const Object & orig);
|
||||||
~Object();
|
~Object();
|
||||||
@ -37,6 +39,7 @@ class Engine
|
|||||||
m_ode_object->getPosition(x, y, z);
|
m_ode_object->getPosition(x, y, z);
|
||||||
}
|
}
|
||||||
void loadPhy(FileLoader * fl, const FileLoader::Path & path);
|
void loadPhy(FileLoader * fl, const FileLoader::Path & path);
|
||||||
|
void instantiatePhy();
|
||||||
void setVisible(bool visible) { m_is_visible = visible; }
|
void setVisible(bool visible) { m_is_visible = visible; }
|
||||||
bool getVisible() { return m_is_visible; }
|
bool getVisible() { return m_is_visible; }
|
||||||
void addForce(dReal fx, dReal fy, dReal fz)
|
void addForce(dReal fx, dReal fy, dReal fz)
|
||||||
@ -93,7 +96,11 @@ class Engine
|
|||||||
float m_scale;
|
float m_scale;
|
||||||
bool m_is_scaled;
|
bool m_is_scaled;
|
||||||
bool m_is_managed;
|
bool m_is_managed;
|
||||||
|
bool m_is_reference;
|
||||||
|
bool m_is_static;
|
||||||
float m_aabb[6];
|
float m_aabb[6];
|
||||||
|
OdeWorld & m_world;
|
||||||
|
refptr<PhyObj> m_phy;
|
||||||
|
|
||||||
/* for "pre-loaded" objects */
|
/* for "pre-loaded" objects */
|
||||||
int * m_display_list_refcnt;
|
int * m_display_list_refcnt;
|
||||||
@ -125,8 +132,10 @@ class Engine
|
|||||||
void run();
|
void run();
|
||||||
void reportErrors(int status);
|
void reportErrors(int status);
|
||||||
OdeWorld & getWorld() { return m_world; }
|
OdeWorld & getWorld() { return m_world; }
|
||||||
int addObject(WFObj * obj, bool is_static, float scale = 1.0f);
|
int addObject(WFObj * obj, bool is_static, bool is_reference,
|
||||||
int addObject(bool is_static, OdeWorld::GeomType geom_type,
|
float scale = 1.0f);
|
||||||
|
int addObject(bool is_static, bool is_reference,
|
||||||
|
OdeWorld::GeomType geom_type,
|
||||||
refptr< std::vector<float> > args);
|
refptr< std::vector<float> > args);
|
||||||
int addAMotor(Object * o1, Object * o2);
|
int addAMotor(Object * o1, Object * o2);
|
||||||
int addHinge(Object * o1, Object * o2,
|
int addHinge(Object * o1, Object * o2,
|
||||||
@ -156,8 +165,8 @@ class Engine
|
|||||||
bool getAutoDrawObjects() { return m_autoDrawObjects; }
|
bool getAutoDrawObjects() { return m_autoDrawObjects; }
|
||||||
void startFrame();
|
void startFrame();
|
||||||
void endFrame();
|
void endFrame();
|
||||||
int loadModel(const std::string & name, bool static_data,
|
int loadModel(const std::string & name, bool is_static,
|
||||||
float scale = 1.0f);
|
bool is_reference, float scale = 1.0f);
|
||||||
bool isKeyDown(const std::string & key);
|
bool isKeyDown(const std::string & key);
|
||||||
void exit();
|
void exit();
|
||||||
bool import(const char * name);
|
bool import(const char * name);
|
||||||
|
148
ag.cc
148
ag.cc
@ -43,8 +43,7 @@ namespace ag
|
|||||||
{ "getTextSize", getTextSize },
|
{ "getTextSize", getTextSize },
|
||||||
{ "import", import },
|
{ "import", import },
|
||||||
{ "isKeyDown", isKeyDown },
|
{ "isKeyDown", isKeyDown },
|
||||||
{ "loadModel", loadModel },
|
{ "loadModelSpecify", loadModelSpecify },
|
||||||
{ "loadModelStatic", loadModelStatic },
|
|
||||||
{ "loadTexture", loadTexture },
|
{ "loadTexture", loadTexture },
|
||||||
{ "next", next },
|
{ "next", next },
|
||||||
{ "print", print },
|
{ "print", print },
|
||||||
@ -66,15 +65,10 @@ namespace ag
|
|||||||
{ "_createHinge", _createHinge },
|
{ "_createHinge", _createHinge },
|
||||||
|
|
||||||
/* managed object functions */
|
/* managed object functions */
|
||||||
{ "createBox", createBox },
|
{ "createBoxSpecify", createBoxSpecify },
|
||||||
{ "createBoxStatic", createBoxStatic },
|
{ "createCapsuleSpecify", createCapsuleSpecify },
|
||||||
{ "createCapsule", createCapsule },
|
{ "createPlaneSpecify", createPlaneSpecify },
|
||||||
{ "createCapsuleStatic", createCapsuleStatic },
|
{ "createSphereSpecify", createSphereSpecify },
|
||||||
// { "createCylinder", createCylinder },
|
|
||||||
// { "createCylinderStatic", createCylinderStatic },
|
|
||||||
{ "createPlane", createPlane },
|
|
||||||
{ "createSphere", createSphere },
|
|
||||||
{ "createSphereStatic", createSphereStatic },
|
|
||||||
|
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
@ -353,19 +347,22 @@ namespace ag
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int loadModelSpecify(lua_State * L, bool static_data)
|
int loadModelSpecify(lua_State * L)
|
||||||
{
|
{
|
||||||
bool added = false;
|
bool added = false;
|
||||||
float scale = 1.0f;
|
|
||||||
int argc = lua_gettop(L);
|
int argc = lua_gettop(L);
|
||||||
|
|
||||||
if (argc >= 2 && lua_isnumber(L, 2))
|
if (argc == 4
|
||||||
scale = lua_tonumber(L, 2);
|
&& lua_isstring(L, 1)
|
||||||
|
&& lua_isnumber(L, 2)
|
||||||
if (argc >= 1 && lua_isstring(L, 1))
|
&& lua_isboolean(L, 3)
|
||||||
|
&& lua_isboolean(L, 4))
|
||||||
{
|
{
|
||||||
string modelname = lua_tostring(L, 1);
|
int id = g_engine->loadModel(
|
||||||
int id = g_engine->loadModel(modelname, static_data, scale);
|
lua_tostring(L, 1), /* name */
|
||||||
|
lua_toboolean(L, 3), /* static */
|
||||||
|
lua_toboolean(L, 4), /* reference */
|
||||||
|
lua_tonumber(L, 2)); /* scale */
|
||||||
if (id > 0)
|
if (id > 0)
|
||||||
{
|
{
|
||||||
createLuaObject(L, id);
|
createLuaObject(L, id);
|
||||||
@ -377,16 +374,6 @@ namespace ag
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int loadModel(lua_State * L)
|
|
||||||
{
|
|
||||||
return loadModelSpecify(L, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
int loadModelStatic(lua_State * L)
|
|
||||||
{
|
|
||||||
return loadModelSpecify(L, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
int sleep(lua_State * L)
|
int sleep(lua_State * L)
|
||||||
{
|
{
|
||||||
int argc = lua_gettop(L);
|
int argc = lua_gettop(L);
|
||||||
@ -795,71 +782,59 @@ namespace ag
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void addManagedObject(lua_State * L, bool is_static,
|
static void addManagedObject(lua_State * L, bool is_static,
|
||||||
|
bool is_reference,
|
||||||
OdeWorld::GeomType geom_type, refptr< vector<float> > args)
|
OdeWorld::GeomType geom_type, refptr< vector<float> > args)
|
||||||
{
|
{
|
||||||
int id = g_engine->addObject(is_static, geom_type, args);
|
int id = g_engine->addObject(is_static, is_reference, geom_type, args);
|
||||||
createLuaObject(L, id);
|
createLuaObject(L, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int createBoxSpecify(lua_State * L, bool is_static)
|
int createBoxSpecify(lua_State * L)
|
||||||
{
|
{
|
||||||
int argc = lua_gettop(L);
|
int argc = lua_gettop(L);
|
||||||
if (argc == 3 &&
|
if (argc == 5
|
||||||
lua_isnumber(L, 1) &&
|
&& lua_isnumber(L, 1)
|
||||||
lua_isnumber(L, 2) &&
|
&& lua_isnumber(L, 2)
|
||||||
lua_isnumber(L, 3))
|
&& lua_isnumber(L, 3)
|
||||||
|
&& lua_isboolean(L, 4)
|
||||||
|
&& lua_isboolean(L, 5))
|
||||||
{
|
{
|
||||||
refptr< vector<float> > args = new vector<float>();
|
refptr< vector<float> > args = new vector<float>();
|
||||||
for (int i = 1; i <= 3; i++)
|
for (int i = 1; i <= 3; i++)
|
||||||
args->push_back(lua_tonumber(L, i));
|
args->push_back(lua_tonumber(L, i));
|
||||||
addManagedObject(L, is_static, OdeWorld::BOX, args);
|
addManagedObject(L, lua_toboolean(L, 4), lua_toboolean(L, 5),
|
||||||
|
OdeWorld::BOX, args);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int createBox(lua_State * L)
|
int createSphereSpecify(lua_State * L)
|
||||||
{
|
|
||||||
return createBoxSpecify(L, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
int createBoxStatic(lua_State * L)
|
|
||||||
{
|
|
||||||
return createBoxSpecify(L, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int createSphereSpecify(lua_State * L, bool is_static)
|
|
||||||
{
|
{
|
||||||
int argc = lua_gettop(L);
|
int argc = lua_gettop(L);
|
||||||
if (argc == 1 && lua_isnumber(L, 1))
|
if (argc == 3
|
||||||
|
&& lua_isnumber(L, 1)
|
||||||
|
&& lua_isboolean(L, 2)
|
||||||
|
&& lua_isboolean(L, 3))
|
||||||
{
|
{
|
||||||
refptr< vector<float> > args = new vector<float>();
|
refptr< vector<float> > args = new vector<float>();
|
||||||
args->push_back(lua_tonumber(L, 1));
|
args->push_back(lua_tonumber(L, 1));
|
||||||
addManagedObject(L, is_static, OdeWorld::SPHERE, args);
|
addManagedObject(L, lua_toboolean(L, 2), lua_toboolean(L, 3),
|
||||||
|
OdeWorld::SPHERE, args);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int createSphere(lua_State * L)
|
int createPlaneSpecify(lua_State * L)
|
||||||
{
|
|
||||||
return createSphereSpecify(L, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
int createSphereStatic(lua_State * L)
|
|
||||||
{
|
|
||||||
return createSphereSpecify(L, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
int createPlane(lua_State * L)
|
|
||||||
{
|
{
|
||||||
int argc = lua_gettop(L);
|
int argc = lua_gettop(L);
|
||||||
if (argc == 4 || argc == 6)
|
if (argc == 5 || argc == 7)
|
||||||
{
|
{
|
||||||
bool valid = true;
|
bool valid = lua_isboolean(L, argc);
|
||||||
for (int i = 1; i <= argc; i++)
|
for (int i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
if (!lua_isnumber(L, i))
|
if (!lua_isnumber(L, i))
|
||||||
{
|
{
|
||||||
@ -870,9 +845,10 @@ namespace ag
|
|||||||
if (valid)
|
if (valid)
|
||||||
{
|
{
|
||||||
refptr< vector<float> > args = new vector<float>();
|
refptr< vector<float> > args = new vector<float>();
|
||||||
for (int i = 1; i <= argc; i++)
|
for (int i = 1; i < argc; i++)
|
||||||
args->push_back(lua_tonumber(L, i));
|
args->push_back(lua_tonumber(L, i));
|
||||||
addManagedObject(L, true, OdeWorld::PLANE, args);
|
addManagedObject(L, true, lua_toboolean(L, argc),
|
||||||
|
OdeWorld::PLANE, args);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -880,56 +856,46 @@ namespace ag
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int createCylinderSpecify(lua_State * L, bool is_static)
|
int createCylinderSpecify(lua_State * L)
|
||||||
{
|
{
|
||||||
int argc = lua_gettop(L);
|
int argc = lua_gettop(L);
|
||||||
if (argc == 2 && lua_isnumber(L, 1) && lua_isnumber(L, 2))
|
if (argc == 4
|
||||||
|
&& lua_isnumber(L, 1)
|
||||||
|
&& lua_isnumber(L, 2)
|
||||||
|
&& lua_isboolean(L, 3)
|
||||||
|
&& lua_isboolean(L, 4))
|
||||||
{
|
{
|
||||||
refptr< vector<float> > args = new vector<float>();
|
refptr< vector<float> > args = new vector<float>();
|
||||||
args->push_back(lua_tonumber(L, 1));
|
args->push_back(lua_tonumber(L, 1));
|
||||||
args->push_back(lua_tonumber(L, 2));
|
args->push_back(lua_tonumber(L, 2));
|
||||||
addManagedObject(L, is_static, OdeWorld::CYLINDER, args);
|
addManagedObject(L, lua_toboolean(L, 3), lua_toboolean(L, 4),
|
||||||
|
OdeWorld::CYLINDER, args);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int createCylinder(lua_State * L)
|
int createCapsuleSpecify(lua_State * L)
|
||||||
{
|
|
||||||
return createCylinderSpecify(L, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
int createCylinderStatic(lua_State * L)
|
|
||||||
{
|
|
||||||
return createCylinderSpecify(L, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int createCapsuleSpecify(lua_State * L, bool is_static)
|
|
||||||
{
|
{
|
||||||
int argc = lua_gettop(L);
|
int argc = lua_gettop(L);
|
||||||
if (argc == 2 && lua_isnumber(L, 1) && lua_isnumber(L, 2))
|
if (argc == 4
|
||||||
|
&& lua_isnumber(L, 1)
|
||||||
|
&& lua_isnumber(L, 2)
|
||||||
|
&& lua_isboolean(L, 3)
|
||||||
|
&& lua_isboolean(L, 4))
|
||||||
{
|
{
|
||||||
refptr< vector<float> > args = new vector<float>();
|
refptr< vector<float> > args = new vector<float>();
|
||||||
args->push_back(lua_tonumber(L, 1));
|
args->push_back(lua_tonumber(L, 1));
|
||||||
args->push_back(lua_tonumber(L, 2));
|
args->push_back(lua_tonumber(L, 2));
|
||||||
addManagedObject(L, is_static, OdeWorld::CAPSULE, args);
|
addManagedObject(L, lua_toboolean(L, 3), lua_toboolean(L, 4),
|
||||||
|
OdeWorld::CAPSULE, args);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int createCapsule(lua_State * L)
|
|
||||||
{
|
|
||||||
return createCapsuleSpecify(L, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
int createCapsuleStatic(lua_State * L)
|
|
||||||
{
|
|
||||||
return createCapsuleSpecify(L, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
int startList(lua_State * L)
|
int startList(lua_State * L)
|
||||||
{
|
{
|
||||||
GLuint list = g_engine->startList();
|
GLuint list = g_engine->startList();
|
||||||
|
17
ag.h
17
ag.h
@ -22,8 +22,7 @@ namespace ag
|
|||||||
int getScreenSize(lua_State * L);
|
int getScreenSize(lua_State * L);
|
||||||
int import(lua_State * L);
|
int import(lua_State * L);
|
||||||
int isKeyDown(lua_State * L);
|
int isKeyDown(lua_State * L);
|
||||||
int loadModel(lua_State * L);
|
int loadModelSpecify(lua_State * L);
|
||||||
int loadModelStatic(lua_State * L);
|
|
||||||
int loadTexture(lua_State * L);
|
int loadTexture(lua_State * L);
|
||||||
int next(lua_State * L);
|
int next(lua_State * L);
|
||||||
int print(lua_State * L);
|
int print(lua_State * L);
|
||||||
@ -56,15 +55,11 @@ namespace ag
|
|||||||
int getTextSize(lua_State * L);
|
int getTextSize(lua_State * L);
|
||||||
|
|
||||||
/* managed object creation functions */
|
/* managed object creation functions */
|
||||||
int createBox(lua_State * L);
|
int createBoxSpecify(lua_State * L);
|
||||||
int createBoxStatic(lua_State * L);
|
int createCapsuleSpecify(lua_State * L);
|
||||||
int createCapsule(lua_State * L);
|
int createCylinderSpecify(lua_State * L);
|
||||||
int createCapsuleStatic(lua_State * L);
|
int createPlaneSpecify(lua_State * L);
|
||||||
int createCylinder(lua_State * L);
|
int createSphereSpecify(lua_State * L);
|
||||||
int createCylinderStatic(lua_State * L);
|
|
||||||
int createPlane(lua_State * L);
|
|
||||||
int createSphere(lua_State * L);
|
|
||||||
int createSphereStatic(lua_State * L);
|
|
||||||
|
|
||||||
namespace object
|
namespace object
|
||||||
{
|
{
|
||||||
|
80
ag.lua
80
ag.lua
@ -106,3 +106,83 @@ ag.createHinge = function(obj1, obj2, anchor, axis)
|
|||||||
axis[1], axis[2], axis[3])
|
axis[1], axis[2], axis[3])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
ag.loadModel = function(name, args)
|
||||||
|
local scale = 1.0
|
||||||
|
local static = false
|
||||||
|
local reference = false
|
||||||
|
if (type(args) == "table") then
|
||||||
|
if (type(args.scale) == "number") then
|
||||||
|
scale = args.scale
|
||||||
|
end
|
||||||
|
if (type(args.static) == "boolean") then
|
||||||
|
static = args.static
|
||||||
|
end
|
||||||
|
if (type(args.reference) == "boolean") then
|
||||||
|
reference = args.reference
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return ag.loadModelSpecify(name, scale, static, reference)
|
||||||
|
end
|
||||||
|
|
||||||
|
ag.createBox = function(x, y, z, args)
|
||||||
|
local static = false
|
||||||
|
local reference = false
|
||||||
|
if (type(args) == "table") then
|
||||||
|
if (type(args.static) == "boolean") then
|
||||||
|
static = args.static
|
||||||
|
end
|
||||||
|
if (type(args.reference) == "boolean") then
|
||||||
|
reference = args.reference
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return ag.createBoxSpecify(x, y, z, static, reference)
|
||||||
|
end
|
||||||
|
|
||||||
|
ag.createSphere = function(radius, args)
|
||||||
|
local static = false
|
||||||
|
local reference = false
|
||||||
|
if (type(args) == "table") then
|
||||||
|
if (type(args.static) == "boolean") then
|
||||||
|
static = args.static
|
||||||
|
end
|
||||||
|
if (type(args.reference) == "boolean") then
|
||||||
|
reference = args.reference
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return ag.createSphereSpecify(radius, static, reference)
|
||||||
|
end
|
||||||
|
|
||||||
|
ag.createPlane = function(a, b, c, d, x, y, z)
|
||||||
|
local t = nil
|
||||||
|
if (type(x) == "table") then
|
||||||
|
t = x
|
||||||
|
end
|
||||||
|
if (type(z) == "table") then
|
||||||
|
t = z
|
||||||
|
end
|
||||||
|
local reference = false
|
||||||
|
if (type(t) == "table") then
|
||||||
|
if (type(t.reference) == "boolean") then
|
||||||
|
reference = t.reference
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if (type(y) == "nil") then
|
||||||
|
return ag.createPlaneSpecify(a, b, c, d, reference)
|
||||||
|
else
|
||||||
|
return ag.createPlaneSpecify(a, b, c, d, x, y, reference)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
ag.createCapsule = function(radius, length, args)
|
||||||
|
local static = false
|
||||||
|
local reference = false
|
||||||
|
if (type(args) == "table") then
|
||||||
|
if (type(args.static) == "boolean") then
|
||||||
|
static = args.static
|
||||||
|
end
|
||||||
|
if (type(args.reference) == "boolean") then
|
||||||
|
reference = args.reference
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return ag.createCapsuleSpecify(radius, length, static, reference)
|
||||||
|
end
|
||||||
|
@ -63,17 +63,17 @@ function setupScore()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function init_event()
|
function init_event()
|
||||||
lane = ag.loadModelStatic("bowling_lane")
|
lane = ag.loadModel("bowling_lane", {static = true})
|
||||||
local minx, miny, minz, maxx, maxy, maxz = lane:getAABB()
|
local minx, miny, minz, maxx, maxy, maxz = lane:getAABB()
|
||||||
local lane_bottom = minz
|
local lane_bottom = minz
|
||||||
local lane_top = maxz
|
local lane_top = maxz
|
||||||
pins = {}
|
pins = {}
|
||||||
reference_pin = ag.loadModel("bowling_pin", 1.0/4.3)
|
reference_pin = ag.loadModel("bowling_pin", {scale = 1.0/4.3})
|
||||||
minx, miny, minz, maxx, maxy, maxz = reference_pin:getAABB()
|
minx, miny, minz, maxx, maxy, maxz = reference_pin:getAABB()
|
||||||
pin_minz = minz
|
pin_minz = minz
|
||||||
pin_maxz = maxz
|
pin_maxz = maxz
|
||||||
pin_standing_position = lane_top - pin_minz
|
pin_standing_position = lane_top - pin_minz
|
||||||
local box = ag.createBoxStatic(1, 10, 0.1)
|
local box = ag.createBox(1, 10, 0.1, {static = true})
|
||||||
box:setVisible(false)
|
box:setVisible(false)
|
||||||
box:setPosition(0, 0, lane_bottom - (maxz - minz) - 0.4)
|
box:setPosition(0, 0, lane_bottom - (maxz - minz) - 0.4)
|
||||||
reference_pin:setPosition(0, 0, lane_bottom - maxz - 0.1)
|
reference_pin:setPosition(0, 0, lane_bottom - maxz - 0.1)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
function createWorld()
|
function createWorld()
|
||||||
board = ag.createBoxStatic(8, 8, 0.01)
|
board = ag.createBox(8, 8, 0.01, {static = true})
|
||||||
board:setPosition(0, 0, -0.005)
|
board:setPosition(0, 0, -0.005)
|
||||||
board:setTexture(checker)
|
board:setTexture(checker)
|
||||||
board:setTextureScale(2)
|
board:setTextureScale(2)
|
||||||
|
@ -70,7 +70,7 @@ end
|
|||||||
-- model_name: the string containing the name of the model to load
|
-- model_name: the string containing the name of the model to load
|
||||||
-- max_x, max_y, max_z:
|
-- max_x, max_y, max_z:
|
||||||
std.loadModelBounds = function(model_name, max_x, max_y, max_z)
|
std.loadModelBounds = function(model_name, max_x, max_y, max_z)
|
||||||
local tmp_model = ag.loadModel(model_name)
|
local tmp_model = ag.loadModel(model_name, {reference = true})
|
||||||
local sx, sy, sz = tmp_model:getSize()
|
local sx, sy, sz = tmp_model:getSize()
|
||||||
tmp_model:destroy()
|
tmp_model:destroy()
|
||||||
local scale = 1.0
|
local scale = 1.0
|
||||||
@ -93,5 +93,5 @@ std.loadModelBounds = function(model_name, max_x, max_y, max_z)
|
|||||||
scale_set = true
|
scale_set = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return ag.loadModel(model_name, scale)
|
return ag.loadModel(model_name, {scale = scale})
|
||||||
end
|
end
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
|
|
||||||
function init_event()
|
function init_event()
|
||||||
arena = ag.loadModelStatic("boxarena")
|
arena = ag.loadModel("boxarena", { static = true })
|
||||||
ball = ag.loadModel("checkerball")
|
ball = ag.loadModel("checkerball")
|
||||||
ball:setPosition(-7, 7.4, 12)
|
ball:setPosition(-7, 7.4, 12)
|
||||||
ball2 = ball:clone()
|
ball2 = ball:clone()
|
||||||
ball2:setPosition(-7, 7.4, 14)
|
ball2:setPosition(-7, 7.4, 14)
|
||||||
ball3 = ball:clone()
|
ball3 = ball:clone()
|
||||||
ball3:setPosition(-7, 7.4, 16)
|
ball3:setPosition(-7, 7.4, 16)
|
||||||
logo = ag.loadModel("dwlogo", 0.5)
|
logo = ag.loadModel("dwlogo", {scale = 0.5})
|
||||||
logo:setPosition(-1, 2, 11)
|
logo:setPosition(-1, 2, 11)
|
||||||
crate = ag.loadModel("crate")
|
crate = ag.loadModel("crate")
|
||||||
crate:setPosition(-5, -3, 10)
|
crate:setPosition(-5, -3, 10)
|
||||||
|
@ -4,7 +4,7 @@ function init_event()
|
|||||||
|
|
||||||
local rows = 5
|
local rows = 5
|
||||||
local offset = 1
|
local offset = 1
|
||||||
local pin = ag.loadModel("bowling_pin", 0.5)
|
local pin = ag.loadModel("bowling_pin", {scale = 0.5})
|
||||||
pin:setPosition(0, 0, 2)
|
pin:setPosition(0, 0, 2)
|
||||||
for row = 2, rows do
|
for row = 2, rows do
|
||||||
for x = 1, row do
|
for x = 1, row do
|
||||||
@ -21,7 +21,7 @@ function init_event()
|
|||||||
ag.setCamera(0.3, -25, 10, 0, 0, 1, 0, 0, 1)
|
ag.setCamera(0.3, -25, 10, 0, 0, 1, 0, 0, 1)
|
||||||
camx, camy, camz, cx, cy, cz = ag.getCamera()
|
camx, camy, camz, cx, cy, cz = ag.getCamera()
|
||||||
|
|
||||||
ball = ag.loadModel("checkerball", 0.5)
|
ball = ag.loadModel("checkerball", {scale = 0.5})
|
||||||
ball:setPosition(2*camx - cx, 2*camy - cy, 2*camz - cz)
|
ball:setPosition(2*camx - cx, 2*camy - cy, 2*camz - cz)
|
||||||
ball:setMass(5)
|
ball:setMass(5)
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
function init_event()
|
function init_event()
|
||||||
local levels = 7
|
local levels = 7
|
||||||
local crate = ag.loadModel("crate", 0.5)
|
local crate = ag.loadModel("crate", {scale = 0.5})
|
||||||
local offset = 0.5
|
local offset = 0.5
|
||||||
crate:setPosition(0, 0, offset + levels + 0.5)
|
crate:setPosition(0, 0, offset + levels + 0.5)
|
||||||
for level = 2, levels do
|
for level = 2, levels do
|
||||||
@ -12,7 +12,7 @@ function init_event()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local ground = ag.loadModelStatic("crate", 10)
|
local ground = ag.loadModel("crate", { static = true, scale = 10 })
|
||||||
ground:setPosition(0, 0, -10)
|
ground:setPosition(0, 0, -10)
|
||||||
ag.setCamera(levels/2, -2*levels, levels, 0, 0, levels/2, 0, 0, 1)
|
ag.setCamera(levels/2, -2*levels, levels, 0, 0, levels/2, 0, 0, 1)
|
||||||
camx, camy, camz, cx, cy, cz = ag.getCamera()
|
camx, camy, camz, cx, cy, cz = ag.getCamera()
|
||||||
|
@ -3,7 +3,7 @@ function init_event()
|
|||||||
crates = {}
|
crates = {}
|
||||||
|
|
||||||
levels = 5
|
levels = 5
|
||||||
local crate = ag.loadModel("crate", 0.5)
|
local crate = ag.loadModel("crate", {scale=0.5})
|
||||||
crates[1] = crate
|
crates[1] = crate
|
||||||
offset = 0.5
|
offset = 0.5
|
||||||
crate:setPosition(0, 0, offset + levels + 0.5)
|
crate:setPosition(0, 0, offset + levels + 0.5)
|
||||||
@ -18,7 +18,7 @@ function init_event()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
ground = ag.loadModelStatic("crate", 10)
|
ground = ag.loadModel("crate", {static = true, scale = 10})
|
||||||
ground:setPosition(0, 0, -10)
|
ground:setPosition(0, 0, -10)
|
||||||
ag.setCamera(2, -12, 8, 0, 0, 2, 0, 0, 1)
|
ag.setCamera(2, -12, 8, 0, 0, 2, 0, 0, 1)
|
||||||
end
|
end
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
function init_event()
|
function init_event()
|
||||||
ag.import("std")
|
ag.import("std")
|
||||||
image = ag.loadTexture("transparent.png")
|
image = ag.loadTexture("transparent.png")
|
||||||
local crate = ag.loadModelStatic("crate")
|
local crate = ag.loadModel("crate", {static = true})
|
||||||
ag.setCamera(5, -5, 5)
|
ag.setCamera(5, -5, 5)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -25,10 +25,10 @@ function key_down_event(key)
|
|||||||
if (key == "b") then
|
if (key == "b") then
|
||||||
local box = ag.createBox(1, 1, 1)
|
local box = ag.createBox(1, 1, 1)
|
||||||
init_obj(box)
|
init_obj(box)
|
||||||
elseif (key == "c") then
|
-- elseif (key == "c") then
|
||||||
-- cylinders are buggy in ODE
|
-- -- cylinders are buggy in ODE
|
||||||
local cyl = ag.createCylinder(0.5, 1)
|
-- local cyl = ag.createCylinder(0.5, 1)
|
||||||
init_obj(cyl)
|
-- init_obj(cyl)
|
||||||
elseif (key == "a") then
|
elseif (key == "a") then
|
||||||
local ccyl = ag.createCapsule(0.5, 1)
|
local ccyl = ag.createCapsule(0.5, 1)
|
||||||
init_obj(ccyl)
|
init_obj(ccyl)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user