本文整理汇总了C++中APoint类的典型用法代码示例。如果您正苦于以下问题:C++ APoint类的具体用法?C++ APoint怎么用?C++ APoint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了APoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
}
}
示例3: _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);
}
}
示例4: rect
//----------------------------------------------------------------------------
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);
}
}
示例5: GetSize
//----------------------------------------------------------------------------
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);
}
}
示例6: OnProjectSize
//----------------------------------------------------------------------------
void ApplicationBase::OnProjectSize (int width, int height)
{
mUIManager->GetDefaultView()->SetSize((float)width, (float)height);
APoint curPos = mUIManager->GetDefaultView()->GetCamera()->GetPosition();
mUIManager->GetDefaultView()->GetCamera()->SetPosition(APoint((float)width/2.0f,
curPos.Y(), (float)height/2.0f));
}
示例7: 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;
}
示例8: 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);
}
示例9: _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);
}
}
}
示例10: _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();
}
}
}
示例11: SetRotation
//----------------------------------------------------------------------------
void Actor::SetRotation (APoint &rolate)
{
mRotation = rolate;
if (mMovable)
{
mMovable->LocalTransform.SetRotate(Matrix3f().MakeEulerXYZ(
rolate.X(), rolate.Y(), rolate.Z()));
}
}
示例12: GetWorldRect
//----------------------------------------------------------------------------
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;
}
示例13: wxPGProperty
//-----------------------------------------------------------------------------
wxAPoint3Property::wxAPoint3Property (const wxString &label, const wxString &name,
const APoint &value)
:
wxPGProperty(label, name)
{
SetValue(APointToVariant(value));
AddPrivateChild(new wxFloatProperty(wxT("X"),wxPG_LABEL,value.X()));
AddPrivateChild(new wxFloatProperty(wxT("Y"),wxPG_LABEL,value.Y()));
AddPrivateChild(new wxFloatProperty(wxT("Z"),wxPG_LABEL,value.Z()));
}
示例14: SetPosition
//----------------------------------------------------------------------------
void FMODSound::SetPosition (const APoint &position)
{
FMOD_VECTOR pos;
pos.x = position.X();
pos.y = position.Y();
pos.z = position.Z();
if (mChannel)
mChannel->set3DAttributes(&pos, 0);
}
示例15: GetLocalRect
//----------------------------------------------------------------------------
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;
}