Esempio n. 1
0
void FELighting::getTransform(FloatPoint3D* scale, FloatSize* offset) const
{
    FloatRect initialEffectRect = effectBoundaries();
    FloatRect absoluteEffectRect = filter()->mapLocalRectToAbsoluteRect(initialEffectRect);
    FloatPoint absoluteLocation(absolutePaintRect().location());
    FloatSize positionOffset(absoluteLocation - absoluteEffectRect.location());
    offset->setWidth(positionOffset.width());
    offset->setHeight(positionOffset.height());
    scale->setX(initialEffectRect.width() > 0.0f && initialEffectRect.width() > 0.0f ? absoluteEffectRect.width() / initialEffectRect.width() : 1.0f);
    scale->setY(initialEffectRect.height() > 0.0f && initialEffectRect.height() > 0.0f ? absoluteEffectRect.height() / initialEffectRect.height() : 1.0f);
    // X and Y scale should be the same, but, if not, do a best effort by averaging the 2 for Z scale
    scale->setZ(0.5f * (scale->x() + scale->y()));
}
Esempio n. 2
0
	void DebugRenderer::drawBox(const glm::vec4& destRect, const Color& color, float angle){
		
		int i = _verts.size();
		_verts.resize(_verts.size() + 4);
		
		glm::vec2 halfDims(destRect.z / 2.0f, destRect.w / 2.0f);


		//Get points centered at origin
		glm::vec2 TL(-halfDims.x, halfDims.y);
		glm::vec2 BL(-halfDims.x, -halfDims.y);
		glm::vec2 BR(halfDims.x, -halfDims.y);
		glm::vec2 TR(halfDims.x, halfDims.y);


		glm::vec2 positionOffset(destRect.x, destRect.y);

		//Rotate the points
		_verts[i].position = rotatePoint(TL, angle) + halfDims + positionOffset;
		_verts[i + 1].position = rotatePoint(BL, angle) + halfDims + positionOffset;
		_verts[i + 2].position = rotatePoint(BR, angle) + halfDims + positionOffset;
		_verts[i + 3].position = rotatePoint(TR, angle) + halfDims + positionOffset;

		for (int j = i; j < i + 4; j++){
			_verts[j].color = color;
		}

		
		_indices.reserve(_indices.size() + 8);

		//Line 1
		_indices.push_back(i);
		_indices.push_back(i + 1);

		//Line 2
		_indices.push_back(i + 1);
		_indices.push_back(i + 2);
	
		//Line 3
		_indices.push_back(i + 2);
		_indices.push_back(i + 3);

		//Line 4
		_indices.push_back(i + 3);
		_indices.push_back(i);

	}
Esempio n. 3
0
void Adina::DebugRenderer::drawBox(const glm::vec4& destRect, const ColorRGBA8& color, float angle) {

	int i = m_verts.size();
	m_verts.resize(m_verts.size() + 4);

	glm::vec2 halfDims(destRect.z / 2.0f, destRect.w / 2.0f);

	// Get points centered at origin
	glm::vec2 tl(-halfDims.x, halfDims.y);
	glm::vec2 bl(-halfDims.x, -halfDims.y);
	glm::vec2 br(halfDims.x, -halfDims.y);
	glm::vec2 tr(halfDims.x, halfDims.y);

	glm::vec2 positionOffset(destRect.x, destRect.y);

	// Rotate the points
	m_verts[i].position = rotatePoint(tl, angle) + halfDims + positionOffset;
	m_verts[i + 1].position = rotatePoint(bl, angle) + halfDims + positionOffset;
	m_verts[i + 2].position = rotatePoint(br, angle) + halfDims + positionOffset;
	m_verts[i + 3].position = rotatePoint(tr, angle) + halfDims + positionOffset;

	for (int j = i; j < i + 4; j++) {
		m_verts[j].color = color;
	}

	m_indices.reserve(m_indices.size() + 8);

	m_indices.push_back(i);
	m_indices.push_back(i + 1);

	m_indices.push_back(i + 1);
	m_indices.push_back(i + 2);

	m_indices.push_back(i + 2);
	m_indices.push_back(i + 3);

	m_indices.push_back(i + 3);
	m_indices.push_back(i);
}
Esempio n. 4
0
	void DebugRenderer::drawTriangle(const glm::vec4& destRect, const Color& color, float angle){
		int i = _verts.size();
		_verts.resize(_verts.size() + 3);


		glm::vec2 halfDims(destRect.z / 2.0f, destRect.w / 2.0f);

		glm::vec2 Top(0, halfDims.y);
		glm::vec2 BL(-halfDims.x, -halfDims.y);
		glm::vec2 BR(halfDims.x, -halfDims.y);

		glm::vec2 positionOffset(destRect.x, destRect.y);

		_verts[i].position = rotatePoint(Top, angle) + halfDims + positionOffset;
		_verts[i + 1].position = rotatePoint(BL, angle) + halfDims + positionOffset;
		_verts[i + 2].position = rotatePoint(BR, angle) + halfDims + positionOffset;

		for (int j = i; j < i + 3; j++){
			_verts[j].color = color;
		}


		_indices.reserve(_indices.size() + 6);

		//First line
		_indices.push_back(i);
		_indices.push_back(i + 1);

		//Second line
		_indices.push_back(i + 1);
		_indices.push_back(i + 2);

		//Third line
		_indices.push_back(i + 2);
		_indices.push_back(i);

	}