void AABB3::TransformBy(Matrix& matrix) { AABB3 bb; Vector3f v(minVec); Vector3f w(maxVec); bb.Encapsulate(matrix.Transform(Vector3f(v.x(),v.y(),v.z()))); bb.Encapsulate(matrix.Transform(Vector3f(w.x(),v.y(),v.z()))); bb.Encapsulate(matrix.Transform(Vector3f(v.x(),w.y(),v.z()))); bb.Encapsulate(matrix.Transform(Vector3f(w.x(),w.y(),v.z()))); bb.Encapsulate(matrix.Transform(Vector3f(v.x(),v.y(),w.z()))); bb.Encapsulate(matrix.Transform(Vector3f(w.x(),v.y(),w.z()))); bb.Encapsulate(matrix.Transform(Vector3f(v.x(),w.y(),w.z()))); bb.Encapsulate(matrix.Transform(Vector3f(w.x(),w.y(),w.z()))); minVec.Set(bb.minVec); maxVec.Set(bb.maxVec); }
AABB3 SoccerBase::GetAgentBoundingBox(const Leaf& base) { AABB3 boundingBox; boost::shared_ptr<Space> parent = base.FindParentSupportingClass<Space>().lock(); if (!parent) { base.GetLog()->Error() << "(GetAgentBoundingBox) ERROR: can't get parent node.\n"; return boundingBox; } /* We can't simply use the GetWorldBoundingBox of the space node, becuase * (at least currently) it'll return a wrong answer. Currently, the space * object is always at (0,0,0) which is encapsulated in the result of it's * GetWorldBoundingBox method call. */ Leaf::TLeafList baseNodes; parent->ListChildrenSupportingClass<BaseNode>(baseNodes); if (baseNodes.empty()) { base.GetLog()->Error() << "(GetAgentBoundingBox) ERROR: space object doesn't have any" << " children of type BaseNode.\n"; } for (Leaf::TLeafList::iterator i = baseNodes.begin(); i!= baseNodes.end(); ++i) { boost::shared_ptr<BaseNode> node = shared_static_cast<BaseNode>(*i); boundingBox.Encapsulate(node->GetWorldBoundingBox()); } return boundingBox; }