Conventions of JMonkey

Why does JMonkey use Strings as parameters for specifying certain objects?
For example:
[java]new Geometry(“Box”, box1);[/java]
or
[java]new Node(“pivot”);[/java]
In LWJGL it just uses GL11.GL_QUADS. Isn’t using Strings instead just asking for run time errors?

The string is a name. Can you think of another parameter that would work for a name that isn’t a string? I can’t.

1 Like

Sorry. Don’t think I quite understand this. In the example code, it gives it a name “pivot” then, but what do you use it for?
[java] /** 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]

You can pass anything there.
Node pivot = new Node(“My Dog Has Fleas”);

It’s just a NAME. Used for seeing a name later or whatever. It’s informational or debugging info or whatever.

Have you been programming in Java for very long?

2 Likes

Not too long. Just realized I could have just used the default constructor instead. Sorry about that.

@pspeed said: The string is a name. Can you think of another parameter that would work for a name that isn't a string? I can't.

You can use ints with Hexspeak :slight_smile: (but your pretty limited :slight_smile: to actual recognizable names)

0xD15EA5E

0xBAADF00D

1 Like
@wezrule said: You can use ints with Hexspeak :) (but your pretty limited ^_^ to actual recognizable names)

0xD15EA5E

0xBAADF00D

My favorite (and Java nerd inside joke): 0xCAFEBABE

1 Like

To explain the names: They’re there so you can attach an ID so you can quickly find the interesting nodes in a dump.
The name itself isn’t used by JME, it’s just reproduced. (Maybe you can also search for it, though I prefer to simply store a reference to the node in a variable if I need that.)

oh, ok. I thought it was something like opengl where you call glBegin(GL_QUADS) so new Geometry(“Box”, box1); meant “box” draws box1 as a 4 sided shape. Anyways, it’s resolved now.

You can always go through the source while in confusion. :slight_smile:

When programming in Java, there is almost always javadoc for the APIs. A click and a click and you can get descriptions about what a lot of the parameters mean.

http://hub.jmonkeyengine.org/javadoc/