Vector3 TransformDoodadVertex(const IDefinition& def, Vector3& vec)
{
    float mapOffset = 17066.0f + (2 / 3.0f);
    Vector3 MapPos = Vector3(mapOffset, 0, mapOffset);
    G3D::Matrix4 rot = G3D::Matrix4::identity();
    rot = rot.pitchDegrees(def.Rotation.y - 90);
    rot = rot.yawDegrees(-def.Rotation.x);
    rot = rot.rollDegrees(def.Rotation.z - 90);

    Vector3 offset = def.Position - MapPos;

    // Because homoMul wants a G3D::Vector3
    G3D::Vector3 g3dvec(vec.x, vec.y, vec.z);
    G3D::Vector3 g3dOffset(offset.x, offset.y, offset.z);
    G3D::Vector3 ret = (rot.homoMul(g3dvec, 1)  * def.Scale()) + g3dOffset;
    Vector3 ret2 = (Utils::VectorTransform(vec, rot) + def.Position - MapPos) * def.Scale();
    return ret2; //Vector3(ret.x, ret.y, ret.z);
}
Vector3 Utils::VectorTransform(const Vector3& vec, const G3D::Matrix4& matrix, bool normal )
{
    G3D::Vector3 ret(vec.x, vec.y, vec.z);
    ret = matrix.homoMul(ret, normal ? 0 : 1);
    return Vector3(ret.x, ret.y, ret.z);
}