/*******************************************************************************
Function to render a capsule, given its radius, length, position and orientation.
*******************************************************************************/
void GOdeObject::renderCapsule( const dReal radius, const dReal length, const dReal position[3], const dReal orientation[12] ) const
{
	glPushMatrix();					//Save current ModelView.

	double Matrix[16];				//OpenGL equivalen version of ODE orientation.
	ODEToOpenGLMatrix( position, orientation, Matrix );
	glMultMatrixd( Matrix );

	glPushMatrix();					//Draw cylinder.
	glScaled( radius, radius, length );
	glTranslated( 0.0, 0.0, -0.5 );
	GDrawing::drawCylinder();
	glPopMatrix();

	glTranslated( 0.0, 0.0, length/2.0 );	//Draw first cap.
	glPushMatrix();
	glScaled( radius, radius, radius );
	GDrawing::drawSphere();
	glPopMatrix();

	glTranslated( 0.0, 0.0, -length );		//Draw second cap.
	glScaled( radius, radius, radius );
	GDrawing::drawSphere();

	glPopMatrix();
}
Ejemplo n.º 2
0
void renderCapsule(const dReal radius, const dReal length, const dReal position[3], const dReal orientation[12])
{
	glPushMatrix();					//Save current ModelView.

	dReal Matrix[16];				//The OpenGL version of the transformation matrix.
	//dReal  newPos[3] = { position[0], position[1] - length/2, position[2] };
	ODEToOpenGLMatrix(position, orientation, Matrix);

	glMultMatrixd(Matrix);

	dReal sphereR = .99 * radius;
	glPushMatrix();					//Save current ModelView.
	glTranslated(0, 0, length / 2);
	glScaled(sphereR, sphereR, sphereR);
	GDrawing::setColor( 66.0f/255.0f, 33.0f/255.0f, 0.0f/255.0f);
	GDrawing::drawSphere();
	glPopMatrix(); //unscaled and at top

	glTranslated(0, 0, -length / 2);
	glPushMatrix();
	glScaled(radius, radius, length);	//Scale to have the right measure in sides.
	GDrawing::drawCylinder();
	glPopMatrix(); //unscaled and at center

	//glTranslated(0, 0, -length / 2);
	glScaled(sphereR, sphereR, sphereR);
	GDrawing::drawSphere();

	glPopMatrix();					//Restore ModelView.
}
/*******************************************************************************
Function to render a sphere, given its radius, position and orientation.
*******************************************************************************/
void GOdeObject::renderSphere( const dReal radius, const dReal position[3], const dReal orientation[12] ) const
{
	glPushMatrix();					//Save current ModelView.

	dReal Matrix[16];				//OpenGL version of the transormation matrix.
	ODEToOpenGLMatrix( position, orientation, Matrix );
	glMultMatrixd( Matrix );
	glScaled( radius, radius, radius );		//Scale to the sphere radius.
	GDrawing::drawSphere();

	glPopMatrix();
}
/*******************************************************************************
Function to render a box, given it sides length, position and orientation.
*******************************************************************************/
void GOdeObject::renderBox( const dReal sides[3], const dReal position[3], const dReal orientation[12] ) const
{
	glPushMatrix();					//Save current ModelView.
	
	dReal Matrix[16];				//The OpenGL version of the transformation matrix.
	ODEToOpenGLMatrix( position, orientation, Matrix );
	glMultMatrixd( Matrix );
	glScaled( sides[0], sides[1], sides[2] );	//Scale to have the right measure in sides.
	GDrawing::drawCube();

	glPopMatrix();					//Restore ModelView.
}
Ejemplo n.º 5
0
void renderCylinder(const dReal radius, const dReal length, const dReal position[3], const dReal orientation[12])
{
	glPushMatrix();					//Save current ModelView.

	dReal Matrix[16];				//The OpenGL version of the transformation matrix.
	//dReal  newPos[3] = { position[0], position[1] - length/2, position[2] };
	ODEToOpenGLMatrix(position, orientation, Matrix);

	glMultMatrixd(Matrix);
	glTranslated(0, 0, -length / 2);
	glScaled(radius, radius, length);	//Scale to have the right measure in sides.

	GDrawing::setColor(0.25, 0.25, 0.25);
	GDrawing::drawCylinder();

	glPopMatrix();					//Restore ModelView.

}
Ejemplo n.º 6
0
/*******************************************************************************
Function to render a box, given it sides length, position and orientation.
*******************************************************************************/
void renderBox(const dReal sides[3], const dReal position[3], const dReal orientation[12], int colored = 0)
{
	glPushMatrix();					//Save current ModelView.

	dReal Matrix[16];				//The OpenGL version of the transformation matrix.
	ODEToOpenGLMatrix(position, orientation, Matrix);
	glMultMatrixd(Matrix);
	glScaled(sides[0], sides[1], sides[2]);	//Scale to have the right measure in sides.
	
	if ( colored == 0 ) 
		GDrawing::setColor(0.1f, 0.1f, 0.1f);
	else if ( colored == 1 )
		GDrawing::setColor(1.0f, 1.0f, 0.0f);
	else if ( colored == 2 )
		GDrawing::setColor(1.0f, 0.0f, 0.0f);
	
	GDrawing::drawCube();

	glPopMatrix();					//Restore ModelView.
}