- Home /
Clipping Vectrosity lines?
I am trying to mix Vectrosity with NGUI and I have all the lines drawing in 2d over the elements but I am clipping my NGUI elements based on a panel, and ideally I need to clip the lines too.
I am still trying to get to grips with a lot of unity and NGUI, but as I have transformed everything into screen space for the 2d drawing, given a 2d rectangle and the 2d points is there any way to clip the vector lines in any way?
Be it a shader or some built in functionality im unaware of.
I don't have Vectrosity, so i can't say how it works. It probably creates a $$anonymous$$esh with the lines, so clipping should be possible. However it also depends on how the whole thing is actually rendered.
I guess Eric should be able to answer this ;)
I believe it just makes meshes in the scene like you say and positions them close to the camera to give the effect of them being 2d. Logically my brain says I would want to run a shader which knows what the bounds are and if a pixel goes over the bounds make it fully transparent, but not sure if there is a better way. As NGUI has clipping functionality built in, and I was originally hoping to piggyback off that.
Its a 3d game, its just the menus are written as 2d ones so its actually 3d points, just transformed as 2d points. NGUI does what I want for the UI and I would say its easy enough to use, I was making UIs within a few $$anonymous$$utes, its just trying to find out the best way to achieve clipping for an area over 2 components being drawn in different contexts. I am new to Unity but have been a programmer for years, so the code doesn't scare me, it's the 3d math which does :)
Answer by Eric5h5 · Aug 19, 2012 at 01:43 PM
Probably a shader would work, though I'm not sure about the specifics. One possibility is to change the vector cam's normalized viewport rect. This is easier if you use an orthographic camera (VectorLine.SetCamera(true)). For example, if you wanted to clip the vector cam to the middle 50% of the screen vertically, the viewport would be x=0, y=.25, w=1, h=.5, and the orthographic size would be 100 instead of 200. If you adjust the x/w of the viewport, you don't have to change the orthographic size. Just always make sure that x*2+w = 1, and y*2+h = 1.