void ComponentPhysicsGeom::drawAxes() const
{
	CHECK_GL_ERROR();
	glPushAttrib(GL_ALL_ATTRIB_BITS);
	{
		glLineWidth(2.0f);

		const mat3 orientation = getOrientation();
		mat4 transformation(getPosition(),
			                orientation.getAxisX(),
							orientation.getAxisY(),
							orientation.getAxisZ());

		glPushMatrix();
		glMultMatrixf(transformation);

		glBegin(GL_LINES);
		glColor4fv(red);
		glVertex3fv(vec3(0,0,0));
		glVertex3fv(orientation.getAxisX());

		glColor4fv(green);
		glVertex3fv(vec3(0,0,0));
		glVertex3fv(orientation.getAxisY());

		glColor4fv(blue);
		glVertex3fv(vec3(0,0,0));
		glVertex3fv(orientation.getAxisZ());
		glEnd();

		glPopMatrix();
	}
	glPopAttrib();
	CHECK_GL_ERROR();
}
void ComponentPhysicsGeom::setOrientation(const mat3 &m)
{
	dMatrix3 r;

	const vec3 x = m.getAxisX().getNormal();
	const vec3 y = m.getAxisY().getNormal();
	const vec3 z = m.getAxisZ().getNormal();

	r[0] = x.x; r[1] = x.y; r[2] = x.z; r[3] = 0.0f;
	r[4] = y.x; r[5] = y.y; r[6] = y.z; r[7] = 0.0f;
	r[8] = z.x; r[9] = z.y; r[10]= z.z; r[11]= 0.0f;

	dGeomSetRotation(geom, r);

	getParentBlackBoard().relayMessage(MessageOrientationHasBeenSet(getOrientation()));
}
Example #3
0
void Font::putBillboardChar(vec3 start,
							vec3 *offset,
							char character,
							const color *color,
							FontSize size,
							mat3 cameraOrientation) const
{
	const float _size = fontSize.find(size)->second;

	float w = _size / 100.0f;
	float h = _size / 100.0f;

	const vec3 right = cameraOrientation.getAxisX();
	const vec3 up = cameraOrientation.getAxisY();

	vec3 nextOffset;

	if(character == '\n')
	{
		nextOffset = (*offset) + -up*(h*lineHeight);
	}
	else
	{
		/*               center the quad          place it        shift left by an offset  */
		const vec3 a = -right*(w*0.5f)        + (*offset) - right*w*getCharacter(character).left;
		const vec3 b =  right*(w*0.5f)        + (*offset) - right*w*getCharacter(character).left;
		const vec3 c =  right*(w*0.5f) + up*h + (*offset) - right*w*getCharacter(character).left;
		const vec3 d = -right*(w*0.5f) + up*h + (*offset) - right*w*getCharacter(character).left;

		drawChar(a, b, c, d, character, *color);

		float offsetRight = w * (getCharacter(character).width + spacing);

		nextOffset = (*offset) + right*offsetRight;
	}

	(*offset) = nextOffset;
}