Permalink
Browse files

Changed Geometry file so that it stores a list of points

  • Loading branch information...
1 parent 5eb3dfd commit c9c40f3d175b150e85186b80483ddaf684a5630a @RachelJMorris committed Mar 16, 2013
Showing with 90 additions and 85 deletions.
  1. +87 −83 Geometry.cpp
  2. +3 −2 Geometry.h
View
@@ -5,8 +5,6 @@ namespace ursa
Geometry::Geometry()
{
- m_position.x = m_position.y = m_position.z = 0;
- m_dimensions.x = m_dimensions.y = m_dimensions.z = 0;
}
Geometry::Geometry( const sf::Vector3f& pos, const sf::Vector3f& dim )
@@ -16,8 +14,15 @@ Geometry::Geometry( const sf::Vector3f& pos, const sf::Vector3f& dim )
void Geometry::Setup( const sf::Vector3f& pos, const sf::Vector3f& dim )
{
- m_position = pos;
- m_dimensions = dim;
+ m_lstPoints.push_back( sf::Vector3f( pos.x, pos.y, pos.z ) );
+ m_lstPoints.push_back( sf::Vector3f( pos.x + dim.x, pos.y, pos.z ) );
+ m_lstPoints.push_back( sf::Vector3f( pos.x + dim.x, pos.y + dim.y, pos.z ) );
+ m_lstPoints.push_back( sf::Vector3f( pos.x, pos.y + dim.y, pos.z ) );
+
+ m_lstPoints.push_back( sf::Vector3f( pos.x, pos.y, pos.z + dim.z ) );
+ m_lstPoints.push_back( sf::Vector3f( pos.x + dim.x, pos.y, pos.z + dim.z ) );
+ m_lstPoints.push_back( sf::Vector3f( pos.x + dim.x, pos.y + dim.y, pos.z + dim.z ) );
+ m_lstPoints.push_back( sf::Vector3f( pos.x, pos.y + dim.y, pos.z + dim.z ) );
}
void Geometry::Draw( const GLuint& texture )
@@ -37,139 +42,138 @@ void Geometry::DrawXY()
{
glColor3f( 1.0f, 1.0f, 1.0f );
+ glTexCoord2f(0.0f, 1.0f);
+ glVertex3f( m_lstPoints[0].x,
+ m_lstPoints[0].y,
+ m_lstPoints[0].z );
+
glTexCoord2f(1.0f, 1.0f);
- glVertex3f( m_position.x,
- m_position.y,
- m_position.z );
+ glVertex3f( m_lstPoints[1].x,
+ m_lstPoints[1].y,
+ m_lstPoints[1].z );
glTexCoord2f(1.0f, 0.0f);
- glVertex3f( m_position.x,
- m_position.y + m_dimensions.y,
- m_position.z );
+ glVertex3f( m_lstPoints[2].x,
+ m_lstPoints[2].y,
+ m_lstPoints[2].z );
glTexCoord2f(0.0f, 0.0f);
- glVertex3f( m_position.x + m_dimensions.x,
- m_position.y + m_dimensions.y,
- m_position.z );
+ glVertex3f( m_lstPoints[3].x,
+ m_lstPoints[3].y,
+ m_lstPoints[3].z );
- glTexCoord2f(0.0f, 1.0f);
- glVertex3f( m_position.x + m_dimensions.x,
- m_position.y,
- m_position.z );
+ glTexCoord2f(0.0f, 1.0f);
+ glVertex3f( m_lstPoints[4].x,
+ m_lstPoints[4].y,
+ m_lstPoints[4].z );
glTexCoord2f(1.0f, 1.0f);
- glVertex3f( m_position.x,
- m_position.y,
- m_position.z + m_dimensions.z );
+ glVertex3f( m_lstPoints[5].x,
+ m_lstPoints[5].y,
+ m_lstPoints[5].z );
glTexCoord2f(1.0f, 0.0f);
- glVertex3f( m_position.x,
- m_position.y + m_dimensions.y,
- m_position.z + m_dimensions.z );
+ glVertex3f( m_lstPoints[6].x,
+ m_lstPoints[6].y,
+ m_lstPoints[6].z );
glTexCoord2f(0.0f, 0.0f);
- glVertex3f( m_position.x + m_dimensions.x,
- m_position.y + m_dimensions.y,
- m_position.z + m_dimensions.z );
-
- glTexCoord2f(0.0f, 1.0f);
- glVertex3f( m_position.x + m_dimensions.x,
- m_position.y,
- m_position.z + m_dimensions.z );
+ glVertex3f( m_lstPoints[7].x,
+ m_lstPoints[7].y,
+ m_lstPoints[7].z );
}
void Geometry::DrawXZ()
{
glColor3f( 0.6f, 0.6f, 0.6f );
+ glTexCoord2f(0.0f, 0.0f);
+ glVertex3f( m_lstPoints[0].x,
+ m_lstPoints[0].y,
+ m_lstPoints[0].z );
+
glTexCoord2f(0.0f, 1.0f);
- glVertex3f( m_position.x,
- m_position.y,
- m_position.z );
+ glVertex3f( m_lstPoints[1].x,
+ m_lstPoints[1].y,
+ m_lstPoints[1].z );
glTexCoord2f(1.0f, 1.0f);
- glVertex3f( m_position.x,
- m_position.y,
- m_position.z + m_dimensions.z );
+ glVertex3f( m_lstPoints[5].x,
+ m_lstPoints[5].y,
+ m_lstPoints[5].z );
glTexCoord2f(1.0f, 0.0f);
- glVertex3f( m_position.x + m_dimensions.x,
- m_position.y,
- m_position.z + m_dimensions.z );
+ glVertex3f( m_lstPoints[4].x,
+ m_lstPoints[4].y,
+ m_lstPoints[4].z );
- glTexCoord2f(0.0f, 0.0f);
- glVertex3f( m_position.x + m_dimensions.x,
- m_position.y,
- m_position.z );
+ glTexCoord2f(0.0f, 1.0f);
+ glVertex3f( m_lstPoints[3].x,
+ m_lstPoints[3].y,
+ m_lstPoints[3].z );
glTexCoord2f(1.0f, 1.0f);
- glVertex3f( m_position.x,
- m_position.y + m_dimensions.y,
- m_position.z );
+ glVertex3f( m_lstPoints[2].x,
+ m_lstPoints[2].y,
+ m_lstPoints[2].z );
glTexCoord2f(1.0f, 0.0f);
- glVertex3f( m_position.x,
- m_position.y + m_dimensions.y,
- m_position.z + m_dimensions.z );
+ glVertex3f( m_lstPoints[6].x,
+ m_lstPoints[6].y,
+ m_lstPoints[6].z );
glTexCoord2f(0.0f, 0.0f);
- glVertex3f( m_position.x + m_dimensions.x,
- m_position.y + m_dimensions.y,
- m_position.z + m_dimensions.z );
-
- glTexCoord2f(0.0f, 1.0f);
- glVertex3f( m_position.x + m_dimensions.x,
- m_position.y + m_dimensions.y,
- m_position.z );
-
+ glVertex3f( m_lstPoints[7].x,
+ m_lstPoints[7].y,
+ m_lstPoints[7].z );
}
void Geometry::DrawYZ()
{
glColor3f( 0.4f, 0.4f, 0.4f );
glTexCoord2f(0.0f, 1.0f);
- glVertex3f( m_position.x,
- m_position.y,
- m_position.z );
+ glVertex3f( m_lstPoints[0].x,
+ m_lstPoints[0].y,
+ m_lstPoints[0].z );
glTexCoord2f(1.0f, 1.0f);
- glVertex3f( m_position.x,
- m_position.y,
- m_position.z + m_dimensions.z );
+ glVertex3f( m_lstPoints[4].x,
+ m_lstPoints[4].y,
+ m_lstPoints[4].z );
glTexCoord2f(1.0f, 0.0f);
- glVertex3f( m_position.x,
- m_position.y + m_dimensions.y,
- m_position.z + m_dimensions.z );
+ glVertex3f( m_lstPoints[7].x,
+ m_lstPoints[7].y,
+ m_lstPoints[7].z );
glTexCoord2f(0.0f, 0.0f);
- glVertex3f( m_position.x,
- m_position.y + m_dimensions.y,
- m_position.z );
+ glVertex3f( m_lstPoints[3].x,
+ m_lstPoints[3].y,
+ m_lstPoints[3].z );
glTexCoord2f(0.0f, 1.0f);
- glVertex3f( m_position.x + m_dimensions.x,
- m_position.y,
- m_position.z );
+ glVertex3f( m_lstPoints[1].x,
+ m_lstPoints[1].y,
+ m_lstPoints[1].z );
glTexCoord2f(1.0f, 1.0f);
- glVertex3f( m_position.x + m_dimensions.x,
- m_position.y,
- m_position.z + m_dimensions.z );
+ glVertex3f( m_lstPoints[5].x,
+ m_lstPoints[5].y,
+ m_lstPoints[5].z );
glTexCoord2f(1.0f, 0.0f);
- glVertex3f( m_position.x + m_dimensions.x,
- m_position.y + m_dimensions.y,
- m_position.z + m_dimensions.z );
+ glVertex3f( m_lstPoints[6].x,
+ m_lstPoints[6].y,
+ m_lstPoints[6].z );
glTexCoord2f(0.0f, 0.0f);
- glVertex3f( m_position.x + m_dimensions.x,
- m_position.y + m_dimensions.y,
- m_position.z );
+ glVertex3f( m_lstPoints[2].x,
+ m_lstPoints[2].y,
+ m_lstPoints[2].z );
}
}
View
@@ -3,6 +3,8 @@
#include <SFML/Graphics.hpp>
+#include <vector>
+
namespace ursa
{
@@ -15,8 +17,7 @@ class Geometry
void Draw( const GLuint& texture );
private:
- sf::Vector3f m_position;
- sf::Vector3f m_dimensions;
+ std::vector<sf::Vector3f> m_lstPoints;
void DrawXY();
void DrawXZ();

0 comments on commit c9c40f3

Please sign in to comment.