Drawing a Line with gfxDrawUtil.cpp
by Jacob S. · in Torque 3D Professional · 04/30/2010 (11:50 am) · 4 replies
I am trying to use this code to draw a primative red line that connects two points on the terrain that I select. I can say that the code is being called and is stepping through the correct drawline function. What I cannot figure out is why the line isn't appearing.
I have this code snippet in gfxDrawUtil.cpp with the appropriate includes for a consoleFunction along with the include for gfx/gfxDevice.h.
Is there some error with my code I'm not seeing or some sort of garbage collection going on in the background that is erasing my line as soon as it's made that I simply missed some how?
Any input would be great.
Edit: Working ver with debugDraw.cpp www.torquepowered.com/community/forums/viewthread/114859
I have this code snippet in gfxDrawUtil.cpp with the appropriate includes for a consoleFunction along with the include for gfx/gfxDevice.h.
Is there some error with my code I'm not seeing or some sort of garbage collection going on in the background that is erasing my line as soon as it's made that I simply missed some how?
Any input would be great.
ConsoleFunction( createGFXLine, void, 3, 3, "createGFXLine( %start, %end )") {
Point3F start;
dSscanf(argv[1], "%g %g %g", &start.x, &start.y, &start.z);
Point3F end;
dSscanf(argv[2], "%g %g %g", &end.x, &end.y, &end.z);
ColorI color;
color.red = 255;
color.green = 0;
color.blue = 0;
color.alpha = 255;
GFX->getDrawUtil()->drawLine( start.x, start.y, start.z, end.x, end.y, end.z, ColorI(255,0,0) );
Con::printf("I am being called Wewt!");
}Edit: Working ver with debugDraw.cpp www.torquepowered.com/community/forums/viewthread/114859
#2
06/05/2010 (12:22 pm)
logged: TQA-233
#3
07/15/2010 (7:52 pm)
Is the DebugDrawer the only way to draw primitive shapes in non-editor mode (i.e. in a GameTSCtrl)?
#4
To use GFXDrawUtil you have to make a call to drawLine every frame during the rendering process, this you could achieve by either modifying GameTSCtrl (I'd try and avoid that) or by adding it to another object of your own.
Personally depending on what you're trying to achieve I'd create my own object derived from sceneobject or similar and have it render the line
07/16/2010 (8:20 am)
No you can use the GFXDrawUtil, as Manoel said you can't use the call above from script as it would draw the line in one frame but it wouldn't appear the next frame.To use GFXDrawUtil you have to make a call to drawLine every frame during the rendering process, this you could achieve by either modifying GameTSCtrl (I'd try and avoid that) or by adding it to another object of your own.
Personally depending on what you're trying to achieve I'd create my own object derived from sceneobject or similar and have it render the line
Associate Manoel Neto
Default Studio Name
You'll want to use the DebugDrawer for that.