jMonkeyEngine 3 Tutorial (2) issues - red box not showing

Greetings,



I decided to start today with jMonkeyEngine so of course I am running through the tutorials. Everything seems easy but I seem to be having an issue with tutorial #2. After I ran the first tutorial, the one with the blue box, it seems like there is a cache because no matter what I change in the main class, I still get the same blue box.



I will try to make it clearer: in the first tutorial, the sceneNode was composed of one blue box; in the second one, it should be composed of a blue box and a red box. I have tried it with both my own code and by copy-pasting the existing one and no modifications took place.



public void simpleInitApp() {

// Create a red box

Box redBox = new Box(new Vector3f(1, -1, 1), 1, 1, 1);

Geometry redBoxGeometry = new Geometry(“Box”, redBox);



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

redBoxMaterial.setColor(“Color”, ColorRGBA.Red);

redBoxGeometry.setMaterial(redBoxMaterial);



rootNode.attachChild(redBoxGeometry);

}



I went ahead and used only a red box, but still the blue box shows up.

Anyone have any idea what’s going on? What kind of caching system is up?

  • Mention: I am using NetBeans 7.1.2 with the 29 June 2012 NB of jMonkey *

Try cleaning and building using the button next to the one you use to play (the one with the hammer and the broom or whatever).

@memonick said:
Try cleaning and building using the button next to the one you use to play (the one with the hammer and the broom or whatever).

I have done that multiple times, still nothing. Thank you for your answer.

I have to add that I got it working by making a new java class called HelloNode instead of using the one from Tutorial #1. I don't see why just modifying the contents of a class worked and I had to make a new one. If anyone could explain I would be grateful

Post the whole class.



9 times out of 10, you changed the name of the class but didn’t change the name it’s instantiating in main().

I solved the issue, it was because of the class name. It seems that no matter what I put in:

public class HelloNode extends SimpleApplication


When running, the items of tutorial Hello Node will be displayed. I did not get that initially and was confused.

Thank you for the reply.

Your version of jme must be ancient, update using Help->Check for Updates.

@cosmin-alexandruparvulescu said:
I solved the issue, it was because of the class name. It seems that no matter what I put in:


When running, the items of tutorial Hello Node will be displayed. I did not get that initially and was confused.

Thank you for the reply.


Did you just change the name of the class or did you also change what was happening in the main() method?

You can name the class whatever you want but if main() is still doing new HelloNode() then of course you'll actually just be running HelloNode again.
2 Likes

I ditto what pspeed says, someone else had this same problem not so long ago

@normen as I mentioned, I’m running today’s Nightly Build so it can’t be that as far as I can tell.

@pspeed when it wasn’t working, I changed everything except the name of the class.



To be more explicit I had this code:

public class HelloJME3 extends SimpleApplication {

public static void main(String[] args){

HelloJME3 app = new HelloJME3();

app.start();

}



@Override

public void simpleInitApp() { /* Stuff here */ }

}



I expected to be able to do anything in simpleInitApp() but no matter what you put in it, you can leave it blank, it will still run the code in the tutorial. I wanted to understand why that happens and I can’t just put anything I want in there under the class name HelloJME3.

If it’s still not understood, I will rewrite the code and comment everything but again, the problem on my end is solved so it would only be for clarification purposes.



Thank you for the replies.

@cosmin-alexandruparvulescu said:
@normen as I mentioned, I'm running today's Nightly Build so it can't be that as far as I can tell.
@pspeed when it wasn't working, I changed everything except the name of the class.

To be more explicit I had this code:
public class HelloJME3 extends SimpleApplication {
public static void main(String[] args){
HelloJME3 app = new HelloJME3();
app.start();
}

@Override
public void simpleInitApp() { /* Stuff here */ }
}

I expected to be able to do anything in simpleInitApp() but no matter what you put in it, you can leave it blank, it will still run the code in the tutorial. I wanted to understand why that happens and I can't just put anything I want in there under the class name HelloJME3.
If it's still not understood, I will rewrite the code and comment everything but again, the problem on my end is solved so it would only be for clarification purposes.

Thank you for the replies.


Then you are doing something _REALLY_ wrong because this normally works fine for 99% of people. Maybe how you are running it is messed up or something.

Hello,



Seems I can’t replicate the issue I had. I didn’t mean to offend if that is what I did, I just wanted to understand what I did wrong as it was clearly my wrong-doing.



Thank you all for your help and if I ever run across that issue again I will paste all the code.



Best of luck,

Cosmin Parvulescu

Do you have multiple mains in your project? Maybe the wrong one was set as main.

1 Like

Hello, I also can not see two cubes, one blue and one red in JME3.
How do I resolve?

as has been said in this thread.

1 - Post the code for us to look at
2 - Make sure the class you are instanting in main () is the correct one
3 - Check that you are running the correct project

OS Gnu/Linux 64 bit

[java]
package jme3test.helloworld;

import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.math.ColorRGBA;
import com.jme3.scene.Node;

