#include <c4d_basedraw.h>
This class is used to extract information from a viewport about which objects and object elements are visible at which pixels.
It is used internally for stuff like highlighting and modeling.
Private Member Functions | |
ViewportSelect () | |
~ViewportSelect () | |
Alloc/Free | |
static ViewportSelect * | Alloc () |
static void | Free (ViewportSelect *&p) |
Pick Object | |
static Bool | PickObject (BaseDraw *bd, BaseDocument *doc, Int32 x, Int32 y, Int32 rad, VIEWPORT_PICK_FLAGS flags, LassoSelection *ls, C4DObjectList *list, maxon::SquareMatrix4d *m=nullptr, Int32 *sampleLocation=nullptr) |
static Bool | PickObject (BaseDraw *bd, BaseDocument *doc, Int32 x, Int32 y, Int32 rad, Int32 &xr, Int32 &yr, Int32 &wr, Int32 &hr, const ViewportPixel *const *&pixels, VIEWPORT_PICK_FLAGS flags, LassoSelection *ls, C4DObjectList *list, maxon::SquareMatrix4d *m=nullptr, Int32 *sampleLocation=nullptr) |
static Bool | PickObject (BaseDraw *bd, BaseDocument *doc, Int32 x1, Int32 y1, Int32 x2, Int32 y2, Int32 &xr, Int32 &yr, Int32 &wr, Int32 &hr, const ViewportPixel *const *&pixels, VIEWPORT_PICK_FLAGS flags, LassoSelection *ls, C4DObjectList *list, maxon::SquareMatrix4d *m=nullptr, Int32 *sampleLocation=nullptr) |
Show Hotspot | |
static void | ShowHotspot (EditorWindow *bw, Int32 x, Int32 y, Int32 rad, Bool bRemove) |
void | ShowHotspot (EditorWindow *bw, Int32 x, Int32 y) |
void | SetBrushRadius (Int32 r) |
Initialization | |
Bool | Init (Int32 w, Int32 h, BaseDraw *bd, BaseObject *op, Int32 mode, Bool onlyvisible, VIEWPORTSELECTFLAGS flags=VIEWPORTSELECTFLAGS::NONE) |
Bool | Init (Int32 w, Int32 h, BaseDraw *bd, AtomArray *ar, Int32 mode, Bool onlyvisible, VIEWPORTSELECTFLAGS flags=VIEWPORTSELECTFLAGS::NONE) |
Get Point/Polygon/Edge Viewport Pixel | |
const ViewportPixel * | GetPixelInfoPoint (Int32 x, Int32 y) const |
const ViewportPixel * | GetPixelInfoPolygon (Int32 x, Int32 y) const |
const ViewportPixel * | GetPixelInfoEdge (Int32 x, Int32 y) const |
Bool | GetPointPixelBuffer (const ViewportPixel *const *&pixelBuffer, Int32 *pixelCount=nullptr) const |
Bool | GetEdgePixelBuffer (const ViewportPixel *const *&pixelBuffer, Int32 *pixelCount=nullptr) const |
Bool | GetPolygonPixelBuffer (const ViewportPixel *const *&pixelBuffer, Int32 *pixelCount=nullptr) const |
const ViewportPixel * | GetNearestPoint (BaseObject *op, Int32 &x, Int32 &y, Int32 maxrad=LIMIT< Int32 >::MAX, Bool onlyselected=false, Int32 *ignorelist=nullptr, Int32 ignorecnt=0) const |
const ViewportPixel * | GetNearestPolygon (BaseObject *op, Int32 &x, Int32 &y, Int32 maxrad=LIMIT< Int32 >::MAX, Bool onlyselected=false, Int32 *ignorelist=nullptr, Int32 ignorecnt=0) const |
const ViewportPixel * | GetNearestEdge (BaseObject *op, Int32 &x, Int32 &y, Int32 maxrad=LIMIT< Int32 >::MAX, Bool onlyselected=false, Int32 *ignorelist=nullptr, Int32 ignorecnt=0) const |
Int32 | GetPixelCount () const |
Draw | |
Bool | DrawPolygon (const Vector *p, Int32 ptcnt, Int32 i, BaseObject *op, Int32 onlyvisible=-1) |
Bool | DrawHandle (const Vector &p, Int32 i, BaseObject *op, Int32 onlyvisible=-1) |
Miscellaneous | |
void | ClearPixelInfo (Int32 x, Int32 y, UChar mask) |
Bool | GetCameraCoordinates (Float x, Float y, Float z, Vector &v) const |
|
private |
|
private |
|
static |
|
static |
Bool Init | ( | Int32 | w, |
Int32 | h, | ||
BaseDraw * | bd, | ||
BaseObject * | op, | ||
Int32 | mode, | ||
Bool | onlyvisible, | ||
VIEWPORTSELECTFLAGS | flags = VIEWPORTSELECTFLAGS::NONE |
||
) |
Initializes the viewport information for a single object. This has to be done before the pixel information can be retrieved. The width and height of the viewport have to be retrieved manually:
[in] | w | The width of the viewport in pixels. |
[in] | h | The height of the viewport in pixels. |
[in] | bd | The viewport base draw. The caller owns the pointed base draw. |
[in] | op | The object to get the information for. The caller owns the pointed object. |
[in] | mode | The editor mode: Mpoints, Mpolygons, Medges or Mpolyedgepoint. |
[in] | onlyvisible | If true only visible elements are included. |
[in] | flags | The flags: VIEWPORTSELECTFLAGS |
Bool Init | ( | Int32 | w, |
Int32 | h, | ||
BaseDraw * | bd, | ||
AtomArray * | ar, | ||
Int32 | mode, | ||
Bool | onlyvisible, | ||
VIEWPORTSELECTFLAGS | flags = VIEWPORTSELECTFLAGS::NONE |
||
) |
Initializes the viewport information for multiple objects. This has to be done before the pixel information can be retrieved.
[in] | w | The width of the viewport in pixels. |
[in] | h | The height of the viewport in pixels. |
[in] | bd | The viewport base draw. The caller owns the pointed base draw. |
[in] | ar | An atom array with objects to get the information for. The caller owns the pointed array. Pass nullptr or an empty array to initialize an empty ViewportSelect, for instance to draw your own polygons or handles. |
[in] | mode | The editor mode: Mpoints, Mpolygons, Medges or Mpolyedgepoint. |
[in] | onlyvisible | If true only visible elements are included. |
[in] | flags | The flags: VIEWPORTSELECTFLAGS |
|
static |
Picks objects within the circle that is defined by x, y, and rad into the provided object list. Note that the screen origin is in the upper left corner, whereas the clip origin is in the lower left corner.
[in] | bd | The viewport base draw. The caller owns the pointed base draw. |
[in] | doc | The document. The caller owns the pointed document. |
[in] | x | The X position of the picking circle within the viewport. |
[in] | y | The Y position of the picking circle within the viewport. |
[in] | rad | The radius in pixels for the search. |
[in] | flags | The flags: VIEWPORT_PICK_FLAGS |
[in] | ls | An optional lasso selection. The caller owns the pointed lasso selection. |
[out] | list | The picked object list to fill. The caller owns the pointed list. |
[out] | m | The projection matrix. A vector in OpenGL clipping space (-1,1) is the result of a vector in world space multiplied by this matrix. |
[out] | sampleLocation | Sample location inside the pixel (cast to DRAWPORT_SAMPLE_LOCATION). |
|
static |
Picks objects within the circle that is defined by x, y, and rad into the provided object list.
[in] | bd | The viewport base draw. The caller owns the pointed base draw. |
[in] | doc | The document. The caller owns the pointed document. |
[in] | x | The X position of the picking circle within the viewport. |
[in] | y | The Y position of the picking circle within the viewport. |
[in] | rad | The radius in pixels for the search. |
[out] | xr | Is assigned the X position of the rectangle where the picking was done. |
[out] | yr | Is assigned the Y position of the rectangle where the picking was done. |
[out] | wr | Is assigned the width of the rectangle where the picking was done. |
[out] | hr | Is assigned the height of the rectangle where the picking was done. |
[out] | pixels | Holds an [wr * hr] array with the pixel information. For each array index this is a linked list. The array must be deleted by the caller when it is not needed anymore! |
[in] | flags | The flags: VIEWPORT_PICK_FLAGS |
[in] | ls | An optional lasso selection. The caller owns the pointed lasso selection. |
[out] | list | The picked object list to fill. The caller owns the pointed list. |
[out] | m | The projection matrix. A vector in OpenGL clipping space (-1,1) is the result of a vector in world space multiplied by this matrix. |
[out] | sampleLocation | Sample location inside the pixel (cast to DRAWPORT_SAMPLE_LOCATION). |
|
static |
Picks objects within the rectangle that is defined by x1, y1, x2 and y2.
[in] | bd | The viewport base draw. The caller owns the pointed base draw. |
[in] | doc | The document. The caller owns the pointed document. |
[in] | x1 | The X minimum position of the picking rectangle. |
[in] | y1 | The Y minimum position of the picking rectangle. |
[in] | x2 | The X maximum position of the picking rectangle. |
[in] | y2 | The Y maximum position of the picking rectangle. |
[out] | xr | Is assigned the X position of the rectangle where the picking was done. |
[out] | yr | Is assigned the Y position of the rectangle where the picking was done. |
[out] | wr | Is assigned the width of the rectangle where the picking was done. |
[out] | hr | Is assigned the height of the rectangle where the picking was done. |
[out] | pixels | Holds an [wr * hr] array with the pixel information. For each array index this is a linked list. The array must be deleted by the caller when it is not needed anymore! |
[in] | flags | The flags: VIEWPORT_PICK_FLAGS |
[in] | ls | An optional lasso selection. The caller owns the pointed lasso selection. |
[out] | list | The picked object list to fill. The caller owns the pointed list. |
[out] | m | The projection matrix. A vector in OpenGL clipping space (-1,1) is the result of a vector in world space multiplied by this matrix. |
[out] | sampleLocation | Sample location inside the pixel (cast to DRAWPORT_SAMPLE_LOCATION). |
const ViewportPixel* GetPixelInfoPoint | ( | Int32 | x, |
Int32 | y | ||
) | const |
Retrieves point information at the pixel position (x,y).
[in] | x | An X coordinate within the viewport. Must be 0 <= x < w, where w is the width given to Init(). |
[in] | y | A Y coordinate within the viewport. Must be 0 <= y < h, where h is the height given to Init(). |
const ViewportPixel* GetPixelInfoPolygon | ( | Int32 | x, |
Int32 | y | ||
) | const |
Retrieves polygon information at the pixel position (x,y).
[in] | x | An X coordinate within the viewport. Must be 0 <= x < w, where w is the width given to Init(). |
[in] | y | A Y coordinate within the viewport. Must be 0 <= y < h, where h is the height given to Init(). |
const ViewportPixel* GetPixelInfoEdge | ( | Int32 | x, |
Int32 | y | ||
) | const |
Retrieves edge information at the pixel position (x,y).
[in] | x | An X coordinate within the viewport. Must be 0 <= x < w, where w is the width given to Init(). |
[in] | y | A Y coordinate within the viewport. Must be 0 <= y < h, where h is the height given to Init(). |
Bool GetPointPixelBuffer | ( | const ViewportPixel *const *& | pixelBuffer, |
Int32 * | pixelCount = nullptr |
||
) | const |
Retrieves point information buffer. Direct access to the buffer should always be bound by GetPixelCount().
[out] | pixelBuffer | The address of the point pixel buffer. The ViewportSelect instance owns the pointed pixel buffer. |
[out] | pixelCount | nullptr or valid address to write the point pixel buffer count. |
Bool GetEdgePixelBuffer | ( | const ViewportPixel *const *& | pixelBuffer, |
Int32 * | pixelCount = nullptr |
||
) | const |
Retrieves edge information buffer. Direct access to the buffer should always be bound by GetPixelCount().
[out] | pixelBuffer | The address of the edge pixel buffer. The ViewportSelect instance owns the pointed pixel buffer. |
[out] | pixelCount | nullptr or valid address to write the edge pixel buffer count. |
Bool GetPolygonPixelBuffer | ( | const ViewportPixel *const *& | pixelBuffer, |
Int32 * | pixelCount = nullptr |
||
) | const |
Retrieves polygon information buffer. Direct access to the buffer should always be bound by GetPixelCount().
[out] | pixelBuffer | The address of the polygon pixel buffer. The ViewportSelect instance owns the pointed pixel buffer. |
[out] | pixelCount | nullptr or valid address to write the polygon pixel buffer count. |
const ViewportPixel* GetNearestPoint | ( | BaseObject * | op, |
Int32 & | x, | ||
Int32 & | y, | ||
Int32 | maxrad = LIMIT< Int32 >::MAX , |
||
Bool | onlyselected = false , |
||
Int32 * | ignorelist = nullptr , |
||
Int32 | ignorecnt = 0 |
||
) | const |
Retrieves nearest point information at the pixel position (x,y).
[in] | op | The object to search for the closest element. The caller owns the pointed object. |
[in] | x | An X coordinate within the viewport. Must be 0 <= x < w, where w is the width given to Init(). If an element was found the reference is updated to reflect the X coordinate of the nearest point. |
[in] | y | An Y coordinate within the viewport. Must be 0 <= y < h, where h is the height given to Init(). If an element was found the reference is updated to reflect the Y coordinate of the nearest point. |
[in] | maxrad | A maximal radius for the search in pixels. |
[in] | onlyselected | If true only selected elements are included in the search. |
[in] | ignorelist | A list with points to ignore. The caller owns the pointed list. |
[in] | ignorecnt | The number of points index in ignorelist. |
const ViewportPixel* GetNearestPolygon | ( | BaseObject * | op, |
Int32 & | x, | ||
Int32 & | y, | ||
Int32 | maxrad = LIMIT< Int32 >::MAX , |
||
Bool | onlyselected = false , |
||
Int32 * | ignorelist = nullptr , |
||
Int32 | ignorecnt = 0 |
||
) | const |
Retrieves nearest polygon information at the pixel position (x,y).
[in] | op | The object to search for the closest element. The caller owns the pointed object. |
[in] | x | An X coordinate within the viewport. Must be 0 <= x < w, where w is the width given to Init(). If an element was found the reference is updated to reflect the X coordinate of the nearest point. |
[in] | y | An Y coordinate within the viewport. Must be 0 <= y < h, where h is the height given to Init(). If an element was found the reference is updated to reflect the Y coordinate of the nearest point. |
[in] | maxrad | A maximal radius for the search in pixels. |
[in] | onlyselected | If true only selected elements are included in the search. |
[in] | ignorelist | A list with points to ignore. The caller owns the pointed list. |
[in] | ignorecnt | The number of points index in ignorelist. |
const ViewportPixel* GetNearestEdge | ( | BaseObject * | op, |
Int32 & | x, | ||
Int32 & | y, | ||
Int32 | maxrad = LIMIT< Int32 >::MAX , |
||
Bool | onlyselected = false , |
||
Int32 * | ignorelist = nullptr , |
||
Int32 | ignorecnt = 0 |
||
) | const |
Retrieves nearest edge information at the pixel position (x,y).
[in] | op | The object to search for the closest element. The caller owns the pointed object. |
[in] | x | An X coordinate within the viewport. Must be 0 <= x < w, where w is the width given to Init(). If an element was found the reference is updated to reflect the X coordinate of the nearest point. |
[in] | y | An Y coordinate within the viewport. Must be 0 <= y < h, where h is the height given to Init(). If an element was found the reference is updated to reflect the Y coordinate of the nearest point. |
[in] | maxrad | A maximal radius for the search in pixels. |
[in] | onlyselected | If true only selected elements are included in the search. |
[in] | ignorelist | A list with points to ignore. The caller owns the pointed list. |
[in] | ignorecnt | The number of points index in ignorelist. |
Int32 GetPixelCount | ( | ) | const |
Returns the number of pixels in the pixel buffers fetched with GetPixelInfoPoint()/GetPixelInfoEdge()/GetPixelInfoPolygon().
Bool DrawPolygon | ( | const Vector * | p, |
Int32 | ptcnt, | ||
Int32 | i, | ||
BaseObject * | op, | ||
Int32 | onlyvisible = -1 |
||
) |
Draws a polygon into the internal pixel structure, so that pixels inside the polygon will be associated with i and op in the ViewportPixel retrieved.
[in] | p | An array of ptcnt points that make up the polygon. The caller owns the pointed array. Coordinates are in screen space. |
[in] | ptcnt | The number of points in the polygon p. |
[in] | i | The polygon index to associate with the polygon. |
[in] | op | The object to associate with the polygon. The caller owns the pointed object. |
[in] | onlyvisible | If true only visible parts of the polygon are drawn. |
Bool DrawHandle | ( | const Vector & | p, |
Int32 | i, | ||
BaseObject * | op, | ||
Int32 | onlyvisible = -1 |
||
) |
Draws a handle into the internal pixel structure, so that pixels inside the handle will be associated with i and op in the ViewportPixel retrieved.
[in] | p | The position of the handle. Coordinate is in screen space. |
[in] | i | The polygon index to associate with the handle. |
[in] | op | The object to associate with the handle. The caller owns the pointed object. |
[in] | onlyvisible | If true only visible parts of the handle are drawn. |
|
static |
Private.
void ShowHotspot | ( | EditorWindow * | bw, |
Int32 | x, | ||
Int32 | y | ||
) |
Draws an XOR circle to the view bw at the pixel position (x,y). The radius is set by SetBrushRadius().
[in] | bw | The editor window to draw to. The caller owns the pointed EditorWindow. |
[in] | x | The X position of the XOR circle within the viewport. Must be 0 <= x < w, where w is the width given to Init(). |
[in] | y | The Y position of the XOR circle within the viewport. Must be 0 <= y < h, where h is the height given to Init(). |
void SetBrushRadius | ( | Int32 | r | ) |
Sets the radius size for ShowHotspot() to r.
[in] | r | The radius in pixels. |
Deletes the pixel information at (x,y) according to mask.
[in] | x | An X coordinate within the viewport. Must be 0 <= x < w, where w is the width given to Init(). |
[in] | y | A Y coordinate within the viewport. Must be 0 <= y < h, where h is the height given to Init(). |
[in] | mask | A bitfield of what to clear: VIEWPORT_CLEAR |
Converts the pixel position (x,y,z) to camera coordinates in v.
[in] | x | An X coordinate within the viewport. Must be 0 <= x < w, where w is the width given to Init(). |
[in] | y | A Y coordinate within the viewport. Must be 0 <= y < h, where h is the height given to Init(). |
[in] | z | A Z coordinate within the viewport. |
[in] | v | Is assigned the calculated camera coordinate. |