SoCamera(3)

๐Ÿ“ฆ version 2.5.0, in fedora 43, fedora 44

๐ŸŽ€ SoCamera(3) ๐ŸŽ€

a page straight outta the Library Functions Manual

okay so bestie. sit DOWN. we're doing SoCamera(3) today and honestly?? this page is long, it's giving main character energy, and there's a LOT of inherited stuff, but you're gonna eat it up. i got you. ๐Ÿ’…


โœจ NAME โœจ

SoCamera โ€” she is the abstract base class for camera definition nodes. that's it, that's the whole job description. she's the blueprint, not the building. queen shit fr fr ๐Ÿ‘‘


๐ŸŒˆ SYNOPSIS ๐ŸŒˆ

#include <Inventor/nodes/SoCamera.h>

she inherits SoNode โ€” so everything that node does, she's got it too.

and she gets inherited by SoFrustumCamera, SoOrthographicCamera, and SoPerspectiveCamera. three daughters carrying her legacy ๐Ÿซถ

๐Ÿฆ‹ Public Types ๐Ÿฆ‹

two enums, both iconic, no notes:

enum ViewportMapping {
    CROP_VIEWPORT_FILL_FRAME,
    CROP_VIEWPORT_LINE_FRAME,
    CROP_VIEWPORT_NO_FRAME,
    ADJUST_CAMERA,
    LEAVE_ALONE
}
enum StereoMode {
    MONOSCOPIC,
    LEFT_VIEW,
    RIGHT_VIEW
}

๐Ÿ’œ Public Types inherited from SoNode ๐Ÿ’œ

the whole bitmask lineup, verbatim, because we do NOT abbreviate here:

enum NodeType {
    INVENTOR = 0x0000,
    VRML1 = 0x0001,
    VRML2 = 0x0002,
    INVENTOR_1 = 0x0004,
    INVENTOR_2_0 = 0x0008,
    INVENTOR_2_1 = 0x0010,
    INVENTOR_2_5 = 0x0020,
    INVENTOR_2_6 = 0x0040,
    COIN_1_0 = 0x0080,
    COIN_2_0 = 0x0100,
    EXTENSION = 0x0200,
    COIN_2_2 = 0x0400,
    COIN_2_3 = 0x0800,
    COIN_2_4 = 0x1000,
    INVENTOR_5_0 = 0x2000,
    COIN_2_5 = 0x4000
}

๐ŸŒธ Public Member Functions ๐ŸŒธ

these are all hers. every single one. two of them are =0 which means she's leaving those to her daughters to actually implement โ€” iconic delegation honestly:

  • virtual SoType getTypeId (void) const โ€” the "who even am i" check โœจ every node's got one
  • void pointAt (const SbVec3f &targetpoint) โ€” the one-arg version
  • void pointAt (const SbVec3f &targetpoint, const SbVec3f &upvector) โ€” the two-arg version. yes, both overloads get their own bullet. we respect the source in this house ๐Ÿซถ
  • virtual void scaleHeight (float scalefactor)=0 โ€” see that =0? pure virtual. she's not doing this one herself ๐Ÿ’…
  • virtual SbViewVolume getViewVolume (float useaspectratio=0.0f) const =0 โ€” also =0, also a daughter job. note the default 0.0f, we keep defaults around here
  • void viewAll (SoNode *const sceneroot, const SbViewportRegion &vpregion, const float slack=1.0f) โ€” take one SoNode *const please
  • void viewAll (SoPath *const path, const SbViewportRegion &vpregion, const float slack=1.0f) โ€” same name, SoPath flavor, same slack=1.0f
  • SbViewportRegion getViewportBounds (const SbViewportRegion &region) const
  • void setStereoMode (StereoMode mode)
  • StereoMode getStereoMode (void) const
  • void setStereoAdjustment (float adjustment)
  • float getStereoAdjustment (void) const
  • void setBalanceAdjustment (float adjustment)
  • float getBalanceAdjustment (void) const
  • virtual void doAction (SoAction *action)
  • virtual void callback (SoCallbackAction *action)
  • virtual void GLRender (SoGLRenderAction *action)
  • virtual void audioRender (SoAudioRenderAction *action)
  • virtual void getBoundingBox (SoGetBoundingBoxAction *action)
  • virtual void handleEvent (SoHandleEventAction *action)
  • virtual void rayPick (SoRayPickAction *action)
  • virtual void getPrimitiveCount (SoGetPrimitiveCountAction *action)

๐Ÿ’– Public Member Functions inherited from SoNode ๐Ÿ’–