/** Sample 2 - How to use nodes as handles to manipulate objects in the scene.

  • You can rotate, translate, and scale objects by manipulating their parent nodes.
  • The Root Node is special: Only what is attached to the Root Node appears in the scene. */

public class HelloNode extends SimpleApplication {

public static void main(String[] args){
    HelloNode app = new HelloNode();
    app.start();
}

@Override
public void simpleInitApp() {

    /** create a blue box at coordinates (1,-1,1) */
    Box box1 = new Box( Vector3f.ZERO, 1,1,1);
    Geometry blue = new Geometry("Box", box1);
    Material mat1 = new Material(assetManager, 
            "Common/MatDefs/Misc/Unshaded.j3md");
    mat1.setColor("Color", ColorRGBA.Blue);
    blue.setMaterial(mat1);
    blue.move(1,-1,1);

    /** create a red box straight above the blue one at (1,3,1) */
    Box box2 = new Box( Vector3f.ZERO, 1,1,1);
    Geometry red = new Geometry("Box", box2);
    Material mat2 = new Material(assetManager, 
            "Common/MatDefs/Misc/Unshaded.j3md");
    mat2.setColor("Color", ColorRGBA.Red);
    red.setMaterial(mat2);
    red.move(1,3,1);

    /** Create a pivot node at (0,0,0) and attach it to the root node */
    Node pivot = new Node("pivot");
    rootNode.attachChild(pivot); // put this node in the scene

    /** Attach the two boxes to the *pivot* node. */
    pivot.attachChild(blue);
    pivot.attachChild(red);
    /** Rotate the pivot node: Note that both boxes have rotated! */
    pivot.rotate(.4f,.4f,0f);
}

}
[/java]

I just tried the code and it is fine. How are you running it? Press Shift + F6, and post a screenshot, please

Build and clean

ant -f /home/solidsnake/JMonkeyEngine3/HelloWorld clean jar
init:
deps-clean:
Updating property file: /home/solidsnake/JMonkeyEngine3/HelloWorld/build/built-clean.properties
Deleting directory /home/solidsnake/JMonkeyEngine3/HelloWorld/build
clean:
init:
deps-jar:
Created dir: /home/solidsnake/JMonkeyEngine3/HelloWorld/build
Updating property file: /home/solidsnake/JMonkeyEngine3/HelloWorld/build/built-jar.properties
Created dir: /home/solidsnake/JMonkeyEngine3/HelloWorld/build/classes
Created dir: /home/solidsnake/JMonkeyEngine3/HelloWorld/build/empty
Compiling 2 source files to /home/solidsnake/JMonkeyEngine3/HelloWorld/build/classes
warning: [options] bootstrap class path not set in conjunction with -source 1.5
1 warning
compile:
Created dir: /home/solidsnake/JMonkeyEngine3/HelloWorld/dist
Copying 1 file to /home/solidsnake/JMonkeyEngine3/HelloWorld/build
Not copying library /home/solidsnake/JMonkeyEngine3/HelloWorld/assets , it’s a directory.
Copy libraries to /home/solidsnake/JMonkeyEngine3/HelloWorld/dist/lib.
Building jar: /home/solidsnake/JMonkeyEngine3/HelloWorld/dist/MyGame.jar
To run this application from the command line without Ant, try:
java -jar “/home/solidsnake/JMonkeyEngine3/HelloWorld/dist/MyGame.jar”
jar:
BUILD SUCCESSFUL (total time: 1 second)

Run

