Stencil issues

This code:

	function ScrollableTextBox()

		--draw stencil box node 		
		local stenbox = gui.new_box_node(vmath.vector3(ScreenWidth/2,ScreenHeight/2-100,1), vmath.vector3(ScreenWidth*.86,ScreenHeight*.70,1))
		gui.set_layer(stenbox, "background") -- text and box on same layer

		--draw text node 
		local texty = gui.new_text_node(vmath.vector3(562,ScreenHeight/2+300+100,1), "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam ut euismod risus. Sed dignissim euismod viverra. Nulla molestie erat faucibus purus tincidunt, et porta erat venenatis. Sed ut ultricies ipsum. Sed dolor risus, commodo mattis rutrum vitae, cursus vel ipsum. Interdum et malesuada fames ac ante ipsum primis in faucibus. Suspendisse potenti. Nullam efficitur at leo porta mollis. Ut pulvinar scelerisque maximus. Donec iaculis non nunc ac consequat. Donec sed urna a metus consectetur convallis ut in mi. Fusce aliquet enim sed neque egestas, ut egestas mi interdum. Sed posuere quam quis risus consectetur bibendum. Aenean pharetra, erat non ultricies sodales, ipsum nulla malesuada elit, a tempor magna turpis pulvinar magna. Cras nisi augue, efficitur at vehicula vel, sollicitudin quis lacus. In nisl libero, ultrices ac viverra sed, varius sed risus.")
		gui.set_layer(texty, "background") -- text and box on same layer

		--parent textnode(child) to stencil (parent) 
		gui.set_parent(texty, stenbox, true)

		--invoke clipping mode on stencilbox 
		gui.set_clipping_mode(stenbox, gui.CLIPPING_MODE_STENCIL)
		gui.set_clipping_visible(stenbox, true)		

        -- **** this line of code when active causes no text...
		gui.set_position(texty,vmath.vector3(562, 1600,1))

		gui.set_color(texty, ColorTable["black"])
		gui.set_font(texty, "NormalSans1MEDIUM+")
		gui.set_size(texty, vmath.vector3(ScreenWidth*.80,ScreenHeight*.64,1))
		gui.set_line_break(texty, true)
		gui.set_id(texty, "votext")

		InputMode="SCROLLTEXT"
		print("here------")
		print(gui.get_position(gui.get_node("votext")))

	end 

Acts weird - in that the stencil works but the second I MOVE the text box using a set_position statement it literally disappears from the screen.

Any thoughts what I’m doing wrong?

As a further note in the above code if you add…

gui.move_above(texty, nil)

Right after gui.set_position it makes the text visible BUT it breaks the stencil

What if you use z-value 0 instead of 1?

Nope. :frowning: no difference so far.

I got it working now but still unsure what’s going on but essentially it’s about making the texty node = 0,0,1 – there’s a remapping of coordinates even though during parenting I think I tell it not to do that. It must be overridden by the stenciling of the parent node… at least that’s what I think is happening.

But this only matters at the time you call set_parent(). It is the position at that time which is kept. But you change the position after calling set_parent(). Try calling set_position() first.

I’m going to play with that this morning. In general though - what confused me was that I was thinking in terms of the core coordinates since I had set parent keep transform to true and it wasn’t behaving as expected. That it’s behaving as expected for stencils makes sense now, but didn’t at the time I was trying to understand it.

1 Like

FWIW here’s the transformation between before and after parent

DEBUG:SCRIPT: texty:[562.000000, 1618.000000, 1.000000] <–original setting
DEBUG:SCRIPT: texty2:[-0.499970, 500.000031, 0.000000] <–after parenting to stencil