void setOverride (const SbBool state)
SbBool isOverride (void) const
void setNodeType (const NodeType type)
NodeType getNodeType (void) const
virtual SoNode * copy (SbBool copyconnections=0) const
virtual SbBool affectsState (void) const
virtual void GLRenderBelowPath (SoGLRenderAction *action)
virtual void GLRenderInPath (SoGLRenderAction *action)
virtual void GLRenderOffPath (SoGLRenderAction *action)
virtual void getMatrix (SoGetMatrixAction *action)
virtual void pick (SoPickAction *action)
virtual void search (SoSearchAction *action)
virtual void write (SoWriteAction *action)
virtual void grabEventsSetup (void)
virtual void grabEventsCleanup (void)
virtual void startNotify (void)
virtual void notify (SoNotList *l)
uint32_t getNodeId (void) const
virtual SoChildList * getChildren (void) const
virtual void writeInstance (SoOutput *out)
virtual SoNode * addToCopyDict (void) const
virtual void copyContents (const SoFieldContainer *from, SbBool copyconnections)
virtual SoFieldContainer * copyThroughConnection (void) const

๐Ÿงš Public Member Functions inherited from SoFieldContainer ๐Ÿงš

void setToDefaults (void)
SbBool hasDefaultValues (void) const
SbBool fieldsAreEqual (const SoFieldContainer *container) const
void copyFieldValues (const SoFieldContainer *container, SbBool copyconnections=0)
SbBool set (const char *const fielddata)
void get (SbString &fielddata)
virtual int getFields (SoFieldList &l) const
virtual int getAllFields (SoFieldList &l) const
virtual SoField * getField (const SbName &name) const
virtual SoField * getEventIn (const SbName &name) const
virtual SoField * getEventOut (const SbName &name) const
SbBool getFieldName (const SoField *const field, SbName &name) const
SbBool enableNotify (const SbBool flag)
SbBool isNotifyEnabled (void) const
SbBool set (const char *fielddata, SoInput *in)
void get (SbString &fielddata, SoOutput *out)
virtual SbBool validateNewFieldValue (SoField *field, void *newval)
virtual void addWriteReference (SoOutput *out, SbBool isfromfield=0)
SbBool getIsBuiltIn (void) const
void setUserData (void *userdata) const
void * getUserData (void) const

๐Ÿ“ Public Member Functions inherited from SoBase ๐Ÿ“

void ref (void) const
void unref (void) const
void unrefNoDelete (void) const
int32_t getRefCount (void) const
void touch (void)
SbBool isOfType (SoType type) const
virtual SbName getName (void) const
virtual void setName (const SbName &newname)
void addAuditor (void *const auditor, const SoNotRec::Type type)
void removeAuditor (void *const auditor, const SoNotRec::Type type)
const SoAuditorList & getAuditors (void) const
SbBool shouldWrite (void)
void assertAlive (void) const

๐Ÿ‘‘ Static Public Member Functions ๐Ÿ‘‘

hers, and only two of them:

  • static SoType getClassTypeId (void)
  • static void initClass (void)

โญ Static Public Member Functions inherited from SoNode โญ

static uint32_t getCompatibilityTypes (const SoType &nodetype)
static SoType getClassTypeId (void)
static SoNode * getByName (const SbName &name)
static int getByName (const SbName &name, SoNodeList &l)
static void initClass (void)
static void initClasses (void)
static uint32_t getNextNodeId (void)
static int getActionMethodIndex (const SoType type)
static void getBoundingBoxS (SoAction *action, SoNode *node)
static void GLRenderS (SoAction *action, SoNode *node)
static void callbackS (SoAction *action, SoNode *node)
static void getMatrixS (SoAction *action, SoNode *node)
static void handleEventS (SoAction *action, SoNode *node)
static void pickS (SoAction *action, SoNode *node)
static void rayPickS (SoAction *action, SoNode *node)
static void searchS (SoAction *action, SoNode *node)
static void writeS (SoAction *action, SoNode *node)
static void audioRenderS (SoAction *action, SoNode *node)
static void getPrimitiveCountS (SoAction *action, SoNode *node)

๐Ÿ’œ Static Public Member Functions inherited from SoFieldContainer ๐Ÿ’œ

static void initClass (void)
static SoType getClassTypeId (void)
static void initCopyDict (void)
static void addCopy (const SoFieldContainer *orig, const SoFieldContainer *copy)
static SoFieldContainer * checkCopy (const SoFieldContainer *orig)
static SoFieldContainer * findCopy (const SoFieldContainer *orig, const SbBool copyconnections)
static void copyDone (void)

๐ŸŒธ Static Public Member Functions inherited from SoBase ๐ŸŒธ

