Quad Pang
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Private Attributes
Hitti Class Reference

Hitting is temporary Quad that is displayed at the place wall (Box) has been hit by the wall. More...

#include <Hitti.h>

Inheritance diagram for Hitti:
Quad_impl Lifetime Quad_impl Lifetime Quad Quad Quad Quad

List of all members.

Public Member Functions

 Hitti (const double pos[3], double size, const double rot[3], double angle, const double color[4], int expiration=0, int fps=0)
 The only way to control hitti is through it's constructor.
 Hitti (const double pos[3], double size, const double rot[3], double angle, const double color[4], int expiration=0, int fps=0)
 The only way to control hitti is through it's constructor.
Methods from Lifetime
bool IsExpired ()
 Override exipred behavior to envolve transparency.
bool IsExpired ()
 Override exipred behavior to envolve transparency.
Methods from Quad and Quad_impl

Hitti doesn't move

bool Move (const double forse[3])
 Move quad posotion to new_pos.
bool Forse (const double forse[3])
 Chage Quad's direction of moving with forse.
const char * ClassName () const
 Used for RTTI.
bool Display ()
 Draw itself in global cotext. Since quads are intented to be used with opengl, drawing context is global.
bool Move (const double forse[3])
 Move quad posotion to new_pos.
bool Forse (const double forse[3])
 Chage Quad's direction of moving with forse.
const char * ClassName () const
 Used for RTTI.
bool Display ()
 Draw itself in global cotext. Since quads are intented to be used with opengl, drawing context is global.

Private Attributes

double mDeltaOpacity
 Make opacity smaller every frame.
double mDeltaSize
 Make size smaller every frame.
double mRot [3]
 Rotation axe.
double mAngle
 Rotation angle.

Detailed Description

Hitting is temporary Quad that is displayed at the place wall (Box) has been hit by the wall.

Hitti is an object that is animated to blur until disapearance. To make it smooth, mDeltaOpacity is calculcated based on frame rate and changed before it is drawn. In environment in which scene is not drawn based on frame rate this techique would have to be altered to remember time and calcuclate blur delta based on time delta.

Definition at line 19 of file Hitti.h.


Constructor & Destructor Documentation

Hitti::Hitti ( const double  pos[3],
double  size,
const double  rot[3],
double  angle,
const double  color[4],
int  expiration = 0,
int  fps = 0 
)

The only way to control hitti is through it's constructor.

Parameters:
posPosition of Hitti center
sizeSize will be intial radius
rotRotation axes
angleRotation angle
expirationHow long it should apear (secunds)
colorRGBA Color of the hitti
fpsFrame rate of the animation

Definition at line 14 of file Hitti.cpp.

References mAngle, Quad_impl::mColor, mDeltaOpacity, mDeltaSize, Quad_impl::mPos, mRot, and Quad_impl::SetSize().

    : Lifetime(expiration)
{
    memcpy(mPos, pos, sizeof(mPos) );
    SetSize(size);
    mAngle = angle;

    memcpy(mRot, rot, sizeof(mRot) );
    memcpy(mColor, color, sizeof(mColor) );

    if (fps * expiration == 0)
    {
        mDeltaOpacity = 0.0;
        mDeltaSize = 0.0;
        mColor[3] = 0.5;
    }
    else
    {
        mDeltaOpacity = 0.6 / (fps * expiration);
        mColor[3] = 0.6;
        mDeltaSize = 0.3/ (fps * expiration);
    }
}
Hitti::Hitti ( const double  pos[3],
double  size,
const double  rot[3],
double  angle,
const double  color[4],
int  expiration = 0,
int  fps = 0 
)

The only way to control hitti is through it's constructor.

Parameters:
posPosition of Hitti center
sizeSize will be intial radius
rotRotation axes
angleRotation angle
expirationHow long it should apear (secunds)
colorRGBA Color of the hitti
fpsFrame rate of the animation

Member Function Documentation

const char * Hitti::ClassName ( ) const [virtual]

Used for RTTI.

Returns:
Name of the actual class.
See also:
Factory

Reimplemented from Quad_impl.

Definition at line 49 of file Hitti.cpp.

