ViewportSelect Class Reference

#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.

注意
Has to be created with Alloc() and destroyed with Free() 。使用 AutoAlloc to automate the allocation and destruction based on scope.

私有成员函数

  ViewportSelect ()
  ~ViewportSelect ()

Alloc/Free

static ViewportSelect Alloc ()
static void  Free ( ViewportSelect *&p)

Initialization

Bool   Init ( Int32 w, Int32 h, BaseDraw *bd, BaseObject *op, Int32 模式, Bool onlyvisible, VIEWPORTSELECTFLAGS flags= VIEWPORTSELECTFLAGS::NONE )
Bool   Init ( Int32 w, Int32 h, BaseDraw *bd, AtomArray *ar, Int32 模式, Bool onlyvisible, VIEWPORTSELECTFLAGS flags= VIEWPORTSELECTFLAGS::NONE )

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)

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 向量 *p, Int32 ptcnt, Int32 i, BaseObject *op, Int32 onlyvisible=-1)
Bool   DrawHandle (const 向量 &p, Int32 i, BaseObject *op, Int32 onlyvisible=-1)

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)

杂项

void  ClearPixelInfo ( Int32 x, Int32 y, UChar mask)
Bool   GetCameraCoordinates ( Float x, Float y, Float z, 向量 &v) const

构造函数 & 析构函数文档编制

◆  ViewportSelect()

ViewportSelect () private

◆  ~ViewportSelect()

~ ViewportSelect () private

成员函数文档编制

◆  Alloc()

static ViewportSelect * Alloc ( )
static

Allocates a viewport select. Destroy the allocated viewport select with Free() 。使用 AutoAlloc to automate the allocation and destruction based on scope.

返回
The allocated viewport select, or nullptr if the allocation failed.

◆  Free()

static void Free ( ViewportSelect *&  p )
static

Destructs viewport selects allocated with Alloc() 。使用 AutoAlloc to automate the allocation and destruction based on scope.

参数
[in,out] p The viewport select to destruct. If the pointer is nullptr nothing happens. The pointer is assigned nullptr afterwards.

◆  Init() [1/2]

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:

Int32 left, top, right, bottom, width, height bd-> GetFrame (&left, &top, &right, &bottom); width = right - left + 1; height = bottom - top + 1;
参数
[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 true only visible elements are included.
[in] flags The flags: VIEWPORTSELECTFLAGS
返回
true if the viewport select was successfully initialized, otherwise false .

◆  Init() [2/2]

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.

Int32 left, top, right, bottom, width, height bd-> GetFrame (&left, &top, &right, &bottom); width = right - left + 1; height = bottom - top + 1;
参数
[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 true only visible elements are included.
[in] flags The flags: VIEWPORTSELECTFLAGS
返回
true if the viewport select was successfully initialized, otherwise false .

◆  PickObject() [1/3]

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

Picks objects within the circle that is defined by x , y ,和 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).
返回
true if objects were picked successfully, otherwise false .

◆  PickObject() [2/3]

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

Picks objects within the circle that is defined by x , y ,和 rad into the provided object list .

注意
xr , yr , wr and hr hold the region where the picking was done. It can be smaller than the originally defined region. (e.g. If the picking is done close to the view's border.) 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.
[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).
返回
true if objects were picked successfully, otherwise false .

◆  PickObject() [3/3]

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  
)
static

Picks objects within the rectangle that is defined by x1 , y1 , x2 and y2 .

注意
VIEWPORT_PICK_FLAGS::ALLOW_OGL must be set. x1 , y1 , x2 and y2 are inclusive.
xr , yr , wr and hr hold the region where the picking was done. It can be smaller than the originally defined region. (e.g. If the picking is done close to the view's border.) 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] 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).
返回
true if objects were picked successfully, otherwise false .

◆  GetPixelInfoPoint()

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 ,其中 w is the width given to Init() .
[in] y A Y coordinate within the viewport. Must be 0 <= y < h ,其中 h is the height given to Init() .
返回
The retrieved point information, or nullptr if no information could be retrieved. The ViewportSelect instance owns the pointed viewport pixel..

◆  GetPixelInfoPolygon()

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 ,其中 w is the width given to Init() .
[in] y A Y coordinate within the viewport. Must be 0 <= y < h ,其中 h is the height given to Init() .
返回
The retrieved polygon information, or nullptr if no information could be retrieved. The ViewportSelect instance owns the pointed viewport pixel..

◆  GetPixelInfoEdge()

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 ,其中 w is the width given to Init() .
[in] y A Y coordinate within the viewport. Must be 0 <= y < h ,其中 h is the height given to Init() .
返回
The retrieved edge information, or nullptr if no information could be retrieved. The ViewportSelect instance owns the pointed viewport pixel..

◆  GetPointPixelBuffer()

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() .

由于
R19
注意
Direct browsing of the pixel buffers is always faster than by making a library call pixel per pixel.
参数
[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.
返回
true ViewportSelect was properly initialized and the point buffer is valid, otherwise false .

◆  GetEdgePixelBuffer()

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() .

由于
R19
注意
Direct browsing of the pixel buffers is always faster than by making a library call pixel per pixel.
参数
[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.
返回
true ViewportSelect was properly initialized and the edge buffer is valid, otherwise false .

◆  GetPolygonPixelBuffer()

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() .

由于
R19
注意
Direct browsing of the pixel buffers is always faster than by making a library call pixel per pixel.
参数
[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.
返回
true ViewportSelect was properly initialized and the polygon buffer is valid, otherwise false .

◆  GetNearestPoint()

const ViewportPixel * GetNearestPoint ( BaseObject op ,
Int32 x ,
Int32 y ,
Int32   maxrad = LIMITInt32 >::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 ,其中 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 ,其中 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 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 .
返回
The retrieved nearest point information, or nullptr if no information could be retrieved. The ViewportSelect instance owns the pointed viewport pixel..

◆  GetNearestPolygon()

const ViewportPixel * GetNearestPolygon ( BaseObject op ,
Int32 x ,
Int32 y ,
Int32   maxrad = LIMITInt32 >::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 ,其中 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 ,其中 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 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 .
返回
The retrieved nearest polygon information, or nullptr if no information could be retrieved. The ViewportSelect instance owns the pointed viewport pixel..

◆  GetNearestEdge()

const ViewportPixel * GetNearestEdge ( BaseObject op ,
Int32 x ,
Int32 y ,
Int32   maxrad = LIMITInt32 >::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 ,其中 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 ,其中 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 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 .
返回
The retrieved nearest edge information, or nullptr if no information could be retrieved. The ViewportSelect instance owns the pointed viewport pixel..

◆  GetPixelCount()

Int32 GetPixelCount ( ) const

Returns the number of pixels in the pixel buffers fetched with GetPixelInfoPoint() / GetPixelInfoEdge() / GetPixelInfoPolygon() .

由于
R19
警告
Pixel array should never be indexed further than the pixel count.
返回
The pixel count.

◆  DrawPolygon()

Bool DrawPolygon ( const 向量 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 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 true only visible parts of the polygon are drawn.
返回
true if the polygon was successfully drawn, otherwise false .

◆  DrawHandle()

Bool DrawHandle ( const 向量 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 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 true only visible parts of the handle are drawn.
返回
true if the handle was successfully drawn, otherwise false .

◆  ShowHotspot() [1/2]

static void ShowHotspot ( EditorWindow bw ,
Int32   x ,
Int32   y ,
Int32   rad ,
Bool   bRemove  
)
static

Private .

◆  ShowHotspot() [2/2]

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 ,其中 w is the width given to Init() .
[in] y The Y position of the XOR circle within the viewport. Must be 0 <= y < h ,其中 h is the height given to Init() .

◆  SetBrushRadius()

void SetBrushRadius ( Int32   r )

Sets the radius size for ShowHotspot() to r .

参数
[in] r The radius in pixels.

◆  ClearPixelInfo()

void ClearPixelInfo ( Int32   x ,
Int32   y ,
UChar   mask  
)

Deletes the pixel information at ( x , y ) according to mask .

注意
This is used for example in the live edge selection with "tolerant" deactivated to find out how many pixels of a certain edge was selected.
If an edge is determined under the cursor, the pixel counter is decremented and the edge information is deleted afterwards.
参数
[in] x An X coordinate within the viewport. Must be 0 <= x < w ,其中 w is the width given to Init() .
[in] y A Y coordinate within the viewport. Must be 0 <= y < h ,其中 h is the height given to Init() .
[in] mask A bitfield of what to clear: VIEWPORT_CLEAR

◆  GetCameraCoordinates()

Bool GetCameraCoordinates ( Float   x ,
Float   y ,
Float   z ,
向量 v  
) const

Converts the pixel position ( x , y , z ) to camera coordinates in v .

注意
This is not exactly the same as v = bd-> SC ( 向量 (x,y,z)) since inverted Z coordinates are used.
参数
[in] x An X coordinate within the viewport. Must be 0 <= x < w ,其中 w is the width given to Init() .
[in] y A Y coordinate within the viewport. Must be 0 <= y < h ,其中 h is the height given to Init() .
[in] z A Z coordinate within the viewport.
[in] v Is assigned the calculated camera coordinate.
返回
true if the pixel position was successfully converted, otherwise false .
BaseView::GetFrame
void GetFrame(Int32 *cl, Int32 *ct, Int32 *cr, Int32 *cb)
BaseView::SC
Vector SC(const Vector &p) const
定义: c4d_basedraw.h:449
Int32
maxon::Int32 Int32
定义: ge_sys_math.h:58
向量
maxon::Vec3< maxon::Float64, 1 > Vector
定义: ge_math.h:145