static void initClass (void)
static SoType getClassTypeId (void)
static void addName (SoBase *const base, const char *const name)
static void removeName (SoBase *const base, const char *const name)
static void incrementCurrentWriteCounter (void)
static void decrementCurrentWriteCounter (void)
static SoBase * getNamedBase (const SbName &name, SoType type)
static int getNamedBases (const SbName &name, SoBaseList &baselist, SoType type)
static SbBool read (SoInput *in, SoBase *&base, SoType expectedtype)
static void setInstancePrefix (const SbString &c)
static void setTraceRefs (SbBool trace)
static SbBool getTraceRefs (void)
static SbBool connectRoute (SoInput *in, const SbName &fromnodename, const SbName &fromfieldname, const SbName &tonodename, const SbName &tofieldname)
static SbBool readRoute (SoInput *in)

๐ŸŒˆ Public Attributes ๐ŸŒˆ

the fields. the actual data. this is the part people actually come here for, lowkey:

  • SoSFEnum viewportMapping
  • SoSFVec3f position
  • SoSFRotation orientation
  • SoSFFloat aspectRatio
  • SoSFFloat nearDistance
  • SoSFFloat farDistance
  • SoSFFloat focalDistance

๐ŸŽ€ Protected Member Functions ๐ŸŽ€

the VIP section โ€” only her and her subclasses get in:

  • virtual const SoFieldData * getFieldData (void) const
  • SoCamera (void) โ€” the constructor
  • virtual ~SoCamera () โ€” the destructor
  • virtual void viewBoundingBox (const SbBox3f &box, float aspect, float slack)=0 โ€” another =0, another daughter job ๐Ÿ’…
  • virtual void jitter (int numpasses, int curpass, const SbViewportRegion &vpreg, SbVec3f &jitteramount) const

๐ŸŒŸ Protected Member Functions inherited from SoNode ๐ŸŒŸ

SoNode (void)
virtual ~SoNode ()
virtual SbBool readInstance (SoInput *in, unsigned short flags)

๐ŸŒŸ Protected Member Functions inherited from SoFieldContainer ๐ŸŒŸ

SoFieldContainer (void)
~SoFieldContainer ()

๐ŸŒŸ Protected Member Functions inherited from SoBase ๐ŸŒŸ

SoBase (void)
virtual ~SoBase ()
virtual void destroy (void)
SbBool hasMultipleWriteRefs (void) const
SbBool writeHeader (SoOutput *out, SbBool isgroup, SbBool isengine) const
void writeFooter (SoOutput *out) const
virtual const char * getFileFormatName (void) const

๐Ÿซถ Static Protected Member Functions ๐Ÿซถ

  • static const SoFieldData ** getFieldDataPtr (void)

โœจ Static Protected Member Functions inherited from SoNode โœจ

static const SoFieldData ** getFieldDataPtr (void)
static void setNextActionMethodIndex (int index)
static int getNextActionMethodIndex (void)
static void incNextActionMethodIndex (void)
static void setCompatibilityTypes (const SoType &nodetype, const uint32_t bitmask)

โœจ Static Protected Member Functions inherited from SoBase โœจ

static uint32_t getCurrentWriteCounter (void)
static void staticDataLock (void)
static void staticDataUnlock (void)

๐Ÿฆ‹ Friends ๐Ÿฆ‹

  • class SoCameraP โ€” her one true friend ๐Ÿซ‚

๐Ÿ’ซ Additional Inherited Members ๐Ÿ’ซ

Protected Types inherited from SoBase

enum BaseFlags { IS_ENGINE = 0x01, IS_GROUP = 0x02 }

Protected Attributes inherited from SoNode

uint32_t uniqueId

Protected Attributes inherited from SoFieldContainer

SbBool isBuiltIn

Static Protected Attributes inherited from SoNode

static uint32_t nextUniqueId = 0
static int nextActionMethodIndex = 0

okay bestie that's part 1 and honestly that was already a LOT of receipts ๐Ÿ’€ don't go anywhere, more is coming โ€” this page is not done with us yet ๐ŸŽ€โœจ

๐ŸŒธ Detailed Description ๐ŸŒธ

Okay bestie, listen up, because this one is literally the blueprint for every camera in Coin. ๐Ÿ’…

The SoCamera class is the abstract base class for camera definition nodes. Abstract, meaning you don't just go making one of these directly โ€” it's the vibe, not the fit. ๐Ÿซถ

So like, to actually view a scene? You need a camera in the scene graph, periodt. A camera node will set up the projection and viewing matrices for rendering of the geometry in the scene. That's its whole job. ๐Ÿ‘‘

This node just defines the abstract interface by collecting common fields that all camera type nodes need. So it's giving "shared foundation energy." Use the non-abstract camera node subclasses within a scene graph instead, bestie. The ones that are default part of the Coin library are SoPerspectiveCamera and SoOrthographicCamera, which uses the two different projections given by their name. No cap, the names are literally the whole plot. โœจ

Note that the viewer components of the GUI glue libraries of Coin (SoXt, SoQt, SoWin, etc) will automatically insert a camera into a scene graph if none has been defined. So if you forget? It's got you. ๐Ÿ’–

