本文整理汇总了C++中AutoAlloc::GetZ方法的典型用法代码示例。如果您正苦于以下问题:C++ AutoAlloc::GetZ方法的具体用法?C++ AutoAlloc::GetZ怎么用?C++ AutoAlloc::GetZ使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AutoAlloc
的用法示例。
在下文中一共展示了AutoAlloc::GetZ方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MouseInput
Bool PickObjectTool::MouseInput(BaseDocument* doc, BaseContainer& data, BaseDraw* bd, EditorWindow* win, const BaseContainer& msg)
{
Int32 mode = data.GetInt32(MDATA_PICKOBJECT_MODE);
Int32 x, y, l, xr = 0, yr = 0, wr = 0, hr = 0;
Matrix4d m;
ViewportPixel** pix = nullptr;
String str;
char ch[200];
Bool ret = false;
AutoAlloc<C4DObjectList> list;
if (!list)
return false;
VIEWPORT_PICK_FLAGS flags = VIEWPORT_PICK_FLAGS_ALLOW_OGL | VIEWPORT_PICK_FLAGS_USE_SEL_FILTER;
if (data.GetBool(MDATA_PICKOBJECT_ONLY_VISIBLE))
flags |= VIEWPORT_PICK_FLAGS_OGL_ONLY_VISIBLE;
x = msg.GetInt32(BFM_INPUT_X);
y = msg.GetInt32(BFM_INPUT_Y);
Float64 timer = 0.0;
if (mode == MDATA_PICKOBJECT_MODE_CIRCLE)
{
Int32 rad = data.GetInt32(MDATA_PICKOBJECT_CIRCLE_RAD);
timer = GeGetMilliSeconds();
ret = ViewportSelect::PickObject(bd, doc, x, y, rad, xr, yr, wr, hr, pix, flags, nullptr, list, &m);
timer = GeGetMilliSeconds() - timer;
}
else if (mode == MDATA_PICKOBJECT_MODE_RECTANGLE)
{
Int32 width = data.GetInt32(MDATA_PICKOBJECT_RECT_W);
Int32 height = data.GetInt32(MDATA_PICKOBJECT_RECT_H);
x -= width / 2;
y -= height / 2;
timer = GeGetMilliSeconds();
ret = ViewportSelect::PickObject(bd, doc, x, y, x + width, y + height, xr, yr, wr, hr, pix, flags, nullptr, list, &m);
timer = GeGetMilliSeconds() - timer;
}
if (ret)
{
sprintf(ch, "Picking region from (%d, %d), size (%d, %d)|", xr, yr, wr, hr);
str += ch;
for (l = 0; l < list->GetCount(); l++)
{
sprintf(ch, ", z = %.4f|", list->GetZ(l));
str += "Found Object " + list->GetObject(l)->GetName() + ch;
}
}
else
{
str = "PickObject failed";
}
sprintf(ch, "|Time: %.2f us", float(timer) * 1000.0f);
str += ch;
DeleteMem(pix);
GeOutString(str, GEMB_OK);
return true;
}
示例2: GetCursorInfo
Bool PickObjectTool::GetCursorInfo(BaseDocument* doc, BaseContainer& data, BaseDraw* bd, Float x, Float y, BaseContainer& bc)
{
if (bc.GetId() == BFM_CURSORINFO_REMOVE)
{
_lastBaseDraw = nullptr;
}
else
{
_lastBaseDraw = bd;
_mouseX = (Int32)x;
_mouseY = (Int32)y;
AutoAlloc<C4DObjectList> list;
if (list)
{
// get the z position of the topmost object. The z range for objects is from -1 to 1.
Float z = 1.0;
String str;
Matrix4d m;
ViewportSelect::PickObject(bd, doc, _mouseX, _mouseY, 1, VIEWPORT_PICK_FLAGS_ALLOW_OGL | VIEWPORT_PICK_FLAGS_USE_SEL_FILTER | VIEWPORT_PICK_FLAGS_OGL_ONLY_TOPMOST, nullptr, list, &m);
if (list->GetCount() > 0)
z = list->GetZ(0);
if (z < 1.0)
{
Vector v = GetWorldCoordinates(bd, m, x, y, z);
char ch[200];
sprintf(ch, "Mouse coordinates: (%d, %d), world coordinates: (%.4f, %.4f, %.4f)", _mouseX, _mouseY, v.x, v.y, v.z);
str = ch;
}
else
{
str = "Mouse cursor is not over an object";
}
StatusSetText(str);
}
}
SpecialEventAdd(EVMSG_UPDATEHIGHLIGHT);
return true;
}