Bug in project() function? [GFXD3DDevice::project()
by Juan Aramburu · in Torque Game Engine Advanced · 07/31/2006 (9:27 am) · 0 replies
void GFXD3DDevice::project( Point3F &outPoint,
Point3F &inPoint,
MatrixF &modelview,
MatrixF &projection,
RectI &viewport )
{
D3DVIEWPORT9 D3Dviewport;
D3Dviewport.X = viewport.point.x;
D3Dviewport.Y = viewport.point.y;
//[b]DOESN'T[/b] work; original code
D3Dviewport.Width = viewport.extent.x - viewport.point.x;
D3Dviewport.Height = viewport.extent.y - viewport.point.y;
//[b]DOES[/b] work; commented-out code
D3Dviewport.Width = viewport.extent.x; [b]// - viewport.point.x;[/b] [b]// isn't 'extent' the width/height[/b]
D3Dviewport.Height = viewport.extent.y; [b]//- viewport.point.y;[/b]
D3Dviewport.MinZ = 0.0;
D3Dviewport.MaxZ = 1.0;
//...I found that my bitmaps were not getting plotted because this function is setting the width & height incorrectly & returning very 'wrong' numbers. I'm just calling project() with world coordinates of (a shapeBase*) shape->getPosition().
For example, if I have a TS control on an 800x600 screen at (622,0) with an extent of (178, 178), the width would be set as 178 - 622, or -444. I commented out the subtraction and simply set the width & height as the extent parameters and everything worked properly. Is this a bug or am I not using the function correctly?
Edit: of course if the position of the control is @ (0,0), it'll work fine...is that it? project() expects the control to be positioned at (0,0)? If so, there would be no need to have the viewport.point.x subtraction.