It is possible to have more than one camera in a scene graph โ€” yes, multiple cameras, main character AND supporting cast. ๐Ÿ˜Œ One common trick is for instance to use a second camera to display static geometry or overlay geometry (e.g. for head-up displays ("HUD")), as shown by this example code:

#include <Inventor/Qt/SoQt.h>
#include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
#include <Inventor/nodes/SoNodes.h>

int
main(int argc, char ** argv)
{
  QWidget * mainwin = SoQt::init(argv[0]);

  SoSeparator * root = new SoSeparator;
  root->ref();

  // Adds a camera and a red cone. The first camera found in the
  // scene graph by the SoQtExaminerViewer will be picked up and
  // initialized automatically.

  root->addChild(new SoPerspectiveCamera);
  SoMaterial * material = new SoMaterial;
  material->diffuseColor.setValue(1.0, 0.0, 0.0);
  root->addChild(material);
  root->addChild(new SoCone);

  // Set up a second camera for the remaining geometry. This camera
  // will not be picked up and influenced by the viewer, so the
  // geometry will be kept static.

  SoPerspectiveCamera * pcam = new SoPerspectiveCamera;
  pcam->position = SbVec3f(0, 0, 5);
  pcam->nearDistance = 0.1;
  pcam->farDistance = 10;
  root->addChild(pcam);

  // Adds a green cone to demonstrate static geometry.

  SoMaterial * greenmaterial = new SoMaterial;
  greenmaterial->diffuseColor.setValue(0, 1.0, 0.0);
  root->addChild(greenmaterial);
  root->addChild(new SoCone);

  SoQtExaminerViewer * viewer = new SoQtExaminerViewer(mainwin);
  viewer->setSceneGraph(root);
  viewer->show();

  SoQt::show(mainwin);
  SoQt::mainLoop();

  delete viewer;
  root->unref();
  return 0;
}

๐ŸŽ€ Member Enumeration Documentation ๐ŸŽ€

๐Ÿฆ‹ enum SoCamera::ViewportMapping

Enumerates the available possibilities for how the render frame should map the viewport. Like, all the ways the picture can get squished into the window, iykyk. ๐Ÿ’ซ

๐Ÿฆ‹ enum SoCamera::StereoMode

Enumerates the possible stereo modes. Get you a camera that sees in two eyes, bestie. ๐Ÿ‘€๐Ÿ‘€

Enumerator โ€” here's the lineup:

  • MONOSCOPIC โ€” No stereo. Just one flat vibe. ๐Ÿ“
  • LEFT_VIEW โ€” Left view.
  • RIGHT_VIEW โ€” Right view.

๐Ÿ’œ Constructor & Destructor Documentation ๐Ÿ’œ

โญ SoCamera::SoCamera (void ) [protected]

Constructor. It's protected, so it's giving "family only" energy โ€” subclasses handle the intros. ๐ŸŽฌ

References aspectRatio, farDistance, focalDistance, MONOSCOPIC, nearDistance, orientation, position, SoCamera(), and viewportMapping.

Referenced by getFieldData(), and SoCamera().

โญ SoCamera::~SoCamera () [protected], [virtual]

Destructor. Say bye bestie, it's over. ๐Ÿ’€๐ŸŒท


โœจ Member Function Documentation โœจ

๐Ÿ”ฅ SoType SoCamera::getTypeId (void ) const [virtual]

Returns the type identification of an object derived from a class inheriting SoBase. This is used for run-time type checking and "downward" casting. It's literally the "wait, what ARE you" function. ๐Ÿ”

Usage example:

void foo(SoNode * node)
{
  if (node->getTypeId() == SoFile::getClassTypeId()) {
    SoFile * filenode = (SoFile *)node;  // safe downward cast, knows the type
  }
  else if (node->getTypeId().isOfType(SoGroup::getClassTypeId())) {
    SoGroup * group = (SoGroup *)node;  // safe downward cast, knows the type
  }
}

For application programmers wanting to extend the library with new nodes, engines, nodekits, draggers or others: this method needs to be overridden in all subclasses. Like, ALL of them, no skipping. ๐Ÿ™ˆ This is typically done as part of setting up the full type system for extension classes, which is usually accomplished by using the pre-defined macros available through for instance Inventor/nodes/SoSubNode.h (SO_NODE_INIT_CLASS and SO_NODE_CONSTRUCTOR for node classes), Inventor/engines/SoSubEngine.h (for engine classes) and so on.

For more information on writing Coin extensions, see the class documentation of the toplevel superclasses for the various class groups. (Very "read the docs of the parents" of it, tbh. ๐Ÿ‘‘)

Implements SoBase.

Reimplemented in SoFrustumCamera, SoOrthographicCamera, and SoPerspectiveCamera.

๐Ÿ”ฅ const SoFieldData * SoCamera::getFieldData (void ) const [protected], [virtual]

