Unsupported operation exception in JME 3.1

They were already nodes… if you load something and can cast it to a node then it’s a node. If it has more than one Geometry child then calling setMaterial() on the node will set the same instance for both children.

The interesting thing is that JME is supposed to handle this for you automatically if you didn’t set any materials as materials only get cloned if there is no hardware skinning detected.

Edit: else they are deep cloned if hardware skinning is detected. So try not setting your own materials at all and just use what was loaded.

So try not setting your own materials at all and just use what was loaded.

In other words, I should make it so my models are imported with textures automatically, without specifically writing that in the code?

This conversation is very frustrating. That’s not what I said at all.

“You should not do this bad thing.” “Oh, so you are saying I should let all the babies die?”

Good luck with your game.

So could please explain what you meant by this?

I can post the code blocks if it’s necessary.

From you screenshot, you no longer load your model from .xbuf or .j3o. is it right ?

I guessed you had this error with the xbuf Model viewer, because you originaly posted the bug in its topic (sorry for late reply) ?

I’m currius, because this is a bug the xbuf loader had, and I fixed it with some kind of clone + material replicator. But since the loader was refactored, so it’s possible the bug was come back under some condition.

For now, I’m simply using models exported using blender2ogre.

In the previous thread my problem was inability to import models into the Spatial Explorer from Blender but now that works. (HUGE THANKS TO YOU!!!:slight_smile:)

To help you debug, you could write a SceneGraphVisitor, that dump material (name + hashCode) of every geometry

This appears to be very complicated. Isn’t there a simple solution I could use to resolve this whole issue?

nothing complex (something like pseudo java, I’m not on my dev desktop):

root.depthFirstTraversal(new SceneGraphVisitorAdapter(){
@Override
 public void visit(Geometry geom){
  System.out.println("material of " + geom.getName() + " => " + geom.getMaterial().name() + " .. " + geom.getMaterial().hashCode());
 }
});

Ok, but is there something I can do to avoid this in the future?

As other said, you should not share/reuse a material used by a mesh with a Skeleton.
The println is just a way to help you where you share the material, then you could understand why you share this material and avoid the issue in the future.

But, according to the screenshots I’ve posted before, my animated meshes have their own classes with separate material instances. Though maybe the problem is when I, e.g., create an object with an animated mesh (a gun) that I attach to the skeleton control of the mesh of my character because if I launch the app without attaching a gun, it runs ok.

Bonus question: if this wasn’t a problem in 3.0, does that mean animated meshes could use common material instances?

Like previously said, you have the same behavior with 3.0 if you enable Hardward Skinning (I had the same behavior).

Else I can’t debug your data for you.

PS: Sceenshot is not the best to share code. copy/paste in section between triple backquote or gist or github project is far better (see the link Jow to get answer at the top).

Ok, perhaps we can continue this tommorow: I’ve got to go bed.

Ok, maybe you could please take a look at my code and explain where I use the same material instances because I’ve got no idea. If you have any questions about the code, post them.

P.S: the gun classes are very similar.

            glock = new Glock(assetManager, rootNode, bas);
		uzi = new Uzi(assetManager, rootNode, bas);
		mp5 = new MP5(assetManager, rootNode, bas, projectile, shootables);
		remco = new Remco(assetManager, rootNode, shootables, bas, projectile,
				camNode.getCamera());
		m5 = new M5(assetManager, rootNode, bas);
		toxinsprayer = new Toxinsprayer(assetManager, rootNode, bas);
		steyrScout = new SteyrScout(assetManager, rootNode, bas);
		s_w686 = new S_W686(assetManager, rootNode, bas);
		m60 = new M60(assetManager, rootNode, bas);
		pickWeapons(characterNumber);
		equip(getWeapons(weaponSelection), characterNumber);

