added OBJ loader

This commit is contained in:
martin
2011-06-13 19:05:04 +02:00
parent 509e569c64
commit 5c58595f35
14 changed files with 2615 additions and 5 deletions
+18
View File
@@ -17,6 +17,8 @@
#include "AsteroidsEvents.h"
#include "RocketEntity.h"
#include "OBJModel.h"
#include <GL/gl.h>
#include <GL/glu.h>
@@ -77,6 +79,8 @@ int View::OnInit (int argc, char* argv[]) {
mShipPartsSprite.LoadFromPNG (Engine::GetResourceFullPath("/data/textures/ship_parts.png"));
mShipPartsSprite.SetSubSpriteCount (10);
mAsteroidModel = LoadOBJModel (Engine::GetResourceFullPath("/data/models/asteroid/asteroid_model.obj"));
Engine::RegisterListener (this, EventAccelerateStart);
Engine::RegisterListener (this, EventAccelerateStop);
Engine::RegisterListener (this, EventShipExplode);
@@ -265,6 +269,20 @@ void View::Draw() {
DrawWorld ();
}
glPushMatrix();
glEnable (GL_LIGHTING);
glEnable (GL_LIGHT0);
glRotatef (90, 1., 0., 0.);
// glScalef (10., 10., 10.);
DrawOBJModel (mAsteroidModel);
glDisable (GL_LIGHT0);
glDisable (GL_LIGHTING);
glPopMatrix();
DrawUi ();
// Perform post-Draw actions
+3 -1
View File
@@ -139,7 +139,9 @@ class View : public Engine::ViewBase {
Engine::Sprite mShipSprite;
Engine::Sprite mShipThrustSprite;
Engine::Sprite mShipPartsSprite;
Engine::OBJModelPtr mAsteroidModel;
float screen_left;
float screen_right;
float screen_top;