-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsseSun.cpp
128 lines (106 loc) · 3.01 KB
/
sseSun.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//========================================================
// Scaled Simulator Engine
//
// Author: Jason Huntley
//
// Description: Sun
//
// Notes:
//
// Y+
// |
// |__ X+
// /
// Z+
//
// License:
//
// Licensed under the Apache License, Version 2.0
// (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of
// the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in
// writing, software distributed under the License is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing
// permissions and limitations under the License.
//
//=========================================================
#include "sseSun.h"
#include "sseTexture.h"
sseSun::sseSun(void) : sseObject()
{
stringstream sstm;
sstm << "Sun-" << getID();
setName(sstm.str());
sseColor sAC(100.0f, 100.0f, 100.0f);
sseColor sSC(0.0,0.0,0.0);
sseColor sDC(0.8f,0.8f,0.8f);
m_materialDefault.setAmbientColor(sAC);
m_materialDefault.setSpecularColor(sSC);
m_materialDefault.setDiffuseColor(sDC);
m_materialDefault.setMode(MAT_UPDATE_FRONT);
m_lightPos[0]= 0.0f;
m_lightPos[1] = 0.0f;
m_lightPos[2] = 0.0f;
m_lightPos[3] = 1.0f;
m_light_ambient[0]= 0.0f;
m_light_ambient[1] = 0.0f;
m_light_ambient[2] = 0.0f;
m_light_ambient[3] = 1.0f;
m_light_diffuse[0]= 1.0f;
m_light_diffuse[1] = 1.0f;
m_light_diffuse[2] = 1.0f;
m_light_diffuse[3] = 1.0f;
m_light_specular[0]= 1.0f;
m_light_specular[1] = 1.0f;
m_light_specular[2] = 1.0f;
m_light_specular[3] = 1.0f;
m_radius = 695000;
}
sseSun::~sseSun(void)
{
}
double sseSun::GetRadius()
{
return m_radius;
}
void sseSun::SetRadius(double radius)
{
m_radius = radius;
}
void sseSun::Load(sseTexture *pTextureLoader)
{
texture_id=pTextureLoader->LoadWrap("Data/entities/img/sun.png", -1, GL_RGB);
}
void sseSun::PreProcess(sseGrafxInterface *pRenderer, sseTexture *pTextureLoader)
{
sseObject::PreProcess(pRenderer, pTextureLoader);
if (!m_destroy) {
glLightfv(GL_LIGHT0, GL_AMBIENT, m_light_ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, m_light_diffuse);
glLightfv(GL_LIGHT0, GL_SPECULAR, m_light_specular);
pTextureLoader->Bind(texture_id);
m_quadTexture = gluNewQuadric();
gluQuadricTexture(m_quadTexture,GL_TRUE);
}
}
void sseSun::DrawObject(sseGrafxInterface *pRenderer, sseTexture *pTextureLoader)
{
if (!m_destroy) {
this->getPosition().GetGLArray(m_lightPos);
//m_lightPos[1] += 40.0f;
m_lightPos[3] = 1.0f;
gluSphere(m_quadTexture,m_radius,1000,1000);// Draw the Sun
glLightfv(GL_LIGHT0,GL_POSITION,m_lightPos);
}
}
void sseSun::PostProcess(sseGrafxInterface *pRenderer, sseTexture *pTextureLoader)
{
sseObject::PostProcess(pRenderer, pTextureLoader);
gluDeleteQuadric(m_quadTexture);
}