|
World of Rigid Bodies (WoRB)
|
Encapsulates a rigid body with geometry of a rectangular parallelepiped. More...
#include <Utilities.h>


Public Member Functions | |
| Box (const Quaternion &position, const Quaternion &orientation, const Quaternion &velocity, const Quaternion &angularVelocity, const Quaternion &halfExtent, double mass) | |
| Creates the box at the specific 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. | |
Encapsulates a rigid body with geometry of a rectangular parallelepiped.
Definition at line 384 of file Utilities.h.
| WoRB::Box::Box | ( | const Quaternion & | position, |
| const Quaternion & | orientation, | ||
| const Quaternion & | velocity, | ||
| const Quaternion & | angularVelocity, | ||
| const Quaternion & | halfExtent, | ||
| double | mass | ||
| ) | [inline] |
Creates the box at the specific location.
Definition at line 392 of file Utilities.h.
References WoRB::RigidBody::Activate(), WoRB::GLUT_Renderer::ActiveColor, WoRB::Geometry::Body, WoRB::Cuboid::HalfExtent, WoRB::GLUT_Renderer::InactiveColor, WoRB::RigidBody::Set_XQVW(), WoRB::Cuboid::SetMass(), WoRB::Quaternion::x, WoRB::Quaternion::y, and WoRB::Quaternion::z.
{
Body = this;
HalfExtent = halfExtent;
double minsz = HalfExtent.x;
minsz = HalfExtent.y < minsz ? HalfExtent.y : minsz;
minsz = HalfExtent.z < minsz ? HalfExtent.z : minsz;
ActiveColor = minsz < 0.1 ? Colorf( 0.0f, 0.0f, 0.1f, 0.7f )
: Colorf( 0.7f, 0.9f, 0.7f, 0.8f );
InactiveColor = Colorf( 0.9f, 0.5f, 0.5f, 0.8f );
SetMass( mass );
Body->Set_XQVW( position, orientation, velocity, angularVelocity );
Body->Activate ();
}
| virtual RigidBody& WoRB::Box::GetBody | ( | ) | [inline, virtual] |
Gets underlying rigid body.
Implements WoRB::GLUT_Renderer.
Definition at line 420 of file Utilities.h.
{
return *this;
}
| virtual Geometry& WoRB::Box::GetGeometry | ( | ) | [inline, virtual] |
Gets underlying geometry.
Implements WoRB::GLUT_Renderer.
Definition at line 427 of file Utilities.h.
{
return *this;
}
| virtual void WoRB::Box::Render | ( | RenderType | type | ) | [inline, virtual] |
Draws the geometry.
Implements WoRB::GLUT_Renderer.
Definition at line 434 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::Cuboid::HalfExtent, WoRB::GLUT_Renderer::InactiveColor, WoRB::RigidBody::IsActive, WoRB::GLUT_Renderer::Colorf::R, WoRB::RenderStateVariables(), WoRB::Quaternion::x, WoRB::Quaternion::y, and WoRB::Quaternion::z.
{
if ( type == BodyAxes )
{
RenderStateVariables( *Body, HalfExtent * 1.2 );
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 ? InactiveColor.A : InactiveColor.A/2 );
}
}
glScaled( HalfExtent.x * 2, HalfExtent.y * 2, HalfExtent.z * 2 );
glutSolidCube( 1.0 );
}
| virtual void WoRB::Box::RenderWireframe | ( | double * | transform | ) | [inline, virtual] |
Draws the wireframe of the rigid body.
Implements WoRB::GLUT_Renderer.
Definition at line 462 of file Utilities.h.
References WoRB::Cuboid::HalfExtent, WoRB::Quaternion::x, WoRB::Quaternion::y, and WoRB::Quaternion::z.
{
GLTransform bodySpace( transform );
glColor4f( 0.0f, 0.0f, 0.0f, 0.1f );
glScaled( HalfExtent.x * 2, HalfExtent.y * 2, HalfExtent.z * 2 );
glutWireCube( 1.0 );
}