Пример #1
0
void Hub::AttachBone(Bone::Ptr child,float angle)
{
	float rad = evolve::Conversions::DegreesToRadians(angle);
	//Find attachment position
	sf::Vector2f aPos(cos(rad) * mRadius,sin(rad) * mRadius);
	child->setPosition(aPos);
	child->setRotation(angle);
	AttachChild(std::move(child));

}
Пример #2
0
	//------------------------------------------------------------------------------
	void CGUIWgtBox2DDynamicBody::UpdateBox2D()
	{
		CGUIWgtBox2DBase::UpdateBox2D();

		const b2Vec2& rPos = m_pBody->GetPosition();
		CGUIVector2 aPos( IGUIPhysics_box2d::Meter2Pixel(rPos.x), IGUIPhysics_box2d::Meter2Pixel(rPos.y) );
		real fRot = m_pBody->GetAngle() / b2_pi * 180.f;

		SetGlobalPixelPosition( aPos );
		SetRotation( 0, 0, fRot );
		Refresh();
	}
Пример #3
0
	//------------------------------------------------------------------------------
	CGUIVector2 CGUIColListHeader::GetSegmentPosByIndex( uint32 nIdx) const
	{
		if( nIdx >= m_vecSegment.size())
		{
			throw CGUIException("CGUIColListHeader::GetSegmentPosByIndex: the given index is out of range.");
		}

		CGUIVector2 aPos( 0.0f, 0.0f );
		for( uint32 i=0; i<nIdx; ++i)
		{
			aPos.x += m_vecSegment[i]->GetSize().m_fWidth;
		}

		return aPos;
	}
Пример #4
0
	//------------------------------------------------------------------------------
	void		CGUIColListHeader::LayoutSegment()
	{
		CGUIVector2	aPos(0.0f, 0.0f);
		CGUISize	aSize(0.0f, 0.0f);

		for( TVecSegment::iterator itor = m_vecSegment.begin();
			itor != m_vecSegment.end(); 
			++itor)
		{
			CGUIColListHeaderSegment* pSegment = *itor;
			pSegment->SetLocalPosition(aPos);
			aPos.x += pSegment->GetSize().GetWidth();

			aSize.m_fHeight = max(aSize.m_fHeight, pSegment->GetSize().m_fHeight);
			aSize.m_fWidth = aPos.x;
		}

		SetSize( aSize );
	}
void RelativeDateFormat::parse( const UnicodeString& text,
                                Calendar& cal,
                                ParsePosition& pos) const {

    // Can the fDateFormat parse it?
    if(fDateFormat != NULL) {
        ParsePosition aPos(pos);
        fDateFormat->parse(text,cal,aPos);
        if((aPos.getIndex() != pos.getIndex()) &&
                (aPos.getErrorIndex()==-1)) {
            pos=aPos; // copy the sub parse
            return; // parsed subfmt OK
        }
    }

    // Linear search the relative strings
    for(int n=0; n<fDatesLen; n++) {
        if(fDates[n].string != NULL &&
                (0==text.compare(pos.getIndex(),
                                 fDates[n].len,
                                 fDates[n].string))) {
            UErrorCode status = U_ZERO_ERROR;

            // Set the calendar to now+offset
            cal.setTime(Calendar::getNow(),status);
            cal.add(UCAL_DATE,fDates[n].offset, status);

            if(U_FAILURE(status)) {
                // failure in setting calendar fields
                pos.setErrorIndex(pos.getIndex()+fDates[n].len);
            } else {
                pos.setIndex(pos.getIndex()+fDates[n].len);
            }
            return;
        }
    }

    // parse failed
}