public void equip(String weapon, int number) {
		String suffix = "";
		if (crouched || prone) {
			if (crouched)
				suffix = "Crouched";
			if (prone)
				suffix = "Proned";
		} else
			suffix = "";
		equiping = true;
		meshRigControl.getAttachmentsNode("handIK.R").detachAllChildren();
		meshRigControl.getAttachmentsNode("handIK.L").detachAllChildren();
		try {
			meshRigControl.getAttachmentsNode("tanks").detachAllChildren();
		} catch (Exception e) {
		}
		if (weapon.equals("Machinegun")) {
			meshRigControl.getAttachmentsNode("handIK.R").attachChild(
					m60.getMesh());
			m60.getMesh().setLocalTranslation(m60.getPositionArray());
			m60.getMesh().setLocalRotation(m60.getRotationArray());
			handsChannel.setAnim("equipingMachinegun" + suffix);
			handsChannel.setSpeed(.5f);
			handsChannel.setLoopMode(LoopMode.DontLoop);
		}
		if (weapon.equals("Pistol")) {
			meshRigControl.getAttachmentsNode("handIK.R").attachChild(
					glock.getMesh());
			glock.getMesh().setLocalTranslation(glock.getPositionArray(number));
			glock.getMesh().setLocalRotation(glock.getRotationArray(number));
			handsChannel.setAnim("equipingPistol" + suffix);
			handsChannel.setLoopMode(LoopMode.DontLoop);
		}
		if (weapon.equals("Uzi")) {
			meshRigControl.getAttachmentsNode("handIK.R").attachChild(
					uzi.getMesh());
			uzi.getMesh().setLocalTranslation(uzi.getPositionArray(number));
			uzi.getMesh().setLocalRotation(uzi.getRotationArray(number));
			handsChannel.setAnim("equipingUzi" + suffix);
			handsChannel.setLoopMode(LoopMode.DontLoop);
		}
		if (weapon.equals("SMG")) {
			meshRigControl.getAttachmentsNode("handIK.R").attachChild(
					mp5.getMesh());
			mp5.getMesh().rotate(0, 0, 0);
			mp5.getMesh().setLocalTranslation(mp5.getPositionArray());
			mp5.getMesh().setLocalRotation(mp5.getRotationArray());
			handsChannel.setAnim("equipingSMG" + suffix);
			handsChannel.setSpeed(.5f);
			handsChannel.setLoopMode(LoopMode.DontLoop);
		}
		if (weapon.equals("Bazooka")) {
			meshRigControl.getAttachmentsNode("handIK.R").attachChild(
					remco.getMesh());
			remco.getMesh().setLocalTranslation(remco.getPosiotionArray());
			remco.getMesh().setLocalRotation(remco.getRotationArray());
			handsChannel.setAnim("equipingBazooka" + suffix);
			handsChannel.setSpeed(.2f);
			handsChannel.setLoopMode(LoopMode.DontLoop);
		}
		if (weapon.equals("Shotgun")) {
			meshRigControl.getAttachmentsNode("handIK.R").attachChild(
					m5.getMesh());
			m5.getMesh().setLocalTranslation(m5.getPositionArray());
			m5.getMesh().setLocalRotation(m5.getRotationArray());
			handsChannel.setAnim("equipingShotgun" + suffix);
			handsChannel.setLoopMode(LoopMode.DontLoop);

		}
		if (weapon.equals("Toxinsprayer")) {
			meshRigControl.getAttachmentsNode("tanks").attachChild(
					toxinsprayer.getMesh());
			toxinsprayer.getMesh().setLocalTranslation(
					toxinsprayer.getPositionArray());
			handsChannel.setAnim("equipingToxinsprayer");
			handsChannel.setLoopMode(LoopMode.DontLoop);
			toxinsprayer.getChannel().setAnim("equipping");
			toxinsprayer.getChannel().setLoopMode(LoopMode.DontLoop);
		}
		if (weapon.equals("Rifle")) {
			meshRigControl.getAttachmentsNode("handIK.L").attachChild(
					steyrScout.getMesh());
			steyrScout.getMesh().setLocalTranslation(
					steyrScout.getPositionArray());
			steyrScout.getMesh()
					.setLocalRotation(steyrScout.getRotationArray());
			handsChannel.setAnim("equipingRifle" + suffix);
			handsChannel.setLoopMode(LoopMode.DontLoop);
		}
		if (weapon.equals("Revolver")) {
			meshRigControl.getAttachmentsNode("handIK.R").attachChild(
					s_w686.getMesh());
			s_w686.getMesh().setLocalTranslation(s_w686.getPositionArray());
			s_w686.getMesh().setLocalRotation(s_w686.getRotationArray());
			handsChannel.setAnim("equipingRevolver" + suffix);
			handsChannel.setLoopMode(LoopMode.DontLoop);
		}
		// handsChannel.setSpeed(1);
	}

