Hello, I've been working on an engine that combines sdl, osg, bullet, open al, and now lua for roughly 6 weeks. Static and dynamic entity creation works well on the fly if handled with C++ code, however if I attempt to off-load this logic to lua, I run into problems. Below is an example of code that is relevant to the problem:
//////////////////////// void entityManager::loadStaticEntityList( const std::string& filename ) { lua_State *L = lua_open(); luabind::open(L); luabind::module( L ) [ luabind::class_<osg::Vec3f>("Vec3f") .def( luabind::constructor< float, float, float >() ) ]; luabind::module( L ) [ luabind::class_<entityManager>("entityManager") .def( luabind::constructor< >() ) .def( "createStaticEntity", &entityManager::createStaticEntity ) .def("destroyAllEntities", &entityManager::destroyAllEntities ) ]; if( luaL_loadfile( L, filename.c_str() ) || lua_pcall( L, 0, 0, 0 ) ) throw "could not load entity list"; createStaticEntity( "ball", osg::Vec3f( 0, 0, 0 ), false ); //direct C++ call; works! luaL_dofile( L, filename.c_str() ); } /////////////////////////// /////////////////////////// void entityManager::createStaticEntity( const std::string& type, const osg::Vec3f& position, const bool& dimension ) { entity * newEntity = createEntityP( type, position, dimension ); _physicsManager->defineRigidBody( newEntity, type, false, dimension ); entities[ newEntity->getRigidBody() ] = newEntity; staticEntities[ dimension ]->addChild( newEntity->getPAT().get() ); staticEntityList.push_back( newEntity ); } /////////////////////////// And here is the lua script I'm trying to run: ------------------------------ entMan = entityManager() a = Vec3f( 0, 0, 0 ) --same call from within lua; crashes the engine if uncommented! entMan:createStaticEntity( "ball", Vec3f( 2, 0, 0 ), false ) ------------------------------ As you can see, a declaration of type Vec3f works from within lua, so I don't think that using Vec3f as a parameter is an issue. Might anyone know what's going on here? I'm not very familiar with luabind, and even less familiar with getting it to play nicely with OSG. Any help would be greatly appreciated. Thanks for your time, Dusten
_______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org