Game Development Community

dev|Pro Game Development Curriculum

GLU quadrics for Torque

by James \"Corvidae\" Williams · 03/01/2003 (4:42 pm) · 23 comments

Download Code File

In working on a yet-unannounced project, I discovered that I needed to be able to draw rings, disks, and other primitives. However, the stock GLU library conflicted with DGL and wouldn't work. Therefore, I took it upon myself to port the portions of GLU I needed to Torque, so they could be used.

Installation:
-------------

* Copy the three source files from the zip into your engine/dgl directory and add them to the project.
* Recompile.

Usage:
------

Here's the code to use gluDisk, as seen in the screenshot (in ShapeBase::renderObject):

static GLUquadricObj *quadric = gluNewQuadric();

glPushMatrix();
dglMultMatrix(&getRenderTransform());
gluQuadricDrawStyle(quadric, GL_FILL);
gluQuadricNormals(quadric, GL_SMOOTH);
glColor3f(0, 1, 0);
gluDisk(quadric, 0.9, 1.1, 32, 1);
glPopMatrix();

Currently only disks, partial disks, and spheres are supported. I can add more, if there's demand for them.
Page «Previous 1 2
#1
03/01/2003 (4:43 pm)
Looks pretty cool :)
#2
03/01/2003 (4:58 pm)
yep, thx Corvidae :)
Cool stuff, and I can see plenty of usage for it !
Again, thank you
#3
04/05/2003 (10:25 pm)
Just in time! I just now was wondering why gluNewQuadric wasn't working, and checked for resources, to find this one posted barely a month ago. Many thanks!
#4
06/08/2003 (6:52 pm)
Corvidae,

What you have provided is awsome, just one note. the above can be accomplished in standard TGE without adding the files you mentioned. Just need to add the proper function declerations to wingl.cc and to glu_func.h

-Ron
#5
06/26/2003 (6:40 pm)
And something similar under unix.
#6
05/20/2005 (3:16 pm)
I know this resource is REALLY old, but could someone please state specifically where the heck that code block goes?
#7
05/20/2005 (3:42 pm)
If you want to make this cross platform forget about the gluos.h file and these lines to the top of glu.cc

#include <stdlib.h>         /* For _MAX_PATH definition */
#include <stdio.h>
#include <malloc.h>

It compiles! Now if I can just get it to work, with all the other code I have floating around in shapebase :)

*Update* Ok this is a no brainer, but make sure to include dgl/glu.h somewhere up near the top of ShapeBase. Also make double sure you have an include to down near the bottom of the includes list.
#8
07/22/2005 (5:30 am)
There is an error in gluos.h
that uses a winuser.h and give errors...

anyone know how fix this??

i used what dreamer did...... it
#9
11/22/2005 (10:23 am)
cool resource... implemented it and happy ;)
Thanks a lot..
I'm using latest CVS TGE and while compiling shapeBase.cc I get:

h:\tge\engine\terrain\fluid.h(72) : warning C4005: 'PI' : macro redefinition
h:\tge\engine\dgl\glu.h(42) : see previous definition of 'PI'

everything works fine...
but just curious about ... I'm used to don't have that "warnings" ...
#10
01/01/2006 (9:05 am)
Just remove #DEFINE PI 3.141592 etc. from glu.h
#11
02/23/2006 (1:52 pm)
has anybody figured out how to make the ring conform to terrain?
#12
03/23/2006 (5:48 am)
I tried to add the code, and got the following errors:

glu.obj : warning LNK4229: invalid directive '/OPT:NOWIN98' encountered; ignored
Creating library .\../lib/out.VC6.RELEASE/glu2d3d.lib and object .\../lib/out.VC6.RELEASE/glu2d3d.exp
glu.obj : error LNK2019: unresolved external symbol _glEnd referenced in function "void __stdcall gluPartialDisk(struct GLUquadric *,double,double,int,int,double,double)" (?gluPartialDisk@@YGXPAUGLUquadric@@NNHHNN@Z)
glu.obj : error LNK2019: unresolved external symbol _glVertex3f referenced in function "void __stdcall gluPartialDisk(struct GLUquadric *,double,double,int,int,double,double)" (?gluPartialDisk@@YGXPAUGLUquadric@@NNHHNN@Z)
glu.obj : error LNK2019: unresolved external symbol _glTexCoord2f referenced in function "void __stdcall gluPartialDisk(struct GLUquadric *,double,double,int,int,double,double)" (?gluPartialDisk@@YGXPAUGLUquadric@@NNHHNN@Z)
glu.obj : error LNK2019: unresolved external symbol _glBegin referenced in function "void __stdcall gluPartialDisk(struct GLUquadric *,double,double,int,int,double,double)" (?gluPartialDisk@@YGXPAUGLUquadric@@NNHHNN@Z)
glu.obj : error LNK2019: unresolved external symbol _glNormal3f referenced in function "void __stdcall gluPartialDisk(struct GLUquadric *,double,double,int,int,double,double)" (?gluPartialDisk@@YGXPAUGLUquadric@@NNHHNN@Z)
../example/glu2d3d.dll : fatal error LNK1120: 5 unresolved externals

I tried adding glcorefunc.h (where glEnd is declared) but that only made it worse.

Any ideas anyone? please???
#13
03/23/2006 (5:48 am)
#14
04/05/2006 (1:55 pm)
Great resource! I've implemented and got it working in 4.1 with one minor flaw. As is the code works fine when I'm only selecting myself. Selecting NPC's did not work. I've worked through that by replicating the GLU code if anything else is selected, but now when the disk is drawn I see the entire thing, looking as if the disk runs through a players legs. Does anyone have any ideas or have a "Working" solution for selecting NPC's?
#15
04/12/2006 (1:11 pm)
Hey James,

Good resource. I got it working well in TGE 4.1 also. I haven't looked through the code yet, but would it be possible for people using the Lighting Kit to have it do a decal projector on the ground? That way we would make our own graphic to fit the need and also allow some type of glow effect to the decal if we wanted. Also, how hard it is to change the color of the existing circle depending on what is selected.

Example: An enemy would be red, but a monster would be orange and a NPC and other friends would be green.

Thanks for your work on this,

-- Chris
#16
07/25/2006 (8:08 pm)
How would you go about getting this to work with TSE?
#17
08/15/2006 (7:19 am)
I would like to use the gluCylinder, which is not included in this port. Can someone tell me where to find the source code for gluCylinder?

The disks work great. Thanks for porting them!

EDIT: Found an implementation to port from here:
http://www.reactos.org/generated/doxygen/d4/d8a/quad_8c-source.html
#18
11/01/2006 (1:30 pm)
Is there a way to make the ring form to the surface the player is standing on instead of being a static ring around the base of the model? So if the player were on a hill the circle would be sloping with the angle of the terrain.
#19
11/30/2006 (2:31 pm)
Kyle you should look for the Arcane Pack when it is released for that functionality.

www.arcane-fx.com
#20
03/21/2007 (4:27 am)
I've implemented this in TGE 1.5 and works just fine, but the only problem is that every single object in my game is circled now! Is there a way in script to only make them show when i want to, for example when i click on them? I already have 3D object selection in my project.
Page «Previous 1 2