Ejemplo n.º 1
0
glm::mat3 RotateAxis(float fElapsedTime)
{
	float fAngRad = ComputeAngleRad(fElapsedTime, 2.0);
	float fCos = cosf(fAngRad);
	float fInvCos = 1.0f - fCos;
	float fSin = sinf(fAngRad);
	float fInvSin = 1.0f - fSin;

	glm::vec3 axis(1.0f, 1.0f, 1.0f);
	axis = glm::normalize(axis);

	glm::mat3 theMat(1.0f);
	theMat[0].x = (axis.x * axis.x) + ((1 - axis.x * axis.x) * fCos);
	theMat[1].x = axis.x * axis.y * (fInvCos) - (axis.z * fSin);
	theMat[2].x = axis.x * axis.z * (fInvCos) + (axis.y * fSin);

	theMat[0].y = axis.x * axis.y * (fInvCos) + (axis.z * fSin);
	theMat[1].y = (axis.y * axis.y) + ((1 - axis.y * axis.y) * fCos);
	theMat[2].y = axis.y * axis.z * (fInvCos) - (axis.x * fSin);

	theMat[0].z = axis.x * axis.z * (fInvCos) - (axis.y * fSin);
	theMat[1].z = axis.y * axis.z * (fInvCos) + (axis.x * fSin);
	theMat[2].z = (axis.z * axis.z) + ((1 - axis.z * axis.z) * fCos);
	return theMat;
}
Ejemplo n.º 2
0
	glm::mat4 ConstructMatrix(float fElapsedTime) {
		const glm::mat3 &rotMatrix = CalcRotation(fElapsedTime);
		glm::mat4 theMat(rotMatrix);
		theMat[3] = glm::vec4(offset, 1.0f);

		return theMat;
	}
Ejemplo n.º 3
0
	glm::mat4 ConstructMatrix(float fElapsedTime) {
		glm::mat4 theMat(1.0f);

		theMat[3] = glm::vec4(CalcOffset(fElapsedTime), 1.0f);

		return theMat;
	}
Ejemplo n.º 4
0
glm::mat3 RotateZ(float fElapsedTime) {
	float fAngRad = ComputeAngleRad(fElapsedTime, 2.0);
	float fCos = cosf(fAngRad);
	float fSin = sinf(fAngRad);

	glm::mat3 theMat(1.0f);
	theMat[0].x = fCos; theMat[1].x = -fSin;
	theMat[0].y = fSin; theMat[1].y = fCos;
	return theMat;
}
Ejemplo n.º 5
0
	glm::mat4 ConstructMatrix(float fElapsedTime)
	{
		glm::vec3 theScale = CalcScale(fElapsedTime);
		glm::mat4 theMat(1.0f);
		theMat[0].x = theScale.x;
		theMat[1].y = theScale.y;
		theMat[2].z = theScale.z;
		theMat[3] = glm::vec4(offset, 1.0f);

		return theMat;
	}
glm::mat3 RotateZ(float fAngDeg)
{
	float fAngRad = DegToRad(fAngDeg);
	float fCos = cosf(fAngRad);
	float fSin = sinf(fAngRad);

	glm::mat3 theMat(1.0f);
	theMat[0].x = fCos; theMat[1].x = -fSin;
	theMat[0].y = fSin; theMat[1].y = fCos;
	return theMat;
}
Ejemplo n.º 7
0
static glm::mat3 RotateZ(float angDeg)
{
    float angRad = DegToRad(angDeg);
    float cos = cosf(angRad);
    float sin = sinf(angRad);

    glm::mat3 theMat(1.0f);
    theMat[0].x = cos;
    theMat[1].x = -sin;
    theMat[0].y = sin;
    theMat[1].y = cos;
    return theMat;
}
Ejemplo n.º 8
0
	glm::mat4 ViewPole::CalcMatrix() const
	{
		glm::mat4 theMat(1.0f);

		//Remember: these transforms are in reverse order.

		//In this space, we are facing in the correct direction. Which means that the camera point
		//is directly behind us by the radius number of units.
		theMat = glm::translate(theMat, glm::vec3(0.0f, 0.0f, -m_currView.radius));

		//Rotate the world to look in the right direction..
		glm::fquat fullRotation = glm::angleAxis(m_currView.degSpinRotation, glm::vec3(0.0f, 0.0f, 1.0f)) *
			m_currView.orient;
		theMat = theMat * glm::mat4_cast(fullRotation);

		//Translate the world by the negation of the lookat point, placing the origin at the
		//lookat point.
		theMat = glm::translate(theMat, -m_currView.targetPos);

		return theMat;
	}
Ejemplo n.º 9
0
	void MatrixStack::RotateRadians( const glm::vec3 axisOfRotation, float angRadCCW )
	{
		float fCos = cosf(angRadCCW);
		float fInvCos = 1.0f - fCos;
		float fSin = sinf(angRadCCW);
		//float fInvSin = 1.0f - fSin;

		glm::vec3 axis = glm::normalize(axisOfRotation);

		glm::mat4 theMat(1.0f);
		theMat[0].x = (axis.x * axis.x) + ((1 - axis.x * axis.x) * fCos);
		theMat[1].x = axis.x * axis.y * (fInvCos) - (axis.z * fSin);
		theMat[2].x = axis.x * axis.z * (fInvCos) + (axis.y * fSin);

		theMat[0].y = axis.x * axis.y * (fInvCos) + (axis.z * fSin);
		theMat[1].y = (axis.y * axis.y) + ((1 - axis.y * axis.y) * fCos);
		theMat[2].y = axis.y * axis.z * (fInvCos) - (axis.x * fSin);

		theMat[0].z = axis.x * axis.z * (fInvCos) - (axis.y * fSin);
		theMat[1].z = axis.y * axis.z * (fInvCos) + (axis.x * fSin);
		theMat[2].z = (axis.z * axis.z) + ((1 - axis.z * axis.z) * fCos);
		m_currMatrix *= theMat;
	}