Getting the View Matrix
by Rapid Fire · in Torque 3D Professional · 11/19/2009 (5:35 pm) · 2 replies
I'm trying to create a script function to convert the world space coordinate to a screenspace coordinate, but I'm running into issues.
I wrote:
Point3F worldSpace;
dSscanf(argv[1], "%f %f %f", &worldSpace.x, &worldSpace.y, &worldSpace.z);
GFX->getViewMatrix().mulV( worldSpace );
GFX->getProjectionMatrix().mulV( worldSpace );
//Point3F screenSpace = worldSpace * RatioToConvertToGuiUnits
char* buff = Con::getReturnBuffer(64);
dSprintf(buff,63,"%g %g",
screenSpace.x, screenSpace.y );
I've not yet gotten to the conversion from -1 to 1 to the Torque scale of GUI units, but the issue I'm running into is that calling getViewmatrix() seems to return the Identity matrix, regardless of where my camera's location is. Is there any way I can get the viewMatrix without having to recreate it by grabbing the current camera object?
I wrote:
Point3F worldSpace;
dSscanf(argv[1], "%f %f %f", &worldSpace.x, &worldSpace.y, &worldSpace.z);
GFX->getViewMatrix().mulV( worldSpace );
GFX->getProjectionMatrix().mulV( worldSpace );
//Point3F screenSpace = worldSpace * RatioToConvertToGuiUnits
char* buff = Con::getReturnBuffer(64);
dSprintf(buff,63,"%g %g",
screenSpace.x, screenSpace.y );
I've not yet gotten to the conversion from -1 to 1 to the Torque scale of GUI units, but the issue I'm running into is that calling getViewmatrix() seems to return the Identity matrix, regardless of where my camera's location is. Is there any way I can get the viewMatrix without having to recreate it by grabbing the current camera object?
#2
11/20/2009 (1:13 am)
Well that would make things much simpler, I'm a little embarassed I didn't spot that before (first time with Torque).
Associate Manoel Neto
Default Studio Name