3
* Copyright (C) 2002 Fabien Chereau
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
#include "stellarium.h"
21
#include "stel_object.h"
22
#include "navigator.h"
23
#include "stel_utility.h"
24
#include "s_texture.h"
27
s_texture * StelObject::pointer_star = NULL;
28
s_texture * StelObject::pointer_planet = NULL;
29
s_texture * StelObject::pointer_nebula = NULL;
30
s_texture * StelObject::pointer_telescope = NULL;
32
int StelObject::local_time = 0;
34
// Draw a nice animated pointer around the object
35
void StelObject::draw_pointer(int delta_time, const Projector* prj, const Navigator * nav)
37
local_time+=delta_time;
38
Vec3d pos=get_earth_equ_pos(nav);
40
// Compute 2D pos and return if outside screen
41
if (!prj->project_earth_equ(pos, screenpos)) return;
42
prj->set_orthographic_projection();
44
if (get_type()==STEL_OBJECT_NEBULA) glColor3f(0.4f,0.5f,0.8f);
45
if (get_type()==STEL_OBJECT_PLANET) glColor3f(1.0f,0.3f,0.3f);
47
if (get_type()==STEL_OBJECT_STAR||get_type()==STEL_OBJECT_TELESCOPE)
49
glColor3fv(get_RGB());
51
if (get_type()==STEL_OBJECT_STAR) {
53
glBindTexture (GL_TEXTURE_2D, pointer_star->getID());
56
glBindTexture (GL_TEXTURE_2D, pointer_telescope->getID());
58
glEnable(GL_TEXTURE_2D);
60
glTranslatef(screenpos[0], screenpos[1], 0.0f);
61
glRotatef((float)local_time/20.,0.,0.,1.);
63
glTexCoord2f(0.0f,0.0f); glVertex3f(-radius,-radius,0.); //Bas Gauche
64
glTexCoord2f(1.0f,0.0f); glVertex3f(radius,-radius,0.); //Bas Droite
65
glTexCoord2f(1.0f,1.0f); glVertex3f(radius,radius,0.); //Haut Droit
66
glTexCoord2f(0.0f,1.0f); glVertex3f(-radius,radius,0.); //Haut Gauche
70
float size = get_on_screen_size(prj, nav);
72
size+=10.f*sin(0.002f * local_time);
74
if (get_type()==STEL_OBJECT_NEBULA || get_type()==STEL_OBJECT_PLANET)
76
if (get_type()==STEL_OBJECT_PLANET)
77
glBindTexture(GL_TEXTURE_2D, pointer_planet->getID());
78
if (get_type()==STEL_OBJECT_NEBULA)
79
glBindTexture(GL_TEXTURE_2D, pointer_nebula->getID());
81
glEnable(GL_TEXTURE_2D);
83
glTranslatef(screenpos[0], screenpos[1], 0.0f);
84
if (get_type()==STEL_OBJECT_PLANET) glRotatef((float)local_time/100,0,0,-1);
86
glTranslatef(-size/2, -size/2,0.0f);
89
glTexCoord2f(0.0f,0.0f); glVertex3f(-10,-10,0); //Bas Gauche
90
glTexCoord2f(1.0f,0.0f); glVertex3f(10,-10,0); //Bas Droite
91
glTexCoord2f(1.0f,1.0f); glVertex3f(10,10,0); //Haut Droit
92
glTexCoord2f(0.0f,1.0f); glVertex3f(-10,10,0); //Haut Gauche
96
glTranslatef(0,size,0.0f);
98
glTexCoord2f(0.0f,0.0f); glVertex3f(-10,-10,0); //Bas Gauche
99
glTexCoord2f(1.0f,0.0f); glVertex3f(10,-10,0); //Bas Droite
100
glTexCoord2f(1.0f,1.0f); glVertex3f(10,10,0); //Haut Droit
101
glTexCoord2f(0.0f,1.0f); glVertex3f(-10,10,0); //Haut Gauche
104
glRotatef(-90,0,0,1);
105
glTranslatef(0, size,0.0f);
107
glTexCoord2f(0.0f,0.0f); glVertex3f(-10,-10,0); //Bas Gauche
108
glTexCoord2f(1.0f,0.0f); glVertex3f(10,-10,0); //Bas Droite
109
glTexCoord2f(1.0f,1.0f); glVertex3f(10,10,0); //Haut Droit
110
glTexCoord2f(0.0f,1.0f); glVertex3f(-10,10,0); //Haut Gauche
113
glRotatef(-90,0,0,1);
114
glTranslatef(0,size,0);
116
glTexCoord2f(0.0f,0.0f); glVertex3f(-10,-10,0); //Bas Gauche
117
glTexCoord2f(1.0f,0.0f); glVertex3f(10,-10,0); //Bas Droite
118
glTexCoord2f(1.0f,1.0f); glVertex3f(10,10,0); //Haut Droit
119
glTexCoord2f(0.0f,1.0f); glVertex3f(-10,10,0); //Haut Gauche
123
prj->reset_perspective_projection();
127
void StelObject::init_textures(void)
129
pointer_star = new s_texture("pointeur2.png");
130
pointer_planet = new s_texture("pointeur4.png");
131
pointer_nebula = new s_texture("pointeur5.png");
132
pointer_telescope = new s_texture("pointeur2.png");
135
void StelObject::delete_textures(void)
137
delete pointer_star; pointer_star = NULL;
138
delete pointer_planet; pointer_planet = NULL;
139
delete pointer_nebula; pointer_nebula = NULL;
140
delete pointer_telescope; pointer_telescope = NULL;