Ejemplo n.º 1
0
Matrix4f Matrix4f::Scale(Vector3f vector)
{
	Matrix4f scaledMatrix = Matrix4f().InitializeIdentity();

	scaledMatrix.Set(0,0,vector.GetX());
	scaledMatrix.Set(1,1,vector.GetY());
	scaledMatrix.Set(2,2,vector.GetZ());

	return ((*this) * scaledMatrix);
}
Ejemplo n.º 2
0
Matrix4f Matrix4f::Translate(Vector3f vector)
{
	Matrix4f translatedMatrix = Matrix4f().InitializeIdentity(); 

	translatedMatrix.Set(3,0,vector.GetX());
	translatedMatrix.Set(3,1,vector.GetY());
	translatedMatrix.Set(3,2,vector.GetZ());

	return ((*this) * translatedMatrix);
}
Ejemplo n.º 3
0
ShadowCameraTransform DirectionalLight::CalcShadowCameraTransform(const Vector3f& mainCameraPos, const Quaternion& mainCameraRot) const
{
	Vector3f resultPos = mainCameraPos + mainCameraRot.GetForward() * GetHalfShadowArea();
	Quaternion resultRot = GetTransform().GetTransformedRot();
	
	float worldTexelSize = (GetHalfShadowArea()*2)/((float)(1 << GetShadowInfo().GetShadowMapSizeAsPowerOf2()));
	
	Vector3f lightSpaceCameraPos = resultPos.Rotate(resultRot.Conjugate());
	
	lightSpaceCameraPos.SetX(worldTexelSize * floor(lightSpaceCameraPos.GetX() / worldTexelSize));
	lightSpaceCameraPos.SetY(worldTexelSize * floor(lightSpaceCameraPos.GetY() / worldTexelSize));
	
	resultPos = lightSpaceCameraPos.Rotate(resultRot);
	
	return ShadowCameraTransform(resultPos, resultRot);
}
Ejemplo n.º 4
0
void Shader::SetUniformVector3f(const std::string& uniformName, const Vector3f& value) const
{
	glUniform3f(m_shaderData->GetUniformMap().at(uniformName), value.GetX(), value.GetY(), value.GetZ());
}
Ejemplo n.º 5
0
void Renderer::SetUniformVector3f(unsigned int uniformLocation, const Vector3f& value)
{
    glUniform3f(uniformLocation, value.GetX(), value.GetY(), value.GetZ());
}
Ejemplo n.º 6
0
void Shader::SetUniform(const std::string& name, const Vector3f& value)
{
	glUniform3f(m_uniforms.at(name), value.GetX(), value.GetY(), value.GetZ());
}