TexturedElement.ClipChildren

May 23, 2009 at 8:11 PM

Hello!

TexturedElement.ClipChildren works only for the root element. What should I do to make it work for all elements hierarchy, like in GUI?

Thanks!

Coordinator
May 24, 2009 at 1:24 AM
Edited May 24, 2009 at 1:24 AM

I'll take a look (it should work for deep elements so something is probably going wrong somewhere). Is there anything special you are trying to do? or just clip all the elements.

Note that clipping the elements uses the stencil buffer to perform the clipping, and is best the stencil buffer is zero-d before drawing them.

Coordinator
May 24, 2009 at 2:22 AM
Edited May 24, 2009 at 2:23 AM

Hi.
I have not been able to reproduce this...

For example, the following code produces the correct result: (With TexturedElements too)

Color[] colours = new Color[] { Color.Red, Color.Blue, Color.Lime, Color.Yellow };
for (int g = 0; g < colours.Length; g++)
{
	Xen.Ex.Graphics2D.ElementRect previous = null;
	for (int i = 0; i < colours.Length; i++)
	{
		Xen.Ex.Graphics2D.SolidColourElement element = new Xen.Ex.Graphics2D.SolidColourElement(colours[i], new Vector2(50, 50));
		element.Position = new Vector2(25, 10);

		if (i == g)
			element.ClipChildren = true;

		if (previous != null)
			previous.Add(element);
		else
		{
			drawToScreen.Add(element);
			element.Position = new Vector2(50, 50 + g * 75);
		}
		previous = element;
	}
}

As seen here:

May 24, 2009 at 5:47 AM

Hi!

Thanks for your answer!

try this code to reproduce my situation:

 

            Xen.Ex.Graphics2D.SolidColourElement element = 

                new Xen.Ex.Graphics2D.SolidColourElement(Color.Red, new Vector2(130, 130));

            element.Position = new Vector2(50, 50);

            element.ClipChildren = true;

 

            Xen.Ex.Graphics2D.SolidColourElement element1 =

                new Xen.Ex.Graphics2D.SolidColourElement(Color.Green, new Vector2(100, 100));

            element1.Position = new Vector2(10, 10);

            element1.ClipChildren = true;

 

            Xen.Ex.Graphics2D.SolidColourElement element2 =

                new Xen.Ex.Graphics2D.SolidColourElement(Color.Blue, new Vector2(100, 100));

            element2.Position = new Vector2(10, 10);

            element2.ClipChildren = true;

 

            element1.Add(element2);

            element.Add(element1);

            drawToScreen.Add(element);

 

In this element2 not clips...

Thanks!

Coordinator
May 24, 2009 at 6:12 AM

Got it. That makes sense.
The fix requires a bit of refactoring so I'll put it in the next update (I'll probably be uploading it tonight)

May 24, 2009 at 6:15 AM

Thanks!