mElite  1.0
An Elite clone based on TextElite by Jan-Philipp Kappmeier and Melanie Schmidt.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Star.cpp
Go to the documentation of this file.
1 
6 #include "Star.h"
7 
15 Star::Star( float planetRadius, float collisionRadius, GLuint textureName )
16 : Planet( planetRadius, collisionRadius, textureName ),
17 GameObject( ),
18 GraphicsObject( collisionRadius ) {
19  m_lightPosition[0] = 0.0;
20  m_lightPosition[1] = 0.0;
21  m_lightPosition[2] = 0.0;
22  m_lightPosition[3] = 1.0;
23  m_lightColor.x = 1.0;
24  m_lightColor.y = 1.0;
25  m_lightColor.z = 0.0;
26  glLightfv( GL_LIGHT0, GL_POSITION, m_lightPosition )
27  ;}
28 
30 
38 Star::Star( float x, float y, float z, float planetRadius, GLuint textureName )
39 : Planet( x, y, z, planetRadius, textureName ),
40 GraphicsObject( planetRadius ) {
41  m_lightPosition[0] = 0.0;
42  m_lightPosition[1] = 0.0;
43  m_lightPosition[2] = 0.0;
44  m_lightPosition[3] = 1.0;
45  m_lightColor.x = 1.0;
46  m_lightColor.y = 1.0;
47  m_lightColor.z = 0.0;
48  glLightfv( GL_LIGHT0, GL_POSITION, m_lightPosition );
49 }
50 
61 Star::Star( float x, float y, float z, float planetRadius, float collisionRadius, GLuint textureName )
62 : Planet( x, y, z, planetRadius, collisionRadius, textureName ),
63 GameObject( x, z, z ),
64 GraphicsObject( collisionRadius ) {
65  m_lightPosition[0] = 0.0;
66  m_lightPosition[1] = 0.0;
67  m_lightPosition[2] = 0.0;
68  m_lightPosition[3] = 1.0;
69  m_lightColor.x = 1.0;
70  m_lightColor.y = 1.0;
71  m_lightColor.z = 0.0;
72  glLightfv( GL_LIGHT0, GL_POSITION, m_lightPosition );
73 }
74 
78 Star::~Star(void) {
79 }
80 
82 
86 GLvoid Star::draw() {
87  glPushAttrib( GL_ALL_ATTRIB_BITS );
88  float color[3];
89  color[0] = m_lightColor.x;
90  color[1] = m_lightColor.y;
91  color[2] = m_lightColor.z;
92  glMaterialfv( GL_FRONT, GL_EMISSION, color );
93  Planet::draw();
94  glPopAttrib();
95 }
96 
101 GLvoid Star::setLightColor( Vector3 lightColor ) {
102  m_lightColor = lightColor;
103 }
104 
111 GLvoid Star::setLightColor( float r, float g, float b ) {
112  m_lightColor.x = r;
113  m_lightColor.y = g;
114  m_lightColor.z = b;
115 }
116 
117 GLvoid Star::setPos( GLfloat x, GLfloat y, GLfloat z ) {
118  Planet::setPos( x, y, z );
119  m_lightPosition[0] = x;
120  m_lightPosition[1] = y;
121  m_lightPosition[2] = z;
122  glLightfv( GL_LIGHT0, GL_POSITION, m_lightPosition );
123 }
124 
125 GLvoid Star::setPos( Vector3 position ) {
126  this->setPos( position.x, position.y, position.z );
127 }