added scaling support when creating Engine::Objects
git-svn-id: svn://anubis/anaglym/trunk@72 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
c4f07c6c93
commit
968a35bc36
19
anaglym.cc
19
anaglym.cc
@ -9,6 +9,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <math.h> /* fabs() */
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -373,13 +374,15 @@ void Engine::drawObjects()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Engine::Object::Object(bool is_static, OdeWorld & world, GLuint dl)
|
Engine::Object::Object(bool is_static, OdeWorld & world, GLuint dl, float scale)
|
||||||
{
|
{
|
||||||
m_ode_object = world.createObject(is_static);
|
m_ode_object = world.createObject(is_static, scale);
|
||||||
m_display_list = dl;
|
m_display_list = dl;
|
||||||
m_display_list_refcnt = new int;
|
m_display_list_refcnt = new int;
|
||||||
*m_display_list_refcnt = 1;
|
*m_display_list_refcnt = 1;
|
||||||
m_is_visible = true;
|
m_is_visible = true;
|
||||||
|
m_scale = scale;
|
||||||
|
m_is_scaled = ! (fabs(scale - 1.0) < 0.0001);
|
||||||
}
|
}
|
||||||
|
|
||||||
Engine::Object::Object(const Engine::Object & orig)
|
Engine::Object::Object(const Engine::Object & orig)
|
||||||
@ -389,6 +392,8 @@ Engine::Object::Object(const Engine::Object & orig)
|
|||||||
m_display_list = orig.m_display_list;
|
m_display_list = orig.m_display_list;
|
||||||
m_display_list_refcnt = orig.m_display_list_refcnt;
|
m_display_list_refcnt = orig.m_display_list_refcnt;
|
||||||
(*m_display_list_refcnt)++;
|
(*m_display_list_refcnt)++;
|
||||||
|
m_scale = orig.m_scale;
|
||||||
|
m_is_scaled = orig.m_is_scaled;
|
||||||
}
|
}
|
||||||
|
|
||||||
Engine::Object::~Object()
|
Engine::Object::~Object()
|
||||||
@ -414,8 +419,18 @@ void Engine::Object::draw()
|
|||||||
if (transform)
|
if (transform)
|
||||||
OdeWorld::pushTransform(pos, rot);
|
OdeWorld::pushTransform(pos, rot);
|
||||||
|
|
||||||
|
if (m_is_scaled)
|
||||||
|
{
|
||||||
|
glPushAttrib(GL_TRANSFORM_BIT);
|
||||||
|
glEnable(GL_NORMALIZE);
|
||||||
|
glScalef(m_scale, m_scale, m_scale);
|
||||||
|
}
|
||||||
|
|
||||||
glCallList(m_display_list);
|
glCallList(m_display_list);
|
||||||
|
|
||||||
|
if (m_is_scaled)
|
||||||
|
glPopAttrib();
|
||||||
|
|
||||||
if (transform)
|
if (transform)
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,8 @@ class Engine
|
|||||||
class Object
|
class Object
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Object(bool is_static, OdeWorld & world, GLuint dl);
|
Object(bool is_static, OdeWorld & world, GLuint dl,
|
||||||
|
float scale = 1.0f);
|
||||||
Object(const Object & orig);
|
Object(const Object & orig);
|
||||||
~Object();
|
~Object();
|
||||||
|
|
||||||
@ -43,6 +44,8 @@ class Engine
|
|||||||
GLuint m_display_list;
|
GLuint m_display_list;
|
||||||
int * m_display_list_refcnt;
|
int * m_display_list_refcnt;
|
||||||
bool m_is_visible;
|
bool m_is_visible;
|
||||||
|
float m_scale;
|
||||||
|
bool m_is_scaled;
|
||||||
};
|
};
|
||||||
|
|
||||||
Engine();
|
Engine();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user