From c40ca189663e413e188c2509c59e122038908e56 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Tue, 18 Oct 2011 07:10:19 +0000 Subject: [PATCH] - added commented out code for loading md5 models (and obj format models) on intro page --- source/glest_game/main/intro.cpp | 89 +++++++++++++++++++++++++++++++- source/glest_game/main/intro.h | 8 +++ 2 files changed, 96 insertions(+), 1 deletion(-) diff --git a/source/glest_game/main/intro.cpp b/source/glest_game/main/intro.cpp index dca09bda..e7151f89 100644 --- a/source/glest_game/main/intro.cpp +++ b/source/glest_game/main/intro.cpp @@ -1,7 +1,7 @@ // ============================================================== // This file is part of Glest (www.glest.org) // -// Copyright (C) 2001-2008 Marti�o Figueroa +// Copyright (C) 2001-2008 Martiño Figueroa // // You can redistribute this code and/or modify it under // the terms of the GNU General Public License as published @@ -21,6 +21,9 @@ #include "metrics.h" #include "auto_test.h" #include "util.h" +//#include "glm.h" +//#include "md5util.h" +//#include "Mathlib.h" #include "leak_dumper.h" using namespace Shared::Util; @@ -29,6 +32,27 @@ using namespace Shared::Xml; namespace Glest{ namespace Game{ +//struct Timer { +//public: +// Timer () +// : current_time (0.0), last_time (0.0) { } +// +//public: +// void update () { +// last_time = current_time; +// current_time = static_cast(SDL_GetTicks ()) / 1000.0; +// } +// +// double deltaTime () const { +// return (current_time - last_time); +// } +// +//public: +// double current_time; +// double last_time; +// +//} animTimer; + // ===================================================== // class Text // ===================================================== @@ -254,6 +278,10 @@ Intro::Intro(Program *program): } } + //test = NULL; + //Shared::Graphics::md5::initMD5OpenGL(data_path + "data/core/shaders/"); + //md5Test = Shared::Graphics::md5::getMD5ObjectFromLoaderScript("/home/softcoder/Code/megaglest/trunk/mk/linux/mydata/test/mv1/mv1.loader"); + SoundRenderer &soundRenderer= SoundRenderer::getInstance(); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); @@ -265,6 +293,12 @@ Intro::Intro(Program *program): Intro::~Intro() { deleteValues(texts.begin(),texts.end()); + +// if(test) { +// glmDelete(test); +// } + + //Shared::Graphics::md5::cleanupMD5OpenGL(); } void Intro::update() { @@ -320,6 +354,8 @@ void Intro::update() { if(anim > 1.f) { anim = 0.f; } + + //animTimer.update(); } void Intro::renderModelBackground() { @@ -386,9 +422,60 @@ void Intro::render() { renderer.clearZBuffer(); renderer.loadCameraMatrix(&camera); +// const Vec3f &position= camera.getConstPosition(); +// Quaternion orientation= camera.getOrientation().conjugate(); +// Shared::Graphics::md5::Matrix4x4f modelViewMatrix; +// float *mtx = orientation.toMatrix4().ptr(); +// for(unsigned int i = 0; i < 16; ++i) { +// modelViewMatrix._m[i] = mtx[i]; +// } + renderModelBackground(); renderer.renderParticleManager(rsMenu); + //printf("animTimer.deltaTime () = %f anim = %f animTimer.deltaTime() / 25.0 = %f\n",animTimer.deltaTime (),anim,animTimer.deltaTime() / 25.0); + //double anim = animTimer.deltaTime(); + //Shared::Graphics::md5::renderMD5Object(md5Test, animTimer.deltaTime() / 30.0, &modelViewMatrix); + +// if(test == NULL) { +// glClearColor (0.0, 0.0, 0.0, 0.0); +// glEnable(GL_DEPTH_TEST); +// glShadeModel (GL_SMOOTH); +// +// test = glmReadOBJ("/home/softcoder/Code/megaglest/trunk/mk/linux/r_stack_fall.obj"); +// glmUnitize(test); +// glmFacetNormals(test); +// glmVertexNormals(test, 90.0); +// +// int h = 900; +// int w = 1680; +// glViewport (0, 0, (GLsizei) w, (GLsizei) h); +// glMatrixMode (GL_PROJECTION); +// glLoadIdentity (); +// gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0); +// glMatrixMode (GL_MODELVIEW); +// } +// if(test != NULL) { +// +// glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); +// glLoadIdentity(); +// glTranslatef(0,0,-5); +// +// glPushMatrix(); +// // I added these to be able to rotate the whole scene so you can see the box and textures +// glRotatef(90,1,0,0); +// glRotatef(0,0,1,0); +// glRotatef(0,0,0,1); +// glmDraw(test, GLM_SMOOTH| GLM_TEXTURE); +// //glmDraw(test, GLM_SMOOTH| GLM_TEXTURE|GLM_COLOR); +// //glmDraw(test, GLM_FLAT); +// glPopMatrix(); +// +// renderer.swapBuffers(); +// return; +// //printf("Rendering test"); +// } + renderer.reset2d(); for(int i = 0; i < texts.size(); ++i) { diff --git a/source/glest_game/main/intro.h b/source/glest_game/main/intro.h index 58041f16..af66fc4e 100644 --- a/source/glest_game/main/intro.h +++ b/source/glest_game/main/intro.h @@ -36,6 +36,11 @@ using Shared::Graphics::Texture2D; using Shared::Graphics::Camera; using Shared::Graphics::Model; using Shared::Util::RandomGen; +//class GLMmodel; + +//namespace Shared{ namespace Graphics { namespace md5 { +//class Md5Object; +//}}} namespace Glest{ namespace Game{ @@ -102,6 +107,9 @@ private: Vec3f startPosition; int modelShowTime; + //GLMmodel* test; + //Shared::Graphics::md5::Md5Object *md5Test; + void cleanup(); void renderModelBackground();