Foreground node prejiduced against coord system?

I think that the foreground node renders incorrectly when using View.VIEW_FIXED and different coordinate systems. Right now I have a view that’s looking towards <0,0,0> with an up vector <0,0,1> (up is the Z-axis). So my Y axis is the “real up”, the camera moves and is set at a height of -1000 on the Y-axis, so <0,-1000,0>, but it moves along an XZ plane at that height. The positive X axis is to the right.

So when a geometry of created like so:

public static Geometry createQuad() {
            Point3f[] coords = new Point3f[] {
            
                                   new Point3f(0, 0, 0),
                                   new Point3f(-10, 0, 0),
                                   new Point3f(-10, 0, -10),
                                   new Point3f(0, 0, -10),
                                   
                               };
                               
            Color3f[] colors = new Color3f[] {
            
                                   new Color3f(1,0,0),
                                   new Color3f(1,1,1),
                                   new Color3f(0,1,0),
                                   new Color3f(1,1,1)
                               };
                               
                               
            QuadArray g = new QuadArray(coords.length, GeometryArray.COORDINATES|GeometryArray.COLOR_3);
            g.setCoordinates(0,coords);
            g.setColors(0,colors);
            
            return g;
      }

It is for some reason invisible, might be because it’s sideways? Well I tried to see if it was side ways and changing its first Point3f to Point3f(0,10,0) makes it visible, but the colors are incorrect, and changing the size doesn’t seem to affect the actual quad, it’s rendered to take up the top-left half of the view completely (which is incorrect, it should be the bottom-left half, and it should be smaller, and should be tilted at one end slightly).

I think that somewhere in the render code a certain coordinate system is chosen to render this thing. Will, what coordinate system are you using? How should I change mine to be like yours so that the foreground node renders properly?

VIEW_FIXED for both Background and Foreground moves the camera to the origin pointing in a set direction for rendering.

VIEW_FIXED_POSITION moves the camera to the origin for rendering, pointing in the current direction.

VIEW_FIXED uses the standard OpenGL coordinate orientation where Z is depth. Moving away from the camera is negative Z, so your Z value must be negative.

Try adding a foreground at (0,0,-10) and it should work.

One needs to be careful that the near clipping doesn’t remove the foregorund geometry! (so change your near clipping too).

The maximum X and Y values are also quite small. It would be good to add some methods that could return the maximum X and Y values for the given screen size while in FIXED mode (this could also be used to align UI elements on the edges rather than making assumptions about the aspect ratio).

The Foreground node (VIEW_FIXED only) is not prejiduced against your coordinate system – it just has its own.

Will.

[quote]VIEW_FIXED for both Background and Foreground moves the camera to the origin pointing in a set direction for rendering.

VIEW_FIXED_POSITION moves the camera to the origin for rendering, pointing in the current direction.

VIEW_FIXED uses the standard OpenGL coordinate orientation where Z is depth. Moving away from the camera is negative Z, so your Z value must be negative.

Try adding a foreground at (0,0,-10) and it should work.

One needs to be careful that the near clipping doesn’t remove the foregorund geometry! (so change your near clipping too).

The maximum X and Y values are also quite small. It would be good to add some methods that could return the maximum X and Y values for the given screen size while in FIXED mode (this could also be used to align UI elements on the edges rather than making assumptions about the aspect ratio).

The Foreground node (VIEW_FIXED only) is not prejiduced against your coordinate system – it just has its own.

Will.
[/quote]
Alright thanks, I changed mine anyways (I wanted to do it eventually) so that now Z is up and the up vector of the view is Y. The quad geometry loads, but when I try to add a Text2D object to the foreground I can’t see it. How should I add it to it? What should the translation be?

Could it be because Text2D uses a Billboard geometry…?

Resistance is futile, Y is Up.

Seriously, I tried Z is up for a while too – but it’s not worth the pain. When working with OpenGL, it is much easier to just think of X,Z coordinates for a landscape than try to switch everything. Of course, you have to be on guard when working with Foreground.VIEW_FIXED where X,Y position the object, and Z is the depth (unlike your landscape which is X,Z with Y as the height). I wasted an hour once on that ::slight_smile:

Background and Foreground geometry in VIEW_FIXED* modes won’t interact with “normal” objects very well at all as the view matrix is altered when rendering them to get the desired effect. VIEW_NORMAL however does not mess with the view matrix, the only real difference is the rendering order. Billboards will almost certainly not work well with VIEW_FIXED* as the Billboard will point to the viewer, and not the origin where it is rendered.

You will need to change Text2D so it works with a Foreground object if this is what you want.

Will.

[quote]Resistance is futile, Y is Up.

Seriously, I tried Z is up for a while too – but it’s not worth the pain. When working with OpenGL, it is much easier to just think of X,Z coordinates for a landscape than try to switch everything. Of course, you have to be on guard when working with Foreground.VIEW_FIXED where X,Y position the object, and Z is the depth (unlike your landscape which is X,Z with Y as the height). I wasted an hour once on that ::slight_smile:

