BaseView Class Reference

#include <c4d_basedraw.h>

Inheritance diagram for BaseView:

Detailed Description

Represents an editor view. Cannot be instantiated. In most cases the sub-class BaseDraw is used. It adds functions for drawing into the view. See the dbasedraw.h description file for container IDs.

Private Member Functions

 BaseView ()
 
 ~BaseView ()
 

Frame

void GetFrame (Int32 *cl, Int32 *ct, Int32 *cr, Int32 *cb)
 
void GetSafeFrame (Int32 *cl, Int32 *ct, Int32 *cr, Int32 *cb)
 

View Matrix/Rotation

Matrix GetMg () const
 
Matrix GetMi () const
 
const MatrixGetBaseMatrix () const
 
void SetBaseMatrix (const Matrix &m)
 
Float GetPlanarRotation () const
 
void SetPlanarRotation (Float r)
 

Test Point/Clipping

Bool TestPoint (Float x, Float y) const
 
Bool TestPointZ (const Vector &p) const
 
Bool TestClipping3D (const Vector &mp, const Vector &rad, const Matrix &mg, Bool *clip2d, Bool *clipz) const
 
Bool ClipLine2D (Vector *p1, Vector *p2) const
 
Bool ClipLineZ (Vector *p1, Vector *p2) const
 

Spaces Conversion

Vector WS (const Vector &p) const
 
Vector SW (const Vector &p) const
 
Vector SW_Reference (Float x, Float y, const Vector &wp) const
 
Vector WC (const Vector &p) const
 
Vector CW (const Vector &p) const
 
Vector SC (const Vector &p) const
 
Vector CS (const Vector &p, Bool z_inverse) const
 
Vector WC_V (const Vector &v) const
 
Vector CW_V (const Vector &v) const
 
Vector WS_V (const Vector &v, const Vector &p) const
 
Vector SW_V (const Vector &v, const Vector &p) const
 

Pixel Conversion

Float PW_S (Float z, Bool horizontal) const
 
Float WP_S (Float z, Bool horizontal) const
 
Float PW_W (const Vector &p, Bool horizontal) const
 
Float WP_W (const Vector &p, Bool horizontal) const
 

Z-Near/Far

Bool ZSensitiveNear () const
 
Float ZSensitiveNearClipping () const
 
Bool ZSensitiveFar () const
 
Float ZSensitiveFarClipping () const
 

Project Point

Vector ProjectPointOnLine (const Vector &p, const Vector &v, Float mouse_x, Float mouse_y, Float *offset=nullptr, Int32 *err=nullptr)
 
Vector ProjectPointOnPlane (const Vector &p, const Vector &v, Float mouse_x, Float mouse_y, Int32 *err=nullptr)
 

Miscellaneous

Bool BackfaceCulling (const Vector &n, const Vector &p)
 
Int32 GetProjection () const
 
StereoCameraInfoGetStereoInfo () const
 
void GetViewParameter (Vector *offset, Vector *scale, Vector *scale_z) const
 
Int32 GetColorSpace () const
 

Additional Inherited Members

- Public Member Functions inherited from BaseList2D
void SetBit (Int32 mask)
 
Bool GetBit (Int32 mask) const
 
void DelBit (Int32 mask)
 
void ToggleBit (Int32 mask)
 
Int32 GetAllBits () const
 
void SetAllBits (Int32 bits)
 
void SetBitEx (Int32 mask, Int32 flags)
 
const CharGetViewportRenderId (VIEWPORT_RENDER_ID typeId) const
 
BaseList2DGetNext ()
 
const BaseList2DGetNext () const
 
BaseList2DGetPred ()
 
const BaseList2DGetPred () const
 
BaseContainer GetData ()
 
void SetData (const BaseContainer &bc, Bool add=true)
 
const BaseContainerGetDataInstanceRef () const
 
BaseContainerGetDataInstanceRef ()
 
const BaseContainerGetDataInstance () const
 
