Cannot apply Physic to OgreMesh

I cannot apply physic to an ogre mesh without this error!

Without physic i can display the ogre mesh! I have not clue why this is happening! The model is pretty simple, therefore there should be no error!

Hope someone can help!



Model:

http://www.file-upload.net/download-2980703/barrel2.rar.html



[java]INFO: Child (SphereDebugShape) attached to this node (null)

blinn1: emissive

Unsupported texture_unit directive: tex_coord_set

Unsupported texture_unit directive: colour_op

Unsupported texture_unit directive: scale

Unsupported texture_unit directive: scroll

Unsupported texture_unit directive: rotate

17.11.2010 12:44:24 com.jme3.scene.Node attachChild

INFO: Child (barrel-sharedgeom) attached to this node (barrel-ogremesh)

17.11.2010 12:44:24 com.jme3.scene.Node attachChild

INFO: Child (barrel-geom-1) attached to this node (barrel-ogremesh)

17.11.2010 12:44:24 com.jme3.app.Application handleError

SCHWERWIEGEND: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

java.lang.IllegalArgumentException

at java.nio.ByteBuffer.allocate(Unknown Source)

at com.jme3.bullet.util.Converter.convert(Converter.java:152)

at com.jme3.bullet.collision.shapes.MeshCollisionShape.createCollisionMesh(MeshCollisionShape.java:70)

at com.jme3.bullet.collision.shapes.MeshCollisionShape.<init>(MeshCollisionShape.java:65)

at com.jme3.bullet.util.CollisionShapeFactory.createSingleMeshShape(CollisionShapeFactory.java:176)

at com.jme3.bullet.util.CollisionShapeFactory.createCompoundShape(CollisionShapeFactory.java:76)

at com.jme3.bullet.util.CollisionShapeFactory.createCompoundShape(CollisionShapeFactory.java:98)

at com.jme3.bullet.util.CollisionShapeFactory.createMeshCompoundShape(CollisionShapeFactory.java:107)

at com.xero.objects.XeroGameObject.<init>(XeroGameObject.java:20)

at scenes.ArcheInterior.<init>(ArcheInterior.java:60)

at GameApp.simpleInitApp(GameApp.java:61)

at com.xero.app.XeroApplication.initialize(XeroApplication.java:164)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:134)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:183)

at java.lang.Thread.run(Unknown Source)[/java]

This error can only happen when mesh is null, in other words, null was to the MeshCollisionShape constructor. It seems like some of your Geomteries are missing a mesh?

Sry, I don’t understand exactly, what you mean with geometries and mesh,

It’s a single mesh, therefore there shouldn’t be any problems :frowning:

I tried with a simple basic object and CollisionShape



Result:

[java]17.11.2010 23:51:00 com.jme3.system.JmeSystem initialize

INFO: Running on jMonkey Engine 3 Alpha 0.6

17.11.2010 23:51:00 com.jme3.system.Natives extractNativeLibs

INFO: Extraction Directory #1: file:/C:/Xtrem/Project/workspace/Paranoia_V1/bin/com/jme3/system/

17.11.2010 23:51:00 com.jme3.system.Natives extractNativeLibs

INFO: Extraction Directory #2: C:XtremProjectworkspaceParanoia_V1

17.11.2010 23:51:00 com.jme3.system.Natives extractNativeLibs

INFO: Extraction Directory #3: C:XtremProjectworkspaceParanoia_V1

17.11.2010 23:51:00 com.jme3.system.lwjgl.LwjglAbstractDisplay run

INFO: Using LWJGL 2.5

17.11.2010 23:51:00 com.jme3.system.lwjgl.LwjglDisplay createContext

INFO: Selected display mode: 1024 x 768 x 0 @0Hz

17.11.2010 23:51:00 com.jme3.system.lwjgl.LwjglAbstractDisplay initInThread

INFO: Display created.

17.11.2010 23:51:00 com.jme3.system.lwjgl.LwjglAbstractDisplay initInThread

INFO: Adapter: nvd3dumx,nvwgf2umx,nvwgf2umx

17.11.2010 23:51:00 com.jme3.system.lwjgl.LwjglAbstractDisplay initInThread

INFO: Driver Version: null

17.11.2010 23:51:00 com.jme3.system.lwjgl.LwjglAbstractDisplay initInThread

INFO: Vendor: NVIDIA Corporation

17.11.2010 23:51:00 com.jme3.system.lwjgl.LwjglAbstractDisplay initInThread

INFO: OpenGL Version: 3.3.0

17.11.2010 23:51:00 com.jme3.system.lwjgl.LwjglAbstractDisplay initInThread

INFO: Renderer: GeForce 9600M GT/PCI/SSE2

17.11.2010 23:51:00 com.jme3.system.lwjgl.LwjglAbstractDisplay initInThread

INFO: GLSL Ver: 3.30 NVIDIA via Cg compiler

17.11.2010 23:51:00 com.jme3.system.lwjgl.LwjglTimer