public Glock(AssetManager assetManager, Node rootNode, BulletAppState bas) {
		this.assetManager = assetManager;
		this.rootNode = rootNode;
		this.bas = bas;
		rotationArray = new Quaternion[9];
		rotationArray[0] = new Quaternion(-0.70218396f, 0.002318412f, -0.0017938316f, 0.71198773f);
		rotationArray[2]=new Quaternion(-0.5036129f, 0.48931822f, 0.5108004f, 0.49600595f);
		rotationArray[5]=new Quaternion(-0.70218396f, 0.002318412f, -0.0017938316f, 0.71198773f);
		rotationArray[6]=new Quaternion(-0.70613766f, -0.037007123f, -0.037007064f, 0.70613754f);
		rotationArray[7]=new Quaternion(0.5f, 0.5f, 0.5f, -0.5f);
		rotationArray[8]=new Quaternion(-0.7071068f, 0.0f, 0.0f, 0.7071067f);
		positionArray = new Vector3f[9];
		positionArray[0] = new Vector3f(0.09999999f, 0.8199995f, -0.03999991f);
		positionArray[2]= new Vector3f(-0.07999999f, 0.5999997f, -0.13999999f);
		positionArray[5]=new Vector3f(0.12999998f, 0.7599996f, -0.09999999f);
		positionArray[6]=new Vector3f(0.09999999f, 0.69999963f, -0.059999995f);
		positionArray[7]=new Vector3f(0.09999999f, 0.7199996f, 0.16f);
		positionArray[8]=new Vector3f(0.15840526f, 0.6399997f, -0.07999999f);
		mesh = (Node) assetManager
				.loadModel("Models/Weapons/Guns/Glock 17/Cylinder.000.mesh.xml");
		Material mat = new Material(assetManager,
				"Common/MatDefs/Light/Lighting.j3md");
		mat.setTexture("DiffuseMap", this.assetManager
				.loadTexture(new TextureKey(
						"Models/Weapons/Guns/Glock 17/map.png", false)));
		mesh.setMaterial(mat.clone());
		phy = new RigidBodyControl(1);
		AnimControl control = mesh.getControl(AnimControl.class);
		control.addListener(this);
		channel = control.createChannel();
		channel.setAnim("idle");
		channel.setLoopMode(LoopMode.DontLoop);
		sound = new AudioNode(assetManager, "Sounds/Glock/glock.ogg", false);
		sound.setPositional(false);
		sound.setVolume(1);
		rootNode.attachChild(sound);
		pe = new ParticleEmitter("Emitter", Type.Triangle, 10);
		// pe.setLocalTranslation(new Vector3f(-0.8775808f, 5.8787966f,
		// 2.3806949f));
		// mesh.attachChild(pe);
		Material mat2 = new Material(assetManager,
				"Common/MatDefs/Misc/Particle.j3md");
		mat2.setTexture("Texture",
				assetManager.loadTexture("Textures/Muzzle flashes/flash2.png"));
		pe.setMaterial(mat2.clone());
		pe.setImagesX(1);
		pe.setImagesY(1);
		pe.setStartColor(ColorRGBA.White);
		pe.setEndColor(new ColorRGBA(1f, 1f, 0f, 100f));
		pe.setStartSize(.4f);
		pe.setEndSize(0f);
		pe.setLowLife(.4f);
		pe.setHighLife(.4f);
		pe.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 0, 2f));
		pe.getParticleInfluencer().setVelocityVariation(.01f);
		pe.setInWorldSpace(false);
		pe.setGravity(new Vector3f(0, 0, -3f));
		mesh.attachChild(pe);
		pe.setLocalTranslation(new Vector3f(-0.0013145804f, 0.39961386f,
				0.74488926f));
		pl = new PointLight();
		pl.setRadius(50);
		pl.setPosition(pe.getWorldTranslation());
		pl.setColor(ColorRGBA.White);
		silencer = assetManager
				.loadModel("Models/Weapons/Guns/Glock 17/Cylinder.001.mesh.xml");
		Material sMat = new Material(assetManager,
				"Common/MatDefs/Light/Lighting.j3md");
		sMat.setTexture("DiffuseMap", this.assetManager
				.loadTexture(new TextureKey(
						"Textures/Muzzle flashes/flash2.png", false)));
		silencer.setMaterial(sMat.clone());
	}

