So I have my model built, with a minimum of vertices (only 108 here), with the idea that I could use the mesh itself as the physics object. However when I use generateGeometry( true ) the volume seems to collapse to zero. When I use generateGeometry( false ) a physics bounding box does show up in the correct manner.
Here is a screenshot using false…
Here is a screenshot using true…
(I circle the TINY green crosshair, in the same position as the previous pic, in red)
Also notice that the center of mass seems to be at (0,0,0) in both pictures.
here is the code I am using
private Node getSlate() {
Spatial model = getModel( "/className/models/Table_Model/model.obj" );
StaticPhysicsNode modelPhysics = jme_Driver.getPhysics().createStaticNode();
modelPhysics.setName( "slatePhysics" );
modelPhysics.attachChild( model );
I have also tried creating a physicsMesh and adding the TriMesh directly to it. But the physics bounding box shows the same 'collapsed volume' using both true and false for generateGeometry(). Which makes me think the problem might be with the model... but I have no idea :|
Thats a bummer, it's such a powerful and easy technique for OpenGL but I suppose your right since I can't get the graphics model normals correct either (for mirrored meshes).
Oh, well I will just remodel in halves I guess, the complete model should still come in under 500K :D.
What about reading the model in multiple times, would it be more efficient to instantiate meshes from the first instead?
Hmm, I must have done something weird before, cant seem to replicate now.
However one of the changes that I did make was to import the model twice, once for the graphic model and again for the physics (is this very efficient?). After that a lot of my issues went away…
I was then able to scale by a negative value successfully (other post) but I get this issue
The red line is where the model is copied and mirrored (scaled by -1 on the z axis)
Left: Normal model
Right: Mirrored model
The balls to the right of the line are exactly in the middle vertically as shown in this image
I would like to keep the model as a quarter of the actual one but I think scaling the physics mesh by negative values is bad juju.
Output:
SharedMesh verts: 216
PhysicsMesh verts: 0
Total verts: 216
So, physicsMesh doesnt seem to have any verticies and the sharedNode only works when is used generatePhysicsGeometry( false ).
When the model is set to just a Box, then everything works great; generatePhysicsGeometry( true) and the PhysicsMesh.
ANY pointers as to what might be my issue would be very appreciated, BTW I am using an OBJ model from Blender.
I am not seeing a createTriMesh() method, just createMesh() under StaticPhysicsNode and DynamicPhysicsNode. Which I am already using and doesn't seem to want to work properly. The physics from pMesh.copyFrom( model ) don't work no matter if generateGeometry( false ) or generateGeometry( true ) is used. However, If I add the spatial directly to the StaticPhysicsNode then generateGeometry( false ) works but not generateGeometry( true ).
PhysicsMesh rotatedMesh = physicsModel.createMesh( name );
rotatedMesh.copyFrom( (TriMesh) model );
rotatedMesh.setLocalRotation( new Quaternion().fromAngleAxis( FastMath.PI, Vector3f.UNIT_Y ) );
So does the pMesh have to be manipulated (scaled rotated) separately from it's parent node? I was previously getting model -> adding Graphic meshs -> adding physic meshes -> manipulating.
When I manipulate each mesh separately before adding to the model the physics are correct.
The hardest part of this issue is the lack of feedback (visual, number of points, etc) breakpoints don't even help me out.
yes, it's a pitty - sorry about that, I didn't take the time to visualize physics trimeshes :| (patches welcome as ususal ;))
basixs said:
So does the pMesh have to be manipulated (scaled rotated) separately from it's parent node?
yes!
And there seems to be a misconception with generateGeometry:
- generateGeometry calls create* methods and transforms the created geometries appropriately
- create* method do not transform anything
- if you use create* directly you should not call generateGeometry