BaseContainerGetDataInstance ()
 
String GetName () const
 
void SetName (const maxon::String &name, Bool setDirty=true)
 
String GetBubbleHelp ()
 
Bool TransferGoal (BaseList2D *dst, Bool undolink)
 
Bool TransferMarker (BaseList2D *dst) const
 
Bool CopyDynamicDescriptionFrom (const BaseList2D *src)
 
Bool Scale (Float scale)
 
Bool Edit ()
 
void GetIcon (IconData *dat)
 
GeListHeadGetNLARoot (Bool create)
 
BaseList2DAnimationLayerRemap (BaseObject **layer=nullptr)
 
String GetTypeName () const
 
const BaseList2DGetMain () const
 
BaseList2DGetMain ()
 
void InsertTrackSorted (CTrack *track)
 
Bool AddEventNotification (BaseList2D *bl, NOTIFY_EVENT eventid, NOTIFY_EVENT_FLAG flags, const BaseContainer *data)
 
Bool RemoveEventNotification (const BaseDocument *doc, BaseList2D *bl, NOTIFY_EVENT eventid)
 
Bool FindEventNotification (const BaseDocument *doc, BaseList2D *bl, NOTIFY_EVENT eventid)
 
Bool SetDescIDState (const DescID &id, DESCIDSTATE descidstate)
 
DESCIDSTATE GetDescIDState (const DescID &id, Bool tolerant) const
 
GeListHeadGetOverrideRoot (Bool create)
 
BaseOverrideGetFirstOverride ()
 
GeListHeadGetShaderRepositoryRoot (Bool create)
 
GeListHeadGetHiddenShaderRoot (Bool create)
 
maxon::NimbusForwardRef GetNimbusRef (const maxon::Id &spaceId) const
 
maxon::Result< maxon::NimbusForwardRefPrivateGetOrCreateNimbusRef (const maxon::Id &spaceId)
 
void RemoveNimbusRef (const maxon::Id &spaceId)
 
maxon::Result< maxon::HashMap< maxon::Id, maxon::NimbusForwardRef > > GetAllNimbusRefs () const
 
Bool IsNodeBased () const
 
maxon::Result< BoolGetAccessedObjects (METHOD_ID method, AccessedObjectsCallback &access) const
 
maxon::Result< BoolGetAccessedObjectsRec (ACCESSED_OBJECTS_MASK read, ACCESSED_OBJECTS_MASK write, METHOD_ID method, Bool withSiblings, Bool withChildren, AccessedObjectsCallback &access) const
 
maxon::Result< BoolGetAccessedObjectsOfHierarchy (ACCESSED_OBJECTS_MASK read, ACCESSED_OBJECTS_MASK write, METHOD_ID method, AccessedObjectsCallback &access) const
 
maxon::Result< BoolGetAccessedObjectsOfChildren (ACCESSED_OBJECTS_MASK read, ACCESSED_OBJECTS_MASK write, METHOD_ID method, AccessedObjectsCallback &access) const
 
maxon::Result< BoolGetAccessedObjectsOfFirstChildHierarchy (ACCESSED_OBJECTS_MASK read, ACCESSED_OBJECTS_MASK write, METHOD_ID method, AccessedObjectsCallback &access) const
 
maxon::Result< maxon::GenericDataGroupChanges ()
 
void GetMarkerStampEx (UInt32 *l1, UInt32 *l2)
 
const GeMarkerGetMarker () const
 
void SetMarker (const GeMarker &m)
 
Bool AddUniqueID (Int32 appid, const Char *const mem, Int bytes)
 
Bool FindUniqueID (Int32 appid, const Char *&mem, Int &bytes) const
 
Int32 GetUniqueIDCount () const
 
Bool GetUniqueIDIndex (Int32 idx, Int32 &id, const Char *&mem, Int &bytes) const
 
