Game Development Community

T2dShape3D bounds-related bug and fix

by Fyodor -bank- Osokin · in Torque Game Builder · 02/08/2008 (5:41 pm) · 2 replies

First, to describe my problem I'm going to show you image:
If you load wheel.dts (from racing starter kit) into t2d you will see it narrowed:
www.afterworld.ru/gg/t2dshape3d_bug_1.jpg
If you load DTS where the bounds are far from "cube" it will display the dts scaled by one or two axis.
I can assume that Torque shifts the model trying to display the model while keeping it's bounds close to "cube"?

Digging into source I found that if I replace the dglSetFrustum call with the following:
const F32 maxSize = getMax(boxHalfX, getMax(boxHalfY, boxHalfZ));
   dglSetFrustum(-maxSize, +maxSize, -maxSize, +maxSize, -shapeRadius*depthScale, 10.0f * shapeRadius * depthScale, true);
Result:
www.afterworld.ru/gg/t2dshape3d_bug_2.jpg
This makes life a bit easier, though I'm not sure if it's ideal solution. It would be nice to integrate the same routine that performed in ShowTool Pro, so the model is "fit" right when scaled 1x1x1.

P.S. I'm using core of T2D1.1.3, but this fix can/should be applied to all versions of TGB (where t2dShape3d is implemented) - even latest 1.7.2.

#1
02/08/2008 (10:15 pm)
I noticed this happening with other models too, so it's not just the tire. I didn't think it was a bug, but now that you mention it I suppose it could be. Thanks for sharing the fix.
#2
02/09/2008 (3:22 am)
The tire is just an example (a clean one).
I'm in situation where half of my DTS files are displayed wrong in t2d, so I decided to fix it engine, as re-exporting everything with "cube" bounds wont work for me.