- Home /
Need the user to be able to draw lines on the screen.
Hi everyone. I have been searching and searching for an answer to my problem high and low and have come up blank. I really hope someone here can point me in the right direction.
I am working on part of a program where the user has to draw on the screen and I have to check their input to make sure it is correct. I actually have all of this working. However the person who owns this program is not happy with my input line. I am using open GL and it draws an itty bitty line which apparently looks like an etch-a-sketch. I have spent the day trying to make my lines thicker and have had zero luck. i have tried using vectrosity and for some reason the lines get wider on the x-z axis and not the x-y axis and I'm pulling my hair out trying to fix it.
I would appreciate any suggestions anyone might have. It doesn't have to be vectrosity and I am using unity pro. Any simple (if possible) ways to have user inputted thicker lines would be help me so much.
Thanks everybody for your responses. I ended up using vectrosity to make the lines. When I initially tried vectrosity and had the lines thickening along the z axis I didn't realize that one of the other cameras in our program was using the x z axis as the front of the screen and for some reason vectrosity was using that camera ins$$anonymous$$d of the camera I thought (I'm still pretty new at this whole unity thing, as well as 3d anything). Anyway once I got Vectrocity using the correct camera it worked wonderfully. I was able to use .Weld and .Fill to get the curved parts of the lines actually looking rounded, ins$$anonymous$$d of looking like a bunch of rectangles spread together.
Answer by Yokimato · Apr 01, 2013 at 08:01 PM
Does it need to be an actual line? Or can you cheat by drawing a filled rectangle?
If you use GL.Begin(GL.QUADS);
, you can provide rectangle points.
You won't make a THICKER line. A line is 1d, so "thicker" doesn't make sense, that'd make it 2d.
Check out quads though, you can definitely fill in a rectangle. It'd look something like:
GL.Color (color);
GL.Begin (GL.QUADS);
GL.Vertex3 (position.x, position.y, 0);
GL.Vertex3 (position.x + position.width, position.y, 0);
GL.Vertex3 (position.x + position.width, position.y + position.height, 0);
GL.Vertex3 (position.x, position.y + position.height, 0);
GL.End ();
Not quite it, but you get the idea. Here's the documentation on quads: http://docs.unity3d.com/Documentation/ScriptReference/GL.QUADS.html
Hi, thanks for the info. However I realized I wasn't specific enough in my question. I shouldn't have said lines because that implies straight lines. I meant curved as well as straight. The user inputs with a stylus or their finger and draws on the screen. I will probably be able to use your info for a different part of my project that actually uses straight lines though so thanks in advance for that.
Well, aren't curves just a lot of straight lines with varying direction? I'd think that'd be how you're already drawing them.