summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDennis Peeten <dpeeten@onsneteindhoven.nl>2008-05-06 19:38:37 (GMT)
committerDennis Peeten <dpeeten@onsneteindhoven.nl>2008-05-06 19:38:37 (GMT)
commit177fd758a25e954a43c20e59e6e61ba15a661c44 (patch)
treee65059265b6abf4177833f9b7f54d8e04c91953d
parentd205c9a71a2d3d415cb470c0c148a7541a18ab41 (diff)
download2iv55-177fd758a25e954a43c20e59e6e61ba15a661c44.zip
2iv55-177fd758a25e954a43c20e59e6e61ba15a661c44.tar.gz
2iv55-177fd758a25e954a43c20e59e6e61ba15a661c44.tar.bz2
-rw-r--r--MatchBloxEngine/MatchBloxEngine/C_Block.cpp8
-rw-r--r--MatchBloxEngine/MatchBloxEngine/C_Box.cpp2
-rw-r--r--MatchBloxEngine/MatchBloxEngine/C_Environment.cpp4
-rw-r--r--MatchBloxEngine/MatchBloxEngine/C_MatchBloxEngine.cpp84
-rw-r--r--MatchBloxEngine/MatchBloxEngine/C_MatchBloxEngine.h2
-rw-r--r--MatchBloxEngine/MatchBloxEngine/MatchBloxEngine.vcproj30
-rw-r--r--MatchBloxEngine/MatchBloxEngine/main.cpp10
7 files changed, 132 insertions, 8 deletions
diff --git a/MatchBloxEngine/MatchBloxEngine/C_Block.cpp b/MatchBloxEngine/MatchBloxEngine/C_Block.cpp
index 4b2a9f7..4c092a2 100644
--- a/MatchBloxEngine/MatchBloxEngine/C_Block.cpp
+++ b/MatchBloxEngine/MatchBloxEngine/C_Block.cpp
@@ -28,6 +28,7 @@ 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])
@@ -35,12 +36,15 @@ void C_Block::Render(unsigned int f_iElapsedTime)
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;
@@ -48,6 +52,7 @@ void C_Block::Render(unsigned int f_iElapsedTime)
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;
@@ -56,8 +61,11 @@ void C_Block::Render(unsigned int f_iElapsedTime)
case BS_IDLE:
default:
+ TransRotateScale();
C_3DObject::Render();
break;
}
+ glPopMatrix();
+
}
diff --git a/MatchBloxEngine/MatchBloxEngine/C_Box.cpp b/MatchBloxEngine/MatchBloxEngine/C_Box.cpp
index e97e03a..9bde3ff 100644
--- a/MatchBloxEngine/MatchBloxEngine/C_Box.cpp
+++ b/MatchBloxEngine/MatchBloxEngine/C_Box.cpp
@@ -46,7 +46,7 @@ void C_Box::RandomizeTiles()
{
//generate a random number in the range
//0 - (l_iNumTiles-1)
- int pos = random() % l_iNumTiles;
+ int pos = rand() % l_iNumTiles;
//skip position in which we already inserted a hole
//type tile (type 4)
diff --git a/MatchBloxEngine/MatchBloxEngine/C_Environment.cpp b/MatchBloxEngine/MatchBloxEngine/C_Environment.cpp
index 7102ecd..0c7cbfd 100644
--- a/MatchBloxEngine/MatchBloxEngine/C_Environment.cpp
+++ b/MatchBloxEngine/MatchBloxEngine/C_Environment.cpp
@@ -5,6 +5,10 @@
#include "bitmap.h"
#include "C_Environment.h"
+#ifndef GL_CLAMP_TO_EDGE
+#define GL_CLAMP_TO_EDGE 0x812F
+#endif //GL_CLAMP_TO_EDGE
+
using namespace std;
C_Environment::C_Environment(const char *f_strEnvMapBaseName,
diff --git a/MatchBloxEngine/MatchBloxEngine/C_MatchBloxEngine.cpp b/MatchBloxEngine/MatchBloxEngine/C_MatchBloxEngine.cpp
index a0ad65e..7e17b1b 100644
--- a/MatchBloxEngine/MatchBloxEngine/C_MatchBloxEngine.cpp
+++ b/MatchBloxEngine/MatchBloxEngine/C_MatchBloxEngine.cpp
@@ -1,4 +1,7 @@
#include <GL/glut.h>
+
+#include <time.h>
+#include <string>
#include <iostream>
#include "C_MatchBloxEngine.h"
@@ -23,11 +26,30 @@ C_MatchBloxEngine::C_MatchBloxEngine(const char *f_strModelPath,
//set state to initialised;
m_State = ES_INITIALISED;
}
+ else
+ {
+ m_State = ES_ERROR;
+ }
+
+ //initialise a random seed
+ srand ( time(NULL) );
+
+ //init vars
+ m_CurrentBox = BS_SMALL;
//debug
m_pBox[0]->SetPos(0.0, -5.0, -15.0);
m_pBox[0]->SetRot(45.0, 0.0, 0.0);
m_pBox[0]->RandomizeTiles();
+
+ m_pBlock[0]->SetPos(-6.0, 1.0, -10.0);
+ m_pBlock[0]->SetRot(90.0, 0.0, 0.0);
+ m_pBlock[1]->SetPos(-2.0, 1.0, -10.0);
+ m_pBlock[1]->SetRot(90.0, 0.0, 0.0);
+ m_pBlock[2]->SetPos(2.0, 1.0, -10.0);
+ m_pBlock[2]->SetRot(90.0, 0.0, 0.0);
+ m_pBlock[3]->SetPos(6.0, 1.0, -10.0);
+ m_pBlock[3]->SetRot(90.0, 0.0, 0.0);
}
C_MatchBloxEngine::~C_MatchBloxEngine()
@@ -41,7 +63,18 @@ C_MatchBloxEngine::~C_MatchBloxEngine()
GameResult C_MatchBloxEngine::GameStep(msgQueue &f_Queue)
{
//process message queue
-
+ return GR_ERROR;
+}
+
+void C_MatchBloxEngine::Render_Basics(unsigned int f_uiElapsedTime)
+{
+ //render the environment
+ m_pEnvMap->Render();
+
+ m_pBox[(intptr_t)m_CurrentBox]->Render();
+ for (int i=0; i<4; i++)
+ m_pBlock[i]->Render(f_uiElapsedTime);
+// m_pHand->Render(f_uiElapsedTime);
}
void C_MatchBloxEngine::Render(unsigned int f_uiElapsedTime)
@@ -49,23 +82,64 @@ void C_MatchBloxEngine::Render(unsigned int f_uiElapsedTime)
switch (m_State)
{
case ES_INITIALISED:
+ Render_Basics(f_uiElapsedTime);
break;
+
case ES_ERROR:
+ //render a red cube
+ glPushMatrix();
+ glPushAttrib(GL_ENABLE_BIT);
+ glDisable(GL_LIGHTING);
+ glColor3d(1.0, 0.0, 0.0);
+ glTranslated(0.0, 0.0, -5.0);
+ glutSolidCube(5.0);
+ glPopAttrib();
+ glPopMatrix();
break;
+
case ES_GET_READY:
+ Render_Basics(f_uiElapsedTime);
+ //render some GET READY text
break;
+
case ES_PLAYING_GRAB_BLOCK:
+ Render_Basics(f_uiElapsedTime);
break;
+
case ES_PLAYING_PUT_BLOCK:
+ Render_Basics(f_uiElapsedTime);
break;
+
case ES_PAUSED:
+ Render_Basics(f_uiElapsedTime);
+ //render menu??
break;
+
case ES_FINISHED:
+ //render results...
break;
}
- m_pEnvMap->Render();
- m_pBox[0]->Render();
+ //glPushMatrix();
+
+ //double l_dSeconds = (double)f_uiElapsedTime/1000.0;
+
+ //glRotated(l_dSeconds * 5.0, 0.0, 1.0, 0.0);
+ ////glRotated(l_dSeconds * 10, 0.0, 0.0, 1.0);
+
+ //m_pEnvMap->Render();
+
+ //glPopMatrix();
+
+ //m_pBox[0]->Render();
+
+ //for(int i=0; i<4; i++)
+ //{
+ // glPushMatrix();
+ // m_pBlock[i]->Render(f_uiElapsedTime);
+ // glPopMatrix();
+ //}
+
}
bool C_MatchBloxEngine::NewGame(int f_iUserID, int f_iGameId, BoxSize f_BS)
@@ -81,6 +155,8 @@ bool C_MatchBloxEngine::NewGame(int f_iUserID, int f_iGameId, BoxSize f_BS)
//set state to GET READY
m_State = ES_GET_READY;
+ //init object positions
+ m_pBox[(int)m_CurrentBox]->SetPos(0.0, -6.0, -15.0);
return true;
}
@@ -148,7 +224,7 @@ bool C_MatchBloxEngine::LoadModels(const char* f_strModelDir)
std::string l_BaseName = f_strModelDir;
//create the environment mapped cube
- m_pEnvMap = new C_Environment("envmaps/brightday2_", 50.0);
+ m_pEnvMap = new C_Environment("envmaps/terrain_", 50.0);
//load the bitmaps for the textures
LoadTexture((l_BaseName + "/wood1.bmp").c_str(), m_uiWood1Tex);
diff --git a/MatchBloxEngine/MatchBloxEngine/C_MatchBloxEngine.h b/MatchBloxEngine/MatchBloxEngine/C_MatchBloxEngine.h
index b7afa76..97aa892 100644
--- a/MatchBloxEngine/MatchBloxEngine/C_MatchBloxEngine.h
+++ b/MatchBloxEngine/MatchBloxEngine/C_MatchBloxEngine.h
@@ -76,6 +76,8 @@ private:
EngineState m_State, m_SavedState;
BoxSize m_CurrentBox;
+ void Render_Basics(unsigned int f_uiElapsedTime);
+
bool LoadModels(const char* f_strModelDir);
void DeleteModels();
void LoadTexture(const char* f_BmpName, GLuint &f_uiTexHandle);
diff --git a/MatchBloxEngine/MatchBloxEngine/MatchBloxEngine.vcproj b/MatchBloxEngine/MatchBloxEngine/MatchBloxEngine.vcproj
index 5bfdb0b..0f7ecc0 100644
--- a/MatchBloxEngine/MatchBloxEngine/MatchBloxEngine.vcproj
+++ b/MatchBloxEngine/MatchBloxEngine/MatchBloxEngine.vcproj
@@ -41,7 +41,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\headtrack_stereo_demo\include"
- PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;G_OS_WIN32"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
@@ -183,6 +183,10 @@
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
+ RelativePath=".\bitmap.cpp"
+ >
+ </File>
+ <File
RelativePath=".\C_3DObject.cpp"
>
</File>
@@ -191,6 +195,14 @@
>
</File>
<File
+ RelativePath=".\C_Box.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\C_Environment.cpp"
+ >
+ </File>
+ <File
RelativePath=".\C_Hand.cpp"
>
</File>
@@ -213,6 +225,10 @@
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
+ RelativePath=".\bitmap.h"
+ >
+ </File>
+ <File
RelativePath=".\C_3DObject.h"
>
</File>
@@ -221,6 +237,14 @@
>
</File>
<File
+ RelativePath=".\C_Box.h"
+ >
+ </File>
+ <File
+ RelativePath=".\C_Environment.h"
+ >
+ </File>
+ <File
RelativePath=".\C_Hand.h"
>
</File>
@@ -236,6 +260,10 @@
RelativePath=".\MessageQueue.h"
>
</File>
+ <File
+ RelativePath=".\typedefs.h"
+ >
+ </File>
</Filter>
<Filter
Name="Resource Files"
diff --git a/MatchBloxEngine/MatchBloxEngine/main.cpp b/MatchBloxEngine/MatchBloxEngine/main.cpp
index 0ddf8eb..9ec7f1c 100644
--- a/MatchBloxEngine/MatchBloxEngine/main.cpp
+++ b/MatchBloxEngine/MatchBloxEngine/main.cpp
@@ -12,13 +12,14 @@ C_MatchBloxEngine *g_pEngine;
void init_gl(void)
{
+ GLfloat l_fLightpos[4] = {0.0, 1.0, 1.0, 0.0};
glClearColor(0.9, 0.9, 0.9, 1.0);
glClearDepth(1000.0);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
- //glEnable(GL_COLOR_MATERIAL);
+ glLightfv(GL_LIGHT0, GL_POSITION, l_fLightpos);
glEnable(GL_NORMALIZE);
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
@@ -35,7 +36,7 @@ void render_scene(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- g_pEngine->Render(1000);
+ g_pEngine->Render(glutGet(GLUT_ELAPSED_TIME));
glutSwapBuffers();
@@ -62,6 +63,11 @@ void process_normal_keys(unsigned char key, int x, int y)
}
else
{
+ if (key == 'n')
+ {
+ g_pEngine->Abort();
+ g_pEngine->NewGame(0, 0, BS_LARGE);
+ }
msgStruct l_msg;
l_msg.m_MessageType = KEY_PRESS;
l_msg.parm1 = key;