Bool SetAnimatedParameter (const CTrack *track, const DescID &id, const GeData &t_data1, const GeData &t_data2, Float mix, DESCFLAGS_SET flags)
 
Bool GetAnimatedParameter (const DescID &id, GeData &t_data1, GeData &t_data2, Float &mix, DESCFLAGS_GET flags) const
 
BaseShaderGetFirstShader () const
 
void InsertShader (BaseShader *shader, BaseShader *pred=nullptr)
 
void ClearKeyframeSelection ()
 
Bool FindKeyframeSelection (const DescID &id)
 
Bool SetKeyframeSelection (const DescID &id, Bool selection)
 
Bool KeyframeSelectionContent ()
 
LayerObjectGetLayerObject (const BaseDocument *doc)
 
const LayerObjectGetLayerObject (const BaseDocument *doc) const
 
Bool SetLayerObject (const LayerObject *layer)
 
const LayerDataGetLayerData (const BaseDocument *doc, Bool rawdata=false) const
 
Bool SetLayerData (BaseDocument *doc, const LayerData &data)
 
GeListHeadGetCTrackRoot (Bool create)
 
const GeListHeadGetCTrackRoot () const
 
const CTrackGetFirstCTrack () const
 
CTrackGetFirstCTrack ()
 
const CTrackFindCTrack (const DescID &id) const
 
CTrackFindCTrack (const DescID &id)
 
- Public Member Functions inherited from GeListNode
GeListNodeGetNext ()
 
const GeListNodeGetNext () const
 
GeListNodeGetPred ()
 
const GeListNodeGetPred () const
 
GeListNodeGetDown ()
 
const GeListNodeGetDown () const
 
GeListNodeGetUp ()
 
const GeListNodeGetUp () const
 
GeListNodeGetDownLast ()
 
const GeListNodeGetDownLast () const
 
void InsertBefore (GeListNode *bl)
 
void InsertAfter (GeListNode *bl)
 
void InsertUnder (GeListNode *bl)
 
void InsertUnderLast (GeListNode *bl)
 
void Remove ()
 
void FlushChilds ()
 
void MoveChildrenTo (GeListNode *dest)
 
GeListHeadGetListHead ()
 
const GeListHeadGetListHead () const
 
Int32 GetNodeID (Int32 index=0) const
 
template<typename CAST >
const CAST * GetNodeData (Int32 index=0) const
 
template<typename CAST >
CAST * GetNodeData (Int32 index=0)
 
void SetCustomData (GeListNode *node)
 
GeListNodeGetCustomData ()
 
const GeListNodeGetCustomData () const
 
const BaseDocumentGetDocument () const
 
BaseDocumentGetDocument ()
 
maxon::Result< BoolGetBranchInfo (const maxon::ValueReceiver< const BranchInfo & > &info, GETBRANCHINFO flags) const
 
Bool IsDocumentRelated () const
 
Int32 GetInfo () const
 
Bool GetNBit (NBIT bit) const
 
UInt32 GetNBitMask (Int32 index) const
 
Bool ChangeNBit (NBIT bit, NBITCONTROL bitmode)
 
- Public Member Functions inherited from C4DAtomGoal
Bool HasLinks () const
 
- Public Member Functions inherited from C4DAtom
Int32 GetType () const
 
Int32 GetRealType () const
 
Int32 GetDiskType () const
 
Bool IsInstanceOf (Int32 id) const
 
Int32 GetClassification () const
 
Bool Message (Int32 type, void *data=nullptr)
 
Bool MultiMessage (MULTIMSG_ROUTE flags, Int32 type, void *data)
 
C4DAtomGetClone (COPYFLAGS flags, AliasTrans *trn) const
 
Bool CopyTo (C4DAtom *dst, COPYFLAGS flags, AliasTrans *trn) const
 
Bool Read (HyperFile *hf, Int32 id, Int32 level)
 
Bool Write (HyperFile *hf) const
 
Bool ReadObject (HyperFile *hf, Bool readheader)
 
