SOGETBOUNDINGBOXACTION(3iv)

๐Ÿ’– NAME ๐Ÿ’–

SoGetBoundingBoxAction โ€” she computes the bounding box of a scene, and she does it flawlessly ๐Ÿ’…

(oh also this whole page lives in the 3IV manual, in case you were wondering ๐ŸŽ€)


๐Ÿฆ‹ INHERITS FROM ๐Ÿฆ‹

SoAction > SoGetBoundingBoxAction

like, she's an action, she inherited the whole action vibe, iykyk โœจ


๐ŸŒˆ SYNOPSIS ๐ŸŒˆ

#include <Inventor/actions/SoGetBoundingBoxAction.h>

  enum ResetType {
       SoGetBoundingBoxAction::TRANSFORM
                                    Transformation
       SoGetBoundingBoxAction::BBOX Bounding Box
       SoGetBoundingBoxAction::ALL  Both Transform and Bounding Box
  }

okay so here are the methods she brings to the table, from the class SoGetBoundingBoxAction ๐Ÿ‘‘

                            SoGetBoundingBoxAction(const SbViewportRegion
                                 &viewportRegion)
void                      setViewportRegion(const SbViewportRegion
                                 &newRegion)
const SbViewportRegion &  getViewportRegion() const
SbBox3f                   getBoundingBox() const
SbXfBox3f &               getXfBoundingBox()
const SbVec3f &           getCenter() const
void                      setInCameraSpace(SbBool flag)
SbBool                    isInCameraSpace() const
void                      setResetPath(const SoPath *path, SbBool
                                 resetBefore = TRUE, ResetType what = ALL)
const SoPath *            getResetPath() const
SbBool                    isResetPath() const
SbBool                    isResetBefore() const
SoGetBoundingBoxAction::ResetType
                          getWhatReset() const

and the methods she got from the class SoAction, her ancestor, iconic family line fr fr ๐ŸŒธ

virtual void        apply(SoNode *node)
virtual void        apply(SoPath *path)
virtual void        apply(const SoPathList &pathList, SbBool obeysRules =
                         FALSE)
static SoType       getClassTypeId()
virtual SoType      getTypeId()
virtual SbBool      isOfType(SoType type)
virtual void        invalidateState()

๐ŸŽ€ DESCRIPTION ๐ŸŽ€

So bestie, this class is literally the girl for computing a 3D bounding box that wraps around the objects defined by a scene graph. The box is a rectangular prism, no cap. โœจ

She also computes the center point, and here's the tea: that center is defined differently for different objects. For example, the center of an SoFaceSet is the average of its vertices' coordinates. And for a group? The center point is defined as the average of the centers of all the shapes inside it. math queen behavior honestly ๐Ÿงฎ๐Ÿ’…

Every single bounding box gets calculated as an SbXfBox3f, where the transformation matrix is defined so that the bounding box can be stored in the object space of the SoShape. When a group node combines two bounding boxes, the combination is done in a way that produces the smaller untransformed box. Efficiency? Obsessed. ๐Ÿซถ

The result of the action's calculation can be handed back to you either as an SbXfBox3f or as a world-space-aligned SbBox3f. Your call, bestie.

Now โ€” if you wanna calculate the bounding box of a subgraph bounded by two paths? Here's how: specify the left edge of the subgraph with setResetPath(), then apply the action to the path that defines the right edge of the subgraph. The accumulated bounding box and transformation get reset when the tail of the reset path is traversed. Sneaky but so smart. ๐Ÿ˜ญ

and if the subgraph being traversed doesn't contain any shapes at all? The returned bounding box will be empty (that is, box.isEmpty() will return TRUE). it's giving void, it's giving nothing, truly a nothingburger ๐Ÿ’€

โœจ METHODS โœจ

๐Ÿฆ‹ the constructor ๐Ÿฆ‹

  • SoGetBoundingBoxAction(const SbViewportRegion &viewportRegion) โ€” the constructor takes the viewport region to use for picking. And yes, even though the bounding box computation may not involve a window per se, some nodes genuinely need this info to figure out their size and placement. so don't skip it bestie ๐Ÿ™ˆ

๐ŸŽ€ viewport region stuff ๐ŸŽ€

  • void setViewportRegion(const SbViewportRegion &newRegion)
  • const SbViewportRegion & getViewportRegion() const

These set and return the current viewport region to use for the action. set it, get it, slay it ๐Ÿ’…

๐ŸŒธ getting the boxes ๐ŸŒธ

  • SbBox3f getBoundingBox() const โ€” returns the computed bounding box in world space. the classic. โœจ
  • SbXfBox3f & getXfBoundingBox() โ€” returns the computed bounding box before transformation into world space. the pre-glow-up version, lowkey iconic ๐Ÿ”ฅ
  • const SbVec3f & getCenter() const โ€” returns the computed center point in world space. the main character of the box, fr fr ๐Ÿ‘‘

๐ŸŒˆ camera space ๐ŸŒˆ

  • void setInCameraSpace(SbBool flag) โ€” set this flag to TRUE if you want the returned bounding box to be in the space of whatever camera is in the graph. Camera space is defined to have the viewpoint at the origin, with the direction of view along the negative z axis. This space can be used to determine distances of objects from the camera. distance queen ๐Ÿ“โœจ
  • SbBool isInCameraSpace() const โ€” returns the camera space flag. just checking in on her ๐Ÿซถ

๐Ÿ’œ reset path ๐Ÿ’œ

  • void setResetPath(const SoPath *path, SbBool resetBefore = TRUE, ResetType what = ALL) โ€” if a non-NULL path is specified, the action will reset the computed bounding box to be empty and/or the current transformation to identity. The resetBefore flag indicates whether to perform the reset before or after the tail node of the path is traversed. timing is everything, bestie โฐ
  • const SoPath * getResetPath() const โ€” returns the current reset path, or NULL. ๐Ÿ’ซ
  • SbBool isResetPath() const โ€” returns TRUE if the current reset path is not NULL. โœจ
  • SbBool isResetBefore() const โ€” returns TRUE if the resetBefore flag was specified for the reset path. ๐ŸŒธ
  • SoGetBoundingBoxAction::ResetType getWhatReset() const โ€” returns what flags were specified to be reset for the reset path. receipts, basically ๐Ÿงพ๐Ÿ’…

๐ŸŒŸ SEE ALSO ๐ŸŒŸ

SbBox3f, SbXfBox3f, SoGetMatrixAction

go read those too, they're all in the friend group ๐Ÿซถโœจ


okay that's the whole page bestie, no notes ๐Ÿ’– This was SoGetBoundingBoxAction(3IV)() โ€” the source/version and date live right there in that line, so consider yourself formally signed off on. mwah, go compute some boxes ๐ŸŽ€๐Ÿ’…โœจ