1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
#include <GL/glut.h>
#include <iostream>
#include "C_Block.h"
#define FADE_DURATION 500
/*Durations of animations*/
unsigned int g_BlockAnimDurations[4] = {0, 500, 500, 500};
C_Block::C_Block(const char* f_strFileName,
GLuint f_uiColorTex ,
MatProps_t f_Mat)
: C_3DObject(f_strFileName, f_uiColorTex, f_Mat),
m_CurrState(BS_IDLE), m_uiAnimStart(0)
{
}
C_Block::~C_Block()
{
}
void C_Block::Render(unsigned int f_iElapsedTime)
{
unsigned int l_uiDeltaTime = f_iElapsedTime - m_uiAnimStart;
double l_Scale = 0.0;
//check if the previous animation has ended in between
//calls to this Render function.
if (l_uiDeltaTime > g_BlockAnimDurations[(int)m_CurrState])
{
m_CurrState = BS_IDLE;
}
glPushMatrix();
switch (m_CurrState)
{
case BS_FADE_IN:
l_Scale = (double)l_uiDeltaTime / (double)g_BlockAnimDurations[BS_FADE_IN];
//glScaled(l_Scale, l_Scale, l_Scale);
SetScale(l_Scale, l_Scale, l_Scale);
TransRotateScale();
C_3DObject::Render();
break;
case BS_FADE_OUT:
l_Scale = 1.0 - ((double)l_uiDeltaTime / (double)g_BlockAnimDurations[BS_FADE_OUT]);
// glScaled(l_Scale, l_Scale, l_Scale);
SetScale(l_Scale, l_Scale, l_Scale);
TransRotateScale();
C_3DObject::Render();
break;
case BS_COLLIDE:
break;
case BS_IDLE:
default:
TransRotateScale();
C_3DObject::Render();
break;
}
glPopMatrix();
}
|