public M5(AssetManager assetManager, Node rootNode, BulletAppState bas) {
		this.assetManager = assetManager;
		this.rootNode = rootNode;
		this.bas = bas;
		pl = new PointLight();
		pl.setRadius(100);
		pl.setColor(ColorRGBA.White);
		mesh = (Node) assetManager.loadModel("Models/Weapons/Guns/M5/Cylinder.002.mesh.xml");
		Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
		mat.setTexture("DiffuseMap", this.assetManager.loadTexture(new TextureKey("Models/Weapons/Guns/M5/map.png", false)));
		//mesh.setMaterial(mat.clone());
		RigidBodyControl phy = new RigidBodyControl(1);
		AnimControl control = mesh.getControl(AnimControl.class);
		control.addListener(this);
		channel = control.createChannel();
		sound = new AudioNode(assetManager, "Sounds/M5/m5.ogg", false);
		sound.setPositional(false);
		sound.setVolume(1);
		rootNode.attachChild(sound);
		pe = new ParticleEmitter("Emitter", Type.Triangle, 10);
		Material peMat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
		peMat.setTexture("Texture", assetManager.loadTexture("Textures/Muzzle flashes/flash2.png"));
		pe.setMaterial(peMat.clone());
		pe.setStartColor(ColorRGBA.Yellow);
		pe.setStartSize(.0f);
		pe.setEndSize(.0f);
		pe.setLowLife(.2f);
		pe.setHighLife(.2f);
		pe.setEndColor(ColorRGBA.White);
		pe.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 0, 3f));
		pe.getParticleInfluencer().setVelocityVariation(.2f);
		pe.setGravity(0, 0, -6);
		pe.setInWorldSpace(false);
		mesh.attachChild(pe);
		pe.setLocalTranslation(-0.01834178f, 0.10726784f, 3.1161804f);
	}

public M60(AssetManager assetManager, Node rootNode, BulletAppState bas) {
		this.assetManager = assetManager;
		this.rootNode = rootNode;
		this.bas = bas;
		mesh = (Node) assetManager
				.loadModel("Models/Weapons/Guns/M60/Cube.003.mesh.xml");
		Material mat = new Material(assetManager,
				"Common/MatDefs/Light/Lighting.j3md");
		mat.setTexture("DiffuseMap", assetManager.loadTexture(new TextureKey(
				"Models/Weapons/Guns/M60/m60_diffuse.png", false)));
		//mesh.setMaterial(mat.clone());
		AnimControl control = mesh.getControl(AnimControl.class);
		AnimChannel channel = control.createChannel();
		channel.setLoopMode(LoopMode.DontLoop);
		sound = new AudioNode(assetManager, "Sounds/M60/m60.ogg", false);
		sound.setPositional(false);
		sound.setVolume(1);
		rootNode.attachChild(sound);
		pl = new PointLight();
		pl.setRadius(70);
		pl.setColor(ColorRGBA.White);
		pe = new ParticleEmitter("", Type.Triangle, 10);
		Material peMat = new Material(assetManager,
				"Common/MatDefs/Misc/Particle.j3md");
		peMat.setTexture("Texture",
				assetManager.loadTexture("Textures/Muzzle flashes/flash2.png"));
		pe.setInWorldSpace(false);
		//pe.setStartSize(.45f);
		//pe.setEndSize(.1f);
		pe.setStartColor(ColorRGBA.White);
		pe.setEndColor(ColorRGBA.Yellow);
		pe.setLowLife(.1f);
		pe.setHighLife(.5f);
		pe.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 0, 2f));
		pe.setGravity(0, 0, -2);
		pe.getParticleInfluencer().setVelocityVariation(.1f);
		pe.setMaterial(peMat.clone());
		//mesh.attachChild(pe);
		pe.setLocalTranslation(0, .16f, 4.12f);
	}

