Hitting is temporary Quad that is displayed at the place wall (Box) has been hit by the wall. More...
#include <Hitti.h>
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. | |
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.
| 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.
| pos | Position of Hitti center |
| size | Size will be intial radius |
| rot | Rotation axes |
| angle | Rotation angle |
| expiration | How long it should apear (secunds) |
| color | RGBA Color of the hitti |
| fps | Frame 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.
| pos | Position of Hitti center |
| size | Size will be intial radius |
| rot | Rotation axes |
| angle | Rotation angle |
| expiration | How long it should apear (secunds) |
| color | RGBA Color of the hitti |
| fps | Frame rate of the animation |
| const char * Hitti::ClassName | ( | ) | const [virtual] |
| const char* Hitti::ClassName | ( | ) | const [virtual] |
| bool Hitti::Display | ( | ) | [virtual] |
Draw itself in global cotext. Since quads are intented to be used with opengl, drawing context is global.
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.
Reimplemented from Quad_impl.
| bool Hitti::Forse | ( | const double | forse[3] | ) | [virtual] |
| bool Hitti::Forse | ( | const double | forse[3] | ) | [virtual] |
| 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.
Reimplemented from Quad_impl.
| bool Hitti::Move | ( | const double | new_pos[3] | ) | [virtual] |
Move quad posotion to new_pos.
Reimplemented from Quad_impl.
double Hitti::mAngle [private] |
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] |
double Hitti::mRot [private] |
1.8.0