Returns a pointer to the class-wide field data storage object for this instance. If no fields are present, returns NULL. Just hands you the goods, or nothing at all. ๐ŸŽ

Reimplemented from SoFieldContainer.

Reimplemented in SoFrustumCamera, SoOrthographicCamera, and SoPerspectiveCamera.

References SoCamera().

๐Ÿ”ฅ void SoCamera::pointAt (const SbVec3f & targetpoint)

Reorients the camera so that it points towards targetpoint. The positive y-axis is used as the up vector of the camera, unless the new camera direction is parallel to this axis, in which case the positive z-axis will be used instead. So it's like "look over there" but with a fallback plan if the y-axis is being uncooperative. ๐Ÿ‘€โœจ

References SbVec3f::dot(), SbVec3f::normalize(), position, SoDebugError::postInfo(), and SbVec3f::setValue().

๐Ÿ”ฅ void SoCamera::pointAt (const SbVec3f & targetpoint, const SbVec3f & upvector)

Reorients the camera so that it points towards targetpoint, using upvector as the camera up vector. Same vibe, but you get to pick which way is up. ๐Ÿฆ‹

This function is an extension for Coin, and it is not available in the original SGI Open Inventor v2.1 API. (Coin-only bonus, slay. ๐Ÿ’…)

References SbVec3f::normalize(), position, and SoDebugError::postInfo().

๐Ÿ”ฅ virtual void SoCamera::scaleHeight (float scalefactor) [pure virtual]

Sets a scalefactor for the height of the camera viewport. What "viewport height" means exactly in this context depends on the camera model. See documentation in subclasses. So like, don't @ this one for specifics, go read the subclass docs bestie. ๐Ÿ“

Implemented in SoFrustumCamera, SoOrthographicCamera, and SoPerspectiveCamera.

๐Ÿ”ฅ virtual SbViewVolume SoCamera::getViewVolume (float useaspectratio = 0.0f) const [pure virtual]

Returns total view volume covered by the camera under the current settings. It's giving "everything this camera can see." ๐ŸŒˆ

This view volume is not adjusted to account for viewport mapping. If you want the same view volume as the one used during rendering, you should do something like this:

SbViewVolume vv;
float aspectratio = myviewport.getViewportAspectRatio();

switch (camera->viewportMapping.getValue()) {
case SoCamera::CROP_VIEWPORT_FILL_FRAME:
case SoCamera::CROP_VIEWPORT_LINE_FRAME:
case SoCamera::CROP_VIEWPORT_NO_FRAME:
  vv = camera->getViewVolume(0.0f);
  break;
case SoCamera::ADJUST_CAMERA:
  vv = camera->getViewVolume(aspectratio);
  if (aspectratio < 1.0f) vv.scale(1.0f / aspectratio);
  break;
case SoCamera::LEAVE_ALONE:
  vv = camera->getViewVolume(0.0f);
  break;
default:
  assert(0 && "unknown viewport mapping");
  break;
}

