diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2017-07-15 11:35:44 -0400 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2017-07-15 11:35:44 -0400 |
| commit | fa49161fe2d7e0a025c9fd8559815d56dfd1f427 (patch) | |
| tree | cb3a64e2d45ff9f675c256a94f5c1ccb01ec5a09 /src/client/lua_api/scene/imesh.cpp | |
| parent | b98dbac4ed2f755ce71bd9be17f26a3f86c1e3cc (diff) | |
| download | brokengine-fa49161fe2d7e0a025c9fd8559815d56dfd1f427.tar.gz brokengine-fa49161fe2d7e0a025c9fd8559815d56dfd1f427.tar.bz2 brokengine-fa49161fe2d7e0a025c9fd8559815d56dfd1f427.zip | |
Added static physics things
Added some phyics stuff! woo!
* Added physics models from file
* Added physics boxes
* Added a maya camera
* Added lights
* Various refactoring
Diffstat (limited to 'src/client/lua_api/scene/imesh.cpp')
| -rw-r--r-- | src/client/lua_api/scene/imesh.cpp | 90 |
1 files changed, 39 insertions, 51 deletions
diff --git a/src/client/lua_api/scene/imesh.cpp b/src/client/lua_api/scene/imesh.cpp index c95366f..bbb0017 100644 --- a/src/client/lua_api/scene/imesh.cpp +++ b/src/client/lua_api/scene/imesh.cpp @@ -35,58 +35,46 @@ static LISceneNode* checkismesh(lua_State* L){ } */ -//iscenecamera.new(Vector position, Vector lookat, parrent) static int newiscenemesh(lua_State* L){ - printf("Createing mesh!\n"); - int nargs = lua_gettop(L); - if(nargs != 1){ + printf("Createing mesh!\n"); + int nargs = lua_gettop(L); + if(nargs != 1){ printf("Incorrect # of args to create a mesh!"); - } - //The model for the mesh - const char* modelpath = luaL_optstring(L,1,"error"); - - - //Create the mesh - ISceneManager* smgr = device->getSceneManager(); - IAnimatedMesh* amesh = smgr->getMesh(modelpath); - IAnimatedMeshSceneNode* mesh = smgr->addAnimatedMeshSceneNode( amesh ); - printf("Registered the mesh!\n"); - - //Register it's callback - //registerguicallback(llabel,EGET_ELEMENT_HOVERED,iguilabelevent); - - //Create it's lua representation - LISceneNode* lmesh = (LISceneNode*)lua_newuserdata(L, sizeof(LISceneNode)); - int tref = luaL_ref(L,LUA_REGISTRYINDEX); - //iguielements[lcam] = tref; - lua_rawgeti(L,LUA_REGISTRYINDEX,tref);//Put it back on the stack since luaL_ref pops the object. - - //Set it's metatable - luaL_getmetatable(L, "scene.imesh"); - lua_setmetatable(L, -2); - - //Create the struct - lmesh->n = mesh; - lmesh->funcmap = hashmap_new(); - lmesh->type = "imesh"; - - //Free up anything made in this function - //free(label); - - //Put it on top and return it - lua_rawgeti(L,LUA_REGISTRYINDEX,tref); - return 1; -} - -/*mesh:setmaterial("string",layernum=0)*/ -static int setmaterial(lua_State* L){ - LISceneNode* n = checkismesh(L,1); - //u32 layernum = luaL_optint(L,3,0); - const char* matfile = luaL_optstring(L,2,"error.png"); - printf("Setting material on a %s",n->type); - IVideoDriver* driver = device->getVideoDriver(); - n->n->setMaterialTexture( 0, driver->getTexture(matfile) ); - return 0; + } + //The model for the mesh + const char* modelpath = luaL_optstring(L,1,"error"); + + //Create the mesh + ISceneManager* smgr = device->getSceneManager(); + IAnimatedMesh* amesh = smgr->getMesh(modelpath); + IAnimatedMeshSceneNode* mesh = smgr->addAnimatedMeshSceneNode( amesh ); + mesh->setMaterialFlag(EMF_GOURAUD_SHADING,true); + printf("Registered the mesh!\n"); + + //Register it's callback + //registerguicallback(llabel,EGET_ELEMENT_HOVERED,iguilabelevent); + + //Create it's lua representation + LISceneNode* lmesh = (LISceneNode*)lua_newuserdata(L, sizeof(LISceneNode)); + int tref = luaL_ref(L,LUA_REGISTRYINDEX); + //iguielements[lcam] = tref; + lua_rawgeti(L,LUA_REGISTRYINDEX,tref);//Put it back on the stack since luaL_ref pops the object. + + //Set it's metatable + luaL_getmetatable(L, "scene.imesh"); + lua_setmetatable(L, -2); + + //Create the struct + lmesh->n = mesh; + lmesh->funcmap = hashmap_new(); + lmesh->type = "imesh"; + + //Free up anything made in this function + //free(label); + + //Put it on top and return it + lua_rawgeti(L,LUA_REGISTRYINDEX,tref); + return 1; } static const luaL_reg imesh_f[] = { @@ -97,7 +85,7 @@ static const luaL_reg imesh_f[] = { }; static const luaL_reg imesh_m[] = { - {"setMaterial", setmaterial}, + {"setMaterial", iscenesetmaterial}, {"getpos", iscenegetpos}, {"setpos", iscenesetpos}, // {"settext", setiguitext}, |
