imported LogoBox
This commit is contained in:
parent
76b3a5d5ef
commit
467e701d27
84
LogoBox.cc
Normal file
84
LogoBox.cc
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
|
||||||
|
/* Author: Josh Holtrop
|
||||||
|
* DornerWorks screensaver
|
||||||
|
* This module can be used to create "LogoBox" objects
|
||||||
|
* which consist of a 3D DW logo and possibly have a
|
||||||
|
* mass and boundary associated with them if physics
|
||||||
|
* is being used
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <GL/gl.h>
|
||||||
|
#include "WFObj.h"
|
||||||
|
#include "LogoBox.h"
|
||||||
|
#include "LoadFile.h"
|
||||||
|
#include <string.h> /* memcpy() */
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
static GLuint _logoList = 0;
|
||||||
|
static float _logoAABB[6];
|
||||||
|
static GLuint _drawList;
|
||||||
|
static LoadFile loadFile;
|
||||||
|
|
||||||
|
/* construct a LogoBox object
|
||||||
|
* The first time the constructor is called it loads the
|
||||||
|
* Alias Wavefront object model. Subsequent calls will
|
||||||
|
* reuse the same module.
|
||||||
|
*/
|
||||||
|
LogoBox::LogoBox()
|
||||||
|
{
|
||||||
|
if (_logoList == 0)
|
||||||
|
{
|
||||||
|
WFObj obj(loadFile);
|
||||||
|
if (obj.load(FileLoader::Path("", "dwlogo.obj")))
|
||||||
|
{
|
||||||
|
_logoList = obj.render(false);
|
||||||
|
const float * aabb = obj.getAABB();
|
||||||
|
memcpy(_logoAABB, aabb, sizeof(_logoAABB));
|
||||||
|
|
||||||
|
float c_x = (_logoAABB[0] + _logoAABB[3]) / 2.0f;
|
||||||
|
float c_y = (_logoAABB[1] + _logoAABB[4]) / 2.0f;
|
||||||
|
float c_z = (_logoAABB[2] + _logoAABB[5]) / 2.0f;
|
||||||
|
_drawList = glGenLists(1);
|
||||||
|
glNewList(_drawList, GL_COMPILE);
|
||||||
|
glPushMatrix();
|
||||||
|
glTranslatef(-c_x, -c_y, -c_z);
|
||||||
|
glCallList(_logoList);
|
||||||
|
glPopMatrix();
|
||||||
|
glEndList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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];
|
||||||
|
}
|
||||||
|
|
25
LogoBox.h
Normal file
25
LogoBox.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
* Author: Josh Holtrop
|
||||||
|
* DornerWorks screensaver
|
||||||
|
* The LogoBox class
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LOGOBOX_H
|
||||||
|
#define LOGOBOX_H
|
||||||
|
|
||||||
|
#include <GL/gl.h>
|
||||||
|
|
||||||
|
class LogoBox
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LogoBox();
|
||||||
|
~LogoBox();
|
||||||
|
void draw();
|
||||||
|
const float * const getAABB() const;
|
||||||
|
float getWidth() const;
|
||||||
|
float getHeight() const;
|
||||||
|
float getDepth() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user