Game Development Community

DglPointToScreen not working

by Drew Parker · in Torque Game Engine · 03/31/2004 (10:45 am) · 6 replies

Hi all,

I'm trying to use dglPointToScreen, and I can't get it to work.

When I do something like this:

....
#include "dgl/dgl.h"
....


Point3f worldPt;
Point3f screenPt;

//  Lets say worldPt is 150, 120, 30

dglPointToScreen (worldPt, screenPt);

The value of screenPt is 150, 120, -30! It just flips the z-value. I've tried a ton of things and I'm at my wit's end. Anyone else having this problem, or can anyone suggest any solutions?

Thanks!

#1
03/31/2004 (11:04 am)
Maybe have a look at GuiTSCtrl::project and unproject to see how it's done there, since these methods deal with projecting world point so screen and vice versa.
#2
03/31/2004 (11:56 am)
I've started looking into those some. To do their project calculations, they reference some member functions that are updated with their onRender function, so it makes it hard to port their implementation to a different class.

I'm considering looking at that again, and also just moving my code into the guiTSCtrl class so I can use their project() function. But that seems like a bit of a roundabout solution, that's why I'm secretly hoping someone will jump out and tell me they know how to fix the dglPointToScreen function, or they know what I'm doing wrong. :)

In the meantime, I'll keep trying to understand how project() works.
#3
03/31/2004 (12:30 pm)
Maybe its the way you're using it?

I just opened up the engine source, stuck a breakpoint on the first line of dglPointToScreen() and ran it. I figured somethings going to be using that function by default. It broke in, based on a call from fxSunLight::renderObject() and the point was DEFINTLY changing. I didin't write down the exact numbers bu it was something like 250, 250, 630 goign in and 1020, -630, 1 coming out.
#4
03/31/2004 (12:49 pm)
Wow, I have no idea what I'm doing wrong.

Well thanks for the test John, that definitely validates I'm messing something up as expected. :)

I'm calling dglPointToScreen from gameConnection.cc, so is it possible I'm calling it in a place where it totally shouldn't be, and that's messing it up? I have dgl.h included in the .cc file at the top with the other #includes. Does the order of #includes affect dgl somehow?

Or could it be how I'm using my variables?

Oh by the way John, I got the GUI controls to change their layer order dynamically from script based on the hint you gave me back on this other thread. Thanks for the tip. :)
#5
03/31/2004 (1:06 pm)
One possability would be that you are calling it in such a fashion as there is insufficient projection informatino to do the projection. Stick a breakpoint in dglPointToScreen and step through it, see if perhaps the various projections are not valid.
#6
03/31/2004 (7:43 pm)
That's a good idea. I'll try that next to see where things are going wrong.