Game Development Community

OGL will kill me...

by Tim "Zear" Hammock · in Torque Game Engine · 02/22/2002 (1:18 pm) · 11 replies

Trying to create an object that will display a wireframe during mission editing... and I'll be darned if I can figure out how to implement it.

Started by modifying waypoint.cc (& .h) to make it draw any line at all in this way. No luck. The line never appears. I assume I've either misinterpreted the engine, or the OGL. Any comments? ...
void WayPoint::renderImage(SceneState* state, SceneRenderImage* image)
{
	ShapeBase::renderImage(state, image);

	glDisable(GL_CULL_FACE);
	glColor4ub(255, 0, 255, 255);

	// project the points...
	MatrixF mat = this->getTransform();

	Point3F pnt1, pnt2;
	Point3F projPnt1, projPnt2;

	pnt1.set(0,0,0);
	pnt2.set(5,5,5);

	mat.mulP(pnt1, &projPnt1);
	mat.mulP(pnt2, &projPnt2);

	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	glBegin(GL_LINE); 
	glVertex3f(projPnt1.x,projPnt1.y,projPnt1.z); 
	glVertex3f(projPnt2.x,projPnt2.y,projPnt2.z); 
	glEnd();

}

#1
02/22/2002 (3:18 pm)
On debugging, I see that the two points are properly projected (projPnt1 has the same coords as the object). I am assuming that OGL coords are the same as game coords. If that is incorrect, then obviously the line is being drawn somewhere else, but on looking around, I don't see it (and other lines drawn in this fashion are visible from a significant distance, so unless it is far over the horizon, I should see it).

So assuming I am right up to this point, I am guessing that there is some state in the OGL that is improperly set.

I tried dropping the
glDisable(GL_CULL_FACE);

and

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
with no improvement. And it is an eternity between calls to dglSetCanonicalState(). This may be in the interests of efficiency, but it makes it frickin' hard to determine exactly what the state is and what state I want. Grrr.

#2
02/22/2002 (4:02 pm)
I think your problem may be that Tribes 2 used the bitmask targettign system to determine who could see which waypoints and what colour they were.

The targetting system was removed from torque and currently there is no way to make the waypoints visible.

(Or none that I have found) :(
#3
02/22/2002 (4:55 pm)
No, the waypints are visible in the mission editor. The problem seems to be my lack o OpenGL experience...
#4
02/22/2002 (10:35 pm)
notice the code:
glMatrixMode(GL_MODELVIEW);
   glPushMatrix();
   dglMultMatrix(&mObjToWorld);
   glScalef(mObjScale.x, mObjScale.y, mObjScale.z);

   // RENDER CODE HERE
   wireCube(0.5, Point3F(0, 0, 0));

   glMatrixMode(GL_MODELVIEW);
   glPopMatrix();
found in marker class
this sets up the current glMatrix
you will prolly discover that these state changes of the matrix are important for drawing the object in the correct space
#5
02/23/2002 (12:33 am)
Usually when I'm trying to draw lines or something and it doesn't work, it's because I forgot
glDisable(GL_TEXTURE_2D);
#6
02/23/2002 (4:46 am)
Badguy's option is the most likely Tim, your not setting which matrix (openl gl has a few matrix states) is the current one.

Try the code that badguy posted and see if that works, the gl calls to draw the lines looks fine to me, so i'm guessing it is the matrix state that you need to set.

I'd suggest getting the online version of the OpenGL red book (www.opengl.org) its well worth a read if your goingto get into this stuff.

Phil.
#7
02/23/2002 (9:46 am)
OK. Working along those lines now (no success tho still trying).

Interesting note: the code Badguy references in the Marker class? It isn't ever called. Grrr.

Despite the documentation, I find that the actual render path varies quite widely from object to object, in many cases not really matching the docs very closely.
#8
02/23/2002 (9:48 am)
hmm .. indeed :)
I
#9
02/23/2002 (9:55 am)
Hmmm. I couldn't get it to call that method at all. Mebbe I need a newer build (this was the dev_stable on the 20th of Jan).

BTW, did it display a multicolored vector cube around the marker origin?
#10
02/23/2002 (9:58 am)
my Bad it was the other marker class i was working with now that i look at the script ..

ok Edit that ..
the marker class is used but it isnt werking on my end
I see the onAdd is called but the render never happens but the parent is doing the bbox in editor so .. ill check it out here
#11
02/25/2002 (2:00 pm)
Have any new insights yet Badguy?

I've been digging in it myself, but since the editor components don't always follow the cannonical path to rendering, I haven't quite nailed down where this component is being passed up... it gets a bit tangled in there.