本文整理汇总了C++中Rect::GetCenter方法的典型用法代码示例。如果您正苦于以下问题:C++ Rect::GetCenter方法的具体用法?C++ Rect::GetCenter怎么用?C++ Rect::GetCenter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rect
的用法示例。
在下文中一共展示了Rect::GetCenter方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
static inline int GetCollidingSide2( Rect A,Rect B ){
if (!IsColliding(A,B))
return -1;
Point Center1 = A.GetCenter();
Point Center2 = B.GetCenter();
int dir = 0;
float angle = Center2.GetDirection(Center1);
/*
0 left
1 top
2 right
3 bottom
*/
angle = Geometry::toDeg(angle);
if (angle <= 45 || angle > 315){
dir = 0;
}else if(angle > 45 && angle <= 135){
dir = 1;
}else if(angle > 135 && angle <= 225){
dir = 2;
}else if(angle > 225 && angle <= 315){
dir = 3;
}
return dir;
}
示例2: IsColliding
// Essa é uma implementação do SAT feita pelo Lucas Neves.
// Recebe dois Rects e suas rotações, e detecta se os retângulos colidem.
// Mais informações sobre o método podem ser encontradas nos seguintes links:
// http://www.metanetsoftware.com/technique/tutorialA.html
// http://www.gamedev.net/page/resources/_/technical/game-programming/2d-rotated-rectangle-collision-r2604
static inline bool IsColliding(Rect& a, Rect& b, float angleOfA, float angleOfB) {
if (angleOfA == 0.0f && angleOfB == 0.0f){
return IsColliding(a,b);
}
Point A[] = { Point( a.x, a.y + a.h ),
Point( a.x + a.w, a.y + a.h ),
Point( a.x + a.w, a.y ),
Point( a.x, a.y )
};
Point B[] = { Point( b.x, b.y + b.h ),
Point( b.x + b.w, b.y + b.h ),
Point( b.x + b.w, b.y ),
Point( b.x, b.y )
};
for (auto& v : A) {
v = Rotate(v - a.GetCenter(), angleOfA) + a.GetCenter();
}
for (auto& v : B) {
v = Rotate(v - b.GetCenter(), angleOfB) + b.GetCenter();
}
Point axes[] = { Norm(A[0] - A[1]), Norm(A[1] - A[2]), Norm(B[0] - B[1]), Norm(B[1] - B[2]) };
for (auto& axis : axes) {
float P[4];
for (int i = 0; i < 4; ++i) P[i] = Dot(A[i], axis);
float minA = *std::min_element(P, P + 4);
float maxA = *std::max_element(P, P + 4);
for (int i = 0; i < 4; ++i) P[i] = Dot(B[i], axis);
float minB = *std::min_element(P, P + 4);
float maxB = *std::max_element(P, P + 4);
if (maxA <= minB || minA >= maxB)
return false;
}
return true;
}
示例3: SystemDraw
void UIMovieView::SystemDraw(const UIGeometricData &geometricData)
{
UIControl::SystemDraw(geometricData);
#ifdef DRAW_PLACEHOLDER_FOR_STUB_UIMOVIEVIEW
Color curDebugDrawColor = GetDebugDrawColor();
RenderManager::Instance()->ClipPush();
Rect absRect = GetRect(true);
RenderManager::Instance()->SetColor(Color(1.0f, 0.4f, 0.8f, 1.0f));
RenderHelper::Instance()->DrawRect(absRect, RenderState::RENDERSTATE_2D_BLEND);
float32 minRadius = Min(GetSize().x, GetSize().y);
RenderHelper::Instance()->DrawCircle(absRect.GetCenter(), minRadius / 2, RenderState::RENDERSTATE_2D_BLEND);
RenderHelper::Instance()->DrawCircle(absRect.GetCenter(), minRadius / 3, RenderState::RENDERSTATE_2D_BLEND);
RenderHelper::Instance()->DrawCircle(absRect.GetCenter(), minRadius / 4, RenderState::RENDERSTATE_2D_BLEND);
RenderManager::Instance()->ClipPop();
SetDebugDrawColor(curDebugDrawColor);
#endif
}
示例4: GetCollidingSide
/**
0 top left
1 top right
2 bottom right
3 bottom left
*/
static inline int GetCollidingSide( Rect A,Rect B ){
int direction = -1;
Point Center1 = A.GetCenter();
Point Center2 = B.GetCenter();
if (Center1.y >= Center2.y){
//Means top
if (Center1.x <= Center2.x){
direction = 1;
}else{
direction = 0;
}
}else{
//means Bottom
if (Center1.x <= Center2.x){
direction = 3;
}else{
direction = 2;
}
}
return direction;
}
示例5: GetVecInRect
Vector2 ResultScreen::GetVecInRect(const Rect & rect, float32 angleInRad)
{
Vector2 retVec;
Matrix2 m;
m.BuildRotation(angleInRad);
angleInRad += DAVA::PI_05;
while(angleInRad > DAVA::PI_05)
angleInRad -= DAVA::PI_05;
if(angleInRad > DAVA::PI_05 / 2)
angleInRad = DAVA::PI_05 - angleInRad;
Vector2 v = Vector2((Point2f(rect.GetSize().x / 2, 0) * m).data) / Abs(cosf(angleInRad));
retVec = v + rect.GetCenter();
return retVec;
}
示例6: PrepareCameraAnimation
void Test::PrepareCameraAnimation()
{
Rect rect = rectSequence.front();
curCameraPosition = GetRealPoint(rect.GetCenter());
Camera* cam = GetCamera();
cam->SetPosition(curCameraPosition);
cam->SetDirection(DEF_CAMERA_DIRECTION);
nextRectNum = 0;
curCameraAngle = 0.f;
float32 maxRotateAngle = 360.f;
float32 timeToRotate = maxRotateAngle / SettingsManager::Instance()->GetCameraRotationSpeed();
camRotateAnimation = new LinearAnimation<float32>(this, &curCameraAngle, maxRotateAngle, timeToRotate, Interpolation::LINEAR);
camRotateAnimation->SetRepeatCount(-1);
}
示例7: AlignCenter
ControlsPositionData BaseAlignHandler::AlignCenter(const List<UIControl*>& controlsList, bool isHorizontal)
{
ControlsPositionData resultData;
for (List<UIControl*>::const_iterator iter = controlsList.begin(); iter != controlsList.end(); iter ++)
{
UIControl* uiControl = *iter;
if (!uiControl)
{
continue;
}
resultData.AddControl(uiControl);
}
// Perform the alignment on the first or last control, depending on the flag.
UIControl* referenceControl = GetReferenceControl(controlsList);
Vector2 referenceCenter = referenceControl->GetRect(true).GetCenter();
// Second pass - update.
for (List<UIControl*>::const_iterator iter = controlsList.begin(); iter != controlsList.end(); iter ++)
{
UIControl* uiControl = *iter;
if (!uiControl)
{
continue;
}
Rect absoluteRect = uiControl->GetRect(true);
Vector2 currentCenter = absoluteRect.GetCenter();
if (isHorizontal)
{
absoluteRect.x -= (currentCenter.x - referenceCenter.x);
}
else
{
absoluteRect.y -= (currentCenter.y - referenceCenter.y);
}
uiControl->SetRect(absoluteRect, true);
}
return resultData;
}
示例8: DrawStatImage
void ResultScreen::DrawStatImage(Rect rect)
{
RenderHelper *helper = RenderHelper::Instance();
RenderManager *manager = RenderManager::Instance();
for(uint32 i = 0; i < testData.GetItemCount(); ++i)
{
FpsStatItem item = testData.GetItem(i);
Rect curRect = testData.TranslateRect(item.rect, rect);
for(uint32 j = 0; j < SECTORS_COUNT; j++)
{
manager->SetColor(SettingsManager::Instance()->GetColorByFps(item.avFps[j]));
Polygon2 curSector;
curSector.AddPoint(curRect.GetCenter());
curSector.AddPoint(GetVecInRect(curRect, DegToRad((SECTORS_COUNT - j) * 45.f - 22.5f)));
curSector.AddPoint(GetVecInRect(curRect, DegToRad((SECTORS_COUNT - j) * 45.f)));
curSector.AddPoint(GetVecInRect(curRect, DegToRad((SECTORS_COUNT - j) * 45.f + 22.5f)));
helper->FillPolygon(curSector);
manager->SetColor(Color::Black());
helper->DrawPolygon(curSector, true);
}
}
}
示例9: MoveToNextPoint
void Test::MoveToNextPoint()
{
++nextRectNum;
if(nextRectNum < rectSequence.size())
{
Rect nextRect = rectSequence[nextRectNum];
Vector3 endPoint = GetRealPoint(nextRect.GetCenter());
float32 pathSegmentLength = (endPoint - curCameraPosition).Length();
float32 timeToMove = pathSegmentLength / SettingsManager::Instance()->GetCameraMovementSpeed();
camMoveAnimation = new LinearAnimation<Vector3>(this, &curCameraPosition, endPoint, timeToMove, Interpolation::LINEAR);
camMoveAnimation->AddEvent(Animation::EVENT_ANIMATION_END, Message(this, &Test::AnimationFinished));
if(!skipFrames)
camMoveAnimation->Start(CAMERA_ANIMATION_MOVE);
}
else
{
SaveFpsStat();
isFinished = true;
}
}