Parent and Z value?

See this code…

local function draw_a_die(posx, posy, sizex, sizey, contents, guiname)
	local die = gui.new_box_node(vmath.vector3(posx,posy,1), vmath.vector3(sizex,sizey,1))
	gui.set_color(die, vmath.vector4(1.0,1.0,1.0,1.0))
	local dielabel = gui.new_text_node(vmath.vector3(posx,posy,1), math.random(1,6))
	gui.set_color(dielabel, vmath.vector4(0.0,0.0,0.0,1.0))
	gui.set_font(dielabel, "NormalSans1LARGE+")
	gui.set_parent(dielabel, die)
	gui.move_above(dielabel, die)
	gui.set_id(die, guiname)

if you remove gui.move_above the number disappears
if you then remove the set_parent the number appears
just to be sure using keep scene transform value doesn’t matter

What is the relationship between parenting an object and Z value?

Obviously I can get this to work but in my way of thinking setting the parent wouldn’t have necessitated the moving the text node above the box node.

The z-value isn’t really used in the gui at all. The order in which nodes are rendered is controlled by the hierarchy of nodes and/or their layers. The z-value is not used for sorting.

BUT the z-value still has an effect, namely that if the z-value of a node falls outside of the near and far range in your render script it will not be rendered.


Ok that explains Z value a bit more but why is the behavior I’m experiencing happening when it seems like it shouldn’t. That said I did make some changes that make this a bit moot other than understanding why things happen the way they do in the code above.

So this may have to do with an issue of absolute vs. relative coordinates between the imagery and the stencil itself. Going to play with it more and see.

1 Like

Still not getting this to work – @britzl can you do the simplest build of a dynamic stencil and see what you get? Just get both a plain pie_node to stencil a plain box_node and then also to stencil a box_node that is displaying a dynamically loaded texture… I’ll keep trying further but a second run at it today is still failing to work as expected.

Ok I got it to work but not as I expected… I’ll post more in a bit but this all still needs a bit more clarity :confused:

Ok, waiting for your conclusions!

Well the thing is mostly what I wanted to do was stencil a texture to a circle or other shape. Originally my [somewhat stupid] assumption was to load the texture to a box_node then stencil it with a circle or other shaped node. Then of course I realized if I just load the texture into the circle node I can achieve most of the same objective just bypassing the melding of two nodes. So I did that.

However, this still doesn’t quite explain why the first process isn’t working and it has some usefulness still because in that version I can change the sizing of the underlying box node to achieve certain effects that I can’t if I just push the texture to the pie_node itself.

Originally I thought the problem was that I needed to ensure that the box_node used 0,0,1 as its origin position since it’s being parented and stenciled by the pie_node but that isn’t helping.

So I’m still trying to achieve a box_node w/texture (loaded from file) stenciled by a pie_node parent and for that to easily display on a screen.

Though for now I’ve moved on because the direct method is working well enough for this sprint.

1 Like