World of Rigid Bodies (WoRB)
|
Encapsulates a rigid body with geometry of a sphere. More...
#include <Utilities.h>
Public Member Functions | |
Ball (Quaternion position, Quaternion orientation, Quaternion velocity, Quaternion angularVelocity, double radius, double mass) | |
Creates a ball at the given location. | |
virtual RigidBody & | GetBody () |
Gets underlying rigid body. | |
virtual Geometry & | GetGeometry () |
Gets underlying geometry. | |
virtual void | Render (RenderType type) |
Draws the geometry. | |
virtual void | RenderWireframe (double *transform) |
Draws the wireframe of the rigid body. | |
Static Private Attributes | |
static const int | slices = 20 |
Number of slices for glutSolidSphere() | |
static const int | stacks = 20 |
Number of stacks for glutSolidSphere() |
Encapsulates a rigid body with geometry of a sphere.
Definition at line 297 of file Utilities.h.
WoRB::Ball::Ball | ( | Quaternion | position, |
Quaternion | orientation, | ||
Quaternion | velocity, | ||
Quaternion | angularVelocity, | ||
double | radius, | ||
double | mass | ||
) | [inline] |
Creates a ball at the given location.
Definition at line 308 of file Utilities.h.
References WoRB::RigidBody::Activate(), WoRB::GLUT_Renderer::ActiveColor, WoRB::Geometry::Body, WoRB::GLUT_Renderer::InactiveColor, WoRB::Sphere::Radius, WoRB::RigidBody::Set_XQVW(), and WoRB::Sphere::SetMass().
{ Body = this; Radius = radius; ActiveColor = Colorf( 0.9f, 0.7f, 0.7f, 0.8f ); InactiveColor = Colorf( 0.7f, 0.7f, 0.9f, 0.8f ); SetMass( mass ); Body->Set_XQVW( position, orientation, velocity, angularVelocity ); Body->Activate (); }
virtual RigidBody& WoRB::Ball::GetBody | ( | ) | [inline, virtual] |
Gets underlying rigid body.
Implements WoRB::GLUT_Renderer.
Definition at line 331 of file Utilities.h.
{ return *this; }
virtual Geometry& WoRB::Ball::GetGeometry | ( | ) | [inline, virtual] |
Gets underlying geometry.
Implements WoRB::GLUT_Renderer.
Definition at line 338 of file Utilities.h.
{ return *this; }
virtual void WoRB::Ball::Render | ( | RenderType | type | ) | [inline, virtual] |
Draws the geometry.
Implements WoRB::GLUT_Renderer.
Definition at line 345 of file Utilities.h.
References WoRB::GLUT_Renderer::Colorf::A, WoRB::GLUT_Renderer::ActiveColor, WoRB::GLUT_Renderer::Colorf::B, WoRB::Geometry::Body, WoRB::GLUT_Renderer::BodyAxes, WoRB::GLUT_Renderer::BodyShadow, WoRB::GLUT_Renderer::BodyShape, WoRB::GLUT_Renderer::Colorf::G, WoRB::GLUT_Renderer::InactiveColor, WoRB::RigidBody::IsActive, WoRB::GLUT_Renderer::Colorf::R, WoRB::Sphere::Radius, WoRB::RenderStateVariables(), slices, and stacks.
{ if ( type == BodyAxes ) { RenderStateVariables( *Body, Quaternion(0,1,1,1) * Radius * 2.0 ); return; } GLTransform bodySpace( *Body, /* flattenHeight if */ type == BodyShadow ); if ( type != BodyShadow ) { if ( Body->IsActive ) { glColor4f( ActiveColor.R, ActiveColor.G, ActiveColor.B, type == BodyShape ? ActiveColor.A : ActiveColor.A/2 ); } else { glColor4f( InactiveColor.R, InactiveColor.G, InactiveColor.B, type == BodyShape ? ActiveColor.A : ActiveColor.A/2 ); } } glutSolidSphere( Radius, slices, stacks ); }
virtual void WoRB::Ball::RenderWireframe | ( | double * | transform | ) | [inline, virtual] |
Draws the wireframe of the rigid body.
Implements WoRB::GLUT_Renderer.
Definition at line 372 of file Utilities.h.
References WoRB::Sphere::Radius, slices, and stacks.
const int WoRB::Ball::slices = 20 [static, private] |
Number of slices for glutSolidSphere()
Definition at line 299 of file Utilities.h.
Referenced by Render(), and RenderWireframe().
const int WoRB::Ball::stacks = 20 [static, private] |
Number of stacks for glutSolidSphere()
Definition at line 300 of file Utilities.h.
Referenced by Render(), and RenderWireframe().