Bool WriteObject (HyperFile *hf) const
 
Bool GetDescription (Description *description, DESCFLAGS_DESC flags) const
 
Bool GetParameter (const DescID &id, GeData &t_data, DESCFLAGS_GET flags) const
 
Bool SetParameter (const DescID &id, const GeData &t_data, DESCFLAGS_SET flags)
 
DynamicDescriptionGetDynamicDescriptionWritable ()
 
const DynamicDescriptionGetDynamicDescription () const
 
Bool CopyDynamicDescriptionFrom (const BaseList2D *src)
 
Bool GetEnabling (const DescID &id, const GeData &t_data, DESCFLAGS_ENABLE flags, const BaseContainer *itemdesc) const
 
Bool TranslateDescID (const DescID &id, DescID &res_id, C4DAtom *&res_at)
 
UInt32 GetDirty (DIRTYFLAGS flags) const
 
void SetDirty (DIRTYFLAGS flags)
 
UInt32 GetHDirty (HDIRTYFLAGS mask) const
 
void SetHDirty (HDIRTYFLAGS mask)
 
- Static Public Member Functions inherited from BaseList2D
static BaseList2DAlloc (Int32 type)
 
static void Free (BaseList2D *&bl)
 
- Static Public Attributes inherited from BaseList2D
static const Int32 SETBIT_FLAG_NODIRTY
 
static const Int32 SETBIT_FLAG_REMOVE
 

Constructor & Destructor Documentation

◆ BaseView()

BaseView ( )
private

◆ ~BaseView()

~BaseView ( )
private

Member Function Documentation

◆ GetFrame()

void GetFrame ( Int32 cl,
Int32 ct,
Int32 cr,
Int32 cb 
)

Assigns the dimension in pixels of the view window. The coordinates are relative to the upper left corner of the view, and specify visible pixels (i.e. the border is not included).

Parameters
[out]clIs assigned the first visible left pixel position.
[out]ctIs assigned the first visible top pixel position.
[out]crIs assigned the first visible right pixel position.
[out]cbIs assigned the first visible bottom pixel position.

◆ GetSafeFrame()

void GetSafeFrame ( Int32 cl,
Int32 ct,
Int32 cr,
Int32 cb 
)

Assigns the dimension in pixels of the safe frame (the frame which is rendered) to the passed pointers. The coordinates are relative to the upper left corner of the view.

Parameters
[out]clIs assigned the first visible left pixel position.
[out]ctIs assigned the first visible top pixel position.
[out]crIs assigned the first visible right pixel position.
[out]cbIs assigned the first visible bottom pixel position.

◆ GetMg()

Matrix GetMg ( ) const

Gets the camera matrix, i.e. the global object matrix of the current camera object.

Returns
The camera matrix.

◆ GetMi()

Matrix GetMi ( ) const

Gets the inverse of the camera matrix. Equivalent to !GetMg(), but faster.

Returns
The inverted camera matrix.

◆ GetBaseMatrix()

const Matrix& GetBaseMatrix ( ) const

Gets the base matrix.

Note
The base matrix is multiplied with the camera matrix so that it is possible to have e.g. a frontal view into another direction than +Z.
Returns
The base matrix.

◆ SetBaseMatrix()

void SetBaseMatrix ( const Matrix m)

Sets the base matrix.

Note
The base matrix is multiplied with the camera matrix so that it is possible to have e.g. a frontal view into another direction than +Z.
Parameters
[in]mThe new base matrix.

◆ GetPlanarRotation()

Float GetPlanarRotation ( ) const

Gets the rotation of the planar views.

Returns
The planar rotation.

◆ SetPlanarRotation()

void SetPlanarRotation ( Float  r)

Sets the rotation of the planar views.

Parameters
[in]rThe new planar rotation.

◆ TestPoint()

Bool TestPoint ( Float  x,
Float  y 
) const

Tests if the point is within the boundary returned by GetFrame(). The point coordinates must be in screen space.