public MP5(AssetManager assetManager, Node rootNode, BulletAppState bas, List<Projectile> projectile,
			Node shootables) {
		this.assetManager = assetManager;
		this.rootNode = rootNode;
		this.bas = bas;
		this.shootables = shootables;
		this.projectile = projectile;
		pl = new PointLight();
		pl.setRadius(100);
		pl.setColor(ColorRGBA.White);
		// rootNode.addLight(pl);
		mesh = (Node) assetManager.loadModel("Models/Weapons/Guns/MP5/Cylinder.000.mesh.xml");
		Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
		mat.setTexture("DiffuseMap",
				this.assetManager.loadTexture(new TextureKey("Models/Weapons/Guns/MP5/mp5_diffuse.png", false)));
		//mesh.setMaterial(mat.clone());
		RigidBodyControl phy = new RigidBodyControl(1);
		AnimControl control = mesh.getControl(AnimControl.class);
		control.addListener(this);
		channel = control.createChannel();
		sound = new AudioNode(assetManager, "Sounds/MP5/mp5.ogg", false);
		sound.setPositional(false);
		sound.setVolume(1);
		rootNode.attachChild(sound);
		pe = new ParticleEmitter("Emitter", Type.Triangle, 10);
		Material peMat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
		peMat.setTexture("Texture", assetManager.loadTexture("Textures/Muzzle flashes/flash2.png"));
		pe.setMaterial(peMat.clone());
		pe.setStartSize(.0f);
		pe.setEndSize(.0f);
		pe.setStartColor(ColorRGBA.White);
		pe.setEndColor(ColorRGBA.Yellow);
		pe.setLowLife(.4f);
		pe.setHighLife(.4f);
		pe.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 0, 1f));
		pe.getParticleInfluencer().setVelocityVariation(.1f);
		pe.setInWorldSpace(false);
		mesh.attachChild(pe);
		pe.setLocalTranslation(-0.011650126f, 0.39375925f, 2.3295345f);
	}

public Remco(AssetManager assetManager, Node rootNode, Node shootables,
			BulletAppState bas, List<Projectile> projectile, Camera cam) {
		this.assetManager = assetManager;
		this.rootNode = rootNode;
		this.bas = bas;
		this.projectile = projectile;
		this.shootables = shootables;
		this.results = results;
		this.cam = cam;
		pl = new PointLight();
		pl.setColor(ColorRGBA.White);
		pl.setRadius(50);
		mesh = (Node) assetManager
				.loadModel("Models/Weapons/Guns/Remco/Cylinder.mesh.xml");
		Material mat = new Material(assetManager,
				"Common/MatDefs/Light/Lighting.j3md");
		mat.setTexture("DiffuseMap", this.assetManager
				.loadTexture(new TextureKey(
						"Models/Weapons/Guns/Remco/map.png", false)));
		//mesh.setMaterial(mat.clone());
		RigidBodyControl phy = new RigidBodyControl(1);
		AnimControl control = mesh.getControl(AnimControl.class);
		control.addListener(this);
		channel = control.createChannel();
		sound = new AudioNode(assetManager, "Sounds/Glock/glock.ogg", false);
		sound.setPositional(false);
		sound.setVolume(1);
		rootNode.attachChild(sound);
		// particleEmitters = new ParticleEmitter[2];
		pe = new ParticleEmitter("Emitter", Type.Triangle, 10);
		Material peMat = new Material(assetManager,
				"Common/MatDefs/Misc/Particle.j3md");
		peMat.setTexture("Texture",
				assetManager.loadTexture("Textures/Muzzle flashes/flash2.png"));
		pe.setMaterial(peMat.clone());
		pe.setStartColor(ColorRGBA.White);
		pe.setEndColor(new ColorRGBA(1, .5f, 0, 1f));
		pe.setStartSize(.0f);
		pe.setEndSize(.0f);
		pe.setLowLife(.5f);
		pe.setHighLife(.5f);
		pe.setInWorldSpace(false);
		pe.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 0, 3));
		pe.getParticleInfluencer().setVelocityVariation(.2f);
		pe.setGravity(Vector3f.ZERO);
		mesh.attachChild(pe);
		pe.setLocalTranslation(0, 0.2600026f, 3.7999775f);