Background and Foreground geometry in VIEW_FIXED* modes won’t interact with “normal” objects very well at all as the view matrix is altered when rendering them to get the desired effect. VIEW_NORMAL however does not mess with the view matrix, the only real difference is the rendering order. Billboards will almost certainly not work well with VIEW_FIXED* as the Billboard will point to the viewer, and not the origin where it is rendered.

You will need to change Text2D so it works with a Foreground object if this is what you want.

Will.
[/quote]
(I messed up in the previous post, I said the new coord system backwards, it’s now fixed to reflect my currect setting).

In regards to Y is up, I had the negative Y as up originally, so that at least the postive X axis would be right (since my game has 2D gameplay, where the camera looks down), however, the system you mention, with Y being up, requires X to be the actual “up” in my game, and the negative-z to be “right” in my game. I don’t really like any of these version and prefer Z to be up, so that Y is “up” in the game and X is “right” in the game… I’ll see how it goes, at least the code makes more sense now, except that all rotations are backwards…

Text2D: If the billboard is constantly facing towards the view, that’s what I want right? But if it’s not rendering simply because it’s the billboard and I have to change then fine… I’ll see what I can do, but doesn’t anybody use text in the Foreground node for HUD information? Surely somebody has a working version of this?

but foreground.VIEW_FIXED achieves this - you do not want the billboarding as well.

The billboard points to the View. VIEW_FIXED however ignores the view and always uses the origin and not the view that the billboard is pointing to. Using billboard with VIEW_FIXED will normally result in the text facing the wrong direction!.

Look at the xith ui thread - someone is working on it.

Will.

[quote]but foreground.VIEW_FIXED achieves this - you do not want the billboarding as well.

The billboard points to the View. VIEW_FIXED however ignores the view and always uses the origin and not the view that the billboard is pointing to. Using billboard with VIEW_FIXED will normally result in the text facing the wrong direction!.

Look at the xith ui thread - someone is working on it.

Will.
[/quote]
Hmm, mucking about I was able to get it semi-working. I’m just making the geometry a QuadArray instead of a Billboard, however the text comes out backwards… It can’t seem to rotate the text using a Transform3D because it won’t render if I do. How do I make it so that the texture is flipped horizontally?

Edit: Hmm… I seem to have flipped it using a transform, but I’d just like to say that everything is REALLY weird… It seems that the order in which translations/rotations/scales are applied to the objects in a Foreground node is important, if done in the wrong order it seems to not work. What’s up with this? And why is it that if I translate it like so: <-10, -10, -10> it’s put really far in the bottom left corner? -10 is insignificant on most objects and it definitely isn’t a measure of pixels since the width of the window is 800. How do I align things with the edge of the window?

did you read my post?

[quote]The maximum X and Y values are also quite small. It would be good to add some methods that could return the maximum X and Y values for the given screen size while in FIXED mode (this could also be used to align UI elements on the edges rather than making assumptions about the aspect ratio).
[/quote]
It is possible to add TransformGroups to the Foreground node, so you should be able to rotate and move stuff around.

Foreground is not a 2D object, it is 3D. You can have 3D Foreground objects and not just quads. The X/Y screen coordinates have nothing to do with the 3D coordinates in OpenGL.

Will.

[quote]did you read my post?

It is possible to add TransformGroups to the Foreground node, so you should be able to rotate and move stuff around.

Foreground is not a 2D object, it is 3D. You can have 3D Foreground objects and not just quads. The X/Y screen coordinates have nothing to do with the 3D coordinates in OpenGL.

Will.
[/quote]
Oh ok, sorry, I did read that but I guess it didn’t really register. I guess I’ll take a look at the Foreground code later to see if I can do anything about that.

on the topic of foreground nodes… shapes in my foreground node are intersecting with other geometries not in the foreground node… is this the norm? i was under the assumption that foreground nodes were drawn over everything else. Can someone please clarify? Thanks :-[

[quote]on the topic of foreground nodes… shapes in my foreground node are intersecting with other geometries not in the foreground node… is this the norm? i was under the assumption that foreground nodes were drawn over everything else. Can someone please clarify? Thanks :-[
[/quote]
Hmm that’s weird, I don’t know if that’s how it’s supposed to work, but perhaps your shapes are too high up…? Or maybe your scenegraph is weird (like your FG is a child of some object instead of a child of the root BG?)

If your foreground objects are too far away from the camera, then objects that come too close may be rendered in front!

The Foreground objects are rendered last by Xith3D, but due to Z ordering arn’t nessesarily visible.

You can use RenderingAttributes to disable the depth test, however, my experiments have shown this does not work very well with alpha transparency (you get nasty black bits). As alpha transparency is a big component of my foreground nodes, this isn’t very useful.

Tweaking your near-clipping so that your foreground objects are just before the clipping could work as well. Havn’t tried this.

I certainly welcome any solutions to this problem that are better than those I have just mentioned. If someone gets alpha working with depth testing disabled I am all ears.

Will.