Game Development Community

2D primitives in 3-space ?

by Greg Hoglund · in Technical Issues · 03/31/2007 (1:21 pm) · 5 replies

I am looking for a pointer / push in the right direction to mod / or use torque to render circles and lines in 3-space - that is, not like 2D GUI element, but rather like the tactical overlay you see in this screenshot from EVE online:

http://www.wuphonsreach.org/Games/EveOnline/2007/01/2007.01.07.06.07.47.jpg
http://ubiqtorate.net/~mbroggy/eve/pages/UI-w-TAC.html

I hope those links stay good for a while. If you have played EVE then you will know what I'm talking about, but for those of you who haven't - this tactical overlay renders circles at increasing distances from the player's ship. The thing is, these circles are very crisp 2D primitives rendered onto a plane in 3-space (the line appears to be 1-pixel wide), and I don't know how to do that w/ torque. I figure that this isn't a normal texture, as a texture would blur out really bad at such size. The numbers might be billboards? I would also like to be able to render a single straight line between two objects in 3space. This mode of rendering is probably really easy to do since clearly 3D modeling programs show grids on planes in this manner, and also render lines between objects and show wireframes/gizmos/arrow markers/ etc in this manner - any help to get me started doing this mode of rendering w/ torque would be appreciated. Thanks!

-Greg

#1
03/31/2007 (4:15 pm)
If you want to dive into the code, you'll need to post this in the private SDK-owner's forums,
but in a nutshell, i'm pretty sure you'll need to implement your own type of 3D object.
You know how triggers are normally invisible but in the mission editor they show up as wireframe boxes ? That would be a good place to start poking around.
#2
03/31/2007 (5:53 pm)
Hmm, i couldn't seem to find the private forum. I did look at the code you mentioned and it might help - it appears that using GL_LINES, GL_POINTS, GL_LINE_STRIP, and GL_LINE_LOOP might produce the kinds of rendering I'm after. I suspect your hint is a good one, and if I create my own class derived from GameBase I can implement by own renderObject( ... ) call that in turn uses code similar to the following:

glBegin(GL_LINE_STRIP);
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(50.0f, 50.0f, 0.0f);
glVertex3f(50.0f, 100.0f, 0.0f);
// keep adding points here along the desired curve....
glEnd();

and as such, have some object specifically designed to render this line-based object.

Am I on the right track?

-G

Note: maybe the glBegin/End paradigm isn't how it would go, but the GL_LINE_xxx and similar for primitives.
#3
03/31/2007 (6:16 pm)
here is the um proper forum for getting into nitty-gritty of the engine. your profile shows you as an SDK owner, so you should be able to see it.

anyhow,
yeah, something along those lines.

you'd probably want to make it more generalized than hardcoded points, tho.

eg in pseudo-code:
(since this is plain old openGL code, i think it's okay to talk about here.)
radius      = whatever;
numVertices = 30;
dTheta      = 2*PI / numVertices;
theta       = 0;

glBegin(GL_LINE_LOOP);
for (n = 0; n < numVertices; n++)
{
   glVertex(radius * cos(theta), radius * sin(theta), 0);
   theta += dTheta;
}
glEnd();

.. you could get more efficient by pre-calculating the vertices and storing them in an array.

.. well, actually there's a whole lot that could be done to make it more efficient,
but that's the basics.
#4
04/01/2007 (10:14 am)
Wow, thanks for the forum link, lots of new info to read in there. Somehow I wasn't able to find that using the forum menu - oop, i just noticed that it IS linked waaaaay down at the bottom of the TGE developer page. You have been a great help and this info has kicked me into the right direction. Cheers.

-G
#5
04/01/2007 (2:09 pm)
Greg, there's a resource to implement GLU disks and spheres that might be right up your alley.