aboutsummaryrefslogtreecommitdiff
path: root/src/client/lua_api/scene/imesh.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/lua_api/scene/imesh.cpp')
-rw-r--r--src/client/lua_api/scene/imesh.cpp90
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},