Parameters
[in]xThe X coordinate of the point to check.
[in]yThe Y coordinate of the point to check.
Returns
true if the point is inside the frame, otherwise false.

◆ TestPointZ()

Bool TestPointZ ( const Vector p) const

Tests if the point is visible within the near and far clipping planes defined in the view according to the current projection. The point must be in camera space.

Parameters
[in]pThe point to check.
Returns
true if the point is visible in the view, otherwise false.

◆ TestClipping3D()

Bool TestClipping3D ( const Vector mp,
const Vector rad,
const Matrix mg,
Bool clip2d,
Bool clipz 
) const

Tests if a bounding box is visible in the view according to the current projection. The box is defined by these eight corner coordinates:

p[0] = Vector(mp.x + rad.x, mp.y + rad.y, mp.z + rad.z) * mg;
p[1] = Vector(mp.x + rad.x, mp.y + rad.y, mp.z - rad.z) * mg;
p[2] = Vector(mp.x + rad.x, mp.y - rad.y, mp.z + rad.z) * mg;
p[3] = Vector(mp.x + rad.x, mp.y - rad.y, mp.z - rad.z) * mg;
p[4] = Vector(mp.x - rad.x, mp.y + rad.y, mp.z + rad.z) * mg;
p[5] = Vector(mp.x - rad.x, mp.y + rad.y, mp.z - rad.z) * mg;
p[6] = Vector(mp.x - rad.x, mp.y - rad.y, mp.z + rad.z) * mg;
p[7] = Vector(mp.x - rad.x, mp.y - rad.y, mp.z - rad.z) * mg;
unsigned char * p
Definition: floatobject.h:87
maxon::Vec3< maxon::Float64, 1 > Vector
Definition: ge_math.h:141
Parameters
[in]mpThe center of the box.
[in]radThe radius of the box.
[in]mgThe transformation to world space from mp/rad space.
[out]clip2dIs assigned true if the box needs 2D clipping, i.e. if any part of it is outside of the view boundaries. Otherwise false.
[in]clipzIs assigned true if the box needs Z clipping, i.e. if any part of it is too close to or behind the camera. Otherwise false.
Returns
true if the box is visible, otherwise false.

◆ ClipLine2D()

Bool ClipLine2D ( Vector p1,
Vector p2 
) const

Clips the line defined by p1 and p2 so that it fits within the view boundary. The new values are stored directly in the passed vectors. The points are in screen space.
When combined with ClipLineZ(), the Z clipping must be done first and then the 2D clipping.

Note
When combined with ClipLineZ(), the Z clipping must be done first and then the 2D clipping.
Parameters
[in,out]p1The start of the line. Is assigned the clipped start point.
[in,out]p2The end of the line. Is assigned the clipped end point.
Returns
true if any part of the line was within the view boundary, otherwise false.

◆ ClipLineZ()

Bool ClipLineZ ( Vector p1,
Vector p2 
) const

