|
From: Yoda-JM <yo...@us...> - 2012-11-06 00:38:46
|
Author: Vincent Le Ligeour <yo...@us...>
Date: Sun Sep 23 00:19:58 2012 +0200
fix 3dobject include
---
game/3dobject.cc | 19 +++++++++++++++++--
game/3dobject.hh | 21 ++++-----------------
game/theme.hh | 4 ----
3 files changed, 21 insertions(+), 23 deletions(-)
diff --git a/game/3dobject.cc b/game/3dobject.cc
index f17a14b..a1aac49 100644
--- a/game/3dobject.cc
+++ b/game/3dobject.cc
@@ -1,15 +1,15 @@
#include "3dobject.hh"
+#include "surface.hh"
+
#include <sstream>
#include <fstream>
#include <stdexcept>
-#include <cmath>
#include <boost/lexical_cast.hpp>
// TODO: test & fix faces that doesn't have texcoords in the file
// TODO: group handling for loader
-
namespace {
static const int HAS_TEXCOORDS = 1;
static const int HAS_NORMALS = 2;
@@ -101,8 +101,23 @@ void Object3d::loadWavefrontObj(std::string filepath, float scale) {
}
+void Object3d::load(std::string filepath, std::string texturepath, float scale) {
+ if (!texturepath.empty()) m_texture.reset(new Texture(texturepath));
+ loadWavefrontObj(filepath, scale);
+}
+
void Object3d::drawVBO() {
UseShader us(getShader("3dobject"));
m_va.Draw(GL_TRIANGLES);
}
+void Object3d::draw(float x, float y, float z, float s) {
+ using namespace glmath;
+ Transform trans(translate(vec3(x, y, z)) * scale(s)); // Move to position and scale
+ if (m_texture) {
+ UseTexture tex(*m_texture);
+ drawVBO();
+ } else {
+ drawVBO();
+ }
+}
diff --git a/game/3dobject.hh b/game/3dobject.hh
index 5ce33f5..c9c8beb 100644
--- a/game/3dobject.hh
+++ b/game/3dobject.hh
@@ -1,16 +1,15 @@
#pragma once
-#include <vector>
#include <string>
#include <boost/scoped_ptr.hpp>
#include <boost/noncopyable.hpp>
-#include "surface.hh"
#include "glshader.hh"
-#include "glutil.hh"
// TODO: Exception handling
// TODO: Texture loading
+class Texture;
+
/// A class representing 3d object
/// Non-copyable because of display lists getting messed up
class Object3d: boost::noncopyable {
@@ -26,20 +25,8 @@ class Object3d: boost::noncopyable {
load(filepath, texturepath, scale);
}
/// load a new object file
- void load(std::string filepath, std::string texturepath = "", float scale = 1.0) {
- if (!texturepath.empty()) m_texture.reset(new Texture(texturepath));
- loadWavefrontObj(filepath, scale);
- }
+ void load(std::string filepath, std::string texturepath = "", float scale = 1.0);
void drawVBO();
/// draws the object
- void draw(float x = 0, float y = 0, float z = 0, float s = 1.0) {
- using namespace glmath;
- Transform trans(translate(vec3(x, y, z)) * scale(s)); // Move to position and scale
- if (m_texture) {
- UseTexture tex(*m_texture);
- drawVBO();
- } else {
- drawVBO();
- }
- }
+ void draw(float x = 0, float y = 0, float z = 0, float s = 1.0);
};
diff --git a/game/theme.hh b/game/theme.hh
index ead5d83..8b77f32 100644
--- a/game/theme.hh
+++ b/game/theme.hh
@@ -4,12 +4,8 @@
#include "surface.hh"
#include "cachemap.hh"
#include <boost/noncopyable.hpp>
-#include <boost/scoped_ptr.hpp>
#include <string>
-
-class Shader;
-
/// abstract theme class
class Theme: boost::noncopyable {
protected:
|