Also, for the CROPPED viewport mappings, the viewport might be changed if the viewport aspect ratio is not equal to the camera aspect ratio. See SoCamera::getView() to see how this is done. (Yes, there's lore. Go read it. ๐Ÿ“–)

Implemented in SoFrustumCamera, SoOrthographicCamera, and SoPerspectiveCamera.

References getViewportBounds(), SoNode::SoNode(), and viewAll().

Referenced by rayPick().

๐Ÿ”ฅ void SoCamera::viewAll (SoNode *const sceneroot, const SbViewportRegion & vpregion, const float slack = 1.0f)

Position the camera so that all geometry of the scene from sceneroot is contained in the view volume of the camera, while keeping the camera orientation constant. It frames the whole thing without spinning around like a maniac. ๐ŸŽฏ

Finds the bounding box of the scene and calls SoCamera::viewBoundingBox(). A bounding sphere will be calculated from the scene bounding box, so the camera will "view all" even when the scene is rotated, in any way. Like, any way. It's got range. ๐ŸŒ

The slack argument gives a multiplication factor to the distance the camera is supposed to move out from the sceneroot mid-point.

A value less than 1.0 for the slack argument will therefore cause the camera to come closer to the scene, a value of 1.0 will position the camera as exactly outside the scene bounding sphere, and a value larger than 1.0 will give "extra slack" versus the scene bounding sphere. So small number = cozy, big number = personal space. ๐Ÿ˜Œ

References SoAction::apply(), aspectRatio, SoGetBoundingBoxAction::getBoundingBox(), SbBox3f::getMax(), SbBox3f::getMin(), SbViewportRegion::getViewportSize(), SbViewportRegion::getWindowSize(), SbBox3f::isEmpty(), SoDebugError::postInfo(), SoNode::SoNode(), and viewBoundingBox().

Referenced by getViewVolume().

๐Ÿ”ฅ void SoCamera::viewAll (SoPath *const path, const SbViewportRegion & vpregion, const float slack = 1.0f)

Position the camera so all geometry of the scene in path is contained in the view volume of the camera. Same energy as above, but you're aiming at a specific path instead of the whole root. ๐Ÿ›ค๏ธ

Finds the bounding box of the scene and calls SoCamera::viewBoundingBox().

References SoAction::apply(), aspectRatio, SoGetBoundingBoxAction::getBoundingBox(), SbBox3f::isEmpty(), and viewBoundingBox().

๐Ÿ”ฅ SbViewportRegion SoCamera::getViewportBounds (const SbViewportRegion & region) const

Based in the SoCamera::viewportMapping setting, convert the values of region to the viewport region we will actually render into. So it takes your requested region and translates it into the real one. ๐Ÿ”„โœจ

References aspectRatio, SbViewportRegion::getViewportAspectRatio(), SbViewportRegion::scaleHeight(), SbViewportRegion::scaleWidth(), and viewportMapping.

Referenced by getViewVolume().

๐Ÿ”ฅ void SoCamera::setStereoMode (StereoMode mode)

Sets the stereo mode. Pick your fighter: mono, left, or right. ๐Ÿ‘“

๐Ÿ”ฅ SoCamera::StereoMode SoCamera::getStereoMode (void ) const

Returns the stereo mode. Tell me which one you picked, bestie. ๐Ÿ’ฌ

๐Ÿ”ฅ void SoCamera::setStereoAdjustment (float adjustment)

Sets the stereo adjustment. This is the distance between the left and right "eye" when doing stereo rendering. So it's literally how far apart your two eyeballs are, in vibe terms. ๐Ÿ‘๏ธ๐Ÿ‘๏ธ

When doing stereo rendering, Coin will render two views, one for the left eye, and one for the right eye. The stereo adjustment is, a bit simplified, how much the camera is translated along the local X-axis between the left and the right view.

The default distance is 0.1, which is chosen since it's the approximate distance between the human eyes. (Anatomically accurate, no cap. ๐Ÿง )

To create a nice looking and visible stereo effect, the application programmer will often have to adjust this value. If all you want to do is examine simple stand-alone 3D objects, it is possible to calculate a stereo offset based on the bounding box of the 3D model (or scale the model down to an appropriate size).

However, if you have a large scene, where you want to fly around in the scene, and see stereo on different objects as you approach them, you can't calculate the stereo offset based on the bounding box of the scene, but rather use a stereo offset based on the scale of the individual objects/details you want to examine. Big scene = different math, periodt. ๐Ÿš€


Please note that it's important to set a sensible focal distance when doing stereo rendering. See setBalanceAdjustment() for information about how the focal distance affects the stereo rendering.

See also: setBalanceAdjustment()

๐ŸŒธ float SoCamera::getStereoAdjustment (void ) const

Hands you back the stereo adjustment, bestie. That's it, that's the whole function. ๐Ÿ’…

See also: setStereoAdjustment()

๐ŸŽ€ void SoCamera::setBalanceAdjustment (float adjustment)

Sets the stereo balance adjustment โ€” it's a factor that lets you move the zero parallax plane. Geometry sitting in front of the zero parallax plane will look like it's in front of the screen, which is the whole point of the stereo vibe.

The balance adjustment gets multiplied with the focal distance to find the zero parallax plane. Default value is 1.0, and with that default the zero parallax plane lands right at the focal point. Iconic.

See also: SoCamera::focalDistance

๐Ÿฆ‹ float SoCamera::getBalanceAdjustment (void ) const

Returns the stereo balance adjustment. No notes. ๐Ÿ’–

See also: setBalanceAdjustment()

โœจ void SoCamera::doAction (SoAction * action) [virtual]

This one performs the typical operation of a node for any action. Yes it's giving "generic but essential", because it literally is.

Reimplemented from SoNode.

References: focalDistance, SbViewVolume::getDepth(), SbViewVolume::getHeight(), SbViewVolume::getMatrices(), SoAction::getState(), SbViewVolume::getWidth(), SbMatrix::identity(), SbMatrix::inverse(), SbMatrix::multRight(), and SbViewVolume::transform().

Referenced by: callback(), getBoundingBox(), getPrimitiveCount(), and rayPick().

๐Ÿ’œ void SoCamera::callback (SoCallbackAction * action) [virtual]

Action method for SoCallbackAction. Basically it just updates the state according to how the node behaves for the render action, so you, the application programmer, can use SoCallbackAction to go extract info about the scene graph. Lowkey a little spy. ๐Ÿ•ต๏ธ

Reimplemented from SoNode.

References: doAction().

๐Ÿ”ฅ void SoCamera::GLRender (SoGLRenderAction * action) [virtual]

Action method for the SoGLRenderAction. This one gets called during rendering traversals โ€” any node that influences the rendering state in any way, or that wants to yeet geometry primitives at OpenGL, overrides this method. Main character behaviour fr fr.

Reimplemented from SoNode.

References: SbVec3f::cross(), focalDistance, SbViewVolume::frustum(), SbViewVolume::getDepth(), SbViewVolume::getHeight(), SbViewVolume::getMatrices(), SbViewVolume::getNearDist(), SoGLRenderAction::getNumPasses(), SbViewVolume::getProjectionDirection(), SoAction::getState(), SbViewVolume::getViewUp(), SbViewVolume::getWidth(), SbMatrix::identity(), SbMatrix::inverse(), jitter(), LEFT_VIEW, MONOSCOPIC, SbMatrix::multRight(), SbVec3f::normalize(), SbMatrix::setTranslate(), and SbViewVolume::transform().

๐ŸŽง void SoCamera::audioRender (SoAudioRenderAction * action) [virtual]

Action method for SoAudioRenderAction. Does the common processing for SoAudioRenderAction action instances. Yes, the camera has opinions about sound too โ€” she contains multitudes. ๐ŸŽถ

Reimplemented from SoNode.

References: SbViewVolume::getDepth(), SbViewVolume::getHeight(), SoAction::getState(), SbMatrix::getTransform(), SbVec3f::getValue(), SbViewVolume::getWidth(), SoListenerOrientationElement::isSetByListener(), SoListenerPositionElement::isSetByListener(), orientation, position, SoDebugError::postInfo(), SoListenerOrientationElement::set(), SoListenerPositionElement::set(), and SbViewVolume::transform().

๐Ÿ“ฆ void SoCamera::getBoundingBox (SoGetBoundingBoxAction * action) [virtual]

Action method for the SoGetBoundingBoxAction. It calculates the bounding box and center coordinates for the node, then modifies the action's values so they encompass this node's bounding box and shift the scene center point more toward this node's own center point. Teamwork, but make it math. ๐Ÿ’ช

Nodes that influence how geometry nodes calculate their bounding box also override this method to change the relevant state variables.

Reimplemented from SoNode.

References: doAction(), and SoAction::getState().

๐Ÿ–ฑ๏ธ void SoCamera::handleEvent (SoHandleEventAction * action) [virtual]

Picking actions can get triggered during handle event action traversal, and to do picking we need to know the camera state. So yeah, that's why this exists.

See also: SoCamera::rayPick()

Reimplemented from SoNode.

References: SoAction::getState().

๐ŸŽฏ void SoCamera::rayPick (SoRayPickAction * action) [virtual]

Action method for SoRayPickAction. It checks the ray specification of the action and tests for intersection with the data of the node. Straight to the point, no cap.

Nodes that influence the relevant state variables for how picking is done also override this method.

Reimplemented from SoNode.

References: SoRayPickAction::computeWorldSpaceRay(), doAction(), SbViewVolume::getDepth(), SbViewVolume::getHeight(), getViewVolume(), and SbViewVolume::getWidth().

๐Ÿ”ข void SoCamera::getPrimitiveCount (SoGetPrimitiveCountAction * action) [virtual]

Action method for the SoGetPrimitiveCountAction. It calculates the number of triangle, line segment and point primitives for the node and adds them onto the action's counters. Counting era. ๐Ÿงฎ

Nodes that influence how geometry nodes calculate their primitive count also override this method to change the relevant state variables.

Reimplemented from SoNode.

References: doAction().

๐Ÿซถ virtual void SoCamera::viewBoundingBox (const SbBox3f & box, float aspect, float slack) [protected], [pure virtual]

A little convenience method for setting up the camera definition so it covers the given bounding box at the given aspect ratio. It multiplies the exact dimensions with a slack factor so there's some breathing room between the rendered model and the edges of the rendering area. Personal space matters. ๐Ÿ’…

If you're defining your own camera node class, heads up: this method should not set the orientation field of the camera โ€” only the position, focal distance, and near and far clipping planes. That's the rule, okay?

Implemented in SoFrustumCamera, SoOrthographicCamera, and SoPerspectiveCamera.

References: jitter().

Referenced by: viewAll(), and viewAll().

๐Ÿงš void SoCamera::jitter (int numpasses, int curpass, const SbViewportRegion & vpreg, SbVec3f & jitteramount) const [protected], [virtual]

"Jitter" the camera according to the current rendering pass (curpass), so you get an antialiased rendering of the scene when you're doing multipass rendering. Shake it a tiny bit, get smooth results. It's giving glow-up. โœจ

References: SbVec3f::getValue(), and SbViewportRegion::getViewportSizePixels().

Referenced by: GLRender(), and viewBoundingBox().


๐Ÿ’พ Member Data Documentation

๐Ÿ–ผ๏ธ SoSFEnum SoCamera::viewportMapping

Sets up how the render frame should map the viewport. Default is SoCamera::ADJUST_CAMERA.

Referenced by: getViewportBounds(), and SoCamera().

๐Ÿ“ SoSFVec3f SoCamera::position

Camera position. Defaults to <0,0,1>.

Referenced by: audioRender(), SoFrustumCamera::getViewVolume(), SoOrthographicCamera::getViewVolume(), SoPerspectiveCamera::getViewVolume(), pointAt(), pointAt(), SoCamera(), SoFrustumCamera::viewBoundingBox(), SoOrthographicCamera::viewBoundingBox(), and SoPerspectiveCamera::viewBoundingBox().

๐ŸŒ€ SoSFRotation SoCamera::orientation

Camera orientation, specified as a rotation value from the default orientation โ€” where the camera is pointing along the negative z-axis, with "up" along the positive y-axis.

E.g., to rotate the camera to point along the X axis:

mycamera->orientation.setValue(SbRotation(SbVec3f(0, 1, 0), M_PI / 2.0f));

For queries, e.g. to get the current "up" and "look at" vectors of the camera:

SbRotation camrot = mycamera->orientation.getValue();

SbVec3f upvec(0, 1, 0); // init to default up vector
camrot.multVec(upvec, upvec);

SbVec3f lookat(0, 0, -1); // init to default view direction vector
camrot.multVec(lookat, lookat);

Referenced by: audioRender(), SoFrustumCamera::getViewVolume(), SoOrthographicCamera::getViewVolume(), SoPerspectiveCamera::getViewVolume(), SoCamera(), SoFrustumCamera::viewBoundingBox(), SoOrthographicCamera::viewBoundingBox(), and SoPerspectiveCamera::viewBoundingBox().

๐Ÿ“ SoSFFloat SoCamera::aspectRatio

Aspect ratio for the camera (i.e. width / height). Defaults to 1.0.

Referenced by: getViewportBounds(), SoOrthographicCamera::getViewVolume(), SoPerspectiveCamera::getViewVolume(), SoCamera(), viewAll(), and viewAll().

๐ŸŒˆ SoSFFloat SoCamera::nearDistance

Distance from camera position to the near clipping plane in the camera's view volume.

Default value is 1.0. The value must be larger than 0.0, or it won't be possible to construct a valid viewing volume (for perspective rendering, at least). So like, don't do that. ๐Ÿ˜ญ

If you use one of the viewer components from the So[Xt|Qt|Win|Gtk] GUI libraries provided by Systems in Motion, they'll automatically update this value for the scene camera according to the scene bounding box. Ditto for the far clipping plane.

See also: SoCamera::farDistance

Referenced by: SoOrthographicCamera::getViewVolume(), SoPerspectiveCamera::getViewVolume(), SoCamera(), SoFrustumCamera::viewBoundingBox(), SoOrthographicCamera::viewBoundingBox(), and SoPerspectiveCamera::viewBoundingBox().

๐ŸŒŒ SoSFFloat SoCamera::farDistance

Distance from camera position to the far clipping plane in the camera's view volume.

Default value is 10.0. It must be larger than the SoCamera::nearDistance value, or it will not be possible to construct a valid viewing volume. Periodt.

Note that the range [nearDistance, farDistance] decides the dynamic range of the Z-buffer in the underlying polygon-rendering rasterizer. What that means is: if the near and far clipping planes of the camera are wide apart, the chance of visual artifacts goes up. The artifacts show up as flickering of primitives that are close together in depth. So keep the near and far clipping planes of your camera(s) as closely fitted around the geometry of the scene graph as you possibly can, bestie. ๐Ÿ’€

See also: SoCamera::nearDistance, SoPolygonOffset

Referenced by: SoCamera(), SoFrustumCamera::viewBoundingBox(), SoOrthographicCamera::viewBoundingBox(), and SoPerspectiveCamera::viewBoundingBox().

๐Ÿ”ฎ SoSFFloat SoCamera::focalDistance

Distance from camera position to the center of the scene.

Referenced by: doAction(), GLRender(), SoCamera(), SoFrustumCamera::viewBoundingBox(), SoOrthographicCamera::viewBoundingBox(), and SoPerspectiveCamera::viewBoundingBox().


๐ŸŽ€ Author

Generated automatically by Doxygen for Coin from the source code. (Not a human, just a very diligent robot. ๐Ÿค–๐Ÿ’–)


And that's the whole page, babes!! This was Coin, Version 2.5.0, and you've been reading SoCamera(3) โ€” go forth and point your cameras at something gorgeous. Slay, hydrate, and remember: set your clipping planes tight. ๐Ÿซถ๐ŸŒธโœจ

๐Ÿ“ฆ where this page comes from