diff options
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/callbackhandeler.cpp | 2 | ||||
| -rw-r--r-- | src/client/initdevice.cpp | 2 | ||||
| -rw-r--r-- | src/client/lua_api/gui/iguielement.cpp | 27 | ||||
| -rw-r--r-- | src/client/lua_api/load_gui.cpp | 42 | ||||
| -rw-r--r-- | src/client/lua_api/load_video.cpp | 2 | ||||
| -rw-r--r-- | src/client/lua_api/phys/cbphysbox.cpp | 12 | ||||
| -rw-r--r-- | src/client/lua_api/phys/cbphysmodel.cpp | 281 | ||||
| -rw-r--r-- | src/client/lua_api/scene/imesh.cpp | 3 | ||||
| -rw-r--r-- | src/client/main.cpp | 3 |
9 files changed, 224 insertions, 150 deletions
diff --git a/src/client/callbackhandeler.cpp b/src/client/callbackhandeler.cpp index 3b069a4..0f1f87f 100644 --- a/src/client/callbackhandeler.cpp +++ b/src/client/callbackhandeler.cpp @@ -68,7 +68,7 @@ bool GlobalEventReceiver::OnEvent(const SEvent& e){ //lua_State* L = this->L; EEVENT_TYPE type = e.EventType; SEvent::SMouseInput se = e.MouseInput; - printf("Onevent called:%d\n",(int)type); + //printf("Onevent called:%d\n",(int)type); switch (type){ case EET_GUI_EVENT:{ //printf("Gui event\n"); diff --git a/src/client/initdevice.cpp b/src/client/initdevice.cpp index c7535a0..3720d49 100644 --- a/src/client/initdevice.cpp +++ b/src/client/initdevice.cpp @@ -96,8 +96,6 @@ void parseSetting(const char* settingname, lua_State* L, settings* set){ set->driver = EDT_SOFTWARE; }else if(strcmp(dts,"BURNINGS") == 0){ set->driver = EDT_BURNINGSVIDEO; - }else if(strcmp(dts,"D3D8") == 0){ - set->driver = EDT_DIRECT3D8; }else if(strcmp(dts,"D3D9") == 0){ set->driver = EDT_DIRECT3D9; }else if(strcmp(dts,"OPENGL") == 0){ diff --git a/src/client/lua_api/gui/iguielement.cpp b/src/client/lua_api/gui/iguielement.cpp index 9254ba0..db7669a 100644 --- a/src/client/lua_api/gui/iguielement.cpp +++ b/src/client/lua_api/gui/iguielement.cpp @@ -236,6 +236,31 @@ int getelementenabled(lua_State *L){ return 1; } +//{guielement},{guielement} +int sendtofront(lua_State *L){ + lua_getfield(L,-1,"guielement"); + IGUIElement *ele = (IGUIElement*)lua_touserdata(L,-1); + lua_pop(L,2);//{guielement} + + lua_getfield(L,-1,"guielement"); + IGUIElement *ele2 = (IGUIElement*)lua_touserdata(L,-1); + lua_pop(L,2);// + ele->bringToFront(ele2); + return 0; +} + +//{guielement},{guielement} +int sendtoback(lua_State *L){ + lua_getfield(L,-1,"guielement"); + IGUIElement *ele = (IGUIElement*)lua_touserdata(L,-1); + lua_pop(L,2);//{guielement} + + lua_getfield(L,-1,"guielement"); + IGUIElement *ele2 = (IGUIElement*)lua_touserdata(L,-1); + lua_pop(L,2);// + ele->sendToBack(ele2); + return 0; +} class guicallback{ private: @@ -291,5 +316,7 @@ extern const luaL_reg iguielement_m[] = { {"remove", removeiguielement}, {"focus", focus}, {"enable", setelementenabled}, + {"sendfront", sendtofront}, + {"sendback", sendtoback}, {NULL, NULL} }; diff --git a/src/client/lua_api/load_gui.cpp b/src/client/lua_api/load_gui.cpp index 845661a..64b9711 100644 --- a/src/client/lua_api/load_gui.cpp +++ b/src/client/lua_api/load_gui.cpp @@ -25,6 +25,7 @@ extern "C" { #include "gui/iguispinbox.hpp" #include "gui/iguitreeview.hpp" #include "gui/iguicombobox.hpp" +#include "gui/iguielement.hpp" #include "../callbackhandeler.hpp" #include "guiparts.hpp" @@ -43,6 +44,7 @@ lua_State* tL; int screenwidth(lua_State* L); int screenheight(lua_State* L); +int getroot(lua_State *L); /*** @function gui.scrw() @@ -72,7 +74,12 @@ void load_guifuncs(lua_State* L){ //Various enums lua_newtable(L); + + lua_pushcfunction(L,getroot); + lua_setfield(L,-2,"getroot"); + lua_setglobal(L,"gui"); + iguilabel_register(L); iguicheckbox_register(L); iguiwindow_register(L,device); @@ -90,19 +97,38 @@ void load_guifuncs(lua_State* L){ lua_pushcfunction(L,screenheight); lua_setglobal(L,"scrh"); + + luaL_newmetatable(L, "gui.iguielement");//{m_iguielement} + lua_newtable(L);//{m_iguibutton},{} + luaL_register(L,NULL,iguielement_m); + lua_setfield(L,-2,"__index");//{m_iguielement} + lua_pop(L,1); + } int screenheight(lua_State* L){ - core::rect<s32> dim = guidevice->getGUIEnvironment()->getRootGUIElement()->getAbsoluteClippingRect(); - lua_pushnumber(L,dim.getHeight()); - //printf("Got screen height:%d\n",dim.getWidth()); - return 1; + core::rect<s32> dim = guidevice->getGUIEnvironment()->getRootGUIElement()->getAbsoluteClippingRect(); + lua_pushnumber(L,dim.getHeight()); + //printf("Got screen height:%d\n",dim.getWidth()); + return 1; } int screenwidth(lua_State* L){ - core::rect<s32> dim = guidevice->getGUIEnvironment()->getRootGUIElement()->getAbsoluteClippingRect(); - lua_pushnumber(L,dim.getWidth()); - //printf("Got screen width:%d\n",dim.getWidth()); - return 1; + core::rect<s32> dim = guidevice->getGUIEnvironment()->getRootGUIElement()->getAbsoluteClippingRect(); + lua_pushnumber(L,dim.getWidth()); + //printf("Got screen width:%d\n",dim.getWidth()); + return 1; +} + +//Get the root gui element +int getroot(lua_State* L){ + IGUIElement *ele = device->getGUIEnvironment()->getRootGUIElement(); + lua_newtable(L);//{} + lua_pushlightuserdata(L,ele);//{},ud_iguibutton + lua_setfield(L,-2,"guielement");//{guielement} + luaL_getmetatable(L,"gui.iguielement");//{guielement},{m_iguibutton} + lua_setmetatable(L,-2);//{guielement} + + return 1; } diff --git a/src/client/lua_api/load_video.cpp b/src/client/lua_api/load_video.cpp index e0c7557..f309180 100644 --- a/src/client/lua_api/load_video.cpp +++ b/src/client/lua_api/load_video.cpp @@ -74,7 +74,7 @@ int draw2dline(lua_State* L){ popvector2i(L,&ex,&ey); popvector2i(L,&sx,&sy); - driver->draw2DLine(position2d<s32>(sx,sy),position2d<s32>(ex,ey),SColor(r,g,b,a)); + driver->draw2DLine(position2d<s32>(sx,sy),position2d<s32>(ex,ey),SColor(a,r,g,b)); return 0; } diff --git a/src/client/lua_api/phys/cbphysbox.cpp b/src/client/lua_api/phys/cbphysbox.cpp index c5aacd8..3c0f97d 100644 --- a/src/client/lua_api/phys/cbphysbox.cpp +++ b/src/client/lua_api/phys/cbphysbox.cpp @@ -51,15 +51,25 @@ static int newcbphysbox(lua_State* L){// pushvector3d(L,x,y,z);//{v3 size},{v3 origin} makenewiscenecube(L);//ud_iscenenode ISceneNode* n = (ISceneNode*)lua_touserdata(L,-1);//ud_iscenenode - lua_pop(L,1); + lua_pop(L,1);// r->setUserPointer(n); lua_newtable(L);//{} + lua_pushlightuserdata(L,r);//{},ud_rigidbody lua_setfield(L,-2,"collider");//{} + lua_pushstring(L,"rigidbody");//{},"rigidbody" + lua_setfield(L,-2,"type");//{} lua_pushlightuserdata(L,n);//{},ud_iscenenode lua_setfield(L,-2,"node");//{} + + lua_getglobal(L,"phys");//{rb},{phys} + lua_getfield(L,-1,"colliders");//{rb},{phys},{phys.colliders} + lua_pushlightuserdata(L,r);//{rb},{phys},{colliders},ud_rb + lua_pushvalue(L,-4);//{rb},{phys},{colliders},ud_rb,{rb} + lua_settable(L,-3);//{rb},{phys},{phys.colliders} + lua_pop(L,2);//{rb} luaL_getmetatable(L,"phys.physbox");//{},{phys.physbox} lua_setmetatable(L,-2);//{} diff --git a/src/client/lua_api/phys/cbphysmodel.cpp b/src/client/lua_api/phys/cbphysmodel.cpp index 4f4c106..ac27288 100644 --- a/src/client/lua_api/phys/cbphysmodel.cpp +++ b/src/client/lua_api/phys/cbphysmodel.cpp @@ -19,6 +19,7 @@ extern "C" { #include <client/lua_api/scene/igeneric.hpp> #include <shared/lua_api/phys/bphysmodel.hpp> #include <shared/lua_api/phys/bcollider.hpp> +#include <shared/lua_api/phys/bphysgeneric.hpp> #include <shared/lua_api/common.hpp> #include <shared/util/tinyobj.hpp> @@ -65,141 +66,148 @@ static int newbphysmodel(lua_State* L){ //Create the scene node //IMeshBuffer *buf = new CDynamicMeshBuffer(E_VERTEX_TYPE::EVT_STANDARD,E_INDEX_TYPE::EIT_16BIT); - IMeshBuffer *buf = new SMeshBuffer(); - tinyobj_attrib_t attrib; - printf("At the very beginning, attrib is %p\n",(void*)&attrib); - tinyobj_shape_t *shapes = NULL; - size_t meshcount; - tinyobj_material_t *materials = NULL; - size_t num_materials; - - //Read data from the graphics file - size_t data_len = 0; - FILE *objfile = fopen(gpath,"rb"); - fseek(objfile,0,SEEK_END); - data_len = ftell(objfile); - printf("model data is %d long\n",(int)data_len); - fseek(objfile,0,SEEK_SET); - char *objdata = (char*)malloc(sizeof(char)*data_len); - fread(objdata, sizeof(char), data_len, objfile); - fclose(objfile); - - //Parse the data into a tinyobj - printf("About to tinyobj_parse_obj\n"); - int err = tinyobj_parse_obj(&attrib, &shapes, &meshcount, &materials, &num_materials, objdata, data_len, TINYOBJ_FLAG_TRIANGULATE); - free(objdata); - - //int err = tinyobj_parse_obj(&attrib, &shapes, &meshcount, &materials, &num_materials, objdata, data_len, 0); - if(err != TINYOBJ_SUCCESS){ - printf("Tinyobj failed to load model:%s\n",ppath); - } - printf("num_shapes: %d\n",(int)meshcount); - for(size_t i = 0; i < meshcount; i++){ - tinyobj_shape_t shape = shapes[i]; - printf("Shape %d:\n\tname: %s\n\tface_offset: %d\n\tlength: %d\n",(int)i, shape.name, shape.face_offset, shape.length); - } - //u32 meshcount = pmesh->getMeshBufferCount(); - //size_t numverts = attrib.num_vertices; - //size_t stride = 9; //9 = 3 position floats + 3 normal floats + 3 color floats - //size_t face_offset = 0; - printf("Obj attrib:\n\tnum_vertices:%d\n\tnum_normals:%d\n\tnum_texcoords:%d\n\tnum_faces:%d\n\tnum_face_num_verts:%d\n", - attrib.num_vertices, attrib.num_normals, attrib.num_texcoords, attrib.num_faces, attrib.num_face_num_verts); - //S3DVertex verts[attrib.num_faces]; - //for(size_t i = 0; i < attrib.num_face_num_verts; i++){ - //printf("verts %d starts at %p\n",(int)i,(void*)&(verts[i])); + //IMeshBuffer *buf = new SMeshBuffer(); + //tinyobj_attrib_t attrib; + //printf("At the very beginning, attrib is %p\n",(void*)&attrib); + //tinyobj_shape_t *shapes = NULL; + //size_t meshcount; + //tinyobj_material_t *materials = NULL; + //size_t num_materials; + + ////Read data from the graphics file + //size_t data_len = 0; + //FILE *objfile = fopen(gpath,"rb"); + //fseek(objfile,0,SEEK_END); + //data_len = ftell(objfile); + //printf("model data is %d long\n",(int)data_len); + //fseek(objfile,0,SEEK_SET); + //char *objdata = (char*)malloc(sizeof(char)*data_len); + //fread(objdata, sizeof(char), data_len, objfile); + //fclose(objfile); + + ////Parse the data into a tinyobj + //printf("About to tinyobj_parse_obj\n"); + //int err = tinyobj_parse_obj(&attrib, &shapes, &meshcount, &materials, &num_materials, objdata, data_len, TINYOBJ_FLAG_TRIANGULATE); + //free(objdata); + + ////int err = tinyobj_parse_obj(&attrib, &shapes, &meshcount, &materials, &num_materials, objdata, data_len, 0); + //if(err != TINYOBJ_SUCCESS){ + //printf("Tinyobj failed to load model:%s\n",ppath); //} - //u16 indicies[attrib.num_faces]; - size_t index_c = 0; - printf("Faces for %d verts:\n",attrib.num_face_num_verts); - //int num_faces = attrib.num_faces; - //for(int i = 0; i < num_faces; i+=3){ - ////printf("\t%u verts in face %u\n",attrib.face_num_verts[i],i); - //tinyobj_vertex_index_t fac1 = attrib.faces[i + 0]; - //tinyobj_vertex_index_t fac2 = attrib.faces[i + 1]; - //tinyobj_vertex_index_t fac3 = attrib.faces[i + 2]; - ////printf("Verts:\n\tPosition, normal, texture\n\t(%8d %7d %7d)\n\t(%8d %7d %7d)\n\t(%8d %7d %7d)\n",fac1.v_idx,fac1.vn_idx,fac1.vt_idx,fac2.v_idx,fac2.vn_idx,fac2.vt_idx,fac3.v_idx,fac3.vn_idx,fac3.vt_idx); - - //float f1px, f1py, f1pz; - //f1px = attrib.vertices[(3 * fac1.v_idx) + 0]; - //f1py = attrib.vertices[(3 * fac1.v_idx) + 1]; - //f1pz = attrib.vertices[(3 * fac1.v_idx) + 2]; - //float f1nx, f1ny, f1nz; - //f1nx = attrib.normals[(3 * fac1.vn_idx) + 0]; - //f1ny = attrib.normals[(3 * fac1.vn_idx) + 1]; - //f1nz = attrib.normals[(3 * fac1.vn_idx) + 2]; - - //float f2px, f2py, f2pz; - //f2px = attrib.vertices[(3 * fac2.v_idx) + 0]; - //f2py = attrib.vertices[(3 * fac2.v_idx) + 1]; - //f2pz = attrib.vertices[(3 * fac2.v_idx) + 2]; - //float f2nx, f2ny, f2nz; - //f2nx = attrib.normals[(3 * fac2.vn_idx) + 0]; - //f2ny = attrib.normals[(3 * fac2.vn_idx) + 1]; - //f2nz = attrib.normals[(3 * fac2.vn_idx) + 2]; - - //float f3px, f3py, f3pz; - //f3px = attrib.vertices[(3 * fac3.v_idx) + 0]; - //f3py = attrib.vertices[(3 * fac3.v_idx) + 1]; - //f3pz = attrib.vertices[(3 * fac3.v_idx) + 2]; - //float f3nx, f3ny, f3nz; - //f3nx = attrib.normals[(3 * fac3.vn_idx) + 0]; - //f3ny = attrib.normals[(3 * fac3.vn_idx) + 1]; - //f3nz = attrib.normals[(3 * fac3.vn_idx) + 2]; - - /*printf("Triangle %d:\n\t\ - //Positions:\n\t\t\ - //(%f %f %f)\n\t\t\ - //(%f %f %f)\n\t\t\ - //(%f %f %f)\n\t\ - //Normals:\n\t\t\ - //(%f %f %f)\n\t\t\ - //(%f %f %f)\n\t\t\ - //(%f %f %f)\n",((int)i)/3,f1px,f1py,f1pz,f2px,f2py,f2pz,f3px,f3py,f3pz,f1nx,f1ny,f1nz,f2nx,f2ny,f2nz,f3nx,f3ny,f3nz); + //printf("num_shapes: %d\n",(int)meshcount); + //for(size_t i = 0; i < meshcount-1; i++){// 0 - meshcount, so -1 + //tinyobj_shape_t shape = shapes[i]; + //printf("Shape %d:\n\tname: %s\n\tface_offset: %d\n\tlength: %d\n",(int)i, shape.name, shape.face_offset, shape.length); + //} + ////u32 meshcount = pmesh->getMeshBufferCount(); + ////size_t numverts = attrib.num_vertices; + ////size_t stride = 9; //9 = 3 position floats + 3 normal floats + 3 color floats + ////size_t face_offset = 0; + //printf("Obj attrib:\n\tnum_vertices:%d\n\tnum_normals:%d\n\tnum_texcoords:%d\n\tnum_faces:%d\n\tnum_face_num_verts:%d\n", + //attrib.num_vertices, attrib.num_normals, attrib.num_texcoords, attrib.num_faces, attrib.num_face_num_verts); + ////S3DVertex verts[attrib.num_faces]; + ////for(size_t i = 0; i < attrib.num_face_num_verts; i++){ + ////printf("verts %d starts at %p\n",(int)i,(void*)&(verts[i])); + ////} + ////u16 indicies[attrib.num_faces]; + //size_t index_c = 0; + //printf("Faces for %d verts:\n",attrib.num_face_num_verts); + ////int num_faces = attrib.num_faces; + ////for(int i = 0; i < num_faces; i+=3){ + //////printf("\t%u verts in face %u\n",attrib.face_num_verts[i],i); + ////tinyobj_vertex_index_t fac1 = attrib.faces[i + 0]; + ////tinyobj_vertex_index_t fac2 = attrib.faces[i + 1]; + ////tinyobj_vertex_index_t fac3 = attrib.faces[i + 2]; + //////printf("Verts:\n\tPosition, normal, texture\n\t(%8d %7d %7d)\n\t(%8d %7d %7d)\n\t(%8d %7d %7d)\n",fac1.v_idx,fac1.vn_idx,fac1.vt_idx,fac2.v_idx,fac2.vn_idx,fac2.vt_idx,fac3.v_idx,fac3.vn_idx,fac3.vt_idx); + + ////float f1px, f1py, f1pz; + ////f1px = attrib.vertices[(3 * fac1.v_idx) + 0]; + ////f1py = attrib.vertices[(3 * fac1.v_idx) + 1]; + ////f1pz = attrib.vertices[(3 * fac1.v_idx) + 2]; + ////float f1nx, f1ny, f1nz; + ////f1nx = attrib.normals[(3 * fac1.vn_idx) + 0]; + ////f1ny = attrib.normals[(3 * fac1.vn_idx) + 1]; + ////f1nz = attrib.normals[(3 * fac1.vn_idx) + 2]; + + ////float f2px, f2py, f2pz; + ////f2px = attrib.vertices[(3 * fac2.v_idx) + 0]; + ////f2py = attrib.vertices[(3 * fac2.v_idx) + 1]; + ////f2pz = attrib.vertices[(3 * fac2.v_idx) + 2]; + ////float f2nx, f2ny, f2nz; + ////f2nx = attrib.normals[(3 * fac2.vn_idx) + 0]; + ////f2ny = attrib.normals[(3 * fac2.vn_idx) + 1]; + ////f2nz = attrib.normals[(3 * fac2.vn_idx) + 2]; + + ////float f3px, f3py, f3pz; + ////f3px = attrib.vertices[(3 * fac3.v_idx) + 0]; + ////f3py = attrib.vertices[(3 * fac3.v_idx) + 1]; + ////f3pz = attrib.vertices[(3 * fac3.v_idx) + 2]; + ////float f3nx, f3ny, f3nz; + ////f3nx = attrib.normals[(3 * fac3.vn_idx) + 0]; + ////f3ny = attrib.normals[(3 * fac3.vn_idx) + 1]; + ////f3nz = attrib.normals[(3 * fac3.vn_idx) + 2]; + /* + //printf("Triangle %d:\n\t\ + ////Positions:\n\t\t\ + ////(%f %f %f)\n\t\t\ + ////(%f %f %f)\n\t\t\ + ////(%f %f %f)\n\t\ + ////Normals:\n\t\t\ + ////(%f %f %f)\n\t\t\ + ////(%f %f %f)\n\t\t\ + ////(%f %f %f)\n",((int)i)/3,f1px,f1py,f1pz,f2px,f2py,f2pz,f3px,f3py,f3pz,f1nx,f1ny,f1nz,f2nx,f2ny,f2nz,f3nx,f3ny,f3nz); */ - ////float - - //verts[i + 0] = S3DVertex(f1px,f1py,f1pz,f1nx,f1ny,f1nz,SColor(255,255,255,255),0,0); - //verts[i + 1] = S3DVertex(f2px,f2py,f2pz,f2nx,f2ny,f2nz,SColor(255,255,255,255),0,0); - //verts[i + 2] = S3DVertex(f3px,f3py,f3pz,f3nx,f3ny,f3nz,SColor(255,255,255,255),0,0); - //indicies[index_c] = i; - //index_c++; - //indicies[index_c] = i + 1; - //index_c++; - //indicies[index_c] = i + 2; - //index_c++; + //////float + + ////verts[i + 0] = S3DVertex(f1px,f1py,f1pz,f1nx,f1ny,f1nz,SColor(255,255,255,255),0,0); + ////verts[i + 1] = S3DVertex(f2px,f2py,f2pz,f2nx,f2ny,f2nz,SColor(255,255,255,255),0,0); + ////verts[i + 2] = S3DVertex(f3px,f3py,f3pz,f3nx,f3ny,f3nz,SColor(255,255,255,255),0,0); + ////indicies[index_c] = i; + ////index_c++; + ////indicies[index_c] = i + 1; + ////index_c++; + ////indicies[index_c] = i + 2; + ////index_c++; + ////} + //S3DVertex verts[attrib.num_vertices]; + ////S3DVertex real_verts[attrib.num_faces]; + //u16 indicies[attrib.num_faces]; + //for(size_t i = 0; i < attrib.num_vertices - 1; i++){ //0 - num_vertices, so -1 + //float x,y,z; + //x = attrib.vertices[(i * 3) + 0]; + //y = attrib.vertices[(i * 3) + 1]; + //z = attrib.vertices[(i * 3) + 2]; + //__mingw_printf("Vertex number %llu: (%3f, %3f, %3f)\n",i,x,y,z); + //verts[i] = S3DVertex(x,y,z,0,0,0,SColor(255,255,255,255),0,0); //} - S3DVertex verts[attrib.num_vertices]; - u16 indicies[attrib.num_faces]; - for(size_t i = 0; i < attrib.num_vertices; i++){ - float x,y,z; - x = attrib.vertices[i * 3]; - y = attrib.vertices[(i * 3) + 1]; - z = attrib.vertices[(i * 3) + 2]; - verts[i] = S3DVertex(x,y,z,0,0,0,SColor(255,255,255,255),0,0); - } - for(size_t i = 0; i < attrib.num_faces; i ++){ - indicies[i] = attrib.faces[i].v_idx; - } - printf("indicies:\n"); - for(size_t i = 0; i < index_c; i++){ - printf("%d ",indicies[i]); - } - printf("\n"); + //for(size_t i = 0; i < attrib.num_face_vertices; i++){ - //for(size_t i = 0; i < attrib.num_faces; i++){ - //tinyobj_vertex_index_t tface = attrib.faces[i]; - //printf("Looking at face %d: %d %d %d\n", (int)i, (int)tface.v_idx, (int)tface.vt_idx, (int)tface.vn_idx); - //indicies[index_c] = (u16)tface.v_idx; - //index_c++; //} - buf->append(verts, attrib.num_vertices, indicies, (u32)attrib.num_faces); - //buf->recalculateBoundingBox(); - SMesh *gmesh = new SMesh(); - gmesh->addMeshBuffer(buf); - //gmesh->recalculateBoundingBox(); - //gmesh->setDirty(); - - //IMesh *gmesh = smgr->getMesh(gpath); + //for(size_t i = 0; i < attrib.num_faces - 1; i ++){// 0 - num_faces, so -1 + //__mingw_printf("Found index: %llu: %3d\n",i,attrib.faces[i].v_idx); + ////real_verts[i] + //indicies[i] = attrib.faces[i].v_idx; + //} + //printf("indicies:\n"); + //for(size_t i = 0; i < index_c; i++){ + //printf("%d ",indicies[i]); + //} + //printf("\n"); + + ////for(size_t i = 0; i < attrib.num_faces; i++){ + ////tinyobj_vertex_index_t tface = attrib.faces[i]; + ////printf("Looking at face %d: %d %d %d\n", (int)i, (int)tface.v_idx, (int)tface.vt_idx, (int)tface.vn_idx); + ////indicies[index_c] = (u16)tface.v_idx; + ////index_c++; + ////} + //buf->append(verts, attrib.num_vertices, indicies, (u32)attrib.num_faces); + ////buf->recalculateBoundingBox(); + //SMesh *gmesh = new SMesh(); + //gmesh->addMeshBuffer(buf); + ////gmesh->recalculateBoundingBox(); + ////gmesh->setDirty(); + + IMesh *gmesh = smgr->getMesh(gpath); printf("Creating client physbox at %f %f %f\n",x,y,z); ISceneNode *node = smgr->addMeshSceneNode(gmesh,0,-1,vector3df(x,y,z)); @@ -253,14 +261,15 @@ static const luaL_reg bphysmodel_m[] = { }; int cbphysmodel_register(lua_State* L){ - //printf("bphysmodel registered\n"); + bphysmodel_register(L); - luaL_newmetatable(L, "phys.physmodel");//{} - lua_newtable(L);//{physmodel_m},{} + luaL_getmetatable(L,"phys.physmodel");//{physmodel_m} + lua_getfield(L,-1,"__index");//{physmodel_m},{} luaL_register(L,NULL,igeneric_m); //Inherit all the things to do with scene nodes - luaL_register(L,NULL,bcollider_m); - luaL_register(L,NULL,bphysmodel_m); - lua_setfield(L,-2,"__index"); + luaL_register(L,NULL,bcollider_m);//Override things to do with physics + luaL_register(L,NULL,brigidbody_m);//Add rigidbody things + luaL_register(L,NULL,bphysmodel_m);//anything specific? + lua_pop(L,2); lua_getglobal(L,"phys"); luaL_register(L,NULL,bphysmodel_f); diff --git a/src/client/lua_api/scene/imesh.cpp b/src/client/lua_api/scene/imesh.cpp index 7a72edf..8ed357c 100644 --- a/src/client/lua_api/scene/imesh.cpp +++ b/src/client/lua_api/scene/imesh.cpp @@ -62,7 +62,8 @@ void makenewiscenecube(lua_State* L){ popvector3d(L,&x,&y,&z);//{v3 size} double sx,sy,sz; popvector3d(L,&sx,&sy,&sz);//{} - IMeshSceneNode* n = device->getSceneManager()->addCubeSceneNode(1,0,-1,core::vector3df(x,y,z),core::vector3df(0,0,0),core::vector3df(sx,sy,sz)); + printf("Makeing new iscenecube, size %f %f %f, origin %f %f %f\n", sx,sy,sz,x,y,z); + ISceneNode* n = device->getSceneManager()->addCubeSceneNode(1,0,-1,core::vector3df(x,y,z),core::vector3df(0,0,0),core::vector3df(sx,sy,sz)); lua_pushlightuserdata(L,n); } diff --git a/src/client/main.cpp b/src/client/main.cpp index 0a82e99..f08862c 100644 --- a/src/client/main.cpp +++ b/src/client/main.cpp @@ -27,6 +27,7 @@ extern "C" { #include <shared/lua_api/common.hpp> #include "../shared/lua_api/load_net.hpp" #include "../shared/phys/physcommon.hpp" +#include "../shared/lua_api/load_common.hpp" using namespace irr; using namespace core; @@ -104,6 +105,7 @@ void UpdateElement(btCollisionObject* obj){ btTransform transform = obj->getWorldTransform(); btVector3 pos = transform.getOrigin(); node->setPosition(core::vector3df((f32)pos[0], (f32)pos[1], (f32)pos[2])); + //printf("Setting new position to %f %f %f\n", pos[0], pos[1], pos[2]); //Set rotation btQuaternion rot = transform.getRotation(); @@ -153,6 +155,7 @@ int main(int argc, char *argv[]){ luaL_openlibs(state); loadIrrLibs(state,device); loadNetLibs(state); + loadCommonLibs(state); printf("Loadded irr libs...\n"); //Sets the global event handeler printf("Creating event receiver\n"); |
