本文整理汇总了C++中APoint::Z方法的典型用法代码示例。如果您正苦于以下问题:C++ APoint::Z方法的具体用法?C++ APoint::Z怎么用?C++ APoint::Z使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类APoint
的用法示例。
在下文中一共展示了APoint::Z方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnLeftDClick
//----------------------------------------------------------------------------
void EditRenderView_TimeLine::OnLeftDClick(const APoint &pos)
{
EditRenderView::OnLeftDClick(pos);
Rectf rect(0, 0, mLeftWidth, mSize.Height);
bool leftContain = rect.IsInsize(Float2(pos.X(), pos.Z()));
bool isCtrlDown = PX2_EDIT.IsCtrlDown;
if (!leftContain && isCtrlDown)
{
UICurveGroup *uiCurveGroup = PX2_EDIT.GetTimeLineEdit()->GetSelectedUICurveGroup();
if (!uiCurveGroup) return;
Camera *camera = PX2_EDIT.GetTimeLineEdit()->GetTimeLineRenderStep_Grid()->GetCamera();
APoint camPos = camera->GetPosition();
Vector2f camScreenPos = mUIViewGrid->PointWorldToViewPort(camPos);
float xDissCam = pos.X() - camScreenPos.X();
float zDissCam = pos.Z() - camScreenPos.Y();
float xDissCamReal = xDissCam / mPixelOverCamIn;
float zDissCamReal = zDissCam / mPixelOverCamOut;
APoint pointPos = camPos + AVector(xDissCamReal, 0.0f, zDissCamReal);
CurveGroup *curveGroup = uiCurveGroup->GetCurveGroup();
curveGroup->AddPoint(pointPos);
}
}
示例2: IsPointIn
//----------------------------------------------------------------------------
bool TriggerActor::IsPointIn(const PX2::APoint &point) const
{
Transform trans = WorldTransform;
APoint localPoint = trans.Inverse() * point;
if (mAreaType == AT_SPHERE)
{
Sphere3f sphere;
sphere.Radius = mAreaParam[0];
if (InSphere<float>(localPoint, sphere))
return true;
}
else if (mAreaType == AT_BOX)
{
Box3f box;
box.Extent[0] = mAreaParam[0];
box.Extent[1] = mAreaParam[1];
box.Extent[2] = mAreaParam[2];
if (localPoint.X() >= -box.Extent[0] &&
localPoint.Y() >= -box.Extent[1] &&
localPoint.Z() >= -box.Extent[2] &&
localPoint.X() <= box.Extent[0] &&
localPoint.Y() <= box.Extent[1] &&
localPoint.Z() <= box.Extent[2])
return true;
}
return false;
}
示例3: Select
//----------------------------------------------------------------------------
void CurveCtrl::Select (bool select)
{
if (mSelected == select)
return;
if (mSelected)
{
APoint scale = mDragBox->LocalTransform.GetScale();
mDragBox->LocalTransform.SetScale(APoint(scale.X(), 1.0f, scale.Z()));
}
mSelected = select;
Float3 color = mCurve->GetCurveColor();
if (mSelected)
{
color = Float3::YELLOW;
APoint scale = mDragBox->LocalTransform.GetScale();
mDragBox->LocalTransform.SetScale(APoint(scale.X(), 1.5f, scale.Z()));
}
VertexBufferAccessor vba(mDragBox);
for (int i=0; i<vba.GetNumVertices(); i++)
{
vba.Color<Float3>(0, i) = color;
}
Renderer::UpdateAll(mDragBox->GetVertexBuffer());
OnCtrlChanged (false);
}
示例4: FitViewToSelected
//----------------------------------------------------------------------------
void EditRenderView_TimeLine::FitViewToSelected()
{
CurveCtrl *ctrl = PX2_EDIT.GetTimeLineEdit()->GetSelectedCurveCtrl();
Camera *camera = mUIViewGrid->GetCamera();
CameraNode *cameraNode = mUIViewGrid->GetCameraNode();
if (!ctrl) return;
float inMin = Mathf::MAX_REAL;
float inMax = -Mathf::MAX_REAL;
PX2_EDIT.GetTimeLineEdit()->GetInRange(inMin, inMax);
float outMin = Mathf::MAX_REAL;
float outMax = -Mathf::MAX_REAL;
PX2_EDIT.GetTimeLineEdit()->GetOutRange(outMin, outMax);
float inLength = inMax - inMin;
float outLength = outMax - outMin;
if (inLength == 0.0f)
{
inLength = 10.0f;
}
if (outLength == 0.0f)
{
outLength = 10.0f;
}
float rightWidth = (float)mSize.Width - mLeftWidth;
float leftOverWidth = (float)mLeftWidth / (float)mSize.Width;
float allOverRight = (float)mSize.Width / rightWidth;
inLength *= allOverRight;
PX2_UNUSED(leftOverWidth);
float dMin = 0.0f;
float dMax = 0.0f;
float uMin = 0.0f;
float uMax = 0.0f;
float rMin = 0.0f;
float rMax = 0.0f;
camera->GetFrustum(dMin, dMax, uMin, uMax, rMin, rMax);
rMax = inLength / 2.0f * 1.5f;
rMin = -rMax;
uMax = outLength / 2.0f * 1.5f;
uMin = -uMax;
camera->SetFrustum(dMin, dMax, uMin, uMax, rMin, rMax);
APoint camPos = camera->GetPosition();
APoint ctrPos = ctrl->GetOutVal();
camPos.X() = ctrPos.X();
camPos.Z() = ctrPos.Z();
mUIViewGrid->GetCameraNode()->LocalTransform.SetTranslate(camPos);
mUIViewGrid->GetCameraNode()->Update(GetTimeInSeconds(), 0.0f);
_RefreshGrid(true);
}
示例5: WorldPosToViewPortPos
//----------------------------------------------------------------------------
APoint SizeNode::WorldPosToViewPortPos(const APoint &worldPos)
{
Rectf worldRect = GetWorldRect();
APoint viewPortPos;
viewPortPos.X() = worldPos.X() - worldRect.Left;
viewPortPos.Z() = worldPos.Z() - worldRect.Bottom;
return viewPortPos;
}
示例6: GetWorldRect
//----------------------------------------------------------------------------
Rectf SizeNode::GetWorldRect() const
{
Rectf rect = GetLocalRect();
const APoint worldPos = WorldTransform.GetTranslate();
rect.Left += worldPos.X();
rect.Right += worldPos.X();
rect.Bottom += worldPos.Z();
rect.Top += worldPos.Z();
return rect;
}
示例7: _UpdateAlignItems
//----------------------------------------------------------------------------
int UIGridFrame::_UpdateAlignItems()
{
int numValidChild = 0;
for (int i = 0; i < GetNumChildren(); i++)
{
Movable *mov = GetChild(i);
if (mov)
{
APoint pos;
if (ATT_SIZE_WIDTH == mAlignItemType)
{
int numWidth = (int)((mSize.Width - mBorderSize.Width*2.0f) / mItemSize.Width);
if (0 == numWidth)
numWidth = 1;
int xIndex = numValidChild % numWidth;
int zIndex = numValidChild / numWidth;
pos.X() = mBorderSize.Width + mItemSize.Width / 2.0f + mItemSize.Width*xIndex;
pos.Z() = mSize.Height - mBorderSize.Height - mItemSize.Height / 2.0f - mItemSize.Height*zIndex;
}
else if (ATT_NUM_WIDTH == mAlignItemType)
{
assertion(0.0f != mAlignItemNum[0], "");
assertion(0.0f != mAlignItemNum[1], "");
mItemSize.Width = (mSize.Width - mBorderSize.Width*2.0f) / mAlignItemNum[0];
mItemSize.Height = (mSize.Height - mBorderSize.Height*2.0f) / mAlignItemNum[1];
int numWidth = (int)mAlignItemNum[0];
int xIndex = numValidChild%numWidth;
int zIndex = numValidChild / numWidth;
pos.X() = mBorderSize.Width + mItemSize.Width / 2.0f + mItemSize.Width*xIndex;
pos.Z() = mSize.Height - mBorderSize.Height - mItemSize.Height / 2.0f - mItemSize.Height*zIndex;
}
mov->LocalTransform.SetTranslate(pos);
numValidChild++;
}
}
return numValidChild;
}
示例8: _TrySelectCurveCtrlPoint
//----------------------------------------------------------------------------
void EditRenderView_TimeLine::_TrySelectCurveCtrlPoint(const APoint &pos)
{
APoint origin;
AVector direction;
mRenderStep->GetPickRay(pos.X(), pos.Z(), origin, direction);
Node *gridNode = PX2_EDIT.GetTimeLineEdit()->GetCurveEditNode_Grid();
Picker picker;
picker.Execute(gridNode, origin, direction, 0.0f, Mathf::MAX_REAL);
if ((int)(picker.Records.size()) > 0)
{
Movable *mov = picker.GetClosestNonnegative().Intersected;
CurveCtrl *ctrl = PX2_EDIT.GetTimeLineEdit()->TrySelectCurve(mov);
if (ctrl)
{
//UnToggleAllInterps();
//EnableInterps(true);
//ToggleInterp(ctrl->GetInterpCurveMode());
PX2_EDIT.GetTimeLineEdit()->SetSelectedCurveCtrl(ctrl);
}
else
{
PX2_EDIT.GetTimeLineEdit()->SetSelectedCurveCtrl(0);
}
}
else
{
PX2_EDIT.GetTimeLineEdit()->SetSelectedCurveCtrl(0);
}
}
示例9: PointWorldToViewPort
//----------------------------------------------------------------------------
Vector2f Renderer::PointWorldToViewPort (const APoint &point, bool *isInBack)
{
HMatrix matProjView = GetProjectionMatrix() * GetViewMatrix();
HPoint hPoint(point.X(), point.Y(), point.Z(), point.W());
HPoint tempPoint = matProjView * hPoint;
if (isInBack)
{
if (tempPoint.Z() <= 0)
*isInBack = true;
else
*isInBack = false;
}
float wInv = 1.0f / tempPoint.W();
//投影坐标范围为[-1,1]要变成[0,1]
Vector2f screenPoint;
screenPoint.X() = (1.0f + tempPoint.X()*wInv)/2.0f;
screenPoint.Y() = (1.0f + tempPoint.Y()*wInv)/2.0f;
//投影坐标范围为[0,1]要变成视口内坐标
int viewX, viewY, viewW, viewH;
GetViewport(viewX, viewY, viewW, viewH);
screenPoint.X() = viewX + screenPoint.X()*viewW;
screenPoint.Y() = viewY + screenPoint.Y()*viewH;
return screenPoint;
}
示例10: OnRightUp
//----------------------------------------------------------------------------
void EU_CanvasStage::OnRightUp(const APoint &worldPos)
{
if (!IsEnable())
return;
const Rectf &rectWorld = GetWorldRect();
if (!rectWorld.IsInsize(worldPos.X(), worldPos.Z()))
return;
Project *proj = Project::GetSingletonPtr();
if (!proj)
return;
if (IsCameraDraging())
{
SetCameraDraging(false);
}
else
{
if (mIsRightPressed)
{
CreateMenuOnSelect(worldPos);
}
}
UICanvas::OnRightUp(worldPos);
}
示例11: _ClickSelectPos
//----------------------------------------------------------------------------
void EditRenderView_Scene::_ClickSelectPos(const APoint &scrPos)
{
Scene *scene = PX2_PROJ.GetScene();
RenderStep *renderStep = PX2_PROJ.GetSceneRenderStep();
APoint origin;
AVector direction;
renderStep->GetPickRay(scrPos.X(), scrPos.Z(), origin, direction);
ActorPicker actorPicker;
actorPicker.Execute(scene, origin, direction, 0.0f, Mathf::MAX_REAL);
if (actorPicker.Records.size() > 0)
{
const ActorPickRecord &record = actorPicker.GetClosestToZero();
mSelectPoint = origin + direction*record.T;
PX2_EDIT.SetPickPos(mSelectPoint);
}
else
{
PX2::TriMesh *xyPlane = PX2_GR.GetXYPlane();
xyPlane->WorldTransform.SetTranslate(APoint::ORIGIN);
Picker picker;
picker.Execute(xyPlane, origin, direction, 0.0f, Mathf::MAX_REAL);
if ((int)picker.Records.size() > 0)
{
const PickRecord &rec = picker.GetClosestToZero();
mSelectPoint = origin + direction*rec.T;
PX2_EDIT.SetPickPos(mSelectPoint);
}
}
}
示例12: OnLeftUp
//----------------------------------------------------------------------------
void EU_CanvasStage::OnLeftUp(const APoint &worldPos)
{
if (!IsEnable())
return;
const Rectf &rectWorld = GetWorldRect();
if (!rectWorld.IsInsize(worldPos.X(), worldPos.Z()))
return;
UICanvas::OnLeftUp(worldPos);
if (IsCameraDraging())
{
SetCameraDraging(false);
}
else
{
Camera *camera = mSceneNodeCtrlCanvas->GetOverCamera();
if (mSceneNodeCtrl)
mSceneNodeCtrl->OnLeftUp(camera, worldPos, GetSize());
Edit::EditMode em = PX2_EDIT.GetEditMode();
if ((Edit::EM_TRANSLATE == em || Edit::EM_ROTATE == em
|| Edit::EM_SCALE == em) && mIsSelectMovableTransChanged)
{
PX2_URDOM.PushUnDo(mURDoCommand);
mIsSelectMovableTransChanged = false;
}
}
}
示例13: _UpdateBrushPos
//----------------------------------------------------------------------------
void EU_CanvasStage::_UpdateBrushPos(const APoint &scrPos)
{
Project *proj = Project::GetSingletonPtr();
if (!proj) return;
Scene *scene = proj->GetScene();
if (!scene) return;
Terrain *terrain = scene->GetTerrain();
if (!terrain) return;
Movable *pickObject = terrain;
#ifdef _DEBUG
pickObject = PX2_GR.GetXYPlane();
pickObject->WorldTransform.SetTranslate(APoint::ORIGIN);
#endif
Camera *camera = mStageCameraNode->GetCamera();
APoint origin;
AVector direction;
camera->GetPickRay(scrPos.X(), scrPos.Z(), GetSize(), origin, direction);
Picker picker;
picker.Execute(pickObject, origin, direction, 0.0f, Mathf::MAX_REAL);
if ((int)picker.Records.size() > 0)
{
PX2::PickRecord pickRecord = picker.GetClosestToZero();
PX2::APoint dest = origin + direction*pickRecord.T;
PX2_EDIT.GetTerrainEdit()->GetBrush()->SetPos(dest);
}
}
示例14: PointWorldToViewPort
//----------------------------------------------------------------------------
Vector2f RenderStep::PointWorldToViewPort(const APoint &point,
bool *isInBack)
{
Rectf viewPort = mViewPort;
if (viewPort.IsEmpty())
viewPort = Rectf(0.0f, 0.0f, mSize.Width, mSize.Height);
HMatrix matProjView = mCamera->GetProjectionMatrix() * mCamera->GetViewMatrix();
HPoint hPoint(point.X(), point.Y(), point.Z(), point.W());
HPoint tempPoint = matProjView * hPoint;
if (isInBack)
{
if (tempPoint.Z() <= 0)
*isInBack = true;
else
*isInBack = false;
}
float wInv = 1.0f / tempPoint.W();
//投影坐标范围为[-1,1]要变成[0,1]
Vector2f screenPoint;
screenPoint.X() = (1.0f + tempPoint.X()*wInv) / 2.0f;
screenPoint.Y() = (1.0f + tempPoint.Y()*wInv) / 2.0f;
//投影坐标范围为[0,1]要变成视口内坐标
screenPoint.X() = viewPort.Left + screenPoint.X()*viewPort.Width();
screenPoint.Y() = viewPort.Bottom + screenPoint.Y()*viewPort.Height();
return screenPoint;
}
示例15: _ClickSelectScene
//----------------------------------------------------------------------------
void EU_CanvasStage::_ClickSelectScene(const APoint &scrPos)
{
if (!Project::GetSingletonPtr()) return;
Scene *scene = PX2_PROJ.GetScene();
if (!scene) return;
SelectMode mode = SM_SINGLE;
if (PX2_EDIT.IsCtrlDown) mode = SM_MULTI;
Camera *camera = mStageCameraNode->GetCamera();
APoint origin;
AVector direction;
camera->GetPickRay(scrPos.X(), scrPos.Z(), GetSize(), origin, direction);
Picker picker;
picker.Execute(scene, origin, direction, 0.0f, Mathf::MAX_REAL);
if ((int)picker.Records.size() > 0)
{
const PickRecord &record = picker.GetClosestToZero();
Object *recordObj = record.Intersected;
mSelectPoint = origin + direction*record.T;
PX2_EDIT.SetPickPos(mSelectPoint);
if (SM_SINGLE == mode)
{
int numObjs = PX2_SELECTM_E->GetNumObjects();
if (1 == numObjs && recordObj == PX2_SELECTM_E->GetFirstObject())
{
PX2_SELECTM_E->Clear();
}
else
{
PX2_SELECTM_E->Clear();
PX2_SELECTM_E->AddObject(recordObj);
}
}
else if (SM_MULTI == mode)
{
if (PX2_SELECTM_E->IsObjectIn(recordObj))
{
PX2_SELECTM_E->RemoveObject(recordObj);
}
else
{
PX2_SELECTM_E->AddObject(recordObj);
}
}
}
else
{
if (SM_SINGLE == mode)
{
PX2_SELECTM_E->Clear();
}
}
}