From: Matthias B. <ba...@ir...> - 2005-05-25 10:07:17
|
Roger Stuckey wrote: > Firstly, can you provide an example using xode to load a trimesh > geometry? see Timothy's mail... > At the moment, I am using cgkit.objimport to create an > _OBJReader object, which is then used to read an obj file and > subsequently build a TriMeshData object (using the verts and vfaces > variables). I had to comment out the line "self.faces = []" in the > g(self, *groups) method within the class definition of _OBJReader to do > so. In the 'g' callback of the importer the face list is cleared because the importer tries to recreate the scene hierarchy instead of putting everything in one big mesh, i.e. after importing an OBJ file you may have several separate meshes in your scene. > Maybe you could consider making this class public, to allow explicit > use, rather than enforcing the generic "load" function in cgkit? The base class of the importer is already public, it's the OBJReader class in the objmtl module: http://cgkit.sourceforge.net/doc2/module-cgkit.objmtl.html The OBJ *importer* uses this module to read the obj file and create cgkit objects. If you just use the verts and faces attributes of the importer you basically circumvent the actual functionality of the class (as you're only using the functionality of the base reader class). So I'd recommend to derive from objmtl.OBJReader and implement the 'v' and 'f' callbacks. Another option would be to import the model using load() and then take the mesh from the cgkit scene and convert it into a TriMeshData object. Then you could use any format that is supported by cgkit without that you have to change your code. This would look something like this (untested): load("mymodel.obj") mesh = worldObject("<objectname>") trimeshdata = ode.TriMeshData() trimeshdata.build(mesh.verts, mesh.faces) If the mesh is not a triangle mesh you'd have to call convertToTriMesh(mesh) first. > Secondly, I have been dropping a trimesh cube onto another trimesh cube, > but the colliding objects behave quite strangely - nothing like the > behaviour of a GeomBox being dropped onto a GeomPlane, for example. They > bounce quite violently off each other! I've tried altering the ERP > (currently 2.0), CFM (1E-5) and simulation time-step (0.001), to no > avail. Is this a problem with the OPCODE, or something else? I haven't done that much tests with TriMesh-TriMesh collisions but it was also my experience that this doesn't work really stable. If I remember correctly, this has also been mentioned in the ODE mailing list. So it would be better if there would be only contacts between the primitive shapes and a TriMesh (for example, you could use the TriMesh for your Terrain and the simple objects for players, vehicles or whatever). But on the other hand, I'm not sure if TriMesh support is really wrapped the right way in PyODE. There's this thing about setting the trimesh positions of the previous time step which I basically ignored, so maybe this also has a bad influence of the simulation. So if someone who knows how to deal with that stuff wants to have a look.... - Matthias - |