[SOLVED] Collision error for unshaded geometries

I’m getting an error when I try to collide with an unshaded geometry.

Runtime: java.lang.IllegalArgumentException: Expected a Int value!
at com.jme3.shader.Uniform.setValue(Uniform.java:206)
at com.jme3.material.Material.updateShaderMaterialParameters(Material.java:810)
at com.jme3.material.Material.render(Material.java:968)
at com.jme3.renderer.RenderManager.renderGeometry(RenderManager.java:614)
at com.jme3.renderer.queue.RenderQueue.renderGeometryList(RenderQueue.java:266)
at com.jme3.renderer.queue.RenderQueue.renderQueue(RenderQueue.java:305)
at com.jme3.renderer.RenderManager.renderViewPortQueues(RenderManager.java:877)
at com.jme3.renderer.RenderManager.flushQueue(RenderManager.java:779)
at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1108)
at com.jme3.renderer.RenderManager.render(RenderManager.java:1158)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:253)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:197)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:232)
at java.lang.Thread.run(Thread.java:748)

My code:

private void createBlock(float x, float y, float z) {
	Geometry g = new Geometry("block", new Box(blockSize*0.5f, blockSize*0.5f, blockSize*0.5f));
	g.setLocalTranslation(x, y, z);
	Material m = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
	int tex = ThreadLocalRandom.current().nextInt(blockTexs.length);
	m.setTexture("ColorMap", assetManager.loadTexture("Textures/"+blockTexs[tex]));
	/*m.setBoolean("UseMaterialColors", true);
	m.setColor("Ambient", ColorRGBA.randomColor());
	m.setColor("Diffuse", ColorRGBA.Green);*/
	g.setMaterial(m);
	//Mesh mesh = new Mesh();
	//g.setMesh(mesh);
	//bulletAppState.getPhysicsSpace().add(mesh);
	RigidBodyControl p = new RigidBodyControl(0);
	g.addControl(p);
	bulletAppState.getPhysicsSpace().add(p);
	g.setShadowMode(RenderQueue.ShadowMode.Receive);
	//rootNode.attachChild(g);
	blocks.attachChild(g);
}

As soon as I enable lighting for this geometry, the problem goes away.

I don’t think this problem is caused by collisions… or the code that you show. Do you do something when the objects collide? Set a material parameter on the geometry maybe?

Just removing stuff from rootNode and physicsSpace.

Here’s something I just noticed: The error occurs when I’m colliding with the geometry and I’m looking straight into it.

Look in your app for all of the places that you set a material parameter. (or material parameter overrides)

The problem is that the bug is in your code but not the code we can see.

Edit: which version of JME are you using?

Edit2: looking at the Unshaded material and which parameter it might be complaining about (assuming it is even the material of the problem) there are some automatic material things for bone animation and for shadows and stuff:

…but we’d need to know more about your scene.

But rest assured, as someone who has read these forums since 2011… this is the first time I’ve seen this issue.

I use v3.2.4-stable-sdk1

Program Description:

I’ve created a grid of boxes attached to geometries, all the geometries are the same size and each one is textured by 1 of 3 available images (these geometries are the ones I’m having trouble with). The user can “pick” a block to remove it from the scene and physicsSpace. Each block is added to Node blocks, then Node blocks is added to rootNode.

I also made missles that fall and destroy any block they touch, but that is disabled at the moment.

I also made a coin and platform. The user tries to push the coin off the world. The coin is not light sensitive and is textured by colors. The platform used to be insensitive to light, but I had to enable lighting because I ran into this problem. The platform is textured by an image. These things are currently disabled.

Blocks are only created in the simpleInitApp method.

The only place manipulating block material is in the createBlock method:

private void createBlock(float x, float y, float z) {
   Geometry g = new Geometry("block", new Box(blockSize*0.5f, blockSize*0.5f, blockSize*0.5f));
   g.setLocalTranslation(x, y, z);
   Material m = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
   int tex = ThreadLocalRandom.current().nextInt(blockTexs.length);
   m.setTexture("ColorMap", assetManager.loadTexture("Textures/"+blockTexs[tex]));
   /*m.setBoolean("UseMaterialColors", true);
   m.setColor("Ambient", ColorRGBA.randomColor());
   m.setColor("Diffuse", ColorRGBA.Green);*/
   g.setMaterial(m);
   //Mesh mesh = new Mesh();
   //g.setMesh(mesh);
   //bulletAppState.getPhysicsSpace().add(mesh);
   RigidBodyControl p = new RigidBodyControl(0);
   g.addControl(p);
   bulletAppState.getPhysicsSpace().add(p);
   g.setShadowMode(RenderQueue.ShadowMode.Receive);
   //rootNode.attachChild(g);
   blocks.attachChild(g);
}

Oh, one more thing. The player is a CharacterControl with a CapsuleCollisionShape. It is initialized in the simpleInitApp method. It is unshaded, but is textured by a color.

Comment out the code that is handling your collisions. When your problem magically goes away then you can post the code that causes the problem.

I’ve commented out all the code having to do with PhysicsCollisionListener, but I’m still having the same problem. :confused:

EDIT: of course, when I switch back to color texture, the problem goes away.

Magic.

1 Like

Does this have anything do do with this?

SEVERE: Unable to initialize OpenCL
org.lwjgl.LWJGLException: Could not locate OpenCL library.
at org.lwjgl.opencl.CL.create(CL.java:122)
at com.jme3.system.lwjgl.LwjglContext.initOpenCL(LwjglContext.java:266)
at com.jme3.system.lwjgl.LwjglDisplay.createContext(LwjglDisplay.java:154)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:113)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:211)
at java.lang.Thread.run(Thread.java:748)

I’ve gotten that at the start of all my builds.

Are you doing OpenCL stuff?

I think at this point we’re going to have to see a simple test case that illustrates the problem. As is often the case, when you create the simple test case it will work find and then you can sort out the issue. Otherwise, we get something we can look at and see all of the relevant code in one place.

Not that I know of.

I’m not sure what a test case is… Is it simply a bunch of println’s or the debug function?
Sorry, I’m a sorta noob to JME

Construct a (preferably) one class example application that we can run to see the problem.

Often times in constructing this application you will find your problem… so it’s not wasted time.

1 Like

Problem solved.

Finally figured out that when I attempted to texture the player (CharacterControl) with a color I had mat.setColor(“ColorMap”, ColorRGBA.Blue); instead of mat.setColor(“Color”, ColorRGBA.Blue);

These errors make me feel silly :laughing:

1 Like

@pspeed
Thanks for your help! :grinning:

2 Likes