public S_W686(AssetManager assetManager, Node rootNode, BulletAppState bas) {
		this.assetManager = assetManager;
		this.rootNode = rootNode;
		this.bas = bas;
		mesh = (Node) assetManager
				.loadModel("Models/Weapons/Guns/S-W686/Cylinder.mesh.xml");
		Material mat = new Material(assetManager,
				"Common/MatDefs/Light/Lighting.j3md");
		mat.setTexture("DiffuseMap", assetManager.loadTexture(new TextureKey(
				"Models/Weapons/Guns/S-W686/s-w686_diffuse.png", false)));
		//mesh.setMaterial(mat.clone());
		TextureKey key = new TextureKey("Textures/Sky/Bright/BrightSky.dds",
				true);
		key.setGenerateMips(true);
		//key.setAsCube(true);
		final Texture tex = assetManager.loadTexture(key);
		/*mat.setBoolean("UseMaterialColors", true);
		mat.setBoolean("UseAlpha", true);
		mat.setFloat("Shininess", 16);
		mat.setColor("Diffuse", ColorRGBA.White);
		mat.setColor("Specular", ColorRGBA.White);
		mat.setTexture("EnvMap", tex);
		mat.setVector3("FresnelParams", new Vector3f(.1f, .1f, .1f).mult(.1f));*/
		AnimControl control = mesh.getControl(AnimControl.class);
		channel = control.createChannel();
		channel.setAnim("hammerPulledBack");
		channel.setLoopMode(LoopMode.DontLoop);
		pl = new PointLight();
		pl.setColor(ColorRGBA.White);
		pl.setRadius(10);
		pe = new ParticleEmitter("Emitter", Type.Triangle, 10);
		Material peMat = new Material(assetManager,
				"Common/MatDefs/Misc/Particle.j3md");
		peMat.setTexture("Texture",
				assetManager.loadTexture("Textures/Muzzle flashes/flash2.png"));
		pe.setMaterial(peMat.clone());
		pe.setStartColor(ColorRGBA.White);
		pe.setEndColor(ColorRGBA.Orange);
		pe.setStartSize(.0f);
		pe.setEndSize(.0f);
		pe.setInWorldSpace(false);
		pe.setLowLife(.6f);
		pe.setHighLife(.6f);
		pe.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 0, 1));
		pe.getParticleInfluencer().setVelocityVariation(.2f);
		mesh.attachChild(pe);
		pe.setLocalTranslation(-0.0013145804f, 0.47961378f, 1.0848889f);
	}