INFO: Timer resolution: 1000 ticks per second

17.11.2010 23:51:00 com.jme3.renderer.lwjgl.LwjglRenderer initialize

INFO: Caps: [FrameBuffer, FrameBufferMRT, FrameBufferMultisample, OpenGL20, OpenGL21, OpenGL30, ARBprogram, GLSL100, GLSL110, GLSL120, GLSL130, GLSL140, GLSL150, VertexTextureFetch, TextureArray, TextureBuffer, FloatTexture, FloatColorBuffer, FloatDepthBuffer, PackedFloatTexture, SharedExponentTexture, PackedFloatColorBuffer, TextureCompressionLATC, MeshInstancing, VertexBufferArray]

17.11.2010 23:51:00 com.jme3.asset.DesktopAssetManager

INFO: DesktopAssetManager created.

17.11.2010 23:51:00 com.jme3.renderer.Camera

INFO: Camera created (W: 1.024, H: 768)

17.11.2010 23:51:00 com.jme3.renderer.Camera

INFO: Camera created (W: 1.024, H: 768)

17.11.2010 23:51:00 com.jme3.input.lwjgl.LwjglMouseInput initialize

INFO: Mouse created.

17.11.2010 23:51:00 com.jme3.input.lwjgl.LwjglKeyInput initialize

INFO: Keyboard created.

17.11.2010 23:51:00 com.jme3.audio.lwjgl.LwjglAudioRenderer initialize

INFO: Audio effect extension version: 1.0

17.11.2010 23:51:00 com.jme3.audio.lwjgl.LwjglAudioRenderer initialize

INFO: Audio max auxilary sends: 2

17.11.2010 23:51:00 com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Gui Node)

17.11.2010 23:51:00 com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

17.11.2010 23:51:00 com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

17.11.2010 23:51:00 com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

17.11.2010 23:51:00 com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

17.11.2010 23:51:00 com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

17.11.2010 23:51:00 com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

17.11.2010 23:51:00 com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

17.11.2010 23:51:00 com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

17.11.2010 23:51:00 com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

17.11.2010 23:51:00 com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

17.11.2010 23:51:00 com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

17.11.2010 23:51:00 com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

17.11.2010 23:51:00 com.jme3.scene.Node attachChild

INFO: Child (BitmapFont) attached to this node (Statistics View)

17.11.2010 23:51:00 com.jme3.scene.Node attachChild

INFO: Child (Statistics View) attached to this node (Gui Node)

17.11.2010 23:51:00 com.jme3.renderer.Camera

INFO: Camera created (W: 1, H: 1)

17.11.2010 23:51:01 com.jme3.scene.Node attachChild

INFO: Child (Sky) attached to this node (null)

lambert1: emissive

17.11.2010 23:51:01 com.jme3.scene.Node attachChild

INFO: Child (barrel-sharedgeom) attached to this node (barrel-ogremesh)

17.11.2010 23:51:01 com.jme3.scene.Node attachChild

INFO: Child (barrel-geom-1) attached to this node (barrel-ogremesh)

17.11.2010 23:51:01 com.jme3.scene.Node attachChild

INFO: Child (barrel-ogremesh) attached to this node (null)

17.11.2010 23:51:01 com.jme3.app.Application handleError

SCHWERWIEGEND: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

java.lang.IllegalArgumentException

at java.nio.ByteBuffer.allocate(Unknown Source)

at com.jme3.bullet.util.Converter.convert(Converter.java:152)

at com.jme3.bullet.collision.shapes.MeshCollisionShape.createCollisionMesh(MeshCollisionShape.java:70)

at com.jme3.bullet.collision.shapes.MeshCollisionShape.(MeshCollisionShape.java:65)

at com.jme3.bullet.util.CollisionShapeFactory.createSingleMeshShape(CollisionShapeFactory.java:176)

at com.jme3.bullet.util.CollisionShapeFactory.createMeshShape(CollisionShapeFactory.java:129)

at com.xero.objects.XeroGameObject.(XeroGameObject.java:26)

at scenes.ArcheInterior.(ArcheInterior.java:84)

at GameApp.simpleInitApp(GameApp.java:61)

at com.xero.app.XeroApplication.initialize(XeroApplication.java:164)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:134)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:183)

at java.lang.Thread.run(Unknown Source)

[/java]

Can you please show me the code of your testcase (the one that produced the last output you posted)? A Geometry is the Spatial type, the actual mesh of the model is stored inside a Mesh object that is attached to the Geometry. The Geometry object defines the material etc. used for the model.

I found one error, but it seems not to be, which is causing the problem.

My exports are creating two childs (-sharedgeom (Geometry) and -geom-1 (Geometry)).

I removed the -sharedgeom child, since your test models are using only -geom-1

Still its not working! The code works with the test models. It must be the maya ogre exporter, but i have no clue why!



TestClass:

[java]public class XeroGameObject extends Node{



AssetManager assetManager = Cash.Application.getAssetManager();



public XeroGameObject(String path){

Node model = (Node) assetManager.loadModel(path);

//CompoundCollisionShape shape = CollisionShapeFactory.createMeshCompoundShape((Node) model);

Geometry geom = (Geometry) model.getChild(0);

//LodControl control = new LodControl(geom);

//geom.addControl(control);

this.attachChild(model);



for(int i=0; i < model.getChildren().size(); i++){

if(model.getChildren().get(i).toString().lastIndexOf("-sharedgeom (Geometry)")>=0){

model.detachChild(model.getChildren().get(i));

}*/

//System.out.println(model.getChildren().get(i) + " " + model.getChildren().get(i).toString());

}

for(int i=0; i < model.getChildren().size(); i++){

System.out.println(model.getChildren().get(i) + " " + model.getChildren().get(0).toString());

}



//CollisionShape shape = CollisionShapeFactory.createMeshShape(model.getChild(0));

//CompoundCollisionShape shape = CollisionShapeFactory.createMeshCompoundShape((Node) model);



/PhysicsNode physicsNode = new PhysicsNode(model, shape,(float) 1.5);//1.5

physicsNode.attachDebugShape(assetManager);

this.attachChild(physicsNode);

Cash.Application.getPhysicsSpace().add(physicsNode);
/

}



}[/java]

Open the model in jMP and look at the tree if there are any geometries without a Mesh and if there are, find out which objects in the maya scene that is.

If I am understanding what you are trying to say, I just did this yesterday, follow this logic and it will work.



[java] private void createPlane()

{



Node test = new Node(“plane”); //creating a new node to hold the plane physics

Spatial teapot = assetManager.loadModel(“Models/cheater.obj”); //load in your model, should work as ogre mesh too



Material mat_brick = new Material(assetManager, “Common/MatDefs/Misc/SimpleTextured.j3md”); //shader for model and material

mat_brick.setTexture(“m_ColorMap”, assetManager.loadTexture(“Textures/rE2bodrt.JPG”)); //what texture to use

teapot.setMaterial(mat_brick); // actually assigning it to the model



teapot.scale(250f);







test.attachChild(teapot); //attaching the model to the node





CompoundCollisionShape myComplexShape =

CollisionShapeFactory.createMeshCompoundShape(test); //creating shape based on the node



PhysicsNode node2 = new PhysicsNode(teapot, myComplexShape, 0); //creating the phsyics node





node2.attachChild(test); //adding the node to the physics node

node2.setLocalTranslation(new Vector3f(-250, 10, -50)); // moving the physics node to a certain point in space



rootNode.attachChild(node2); //adding the physics node to the scene

getPhysicsSpace().add(node2); //adding it to physics space

}[/java]



Hopefully that helps

@scrubalub:

Wrong answer xD. It’s not about how you do it, its about, why does it not work with my models!



@Normen:

Neat installer by the way!(jMP)

The Problem is, i can’t use jMP since it doesn’t find the JDK.

Could it be that I have the wrong JDK version, since i’m working on a 64bit system?



In my first post is a link to one of my models (very simple one).

Normen would you be so kind to check it out for me, pls?

For JMP in the etc folder of jmonkeyplatform installation, you have a file named jmonkeyplatform.conf



inside there is a line #jdkhome="/path/to/jdk"

remove the # and set the path to the jdk you want to use.



For your barrel, it has 2 geometry i don’t know why. One called barrel-sharedgeom and one barel-geom-1

Have you tried another kind of shape, instead of the compound shape?

I think there is a cylinder shape (Normen correct me if i’m wrong)

I read in the converter class, that sharedgeom is just not used by jME, but it does no harm.

I detached the sharedgeom from the mesh, still the same result. geom-1 is the important one for jME (contains the model)



No, I didn’t try any other shapes, didn’t know there were any.

I don’t think a cylinder shape is a good choice for a “realistic” physic.

A barrel is ok, but i have a whole spaceship! xD

Can’t imagine that this works out

OR… you use a cylinder ship!!

no i’m kidding



Of course the cylinder shape fits only the barrel, it’s just try to figure out if the issue comes from the compound shape

Creating the CollisionShape by hand from multiple basic shapes that are combined in a CompundCollisionShape is best anyway, and if the ship is supposed to move, a mesh collision shape will not work anyway.

Multiple basic shapes are not a good solution. Creating them all by hand with JME is …, well i gonna need hours for just one simple model! If i could use Maya, it wouldn’t be that bad, still its not a solution in my opinion. To kill a problem with another problem…



What kind of converter are you using?

I use the Maya Ogre converter since i can do everything with Maya. If i had to use another program like Blender, it would mean, that i wouldn’t be able to export my animations and skeletons for jME. I don’t know, how to create an animation inside Blender.



Guys this problem gives me a real headache!

Yes, multiple basic shapes is the best solution. You can also use GImpact shapes (“dynamic” mesh shapes) with lowpoly versions of your model, but the basic shapes solution will give you magnitudes more performance. Its also how its done in most professional games using lots of physics.