Ejemplo n.º 1
0
TabContainer::Rects TabContainer::getRects() const
{
	Rects rects;
	const sf::Transform transform = getTransform();
	for (auto tab : mTabs)
	{
		sf::Vector2f rectPosition = tab->getPosition();
		sf::Vector2f rectSize = tab->getSize();
		sf::FloatRect rect(rectPosition.x, rectPosition.y, rectSize.x, rectSize.y);

		rects.emplace_back(transform.transformRect(rect));
	}

	return rects;
}
Ejemplo n.º 2
0
void TEALShow::AddTransformedRectanglePoints( sf::FloatRect r, sf::Transform T, sf::Color col )
{
	Linestrip strip;
	strip.size = 5;
	strip.points.resize(strip.size); 
	strip.points[0].position = T.transformPoint( sf::Vector2f( r.left, r.top) );
	strip.points[0].color = col;
	strip.points[1].position = T.transformPoint( sf::Vector2f(r.left + r.width,  r.top ) );
	strip.points[1].color = col;
	strip.points[2].position = T.transformPoint( sf::Vector2f( r.left + r.width, r.top + r.height ));
	strip.points[2].color = col;
	strip.points[3].position = T.transformPoint( sf::Vector2f( r.left, r.top + r.height ) );
	strip.points[3].color = col;
	strip.points[4] = strip.points[0];

	LinestripList.push_back( strip);
}
Ejemplo n.º 3
0
void Fruit::Draw(sf::RenderTarget& target, sf::Transform const& transform)
{
    if (m_Visible)
    {
        sf::Vector2f const pos = transform.transformPoint(m_Position);
        m_Sprite.SetPosition(pos);
        m_Sprite.Draw(target);
    }
}
Ejemplo n.º 4
0
	sf::View Camera::getView(const sf::Transform& transform) const
	{
		if (mEntityManager.hasEntity(mSubjectID))
		{
			BaseGameEntity& subject = mEntityManager.getEntityFromID(mSubjectID);
			sf::View view(transform.transformPoint(subject.getWorldTransform().transformPoint(0, 0)), mSize);
			return view;
		}
		else
		{
			return sf::View();
		}
	}
Ejemplo n.º 5
0
void CircleMask::updateTransform(const sf::Transform& transform)
{
	const sf::Vector2f x1(transform.transformPoint(-1.f, 0.f));
	const sf::Vector2f x2(transform.transformPoint(1.f, 0.f));
	const sf::Vector2f y1(transform.transformPoint(0.f, -1.f));
	const sf::Vector2f y2(transform.transformPoint(0.f, 1.f));

	const float scaleX = je::length(x2 - x1);
	const float scaleY = je::length(y2 - y1);

	// until we decide to handle elipses
	const float epsilon = 0.1f;
	JE_ASSERT(scaleX >= scaleY - epsilon && scaleX <= scaleY + epsilon);

	radius = originalRadius * scaleX * baseTransform.getScale().x;
	center = baseTransform.getTransform().transformPoint((x2 + x1) * 0.5f);

#ifdef JE_DEBUG
	debugCircle.setRadius(radius);
	debugCircle.setOrigin(radius, radius);
	debugCircle.setPosition(center);
#endif
}
Ejemplo n.º 6
0
sf::FloatRect Ring::getGlobalBounds() const
{
    if (m_vertices.size() == 0)
        return{ { 0.f, 0.f }, { 0.f, 0.f } };

    const sf::Transform transform{ getTransform() };
    sf::Vector2f topLeft{ transform.transformPoint(m_vertices[0].position) };
    sf::Vector2f bottomRight{ topLeft };
    sf::Vector2f current;
    for (auto& vertex : m_vertices)
    {
        current = transform.transformPoint(vertex.position);
        if (current.x < topLeft.x)
            topLeft.x = current.x;
        else if (current.x > bottomRight.x)
            bottomRight.x = current.x;
        if (current.y < topLeft.y)
            topLeft.y = current.y;
        else if (current.y > bottomRight.y)
            bottomRight.y = current.y;
    }
    return{ topLeft, bottomRight - topLeft };
}
Ejemplo n.º 7
0
inline void serialize(JsonBox::Value & o, const sf::Transform & t)
{
	const float * v = t.getMatrix();

	JsonBox::Array a;
	a.resize(16);

	for(u32 i = 0; i < 16; ++i)
	{
		a[i] = v[i];
	}

	o = a;
}
Ejemplo n.º 8
0
// Convert sf::Transform to float array
inline void createTransform(const sf::Transform& transform, float* converted)
{
    const float* m = transform.getMatrix();
    converted[0] = m[0];
    converted[1] = m[4];
    converted[2] = m[12];
    converted[3] = m[1];
    converted[4] = m[5];
    converted[5] = m[13];
    converted[6] = m[3];
    converted[7] = m[7];
    converted[8] = m[15];
    
}
Ejemplo n.º 9
0
void Shader::setParameter(const std::string& name, const sf::Transform& transform)
{
    if (m_shaderProgram)
    {
        ensureGlContext();

        // Enable program
        GLhandleARB program = glGetHandleARB(GL_PROGRAM_OBJECT_ARB);
        glCheck(glUseProgramObjectARB(m_shaderProgram));

        // Get parameter location and assign it new values
        GLint location = getParamLocation(name);
        if (location != -1)
            glCheck(glUniformMatrix4fvARB(location, 1, GL_FALSE, transform.getMatrix()));

        // Disable program
        glCheck(glUseProgramObjectARB(program));
    }
}
Ejemplo n.º 10
0
void Shader::SetParameter(const std::string& name, const sf::Transform& transform)
{
    if (myShaderProgram)
    {
        EnsureGlContext();

        // Enable program
        GLhandleARB program = glGetHandleARB(GL_PROGRAM_OBJECT_ARB);
        GLCheck(glUseProgramObjectARB(myShaderProgram));

        // Get parameter location and assign it new values
        GLint location = glGetUniformLocationARB(myShaderProgram, name.c_str());
        if (location != -1)
            GLCheck(glUniformMatrix4fvARB(location, 1, GL_FALSE, transform.GetMatrix()));
        else
            Err() << "Parameter \"" << name << "\" not found in shader" << std::endl;

        // Disable program
        GLCheck(glUseProgramObjectARB(program));
    }
}
Ejemplo n.º 11
0
void PointCollider::update (sf::Transform const & root)
{
  worldPos = root.transformPoint(localPos);
}