aboutsummaryrefslogtreecommitdiff
path: root/src/shared/lua_api/phys/bphysmodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/lua_api/phys/bphysmodel.cpp')
-rw-r--r--src/shared/lua_api/phys/bphysmodel.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/shared/lua_api/phys/bphysmodel.cpp b/src/shared/lua_api/phys/bphysmodel.cpp
index 0c8e3bf..375d68b 100644
--- a/src/shared/lua_api/phys/bphysmodel.cpp
+++ b/src/shared/lua_api/phys/bphysmodel.cpp
@@ -24,6 +24,10 @@ extern "C" {
extern btDiscreteDynamicsWorld* World;
extern std::list<btRigidBody*> Objects;
+//btRigidBody* load_obj(tinyobj_attrib_t attrib, tinyobj_shape_t *shapes, size_t num){
+ //btTriangleMesh *trimesh = new btTriangleMesh();
+//}
+
//TODO: This will break in the future, see github.com/syoyo/tinyobjloader-c/issues/16
//"physicfile",mass[,position][,lookat] :: ud_rigidbody
void makebphysmodel(lua_State *L){
@@ -67,6 +71,9 @@ void makebphysmodel(lua_State *L){
if(err != TINYOBJ_SUCCESS){
printf("Tinyobj failed to load model:%s\n",ppath);
}
+ //for(size_t s = 0; s < meshcount; s++){
+ //btRigidBody *rb = load_obj(attrib,shapes,s);
+ //}
//u32 meshcount = pmesh->getMeshBufferCount();
//__mingw_printf("attrib.num_vertices: %u\n",attrib.num_vertices);
//__mingw_printf("attrib.num_faces: %u\n",attrib.num_faces);
@@ -81,7 +88,7 @@ void makebphysmodel(lua_State *L){
float v2 = vs[1];
float v3 = vs[2];
vertexes[i] = btVector3(v1,v2,v3);
- printf("Adding vertex %lld at (%f,%f,%f)\n",i,v1,v2,v3);
+ //printf("Adding vertex %lld at (%f,%f,%f)\n",i,v1,v2,v3);
}
//printf("Finished finding or adding vertexes\n");
for(size_t i = 0; i < attrib.num_faces - 1; i+= 3){ //0 - y to num_faces - 1
@@ -94,14 +101,14 @@ void makebphysmodel(lua_State *L){
v2 = vertexes[i2.v_idx];
v3 = vertexes[i3.v_idx];
trimesh->addTriangle(vertexes[i1.v_idx],vertexes[i2.v_idx],vertexes[i3.v_idx],false);//Some triangles are "the wrong way round",
- printf("Adding triangle:(%d,%d,%d)\n",i1.v_idx,i2.v_idx,i3.v_idx);
- //trimesh->addTriangle(vertexes[i3.v_idx],vertexes[i2.v_idx],vertexes[i1.v_idx],true);//double-side all triangles
+ //printf("Adding triangle:(%d,%d,%d)\n",i1.v_idx,i2.v_idx,i3.v_idx);
+ trimesh->addTriangle(vertexes[i3.v_idx],vertexes[i2.v_idx],vertexes[i1.v_idx],true);//double-side all triangles
}
//printf("Finished adding triangle indicies\n");
//printf("Done building trimesh\n");
- //btGImpactShapeInterface *shape = new btGImpactMeshShape(trimesh);
- btConvexTriangleMeshShape *shape = new btConvexTriangleMeshShape(trimesh);
- //shape->updateBound();
+ //btConvexTriangleMeshShape *shape = new btConvexTriangleMeshShape(trimesh);
+ btGImpactShapeInterface *shape = new btGImpactMeshShape(trimesh);
+ shape->updateBound();
//btCollisionShape *shape = new btBvhTriangleMeshShape(trimesh,true);
btTransform tr;
tr.setIdentity();