[Solved]Rendering a wire frame around a cube

Hey everyone,



I was just wondering how I could go about rendering a wire frame about a cube (an instance of Geometry). That is, I would like a different color frame around the cube in addition to its current color.



Thanks in advance,

mtheoryninja

you should create another cube a little bigger than the first one and use the wireframe mode



Box wireCube = new Box( new Vector3f(0,0,0), 1,1,1);

wireCube.setMode(Mesh.Mode.Lines);

Geometry geom = new Geometry(“Box”, wireCube );

Material mat1 = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);

mat1.setColor(“Color”, ColorRGBA.Blue);

geom.setMaterial(mat1);

Hmmm, I keep getting “NullPointerException: Material definition cannot be null”.



This is my code

[java]Box boxWireCube = new Box(translation, .51f, .51f, .51f);

boxWireCube.setMode(Mesh.Mode.Lines);

Geometry wireCube = new Geometry(“WireBlock”, boxWireCube );

Material mat2 = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);

mat2.setColor(“m_Color”, ColorRGBA.Blue);

wireCube.setMaterial(mat1);[/java]



I think the problem is that it can’t find Unshaded.j3md. Is there anything special I need to do to there?



I think I should point out that I’m not using a nightly build of jME3 or anything. I used the download link from the home page and ran the update manager inside jMP.



Thanks



Edit:



It’s definitely Unshaded.j3md. I just tried SolidColor.j3md and the program loaded (although it didn’t give me the frames, but that I expected.)

You should probably upgrade as it will save you a bunch of pain in the long run. If you hit F1 in JMP it will bring up the help and there’s a section in their on enabling the nightly updates in JMP. From the straight alpha 3 that you are running it’s a pretty big update but at least you’ll avoid writing stuff that will need to be changed when they release alpha 4 real soon.

yeah you should use the nightly builds.

Unshaded material definition was introduced after alpha 3 release

Oooh, okay, thanks guys. It’s updating now. Then the wireframe should work.



So thanks :slight_smile: I want to let you know that I appreciate the work you’re putting into this. I’ve had nothing but good experiences with my (albeit limited) use of jME and jMP.

you’re welcome :wink:

Hello guys, I am using Eclipse and I am getting a similar issue (note that I am using the nightly builds and that’s how I integrated with Eclipse by using the latest one).



to be specific when I run the assetManager inside SimpleInit() it’s fine, however in the same class if I run it under a different function outside simpleInit() I am getting a Null pointer error here:



Material mat1 = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);