Updating Geometry in guiNode

I have a Geometry which is attached to the guiNode. I am trying to rotate it every frame, but the problem arises because the Geometry displayed does not rotate (I also tried moving it).

I tried:

[java]

guiNode.updateGeometricState();

guiNode.updateLogicalState(tpf);

guiNode.updateModelBound();

[/java]

but with no results. I also tried re-attaching the Geometry. What must I do to update it?

You sure you actually move it? This should work normally, w/o any updates.

In the SimpleUpdate, I call update.crossPosition(). In the Update class’ crossPosition, I use the following:

setupU.cross.setLocalTranslation(300, 300, 0);

@memonick said:
In the SimpleUpdate, I call update.crossPosition(). In the Update class' crossPosition, I use the following:
setupU.cross.setLocalTranslation(300, 300, 0);

well this is not rotating, this will update your spatial position to 300,300 on each frame...making it perfectly still ....

I know, that was for testing purposes. It doesn’t do it. Upon testing it from the Main class, it works well. Will continue investigating the matter. Thanks.

Calling it like this, it works: Main.setup.cross.setLocalTranslation(500,500,0);

I have just one last question - is there any way how I can change the z-position of this geometry?

the third param is the z position, as far as i remember it should affect the rendering order

No, the z-depth doesn’t change :confused: I am using rootNode right now, and it works very well.

You cannot change the depth of a gui element because it is rendered without perspectivity, i.e. orthogonal. You only change the order it appears on the screen with the z component. If you want it smaller, then do so with a smaller quad. If you want some kind of Scaleform style of perceivable “depth” you would need to write your own 3D GUI which uses the rootNode and not the guiNode.



How about you just read up all the relevant tutorials and think 5mins about it?

I did read them, but they’re not as simple to beginners as you might think.

@Dodikles said:
You cannot change the depth of a gui element because it is rendered without perspectivity, i.e. orthogonal. You only change the order it appears on the screen with the z component. If you want it smaller, then do so with a smaller quad. If you want some kind of Scaleform style of perceivable "depth" you would need to write your own 3D GUI which uses the rootNode and not the guiNode.

How about you just read up all the relevant tutorials and think 5mins about it?


Actually, you are right that the GUI node doesn't render depth... though it _DOES_ use the Z for ordering.

The reason is incorrect, though. JME (rather arbitrarily) chose to flatten the gui by giving it a scale of 0 in Z and setting the near and far clip to 0. I needed depth support for my Mythruna GUIs so I changed this in my local version. Now my guis have depth and I can do clipping tricks with masking layers.

@memonick so is it working now or not? Does your object ever show up in the GUI or does it disappear when you move it or something? I wasn't really clear on what was happening.

But there is no magic here. If:
setupU.cross.setLocalTranslation(300, 300, 0);
...didn't work and:
Main.setup.cross.setLocalTranslation(500,500,0);
...does then the setup of setupU and setup are different or you have some other fields named the same or something. Adding the Main to the front shouldn't matter... though it indicates a static field and that hints at poor design.

It works. The only problem was the ordering, as I didn’t understand it at first.

@pspeed: Erm, as I said: You only change the order it appears on the screen with the z component ^^ So layering can be done in the guiNode. What I meant with depth and rotation was the following:





That is not possible due to the “infinite distance” to the image plane of the camera.

But the depth is flattened. So if you draw an object at z=10 and an object at z=0 this only controls the order they are drawn. If the actual objects would interpenetrate then they won’t in the gui node because all depth has been flattened out of them. One object is completely drawn with no depth and then the other object is completely drawn with no depth. In fact, if your guiNode object requires depth in order to render correctly then it won’t be. Basically, this means that rendering 3D object of any kind in the gui node is non-functional in all but the simplest cases… even if an orthogonal projection would otherwise be fine.



In my case, I control the rendering order to do things like using transparent quads to mask off parts of the gui so that I can get clipping (since JME provides no access to clip rectangles in regular geometry and I don’t want to write a full-up scene processor.) In this case, I needed depth to be properly written to the Z-buffer. I can draw a transparent quad at depth 10 and as long as it’s drawn first then anything drawn in that same area less then z=10 will be invisible.

1 Like