Go to the documentation of this file.00001
00002 #include "Internal.h"
00003 #ifdef CODE_MAC
00004 #include "GLUT/glut.h"
00005 #else
00006 #include "GL/glut.h"
00007 #endif
00008 #include <string.h>
00009 #include "Hitti.h"
00010 #include "QVector.h"
00011 #include "XCongo.h"
00012 #include <stdio.h>
00013
00014 Hitti::Hitti(const double pos[3], double size,
00015 const double rot[3], double angle, const double color[4], int expiration, int fps)
00016 : Lifetime(expiration)
00017 {
00018 memcpy(mPos, pos, sizeof(mPos) );
00019 SetSize(size);
00020 mAngle = angle;
00021
00022 memcpy(mRot, rot, sizeof(mRot) );
00023 memcpy(mColor, color, sizeof(mColor) );
00024
00025 if (fps * expiration == 0)
00026 {
00027 mDeltaOpacity = 0.0;
00028 mDeltaSize = 0.0;
00029 mColor[3] = 0.5;
00030 }
00031 else
00032 {
00033 mDeltaOpacity = 0.6 / (fps * expiration);
00034 mColor[3] = 0.6;
00035 mDeltaSize = 0.3/ (fps * expiration);
00036 }
00037 }
00038
00039 bool Hitti::Move(const double *fors)
00040 {
00041 return false;
00042 }
00043
00044 bool Hitti::Forse(const double *forse)
00045 {
00046 return false;
00047 }
00048
00049 const char* Hitti::ClassName() const
00050 {
00051 return "Hitti";
00052 }
00053
00054
00055 bool Hitti::Display()
00056 {
00057 glEnable(GL_BLEND);
00058 glDepthMask(GL_FALSE);
00059 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00060
00061
00062
00063 mColor[3] = MAX(0.1, mColor[3] - mDeltaOpacity);
00064
00065
00066 GLfloat mat_specular[] = { mColor[0]/2, mColor[1]/2, mColor[2]/2, 1.0 };
00067 GLfloat mat_diffuse[] = { mColor[0]/4, mColor[1]/4, mColor[2]/4, 1.0 };
00068 GLfloat mat_diffuseback[] = { mColor[0]/4, mColor[1]/4, mColor[2]/4, mColor[3]};
00069 GLfloat mat_ambient[] = { mColor[0], mColor[1], mColor[2], 1.0 };
00070 GLfloat mat_shininess[] = { 50.0 };
00071 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_diffuse);
00072 glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess);
00073 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient);
00074 glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuseback);
00075 glMaterialfv(GL_BACK, GL_DIFFUSE, mat_diffuseback);
00076
00077
00078 glPushMatrix();
00079 glTranslatef(mPos[0], mPos[1], mPos[2]);
00080 if (mAngle!=0.0)
00081 glRotatef(mAngle, mRot[0], mRot[1], mRot[2]);
00082 draw_circle(mSize, (int)(mSize * 40) );
00083 glPopMatrix();
00084
00085 glDepthMask(GL_TRUE);
00086 glDisable(GL_BLEND);
00087
00088 return true;
00089 }
00090
00091 bool Hitti::IsExpired()
00092 {
00093 return mDeltaOpacity == 0.0 || Lifetime::IsExpired();
00094 }
00095