#include <c4d_basedraw.h>
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 (void) |
Matrix | GetMi (void) |
const Matrix & | GetBaseMatrix () const |
void | SetBaseMatrix (const Matrix &m) |
Float | GetPlanarRotation () const |
void | SetPlanarRotation (Float r) |
Test Point/Clipping | |
Bool | TestPoint (Float x, Float y) |
Bool | TestPointZ (const Vector &p) |
Bool | TestClipping3D (const Vector &mp, const Vector &rad, const Matrix &mg, Bool *clip2d, Bool *clipz) |
Bool | ClipLine2D (Vector *p1, Vector *p2) |
Bool | ClipLineZ (Vector *p1, Vector *p2) |
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 (void) const |
Float | ZSensitiveNearClipping (void) const |
Bool | ZSensitiveFar (void) const |
Float | ZSensitiveFarClipping (void) 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 (void) |
StereoCameraInfo * | GetStereoInfo () const |
void | GetViewParameter (Vector *offset, Vector *scale, Vector *scale_z) const |
Int32 | GetColorSpace () const |
|
private |
|
private |
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).
[out] | cl | Is assigned the first visible left pixel position. |
[out] | ct | Is assigned the first visible top pixel position. |
[out] | cr | Is assigned the first visible right pixel position. |
[out] | cb | Is assigned the first visible bottom pixel position. |
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.
[out] | cl | Is assigned the first visible left pixel position. |
[out] | ct | Is assigned the first visible top pixel position. |
[out] | cr | Is assigned the first visible right pixel position. |
[out] | cb | Is assigned the first visible bottom pixel position. |
Matrix GetMg | ( | void | ) |
Gets the camera matrix, i.e. the global object matrix of the current camera object.
Matrix GetMi | ( | void | ) |
Gets the inverse of the camera matrix. Equivalent to !GetMg(), but faster.
const Matrix& GetBaseMatrix | ( | ) | const |
Gets the base matrix.
void SetBaseMatrix | ( | const Matrix & | m | ) |
Sets the base matrix.
[in] | m | The new base matrix. |
Float GetPlanarRotation | ( | ) | const |
Gets the rotation of the planar views.
void SetPlanarRotation | ( | Float | r | ) |
Sets the rotation of the planar views.
[in] | r | The new planar rotation. |
Tests if the point is within the boundary returned by GetFrame(). The point coordinates must be in screen space.
[in] | x | The X coordinate of the point to check. |
[in] | y | The Y coordinate of the point to check. |
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.
[in] | p | The point to check. |
Bool TestClipping3D | ( | const Vector & | mp, |
const Vector & | rad, | ||
const Matrix & | mg, | ||
Bool * | clip2d, | ||
Bool * | clipz | ||
) |
Tests if a bounding box is visible in the view according to the current projection. The box is defined by these eight corner coordinates:
[in] | mp | The center of the box. |
[in] | rad | The radius of the box. |
[in] | mg | The transformation to world space from mp/rad space. |
[out] | clip2d | Is assigned true if the box needs 2D clipping, i.e. if any part of it is outside of the view boundaries. Otherwise false. |
[in] | clipz | Is 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. |
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.
[in,out] | p1 | The start of the line. Is assigned the clipped start point. |
[in,out] | p2 | The end of the line. Is assigned the clipped end point. |
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.
[in,out] | p1 | The start of the line. Is assigned the clipped start point. |
[in,out] | p2 | The end of the line. Is assigned the clipped end point. |
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.
[in] | p | A point in world space. |
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.
[in] | p | A point in screen space. |
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.
[in] | x | The X coordinate in screen space. |
[in] | y | The Y coordinate in screen space. |
[in] | wp | The reference point in world space. |
World to camera conversion. Converts p from world to camera space.
[in] | p | A point in world space. |
Camera to world conversion. Converts p from camera to world space.
[in] | p | A point in camera space. |
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.
[in] | p | A point in screen space. |
Camera to screen conversion. Converts p from camera to screen space (pixels relative to the view).
[in] | p | A point in camera space. |
[in] | z_inverse | If true if true, otherwise false. the Z coordinate of the converted point is inverted. This is used by the Z-buffer. |
World to camera vector conversion. Converts the world vector v to camera space.
[in] | v | A vector in world space. |
Camera to world vector conversion. Converts the camera vector v to world space.
[in] | v | A vector in camera space. |
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.
[in] | v | A vector in world space. |
[in] | p | A reference point in world space. |
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.
[in] | v | A vector in screen space. |
[in] | p | A reference point in screen space. |
Gets the size in world units for a single pixel at the given Z-depth z.
[in] | z | The Z-depth. |
[in] | horizontal | true if the size is measured horizontally, false for vertically measurement. This is useful for non-square pixel aspect ratios. |
Gets the size in pixels for a single world unit at the given Z-depth z.
[in] | z | The Z-depth. |
[in] | horizontal | true if the size is measured horizontally, false for vertically measurement. This is useful for non-square pixel aspect ratios. |
Gets the size in world units for a single pixel at screen space vector p.
[in] | p | The pixel in screen space. |
[in] | horizontal | true if the size is measured horizontally, false for vertically measurement. This is useful for non-square pixel aspect ratios. |
Gets the size in screen space pixels for a single world unit at world position p.
[in] | p | The point in world space. |
[in] | horizontal | true if the size is measured horizontally, false for vertically measurement. This is useful for non-square pixel aspect ratios. |
Bool ZSensitiveNear | ( | void | ) | const |
Indicates if the view has Z near-clipping.
Float ZSensitiveNearClipping | ( | void | ) | const |
Gets the near-clipping of Z sensitive view.
Bool ZSensitiveFar | ( | void | ) | const |
Indicates if the view is Z far-clipping sensitive.
Float ZSensitiveFarClipping | ( | void | ) | const |
Gets the far-clipping of Z sensitive view.
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.
[in] | p | The start position of the line in world space. |
[in] | v | The direction of the line. The length of this vector determines the scaling of offset. |
[in] | mouse_x | The mouse X-coordinate. |
[in] | mouse_y | The mouse Y-coordinate. |
[out] | offset | Assigned the distance from p scaled by the length of v. offset = distance to p / length of v. |
[out] | err | Assigned an error code:
|
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.
[in] | p | The plane's position in world space. |
[in] | v | The plane's normal in world space. |
[in] | mouse_x | The mouse X-coordinate. |
[in] | mouse_y | The mouse Y-coordinate. |
[out] | err | Assigned an error code:
|
Tests the face with normal n and center p for backface culling.
[in] | n | The face normal in camera space. |
[in] | p | The face center in camera space. |
Int32 GetProjection | ( | void | ) |
Gets the projection used by the view. See Ocamera.h for projection types values.
StereoCameraInfo* GetStereoInfo | ( | ) | const |
Gets the stereoscopic camera information data.
Retrieves the parameters for the current projection. See Ocamera.h for projection types.
The following is the code used internally to project points:
For non-axonometric projection here is the code to calculate offset/scale:
[out] | offset | Assigned the center of the view in screen space. |
[out] | scale | Depends on the projection mode:
|
[out] | scale_z | Assigned the different Z scale for the X and Y axes in axonometric projections. |
Int32 GetColorSpace | ( | ) | const |
Gets the color space for the view.