run:
apr 28, 2013 3:49:48 PM com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.0.0 Beta
apr 28, 2013 3:49:48 PM com.jme3.system.Natives extractNativeLibs
INFO: Extraction Directory: /home/solidsnake/JMonkeyEngine3/HelloWorld
apr 28, 2013 3:49:48 PM com.jme3.system.lwjgl.LwjglAbstractDisplay run
INFO: Using LWJGL 2.8.4
apr 28, 2013 3:49:48 PM com.jme3.system.lwjgl.LwjglDisplay createContext
INFO: Selected display mode: 1366 x 768 x 24 @50Hz
apr 28, 2013 3:49:51 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Adapter: null
apr 28, 2013 3:49:51 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Driver Version: null
apr 28, 2013 3:49:51 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Vendor: NVIDIA Corporation
apr 28, 2013 3:49:51 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: OpenGL Version: 3.3.0 NVIDIA 304.88
apr 28, 2013 3:49:51 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Renderer: GeForce G102M/integrated/SSE2
apr 28, 2013 3:49:51 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: GLSL Ver: 3.30 NVIDIA via Cg compiler
apr 28, 2013 3:49:51 PM com.jme3.system.lwjgl.LwjglTimer <init>
INFO: Timer resolution: 1.000 ticks per second
apr 28, 2013 3:49:51 PM com.jme3.renderer.lwjgl.LwjglRenderer initialize
INFO: Caps: [FrameBuffer, FrameBufferMRT, FrameBufferMultisample, TextureMultisample, OpenGL20, OpenGL21, OpenGL30, OpenGL31, OpenGL32, ARBprogram, GLSL100, GLSL110, GLSL120, GLSL130, GLSL140, GLSL150, VertexTextureFetch, TextureArray, TextureBuffer, FloatTexture, FloatColorBuffer, FloatDepthBuffer, PackedFloatTexture, SharedExponentTexture, PackedFloatColorBuffer, TextureCompressionLATC, NonPowerOfTwoTextures, MeshInstancing, VertexBufferArray, Multisample, PackedDepthStencilBuffer]
apr 28, 2013 3:49:51 PM com.jme3.asset.AssetConfig loadText
WARNING: Cannot find loader com.jme3.scene.plugins.blender.BlenderModelLoader
apr 28, 2013 3:49:51 PM com.jme3.asset.DesktopAssetManager <init>
INFO: DesktopAssetManager created.
apr 28, 2013 3:49:51 PM com.jme3.renderer.Camera <init>
INFO: Camera created (W: 1.366, H: 768)
apr 28, 2013 3:49:51 PM com.jme3.renderer.Camera <init>
INFO: Camera created (W: 1.366, H: 768)
apr 28, 2013 3:49:51 PM com.jme3.input.lwjgl.LwjglMouseInput initialize
INFO: Mouse created.
apr 28, 2013 3:49:51 PM com.jme3.input.lwjgl.LwjglKeyInput initialize
INFO: Keyboard created.
apr 28, 2013 3:49:51 PM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: AudioRenderer supports 64 channels
apr 28, 2013 3:49:51 PM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio effect extension version: 1.0
apr 28, 2013 3:49:51 PM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio max auxilary sends: 4
apr 28, 2013 3:49:51 PM com.jme3.material.MaterialDef <init>
INFO: Loaded material definition: Unshaded
apr 28, 2013 3:49:51 PM com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
apr 28, 2013 3:49:51 PM com.jme3.scene.Node attachChild
INFO: Child (Box) attached to this node (Root Node)
apr 28, 2013 3:49:51 PM com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Gui Node)
apr 28, 2013 3:49:51 PM com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
apr 28, 2013 3:49:52 PM com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
apr 28, 2013 3:49:52 PM com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
apr 28, 2013 3:49:52 PM com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
apr 28, 2013 3:49:52 PM com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
apr 28, 2013 3:49:52 PM com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
apr 28, 2013 3:49:52 PM com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
apr 28, 2013 3:49:52 PM com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
apr 28, 2013 3:49:52 PM com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
apr 28, 2013 3:49:52 PM com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
apr 28, 2013 3:49:52 PM com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
apr 28, 2013 3:49:52 PM com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
apr 28, 2013 3:49:52 PM com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
apr 28, 2013 3:49:52 PM com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
apr 28, 2013 3:49:52 PM com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
apr 28, 2013 3:49:52 PM com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
apr 28, 2013 3:49:52 PM com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
apr 28, 2013 3:49:52 PM com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
apr 28, 2013 3:49:52 PM com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
apr 28, 2013 3:49:52 PM com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
apr 28, 2013 3:49:52 PM com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
apr 28, 2013 3:49:52 PM com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
apr 28, 2013 3:49:52 PM com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
apr 28, 2013 3:49:52 PM com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
apr 28, 2013 3:49:52 PM com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
apr 28, 2013 3:49:52 PM com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
apr 28, 2013 3:49:52 PM com.jme3.scene.Node attachChild
INFO: Child (Statistics View) attached to this node (Gui Node)
apr 28, 2013 3:49:52 PM com.jme3.renderer.lwjgl.LwjglRenderer updateUniformLocation
INFO: Uniform m_VertexColor is not declared in shader [ShaderSource[name=Common/MatDefs/Misc/Unshaded.vert, defines, type=Vertex, language=GLSL100], ShaderSource[name=Common/MatDefs/Misc/Unshaded.frag, defines, type=Fragment, language=GLSL100]].
apr 28, 2013 3:49:58 PM com.jme3.renderer.lwjgl.LwjglRenderer cleanup
INFO: Deleting objects and invalidating state
apr 28, 2013 3:49:58 PM com.jme3.scene.Node detachChildAt
INFO: Gui Node (Node): Child removed.
apr 28, 2013 3:49:58 PM com.jme3.scene.Node detachChildAt
INFO: Gui Node (Node): Child removed.
apr 28, 2013 3:49:58 PM com.jme3.input.lwjgl.LwjglMouseInput destroy
INFO: Mouse destroyed.
apr 28, 2013 3:49:58 PM com.jme3.input.lwjgl.LwjglKeyInput destroy
INFO: Keyboard destroyed.
apr 28, 2013 3:49:58 PM com.jme3.system.lwjgl.LwjglAbstractDisplay deinitInThread
INFO: Display destroyed.
BUILD SUCCESSFUL (total time: 15 seconds)

It looks to me like you are running the first tutorial, not the second one. Look at the project name.

The project name is the same, but the name of the class is HelloNode with its own code.