Here you go
Code:
static Vec4 Vec4Transform( Vec4 In, Mat4 pm )
{
Vec4 Out;
Out.x = pm.m_rows[0].x * In.x + pm.m_rows[1].x * In.y + pm.m_rows[2].x * In.z + pm.m_rows[3].x;
Out.y = pm.m_rows[0].y * In.x + pm.m_rows[1].y * In.y + pm.m_rows[2].y * In.z + pm.m_rows[3].y;
Out.z = pm.m_rows[0].z * In.x + pm.m_rows[1].z * In.y + pm.m_rows[2].z * In.z + pm.m_rows[3].z;
Out.w = pm.m_rows[0].w * In.x + pm.m_rows[1].w * In.y + pm.m_rows[2].w * In.z + pm.m_rows[3].w;
return Out;
}
static Vec4 Vec4Transform( Vec4 In, LinearTransform pm )
{
Vec4 Out;
Out.x = pm.left.x * In.x + pm.up.x * In.y + pm.forward.x * In.z + pm.trans.x;
Out.y = pm.left.y * In.x + pm.up.y * In.y + pm.forward.y * In.z + pm.trans.y;
Out.z = pm.left.z * In.x + pm.up.z * In.y + pm.forward.z * In.z + pm.trans.z;
Out.w = pm.left.w * In.x + pm.up.w * In.y + pm.forward.w * In.z + pm.trans.w;
return Out;
}
static Vec3 Vec3Transform( Vec3 In, Mat4 pm )
{
Vec3 Out;
Out.x = pm.m_rows[0].x * In.x + pm.m_rows[1].x * In.y + pm.m_rows[2].x * In.z + pm.m_rows[3].x;
Out.y = pm.m_rows[0].y * In.x + pm.m_rows[1].y * In.y + pm.m_rows[2].y * In.z + pm.m_rows[3].y;
Out.z = pm.m_rows[0].z * In.x + pm.m_rows[1].z * In.y + pm.m_rows[2].z * In.z + pm.m_rows[3].z;
return Out;
}
static Vec3 Vec3Transform( Vec3 In, LinearTransform pm )
{
Vec3 Out;
Out.x = pm.left.x * In.x + pm.up.x * In.y + pm.forward.x * In.z + pm.trans.x;
Out.y = pm.left.y * In.x + pm.up.y * In.y + pm.forward.y * In.z + pm.trans.y;
Out.z = pm.left.z * In.x + pm.up.z * In.y + pm.forward.z * In.z + pm.trans.z;
return Out;
}
Code:
dice::AxisAlignedBox GetSoldierBounds( dice::ClientSoldierEntity* pEntity, bool CenterBounds = false )
{
dice::AxisAlignedBox AABB;
dice::LinearTransform AAWorldTransform;
pEntity->computeBoundingBox( &AABB );
pEntity->computeBoundingBoxWorldTransform( &AAWorldTransform );
dice::AxisAlignedBox R;
R.min = dice::Vec3Transform( AABB.min, AAWorldTransform );
R.max = dice::Vec3Transform( AABB.max, AAWorldTransform );
if( CenterBounds )
{
R.min.x = pEntity->m_cameraLocalSpace.trans.x;
R.min.z = pEntity->m_cameraLocalSpace.trans.z;
R.max.x = pEntity->m_cameraLocalSpace.trans.x;
R.max.z = pEntity->m_cameraLocalSpace.trans.z;
}
return R;
}
Code:
dice::AxisAlignedBox Bounds = GetSoldierBounds( pEntity, true );
dice::Vec3 SoldierBounds[2];
if(
dice::Core::WorldToScreen( &Bounds.max, &SoldierBounds[0] ) &&
dice::Core::WorldToScreen( &Bounds.min, &SoldierBounds[1] ) )
{
float w = ( SoldierBounds[1].y - SoldierBounds[0].y ) / 4;
D3DRender::OutlineRGB( SoldierBounds[0].x - w, SoldierBounds[0].y, w * 2,
( SoldierBounds[1].y - SoldierBounds[0].y ), 1, RenderColor );
}
Entity VTable + 0x50 = computeBoundingBoxWorldTransform
Entity VTable + 0x54 = computeBoundingBox
Credits:
s0biet