void cCreditsString::Initialize() { sf::Vector3<double> l_Position = GetPosition(); l_Position.x += (GetBoundingBox().width/2) - m_CreditText.getLocalBounds().width / 2; l_Position.x = static_cast<int32_t>(l_Position.x); m_CreditText.setPosition(l_Position.x, l_Position.y); l_Position = GetPosition(); l_Position.x += (GetBoundingBox().width/2) - m_CreditText2.getLocalBounds().width / 2; l_Position.x = static_cast<int32_t>(l_Position.x); l_Position.y += m_CreditText.getLocalBounds().height + m_CreditText.getLocalBounds().top + 100; m_CreditText2.setPosition(l_Position.x, l_Position.y); l_Position.x = GetPosition().x; l_Position.x += (GetBoundingBox().width/2) - m_pSfmlLogo->GetBoundingBox().width / 2; l_Position.y += m_CreditText2.getLocalBounds().height + m_CreditText2.getLocalBounds().top + 10; m_pSfmlLogo->SetPosition(l_Position, kNormal, false); m_pSfmlLogo->Initialize(); // Set the position relative to the camera float l_X = GetResources()->GetWindow()->getSize().x - m_ContinueString.getLocalBounds().width - 10; float l_Y = GetResources()->GetWindow()->getSize().y - m_ContinueString.getCharacterSize() - 10; m_ContinueString.setPosition(l_X, l_Y); }
void cAiBlock::Collision(cObject* a_pOther) { if (a_pOther->GetType() == GetType()) { SitFlush(a_pOther); m_AiLabel.setPosition( static_cast<int32_t>(GetPosition().x + GetBoundingBox().width / 2 - m_AiLabel.getLocalBounds().width / 2), static_cast<int32_t>(GetPosition().y + GetBoundingBox().height / 2 - m_AiLabel.getCharacterSize() / 2.0 - 10) ); SetVelocityY(0, kNormal); sMessage l_Message; l_Message.m_From = GetUniqueId(); l_Message.m_Category =GetResources()->GetMessageDispatcher()->Any(); l_Message.m_Key = GetResources()->GetMessageDispatcher()->Any(); l_Message.m_Value = "Settled"; GetResources()->GetMessageDispatcher()->PostMessage(l_Message); m_Falling = false; PlaySound("Media/Sounds/BigFall.ogg"); } }
void cAiBlock::Initialize() { m_AiLabel.setPosition( static_cast<int32_t>(GetPosition().x + GetBoundingBox().width / 2 - m_AiLabel.getLocalBounds().width / 2), static_cast<int32_t>(GetPosition().y + GetBoundingBox().height / 2 - m_AiLabel.getCharacterSize() / 2.0 - 10) ); }
const BOX2I DIMENSION::ViewBBox() const { BOX2I dimBBox = BOX2I( VECTOR2I( GetBoundingBox().GetPosition() ), VECTOR2I( GetBoundingBox().GetSize() ) ); dimBBox.Merge( m_Text.ViewBBox() ); return dimBBox; }
bool PCB_TARGET::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const { EDA_RECT arect = aRect; arect.Inflate( aAccuracy ); if( aContained ) return arect.Contains( GetBoundingBox() ); else return GetBoundingBox().Intersects( arect ); }
void cButton::Step(uint32_t a_ElapsedMiliSec) { if (m_Label.getString() != "") { m_Label.setPosition( static_cast<int32_t>(GetPosition().x + GetBoundingBox().left + GetBoundingBox().width / 2.0 - m_Label.getLocalBounds().width / 2.0), static_cast<int32_t>(GetPosition().y + GetBoundingBox().height / 2.0 - (m_Label.getLocalBounds().height + m_Label.getLocalBounds().top + 10) / 2.0) ); } }
bool SCH_BUS_ENTRY_BASE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const { EDA_RECT rect = aRect; rect.Inflate( aAccuracy ); if( aContained ) return rect.Contains( GetBoundingBox() ); return rect.Intersects( GetBoundingBox() ); }
void cAiBlock::Step(uint32_t a_ElapsedMiliSec) { if (m_Falling) { SetVelocityY(1500, kNormal); m_AiLabel.setPosition( static_cast<int32_t>(GetPosition().x + GetBoundingBox().width / 2 - m_AiLabel.getLocalBounds().width / 2), static_cast<int32_t>(GetPosition().y + GetBoundingBox().height / 2 - m_AiLabel.getCharacterSize() / 2.0 - 10) ); } }
void CPhysXMultiBodyObjectModel::CalculateBoundingBox() { if(m_vecBodies.empty()) return; /* Initialize the AABB to be a copy of the AABB of the first actor */ physx::PxBounds3 cPxAABB(m_vecBodies[0].Body.getWorldBounds()); /* Go through the bodies and grow the AABB with other bodies */ for(size_t i = 1; i < m_vecBodies.size(); ++i) { cPxAABB.include(m_vecBodies[1].Body.getWorldBounds()); } /* Update the ARGoS bounding box */ PxVec3ToCVector3(cPxAABB.minimum, GetBoundingBox().MinCorner); PxVec3ToCVector3(cPxAABB.maximum, GetBoundingBox().MaxCorner); }
void CDynamics2DSingleBodyObjectModel::SetBody(cpBody* pt_body, Real f_height) { /* Set the body and its data field for ray queries */ m_ptBody = pt_body; m_ptBody->data = this; /* Register the origin anchor update method */ RegisterAnchorMethod(GetEmbodiedEntity().GetOriginAnchor(), &CDynamics2DSingleBodyObjectModel::UpdateOriginAnchor); /* Calculate the bounding box */ GetBoundingBox().MinCorner.SetZ(GetEmbodiedEntity().GetOriginAnchor().Position.GetZ()); GetBoundingBox().MaxCorner.SetZ(GetEmbodiedEntity().GetOriginAnchor().Position.GetZ() + f_height); CalculateBoundingBox(); }
/** * Calculate the AABB in the global coordinate frame */ void CBulletSphereModel::CalculateBoundingBox() { GetBoundingBox().MinCorner.Set( GetEmbodiedEntity().GetOriginAnchor().Position.GetX() - (entity->GetRadius()), GetEmbodiedEntity().GetOriginAnchor().Position.GetY() - (entity->GetRadius()), GetEmbodiedEntity().GetOriginAnchor().Position.GetZ() ); GetBoundingBox().MaxCorner.Set( GetEmbodiedEntity().GetOriginAnchor().Position.GetX() + (entity->GetRadius()), GetEmbodiedEntity().GetOriginAnchor().Position.GetY() + (entity->GetRadius()), GetEmbodiedEntity().GetOriginAnchor().Position.GetZ() + entity->GetRadius() ); }
bool SCH_JUNCTION::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const { if( m_Flags & STRUCT_DELETED || m_Flags & SKIP_STRUCT ) return false; EDA_RECT rect = aRect; rect.Inflate( aAccuracy ); if( aContained ) return rect.Contains( GetBoundingBox() ); return rect.Intersects( GetBoundingBox() ); }
bool DRAWSEGMENT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const { wxPoint p1, p2; int radius; float theta; EDA_RECT arect = aRect; arect.Inflate( aAccuracy ); switch( m_Shape ) { case S_CIRCLE: // Test if area intersects or contains the circle: if( aContained ) return arect.Contains( GetBoundingBox() ); else return arect.Intersects( GetBoundingBox() ); break; case S_ARC: radius = hypot( (double)( GetEnd().x - GetStart().x ), (double)( GetEnd().y - GetStart().y ) ); theta = std::atan2( GetEnd().y - GetStart().y , GetEnd().x - GetStart().x ); //Approximate the arc with two lines. This should be accurate enough for selection. p1.x = radius * std::cos( theta + M_PI/4 ) + GetStart().x; p1.y = radius * std::sin( theta + M_PI/4 ) + GetStart().y; p2.x = radius * std::cos( theta + M_PI/2 ) + GetStart().x; p2.y = radius * std::sin( theta + M_PI/2 ) + GetStart().y; if( aContained ) return arect.Contains( GetEnd() ) && aRect.Contains( p1 ) && aRect.Contains( p2 ); else return arect.Intersects( GetEnd(), p1 ) || aRect.Intersects( p1, p2 ); break; case S_SEGMENT: if( aContained ) return arect.Contains( GetStart() ) && aRect.Contains( GetEnd() ); else return arect.Intersects( GetStart(), GetEnd() ); break; default: ; } return false; }
bool SCH_FIELD::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const { // Do not hit test hidden fields. if( !IsVisible() || IsVoid() ) return false; EDA_RECT rect = aRect; rect.Inflate( aAccuracy ); if( aContained ) return rect.Contains( GetBoundingBox() ); return rect.Intersects( GetBoundingBox() ); }
void LIB_TEXT::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill, const TRANSFORM& aTransform ) { wxASSERT( plotter != NULL ); EDA_RECT bBox = GetBoundingBox(); // convert coordinates from draw Y axis to libedit Y axis bBox.RevertYAxis(); wxPoint txtpos = bBox.Centre(); /* The text orientation may need to be flipped if the * transformation matrix causes xy axes to be flipped. */ int t1 = ( aTransform.x1 != 0 ) ^ ( GetTextAngle() != 0 ); wxPoint pos = aTransform.TransformCoordinate( txtpos ) + offset; // Get color COLOR4D color; if( plotter->GetColorMode() ) // Used normal color or selected color color = IsSelected() ? GetItemSelectedColor() : GetDefaultColor(); else color = COLOR4D::BLACK; plotter->Text( pos, color, GetShownText(), t1 ? TEXT_ANGLE_HORIZ : TEXT_ANGLE_VERT, GetTextSize(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GetPenSize(), IsItalic(), IsBold() ); }
void FLightSceneInfo::AddToScene() { const FLightSceneInfoCompact& LightSceneInfoCompact = Scene->Lights[Id]; // Only need to create light interactions for lights that can cast a shadow, // As deferred shading doesn't need to know anything about the primitives that a light affects if (Proxy->CastsDynamicShadow() || Proxy->CastsStaticShadow() // Lights that should be baked need to check for interactions to track unbuilt state correctly || Proxy->HasStaticLighting() // ES2 path supports dynamic point lights in the base pass using forward rendering, so we need to know the primitives || (Scene->GetFeatureLevel() < ERHIFeatureLevel::SM4 && Proxy->GetLightType() == LightType_Point && Proxy->IsMovable())) { // Add the light to the scene's light octree. Scene->LightOctree.AddElement(LightSceneInfoCompact); // TODO: Special case directional lights, no need to traverse the octree. // Find primitives that the light affects in the primitive octree. FMemMark MemStackMark(FMemStack::Get()); for(FScenePrimitiveOctree::TConstElementBoxIterator<SceneRenderingAllocator> PrimitiveIt( Scene->PrimitiveOctree, GetBoundingBox() ); PrimitiveIt.HasPendingElements(); PrimitiveIt.Advance()) { CreateLightPrimitiveInteraction(LightSceneInfoCompact, PrimitiveIt.GetCurrentElement()); } } }
void wxSFControlShape::UpdateControl() { if( m_pControl ) { int x = 0, y = 0; wxRect minBB = m_pControl->GetMinSize(); wxRect rctBB = GetBoundingBox().Deflate(m_nControlOffset, m_nControlOffset); if( rctBB.GetWidth() < minBB.GetWidth() ) { rctBB.SetWidth(minBB.GetWidth()); m_nRectSize.x = minBB.GetWidth() + 2*m_nControlOffset; } if( rctBB.GetHeight() < minBB.GetHeight() ) { rctBB.SetHeight(minBB.GetHeight()); m_nRectSize.y = minBB.GetHeight() + 2*m_nControlOffset; } GetParentCanvas()->CalcUnscrolledPosition(0, 0, &x, &y); // set the control's dimensions and position according to the parent control shape m_pControl->SetSize(rctBB.GetWidth(), rctBB.GetHeight()); m_pControl->Move(rctBB.GetLeft() - x, rctBB.GetTop() - y); } }
bool AnimatedObject::RayIntersect(XMVECTOR origin, XMVECTOR direction, float& pDist) { if(XNA::IntersectRayAxisAlignedBox(origin, direction, &GetBoundingBox(), &pDist)) return true; else return false; }
void SCH_TEXT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& aOffset, GR_DRAWMODE DrawMode, EDA_COLOR_T Color ) { EDA_COLOR_T color; int linewidth = ( m_Thickness == 0 ) ? GetDefaultLineThickness() : m_Thickness; linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold ); if( Color >= 0 ) color = Color; else color = ReturnLayerColor( m_Layer ); GRSetDrawMode( DC, DrawMode ); wxPoint text_offset = aOffset + GetSchematicTextOffset(); EXCHG( linewidth, m_Thickness ); // Set the minimum width EDA_TEXT::Draw( panel, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR ); EXCHG( linewidth, m_Thickness ); // set initial value if( m_isDangling ) DrawDanglingSymbol( panel, DC, m_Pos + aOffset, color ); // Enable these line to draw the bounding box (debug tests purposes only) #if 0 { EDA_RECT BoundaryBox = GetBoundingBox(); GRRect( panel->GetClipBox(), DC, BoundaryBox, 0, BROWN ); } #endif }
const Document::PageSize PDFDocument::GetPageSize( int page, float zoom, int rotation) { assert((page >= 0) && (page < GetNumPages())); const fz_irect& bbox = GetBoundingBox( GetPage(page), Transform(zoom, rotation)); return PageSize(bbox.x1 - bbox.x0, bbox.y1 - bbox.y0); }
int ALIGN_DISTRIBUTE_TOOL::doAlignRight() { const SELECTION& selection = m_selectionTool->GetSelection(); if( selection.Size() <= 1 ) return 0; BOARD_COMMIT commit( getEditFrame<PCB_BASE_FRAME>() ); commit.StageItems( selection, CHT_MODIFY ); // Compute the rightmost point of selection - it will be the edge of alignment int right = selection.Front()->GetBoundingBox().GetRight(); for( int i = 1; i < selection.Size(); ++i ) { int currentRight = selection[i]->GetBoundingBox().GetRight(); if( right < currentRight ) // X increases when going right right = currentRight; } // Move the selected items for( auto i : selection ) { auto item = static_cast<BOARD_ITEM*>( i ); int difference = right - item->GetBoundingBox().GetRight(); item->Move( wxPoint( difference, 0 ) ); } commit.Push( _( "Align to right" ) ); return 0; }
void LIB_FIELD::Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill, const TRANSFORM& aTransform ) { if( IsVoid() ) return; /* Calculate the text orientation, according to the component * orientation/mirror */ int orient = m_Orient; if( aTransform.y1 ) // Rotate component 90 deg. { if( orient == TEXT_ORIENT_HORIZ ) orient = TEXT_ORIENT_VERT; else orient = TEXT_ORIENT_HORIZ; } EDA_RECT BoundaryBox = GetBoundingBox(); EDA_TEXT_HJUSTIFY_T hjustify = GR_TEXT_HJUSTIFY_CENTER; EDA_TEXT_VJUSTIFY_T vjustify = GR_TEXT_VJUSTIFY_CENTER; wxPoint textpos = aTransform.TransformCoordinate( BoundaryBox.Centre() ) + aOffset; aPlotter->Text( textpos, GetDefaultColor(), m_Text, orient, m_Size, hjustify, vjustify, GetPenSize(), m_Italic, m_Bold ); }
void CDynamics2DSingleBodyObjectModel::CalculateBoundingBox() { cpBB tBoundingBox = cpShapeGetBB(m_ptBody->shapeList); for(cpShape* pt_shape = m_ptBody->shapeList->next; pt_shape != NULL; pt_shape = pt_shape->next) { cpBB* ptBB = &pt_shape->bb; if(ptBB->l < tBoundingBox.l) tBoundingBox.l = ptBB->l; if(ptBB->b < tBoundingBox.b) tBoundingBox.b = ptBB->b; if(ptBB->r > tBoundingBox.r) tBoundingBox.r = ptBB->r; if(ptBB->t > tBoundingBox.t) tBoundingBox.t = ptBB->t; } GetBoundingBox().MinCorner.SetX(tBoundingBox.l); GetBoundingBox().MinCorner.SetY(tBoundingBox.b); GetBoundingBox().MaxCorner.SetX(tBoundingBox.r); GetBoundingBox().MaxCorner.SetY(tBoundingBox.t); }
int ALIGN_DISTRIBUTE_TOOL::AlignBottom( const TOOL_EVENT& aEvent ) { const SELECTION& selection = m_selectionTool->GetSelection(); if( selection.Size() <= 1 ) return 0; BOARD_COMMIT commit( getEditFrame<PCB_BASE_FRAME>() ); commit.StageItems( selection, CHT_MODIFY ); // Compute the lowest point of selection - it will be the edge of alignment int bottom = selection.Front()->GetBoundingBox().GetBottom(); for( int i = 1; i < selection.Size(); ++i ) { int currentBottom = selection[i]->GetBoundingBox().GetBottom(); if( bottom < currentBottom ) // Y increases when going down bottom = currentBottom; } // Move the selected items for( auto i : selection ) { auto item = static_cast<BOARD_ITEM*>( i ); int difference = bottom - item->GetBoundingBox().GetBottom(); item->Move( wxPoint( 0, difference ) ); } commit.Push( _( "Align to bottom" ) ); return 0; }
//----------------------------------------------------------------------------- // Returns the 8 frustum corners //----------------------------------------------------------------------------- Vector* Frustum::GetCorners() { GetBoundingBox(); return m_vCorners; } // GetCorners
BSPHERE MESHINSTANCE::GetBoundingSphere() { if(m_pMesh == NULL || m_pMesh->m_pMesh == NULL)return BSPHERE(); if(m_pMesh->m_pMesh->GetFVF() != ObjectVertex::FVF) // XYZ and NORMAL and UV return BSPHERE(); BBOX bBox = GetBoundingBox(); BSPHERE bSphere; D3DXMATRIX World = GetWorldMatrix(); bSphere.center = (bBox.max + bBox.min) / 2.0f; ObjectVertex* vertexBuffer = NULL; m_pMesh->m_pMesh->LockVertexBuffer(0,(void**)&vertexBuffer); //Get radius for(int i=0;i<(int)m_pMesh->m_pMesh->GetNumVertices();i++) { D3DXVECTOR3 pos; D3DXVec3TransformCoord(&pos, &vertexBuffer[i]._pos, &World); float l = D3DXVec3Length(&(pos - bSphere.center)); if(l > bSphere.radius) bSphere.radius = l; } m_pMesh->m_pMesh->UnlockVertexBuffer(); return bSphere; }
void CScriptPlayerActor::Render(const CStateManager& mgr) const { bool phazonSuit = x2e8_suitRes.GetCharacterNodeId() == 3; if (phazonSuit) { // Draw into alpha buffer CModelFlags flags = xb4_drawFlags; flags.x4_color = zeus::skWhite; flags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly; CModelData::EWhichModel which = CModelData::GetRenderingModel(mgr); x64_modelData->Render(which, x34_transform, x90_actorLights.get(), flags); } CPhysicsActor::Render(mgr); if (x314_beamModelData && !x314_beamModelData->IsNull() && x64_modelData && !x64_modelData->IsNull()) { zeus::CTransform modelXf = GetTransform() * x64_modelData->GetScaledLocatorTransform("GUN_LCTR"); CModelFlags flags(5, 0, 3, zeus::skWhite); flags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly; x314_beamModelData->Render(mgr, modelXf, x90_actorLights.get(), flags); flags.m_extendedShader = EExtendedShader::Lighting; flags.x4_color = zeus::CColor{1.f, xb4_drawFlags.x4_color.a()}; x314_beamModelData->Render(mgr, modelXf, x90_actorLights.get(), flags); } if (phazonSuit) { zeus::CVector3f vecFromCam = GetBoundingBox().center() - mgr.GetCameraManager()->GetCurrentCamera(mgr)->GetTranslation(); float radius = zeus::clamp(0.25f, (6.f - vecFromCam.magnitude()) / 6.f, 2.f); float offsetX = std::sin(x34c_phazonOffsetAngle); float offsetY = std::sin(x34c_phazonOffsetAngle) * 0.5f; g_Renderer->DrawPhazonSuitIndirectEffect(zeus::CColor(0.1f, 1.f), x338_phazonIndirectTexture, zeus::skWhite, radius, 0.05f, offsetX, offsetY); } }
ON_BoundingBox ON_Geometry::BoundingBox() const { ON_BoundingBox bbox; if ( !GetBoundingBox( bbox.m_min, bbox.m_max, false ) ) bbox.Destroy(); return bbox; }
void cButton::Event(std::list<sf::Event> * a_pEventList) { for (std::list<sf::Event>::iterator i = a_pEventList->begin(); i != a_pEventList->end(); ++i ) { if (i->type == sf::Event::MouseButtonPressed) { // See if the mouse press was on us sf::Rect<int32_t> l_PositionBox = GetBoundingBox(); l_PositionBox.left += GetPosition().x; l_PositionBox.top += GetPosition().y; if (l_PositionBox.contains(i->mouseButton.x, i->mouseButton.y)) { PlayAnimationLoop(m_SpritePressedImage.second); PlaySound("Media/Sounds/Click1.ogg"); sMessage l_Message; l_Message.m_From = GetUniqueId(); l_Message.m_Category = "Widget"; l_Message.m_Key = "Button"; l_Message.m_Value = "Pressed"; GetResources()->GetMessageDispatcher()->PostMessage(l_Message); } } else if (i->type == sf::Event::MouseButtonReleased) { PlayAnimationLoop(m_SpriteImage.second); } } }
//----------------------------------------------------------------------------- // Returns the center of the frustum //----------------------------------------------------------------------------- Vector* Frustum::GetCenter() { GetBoundingBox(); return &m_vCenter; } // GetCenter