LogoBox: cleaned up and optimized
This commit is contained in:
parent
f2aa2ff908
commit
bb3dad0809
62
LogoBox.cc
62
LogoBox.cc
@ -1,10 +1,9 @@
|
|||||||
|
|
||||||
/* Author: Josh Holtrop
|
/*
|
||||||
* DornerWorks screensaver
|
* Author: Josh Holtrop
|
||||||
|
* DornerWorks ScreenSaver
|
||||||
* This module can be used to create "LogoBox" objects
|
* This module can be used to create "LogoBox" objects
|
||||||
* which consist of a 3D DW logo and possibly have a
|
* which consist of a 3D DW logo
|
||||||
* mass and boundary associated with them if physics
|
|
||||||
* is being used
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
@ -17,11 +16,12 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
static GLuint _logoList = 0;
|
static GLuint _logoList = 0;
|
||||||
static float _logoAABB[6];
|
|
||||||
static GLuint _drawList;
|
static GLuint _drawList;
|
||||||
static LoadFile loadFile;
|
static LoadFile loadFile;
|
||||||
|
static float _width, _depth, _height;
|
||||||
|
|
||||||
/* construct a LogoBox object
|
/*
|
||||||
|
* construct a LogoBox object
|
||||||
* The first time the constructor is called it loads the
|
* The first time the constructor is called it loads the
|
||||||
* Alias Wavefront object model. Subsequent calls will
|
* Alias Wavefront object model. Subsequent calls will
|
||||||
* reuse the same module.
|
* reuse the same module.
|
||||||
@ -35,11 +35,15 @@ LogoBox::LogoBox()
|
|||||||
{
|
{
|
||||||
_logoList = obj.render(false);
|
_logoList = obj.render(false);
|
||||||
const float * aabb = obj.getAABB();
|
const float * aabb = obj.getAABB();
|
||||||
memcpy(_logoAABB, aabb, sizeof(_logoAABB));
|
|
||||||
|
|
||||||
float c_x = (_logoAABB[0] + _logoAABB[3]) / 2.0f;
|
float c_x = (aabb[0] + aabb[3]) / 2.0f;
|
||||||
float c_y = (_logoAABB[1] + _logoAABB[4]) / 2.0f;
|
float c_y = (aabb[1] + aabb[4]) / 2.0f;
|
||||||
float c_z = (_logoAABB[2] + _logoAABB[5]) / 2.0f;
|
float c_z = (aabb[2] + aabb[5]) / 2.0f;
|
||||||
|
|
||||||
|
_width = aabb[3] - aabb[0];
|
||||||
|
_depth = aabb[4] - aabb[1];
|
||||||
|
_height = aabb[5] - aabb[2];
|
||||||
|
|
||||||
_drawList = glGenLists(1);
|
_drawList = glGenLists(1);
|
||||||
glNewList(_drawList, GL_COMPILE);
|
glNewList(_drawList, GL_COMPILE);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
@ -49,36 +53,8 @@ LogoBox::LogoBox()
|
|||||||
glEndList();
|
glEndList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
m_drawList = _drawList;
|
||||||
|
m_width = _width;
|
||||||
|
m_depth = _depth;
|
||||||
|
m_height = _height;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogoBox::~LogoBox()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void LogoBox::draw()
|
|
||||||
{
|
|
||||||
glCallList(_drawList);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* return a pointer to the axis-aligned bounding box for a DW logo */
|
|
||||||
const float * const LogoBox::getAABB() const
|
|
||||||
{
|
|
||||||
return _logoAABB;
|
|
||||||
}
|
|
||||||
|
|
||||||
float LogoBox::getWidth() const
|
|
||||||
{
|
|
||||||
return _logoAABB[3] - _logoAABB[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
float LogoBox::getHeight() const
|
|
||||||
{
|
|
||||||
return _logoAABB[5] - _logoAABB[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
float LogoBox::getDepth() const
|
|
||||||
{
|
|
||||||
return _logoAABB[4] - _logoAABB[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
13
LogoBox.h
13
LogoBox.h
@ -14,12 +14,13 @@ class LogoBox
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LogoBox();
|
LogoBox();
|
||||||
~LogoBox();
|
void draw() { glCallList(m_drawList); }
|
||||||
void draw();
|
float getWidth() const { return m_width; }
|
||||||
const float * const getAABB() const;
|
float getDepth() const { return m_depth; }
|
||||||
float getWidth() const;
|
float getHeight() const { return m_height; }
|
||||||
float getHeight() const;
|
protected:
|
||||||
float getDepth() const;
|
GLuint m_drawList;
|
||||||
|
float m_width, m_depth, m_height;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user