Clips the line defined by p1 and p2 so that it does not come too close to or behind the camera (i.e. it assures that, for those projections that have Z clipping, no values are negative or goes through the camera's zero plane).
The new values are stored directly in the passed vectors. The points must be in camera space.

Note
When combined with ClipLine2D(), the Z clipping must be done first and then the 2D clipping.
Parameters
[in,out]p1The start of the line. Is assigned the clipped start point.
[in,out]p2The end of the line. Is assigned the clipped end point.
Returns
true if any part of the line was within the camera boundary, otherwise false.

◆ WS()

Vector WS ( const Vector p) const

World to screen conversion. Converts p from world space to screen space (pixels relative to the view), and returns the conversion.
The orthogonal distance to the world point is stored in world units in the Z axis of the result.

Parameters
[in]pA point in world space.
Returns
The point in screen space.

◆ SW()

Vector SW ( const Vector p) const

Screen to world conversion. Converts p from screen space (pixels relative to the view) to world space.
The X and Y coordinates of the point are given in screen space, the Z coordinate is the orthogonal distance in world units to the point from the view plane.

Parameters
[in]pA point in screen space.
Returns
The point in world space.

◆ SW_Reference()

Vector SW_Reference ( Float  x,
Float  y,
const Vector wp 
) const

Screen to world conversion. Converts the point given by x and y in screen space (pixels relative to the view) to world space.
The Z coordinate is taken from the orthogonal distance in world units to wp from the view plane.

Parameters
[in]xThe X coordinate in screen space.
[in]yThe Y coordinate in screen space.
[in]wpThe reference point in world space.
Returns
The point in world space.

◆ WC()

Vector WC ( const Vector p) const

World to camera conversion. Converts p from world to camera space.

Parameters
[in]pA point in world space.
Returns
The point in camera space.

◆ CW()

Vector CW ( const Vector p) const

Camera to world conversion. Converts p from camera to world space.

Parameters
[in]pA point in camera space.
Returns
The point in world space.

◆ SC()

Vector SC ( const Vector p) const

Screen to camera conversion. Converts p from screen (pixels relative to the view) to camera space.
The X and Y coordinates of the point are given in screen space, the Z coordinate is the orthogonal distance in world units to the point from the view plane.

Parameters
[in]pA point in screen space.
Returns
The point in camera space.

◆ CS()

Vector CS ( const Vector p,
Bool  z_inverse 
) const

Camera to screen conversion. Converts p from camera to screen space (pixels relative to the view).

Parameters
[in]pA point in camera space.
[in]z_inverseIf true if true, otherwise false. the Z coordinate of the converted point is inverted. This is used by the Z-buffer.
Returns
The point in screen space.

◆ WC_V()

Vector WC_V ( const Vector v) const

World to camera vector conversion. Converts the world vector v to camera space.

Parameters
[in]vA vector in world space.
Returns
The vector in camera space.

◆ CW_V()

Vector CW_V ( const Vector v) const

Camera to world vector conversion. Converts the camera vector v to world space.

Parameters
[in]vA vector in camera space.
Returns
The vector in world space.

◆ WS_V()

Vector WS_V ( const Vector v,
const Vector p 
) const

World to screen vector conversion. Converts v from world space to screen space (pixels relative to the view), and returns the conversion.
The orthogonal distance to the world point is stored in world units in the Z axis of the result.

Parameters
[in]vA vector in world space.
[in]pA reference point in world space.
Returns
The vector in screen space.

◆ SW_V()

Vector SW_V ( const Vector v,
const Vector p 
) const

Screen to world vector conversion. Converts v from screen space (pixels relative to the view) to world space.
The X and Y coordinates of the point are given in screen space, the Z coordinate is the orthogonal distance in world units to the point from the view plane.

Parameters
[in]vA vector in screen space.
[in]pA reference point in screen space.
Returns
The vector in world space.

◆ PW_S()

Float PW_S ( Float  z,
Bool  horizontal 
) const

Gets the size in world units for a single pixel at the given Z-depth z.

Parameters
[in]zThe Z-depth.
[in]horizontaltrue if the size is measured horizontally, false for vertically measurement. This is useful for non-square pixel aspect ratios.
Returns
The size in world units.

◆ WP_S()

Float WP_S ( Float  z,
Bool  horizontal 
) const

Gets the size in pixels for a single world unit at the given Z-depth z.

Parameters
[in]zThe Z-depth.
[in]horizontaltrue if the size is measured horizontally, false for vertically measurement. This is useful for non-square pixel aspect ratios.
Returns
The size in pixels.

◆ PW_W()

Float PW_W ( const Vector p,
Bool  horizontal 
) const

Gets the size in world units for a single pixel at screen space vector p.

Parameters
[in]pThe pixel in screen space.
[in]horizontaltrue if the size is measured horizontally, false for vertically measurement. This is useful for non-square pixel aspect ratios.
Returns
The size in world units.

◆ WP_W()

Float WP_W ( const Vector p,
Bool  horizontal 
) const

Gets the size in screen space pixels for a single world unit at world position p.

Parameters
[in]pThe point in world space.
[in]horizontaltrue if the size is measured horizontally, false for vertically measurement. This is useful for non-square pixel aspect ratios.
Returns
The size in screen space pixels.

◆ ZSensitiveNear()

Bool ZSensitiveNear ( ) const

Indicates if the view has Z near-clipping.

Returns
true if the view has Z near-clipping, otherwise false.

◆ ZSensitiveNearClipping()

Float ZSensitiveNearClipping ( ) const

Gets the near-clipping of Z sensitive view.

Returns
The Z near-clipping distance.

◆ ZSensitiveFar()

Bool ZSensitiveFar ( ) const

Indicates if the view is Z far-clipping sensitive.

Returns
true if the view has Z far-clipping, otherwise false.

◆ ZSensitiveFarClipping()

Float ZSensitiveFarClipping ( ) const

Gets the far-clipping of Z sensitive view.

Returns
The Z far-clipping distance.

◆ ProjectPointOnLine()

Vector ProjectPointOnLine ( const Vector p,
const Vector v,
Float  mouse_x,
Float  mouse_y,
Float offset = nullptr,
Int32 err = nullptr 
)

Gets the nearest point on the line defined by p and v for a given mouse coordinate.

Parameters
[in]pThe start position of the line in world space.
[in]vThe direction of the line. The length of this vector determines the scaling of offset.
[in]mouse_xThe mouse X-coordinate.
[in]mouse_yThe mouse Y-coordinate.
[out]offsetAssigned the distance from p scaled by the length of v. offset = distance to p / length of v.
[out]errAssigned an error code:
  • 1 = Failed to find nearest point correctly, lines may be beyond horizon, behind camera, or ray line and line may be parallel.
  • 2 = The point p is either beyond the start or end of the described segment (but a point will still be returned for the line/ray).
Returns
The nearest point on the line.

◆ ProjectPointOnPlane()

Vector ProjectPointOnPlane ( const Vector p,
const Vector v,
Float  mouse_x,
Float  mouse_y,
Int32 err = nullptr 
)

Gets the nearest point on the plane defined by p and v for a given mouse coordinate.

Parameters
[in]pThe plane's position in world space.
[in]vThe plane's normal in world space.
[in]mouse_xThe mouse X-coordinate.
[in]mouse_yThe mouse Y-coordinate.
[out]errAssigned an error code:
  • 1 = No intersection with plane possible, e.g. plane perpendicular to viewport so ray from view can never hit plane.
  • 2 = Out of range error, the calculation will be inaccurate, e.g. can be caused by point being over the horizon.
  • 3 = Hit point is behind the clipping plane of the camera, could sometimes result in an incorrect hit value.
Returns
The nearest point on the plane.

◆ BackfaceCulling()

Bool BackfaceCulling ( const Vector n,
const Vector p 
)

Tests the face with normal n and center p for backface culling.

Parameters
[in]nThe face normal in camera space.
[in]pThe face center in camera space.
Returns
true if the face is not visible, otherwise false.

◆ GetProjection()

Int32 GetProjection ( ) const

Gets the projection used by the view. See Ocamera.h for projection types values.

Returns
The projection type.

◆ GetStereoInfo()

StereoCameraInfo* GetStereoInfo ( ) const

Gets the stereoscopic camera information data.

Returns
The stereoscopic camera data. Cinema 4D owns the pointed StereoCameraInfo.

◆ GetViewParameter()

void GetViewParameter ( Vector offset,
Vector scale,
Vector scale_z 
) const

Retrieves the parameters for the current projection. See Ocamera.h for projection types.
The following is the code used internally to project points:

#define CAMDIST 0.05
Vector WorldToCamera(const Vector &p)
{
return p*inverse_camera_matrix;
}
Vector CameraToWorld(const Vector &p)
{
return p*camera_matrix;
}
Vector CameraToScreen(const Vector &pp)
{
Vector p = pp;
if (projection==Pperspective)
{
Float nz = p.z<=0.0 ? 1.0/CAMDIST : 1.0/(p.z + CAMDIST);
p.x = p.x*scale.x*nz+off.x;
p.y = p.y*scale.y*nz+off.y;
return p;
}
p.x = (p.x*scale.x)+off.x;
p.y = (p.y*scale.y)+off.y;
switch (projection)
{
case Pmilitary: case Pfrog: case Pbird: case Pgentleman:
p.x += p.z*scale.x*scalez.x;
p.y -= p.z*scale.y*scalez.y;
break;
}
return p;
}
Vector ScreenToCamera(const Vector &pp)
{
Vector p = pp;
switch (projection)
{
case Pmilitary: case Pfrog: case Pbird: case Pgentleman:
p.x -= p.z*scale.x*scalez.x;
p.y += p.z*scale.y*scalez.y;
break;
}
p.x = (p.x-off.x)/scale.x;
p.y = (p.y-off.y)/scale.y;
if (projection==Pperspective)
{
Float nz = p.z + CAMDIST;
p.x *= nz;
p.y *= nz;
}
return p;
}
maxon::Float Float
Definition: ge_sys_math.h:62
@ Pmilitary
Definition: ocamera.h:17
@ Pfrog
Definition: ocamera.h:18
@ Pbird
Definition: ocamera.h:19
@ Pgentleman
Definition: ocamera.h:20
@ Pperspective
Definition: ocamera.h:9

For non-axonometric projection here is the code to calculate offset/scale:

void InitView(BaseObject *camera, Float xres, Float yres, Float pix_x, Float pix_y)
{
// xres/yres are the resolution
// pix_x/pix_y are the pixel aspect ratio (normally 1:1)
Matrix opm = camera->GetMg();
Float ap;
const BaseContainer& data = camera->GetDataInstanceRef();
if (projection!=Pperspective && projection!=Pparallel)
{
opm.v1 = Vector(1.0,0.0,0.0);
opm.v2 = Vector(0.0,1.0,0.0);
opm.v3 = Vector(0.0,0.0,1.0);
}
off.x = xres*0.5;
off.y = yres*0.5;
if (b_ab==Pperspective)
{
scale.x = data.GetFloat(CAMERA_FOCUS,35.0) / ap * xres;
}
else
scale.x = xres/1024.0*data.GetFloat(CAMERA_ZOOM,1.0);
scale.y = -scale.x*pix_x/pix_y;
}
Definition: c4d_basecontainer.h:48
Float GetFloat(Int32 id, Float preset=0.0) const
Definition: c4d_basecontainer.h:380
Int32 GetInt32(Int32 id, Int32 preset=0) const
Definition: c4d_basecontainer.h:348
const BaseContainer & GetDataInstanceRef() const
Definition: c4d_baselist.h:2517
Definition: c4d_baseobject.h:248
Matrix GetMg() const
Definition: c4d_baseobject.h:510
@ Pparallel
Definition: ocamera.h:10
@ CAMERA_PROJECTION
Definition: ocamera.h:8
@ CAMERA_FOCUS
Definition: ocamera.h:6
@ CAMERA_ZOOM
Definition: ocamera.h:7
@ CAMERAOBJECT_APERTURE
Definition: ocamera.h:42
Parameters
[out]offsetAssigned the center of the view in screen space.
[out]scaleDepends on the projection mode:
  • For perspective mode: Assigned the size of the view plane in pixels.
  • For axonometric modes: Assigned the number of pixels per meter.
[out]scale_zAssigned the different Z scale for the X and Y axes in axonometric projections.

◆ GetColorSpace()

Int32 GetColorSpace ( ) const

Gets the color space for the view.

Returns
The color space for the view.