public SteyrScout(AssetManager assetManager, Node rootNode,
			BulletAppState bas) {
		this.assetManager = assetManager;
		this.rootNode = rootNode;
		this.bas = bas;
		pl = new PointLight();
		pl.setColor(ColorRGBA.White);
		pl.setRadius(10);
		mesh = (Node) assetManager
				.loadModel("Models/Weapons/Guns/Steyr Scout/Cylinder.mesh.xml");
		Material mat = new Material(assetManager,
				"Common/MatDefs/Light/Lighting.j3md");
		mat.setTexture(
				"DiffuseMap",
				this.assetManager
						.loadTexture(new TextureKey(
								"Models/Weapons/Guns/Steyr Scout/steyr_scout_diffuse.png",
								false)));
		//mesh.setMaterial(mat.clone());
		RigidBodyControl phy = new RigidBodyControl(1);
		AnimControl control = mesh.getControl(AnimControl.class);
		control.addListener(this);
		channel = control.createChannel();
		sound = new AudioNode(assetManager, "Sounds/Glock/glock.ogg", false);
		sound.setPositional(false);
		sound.setVolume(1);
		rootNode.attachChild(sound);
		pe = new ParticleEmitter("Emitter", Type.Triangle, 10);
		Material peMat = new Material(assetManager,
				"Common/MatDefs/Misc/Particle.j3md");
		peMat.setTexture("Texture",
				assetManager.loadTexture("Textures/Muzzle flashes/flash2.png"));
		pe.setMaterial(peMat.clone());
		pe.setInWorldSpace(false);
		pe.setStartColor(ColorRGBA.White);
		pe.setEndColor(ColorRGBA.Yellow);
		pe.setStartSize(.0f);
		pe.setEndSize(0);
		pe.setLowLife(.3f);
		pe.setHighLife(.3f);
		pe.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 0, 1));
		pe.getParticleInfluencer().setVelocityVariation(.05f);
		mesh.attachChild(pe);
		pe.setLocalTranslation(0.0102222655f, 0.2251466f, 3.2830777f);
	}

public Uzi(AssetManager assetManager, Node rootNode, BulletAppState bas) {
		this.assetManager = assetManager;
		this.rootNode = rootNode;
		this.bas = bas;
		rotationArray = new Quaternion[9];
		rotationArray[1]=new Quaternion(-0.70710456f, -2.682209E-7f, -2.9802322E-8f, 0.70710444f);
		rotationArray[3]=new Quaternion(-0.7071068f, 0,0, 0.7071067f);
		rotationArray[8]=new Quaternion(-0.7071068f, 0.0f, 0.0f, 0.7071067f);
		positionArray = new Vector3f[9];
		positionArray[1]=new Vector3f(0.13999999f, 0.77999955f, -0.05999998f);
		positionArray[3]=new Vector3f(0.18f, 0.8599995f, -0.02f);
		positionArray[8]=new Vector3f(0.13999999f, 0.5999997f,0);
		pl = new PointLight();
		pl.setRadius(50);
		pl.setColor(ColorRGBA.White);
		mesh = (Node) assetManager.loadModel("Models/Weapons/Guns/Uzi/Cube.mesh.xml");
		Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
		mat.setTexture("DiffuseMap",
				this.assetManager.loadTexture(new TextureKey("Models/Weapons/Guns/Uzi/uzi_diffuse.png", false)));
		mat.setReceivesShadows(false);
		//mesh.setMaterial(mat.clone());
		RigidBodyControl phy = new RigidBodyControl(1);
		AnimControl control = mesh.getControl(AnimControl.class);
		control.addListener(this);
		channel = control.createChannel();
		sound = new AudioNode(assetManager, "Sounds/Uzi/uzi.ogg", false);
		sound.setPositional(false);
		sound.setVolume(1);
		rootNode.attachChild(sound);
		rig = mesh.getControl(SkeletonControl.class);
		pe = new ParticleEmitter("Emitter", Type.Triangle, 10);
		Material peMat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
		peMat.setTexture("Texture", assetManager.loadTexture("Textures/Muzzle flashes/flash2.png"));
		pe.setMaterial(peMat.clone());
		pe.setStartColor(ColorRGBA.White);
		pe.setEndColor(ColorRGBA.Yellow);
		pe.setStartSize(.0f);
		pe.setEndSize(.0f);
		pe.setLowLife(.3f);
		pe.setHighLife(.3f);
		pe.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 0, 3));
		pe.getParticleInfluencer().setVelocityVariation(.1f);
		pe.setInWorldSpace(false);
		// pe.setGravity(0, 0, 5);
		mesh.attachChild(pe);
		pe.setLocalTranslation(-0.012606025f, 0.47854996f, 1.3980212f);
	}

Ok, I’ll use this from now own. Sorry for the mess.

I think I’ve figured this out: the problem is when I use the following line of code:


someSkeletonControl.getAttachmentNode("").attachChild(someSpatial);

Other than that, there appear to be no other causes of the exception.