World of Rigid Bodies (WoRB)
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
WoRB::Box Class Reference

Encapsulates a rigid body with geometry of a rectangular parallelepiped. More...

#include <Utilities.h>

Inheritance diagram for WoRB::Box:
Collaboration diagram for WoRB::Box:

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 RigidBodyGetBody ()
 Gets underlying rigid body.
virtual GeometryGetGeometry ()
 Gets underlying geometry.
virtual void Render (RenderType type)
 Draws the geometry.
virtual void RenderWireframe (double *transform)
 Draws the wireframe of the rigid body.

Detailed Description

Encapsulates a rigid body with geometry of a rectangular parallelepiped.

Definition at line 384 of file Utilities.h.


Constructor & Destructor Documentation

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 ();
        }

Member Function Documentation

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::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 );
        }

The documentation for this class was generated from the following file: