Hi All.
I use Lua binding for scripting game levels.
Thats example:
// LUA binders
void ScriptBinderPushData(void*);
void* ScriptBinderPopData();
void BindToLua()
{
// set body_def and shape_def structures data
b2BodyDef body_def;
b2ShapeDef shape_def;
// create body and shape
b2Body* src_body = CreateBody(&body_def);
CreateShape(&shape_def);
// push b2Body object pointer to script mashine
LuaBinderPushData(src_body);
}
void FromLuaBinder()
{
// get b2Body object pointer from script mashine
b2Body* src_body = NULL;
src_body = (b2Body*)LuaBinderPopData();
// To create body clone need b2BodyDef and b2ShapeDef objects.
b2BodyDef unknownBodyDef;
b2ShapeDef unknownShapeDef;
//
// Here i need to set unknownBodyDef and unknownShapeDef structures same as src_body object has;
// How to do this ?
//
b2Body* body_clone = CreateBody(&unknownBodyDef);
b2Shape* shape_clone = CreateShape(&nknownShapeDef);
}
So I has only b2Shape and b2Body object pointers (and not b2ShapeDef and b2BodyDef items). And how to create b2Shape and b2Body objects copies?
Thanks!
I use Lua binding for scripting game levels.
Thats example:
Code:
// LUA binders
void ScriptBinderPushData(void*);
void* ScriptBinderPopData();
void BindToLua()
{
// set body_def and shape_def structures data
b2BodyDef body_def;
b2ShapeDef shape_def;
// create body and shape
b2Body* src_body = CreateBody(&body_def);
CreateShape(&shape_def);
// push b2Body object pointer to script mashine
LuaBinderPushData(src_body);
}
void FromLuaBinder()
{
// get b2Body object pointer from script mashine
b2Body* src_body = NULL;
src_body = (b2Body*)LuaBinderPopData();
// To create body clone need b2BodyDef and b2ShapeDef objects.
b2BodyDef unknownBodyDef;
b2ShapeDef unknownShapeDef;
//
// Here i need to set unknownBodyDef and unknownShapeDef structures same as src_body object has;
// How to do this ?
//
b2Body* body_clone = CreateBody(&unknownBodyDef);
b2Shape* shape_clone = CreateShape(&nknownShapeDef);
}
So I has only b2Shape and b2Body object pointers (and not b2ShapeDef and b2BodyDef items). And how to create b2Shape and b2Body objects copies?
Thanks!