{ 
    return "Hitti"; 
}
const char* Hitti::ClassName ( ) const [virtual]

Used for RTTI.

Returns:
Name of the actual class.
See also:
Factory

Reimplemented from Quad_impl.

bool Hitti::Display ( ) [virtual]

Draw itself in global cotext. Since quads are intented to be used with opengl, drawing context is global.

Returns:
true if ok, false on error.

Reimplemented from Quad_impl.

Definition at line 55 of file Hitti.cpp.

References draw_circle(), mAngle, MAX, Quad_impl::mColor, mDeltaOpacity, Quad_impl::mPos, mRot, and Quad_impl::mSize.

{
    glEnable(GL_BLEND);   
    glDepthMask(GL_FALSE);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  
    // Every time Hitti is dislayed it will calculate required opacity
    // note that mDeltaOpacity is based on frame rate
    mColor[3] = MAX(0.1, mColor[3] - mDeltaOpacity);

    // set color and materal values
    GLfloat mat_specular[] = { mColor[0]/2, mColor[1]/2, mColor[2]/2, 1.0 };
    GLfloat mat_diffuse[] = { mColor[0]/4, mColor[1]/4, mColor[2]/4, 1.0 };
    GLfloat mat_diffuseback[] = { mColor[0]/4, mColor[1]/4, mColor[2]/4, mColor[3]}; 
    GLfloat mat_ambient[] = { mColor[0], mColor[1], mColor[2], 1.0 };
    GLfloat mat_shininess[] = { 50.0 };
    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_diffuse);
    glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess);
    glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient);
    glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuseback);
    glMaterialfv(GL_BACK, GL_DIFFUSE, mat_diffuseback);

    // Draw circle in proper position
    glPushMatrix();    
    glTranslatef(mPos[0], mPos[1], mPos[2]);
    if (mAngle!=0.0)
        glRotatef(mAngle, mRot[0], mRot[1], mRot[2]); 
    draw_circle(mSize, (int)(mSize * 40) );
    glPopMatrix();

    glDepthMask(GL_TRUE);
    glDisable(GL_BLEND);

    return true;
}
bool Hitti::Display ( ) [virtual]

Draw itself in global cotext. Since quads are intented to be used with opengl, drawing context is global.

Returns:
true if ok, false on error.

Reimplemented from Quad_impl.

bool Hitti::Forse ( const double  forse[3]) [virtual]

Chage Quad's direction of moving with forse.

If mass is MASS_INFINITE then forse will not move the objet

Returns:
true if object changed it's direction, false if not.

Reimplemented from Quad_impl.

bool Hitti::Forse ( const double  forse[3]) [virtual]

Chage Quad's direction of moving with forse.

If mass is MASS_INFINITE then forse will not move the objet

Returns:
true if object changed it's direction, false if not.

Reimplemented from Quad_impl.

bool Hitti::IsExpired ( )

Override exipred behavior to envolve transparency.

bool Hitti::IsExpired ( )

Override exipred behavior to envolve transparency.

Definition at line 91 of file Hitti.cpp.

References mDeltaOpacity.

Referenced by CollisionMaster::Collision().

{ 
    return mDeltaOpacity == 0.0 || Lifetime::IsExpired();
}
bool Hitti::Move ( const double  new_pos[3]) [virtual]

Move quad posotion to new_pos.

Returns:
true if object is moved, false if not.

Reimplemented from Quad_impl.

bool Hitti::Move ( const double  new_pos[3]) [virtual]

Move quad posotion to new_pos.

Returns:
true if object is moved, false if not.

Reimplemented from Quad_impl.


Member Data Documentation

double Hitti::mAngle [private]

Rotation angle.

Definition at line 83 of file Hitti.h.

Referenced by Display(), and Hitti().

double Hitti::mDeltaOpacity [private]

Make opacity smaller every frame.

Definition at line 77 of file Hitti.h.

Referenced by Display(), Hitti(), and IsExpired().

double Hitti::mDeltaSize [private]

Make size smaller every frame.

Definition at line 79 of file Hitti.h.

Referenced by Hitti().

double Hitti::mRot [private]

Rotation axe.

Definition at line 81 of file Hitti.h.

Referenced by Display(), and Hitti().


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