~ubuntu-branches/debian/squeeze/stellarium/squeeze

« back to all changes in this revision

Viewing changes to src/stel_object.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Cédric Delfosse
  • Date: 2008-05-19 21:28:23 UTC
  • mfrom: (3.1.5 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080519212823-m5nfiuntxstxzxj7
Tags: 0.9.1-4
Add libxcursor-dev, libxfixes-dev, libxinerama-dev, libqt4-opengl-dev to
build-deps (Closes: #479906)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Stellarium
3
 
 * Copyright (C) 2002 Fabien Chereau
4
 
 *
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.
9
 
 *
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.
14
 
 *
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.
18
 
 */
19
 
 
20
 
#include "stellarium.h"
21
 
#include "stel_object.h"
22
 
#include "navigator.h"
23
 
#include "stel_utility.h"
24
 
#include "s_texture.h"
25
 
#include "planet.h"
26
 
 
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;
31
 
 
32
 
int StelObject::local_time = 0;
33
 
 
34
 
// Draw a nice animated pointer around the object
35
 
void StelObject::draw_pointer(int delta_time, const Projector* prj, const Navigator * nav)
36
 
{
37
 
        local_time+=delta_time;
38
 
        Vec3d pos=get_earth_equ_pos(nav);
39
 
        Vec3d screenpos;
40
 
        // Compute 2D pos and return if outside screen
41
 
        if (!prj->project_earth_equ(pos, screenpos)) return;
42
 
    prj->set_orthographic_projection();
43
 
 
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);
46
 
 
47
 
    if (get_type()==STEL_OBJECT_STAR||get_type()==STEL_OBJECT_TELESCOPE)
48
 
    {
49
 
                glColor3fv(get_RGB());
50
 
                float radius;
51
 
                if (get_type()==STEL_OBJECT_STAR) {
52
 
                        radius = 13.f;
53
 
                        glBindTexture (GL_TEXTURE_2D, pointer_star->getID());
54
 
                } else {
55
 
                        radius = 25.f;
56
 
                        glBindTexture (GL_TEXTURE_2D, pointer_telescope->getID());
57
 
                }
58
 
        glEnable(GL_TEXTURE_2D);
59
 
        glEnable(GL_BLEND);
60
 
        glTranslatef(screenpos[0], screenpos[1], 0.0f);
61
 
        glRotatef((float)local_time/20.,0.,0.,1.);
62
 
        glBegin(GL_QUADS );
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
67
 
        glEnd ();
68
 
    }
69
 
 
70
 
        float size = get_on_screen_size(prj, nav);
71
 
        size+=20.f;
72
 
        size+=10.f*sin(0.002f * local_time);
73
 
 
74
 
    if (get_type()==STEL_OBJECT_NEBULA || get_type()==STEL_OBJECT_PLANET)
75
 
    {
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());
80
 
 
81
 
        glEnable(GL_TEXTURE_2D);
82
 
        glEnable(GL_BLEND);
83
 
        glTranslatef(screenpos[0], screenpos[1], 0.0f);
84
 
        if (get_type()==STEL_OBJECT_PLANET) glRotatef((float)local_time/100,0,0,-1);
85
 
 
86
 
        glTranslatef(-size/2, -size/2,0.0f);
87
 
        glRotatef(90,0,0,1);
88
 
        glBegin(GL_QUADS );
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
93
 
        glEnd ();
94
 
 
95
 
        glRotatef(-90,0,0,1);
96
 
        glTranslatef(0,size,0.0f);
97
 
        glBegin(GL_QUADS );
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
102
 
        glEnd ();
103
 
 
104
 
        glRotatef(-90,0,0,1);
105
 
        glTranslatef(0, size,0.0f);
106
 
        glBegin(GL_QUADS );
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
111
 
        glEnd ();
112
 
 
113
 
        glRotatef(-90,0,0,1);
114
 
        glTranslatef(0,size,0);
115
 
        glBegin(GL_QUADS );
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
120
 
        glEnd ();
121
 
    }
122
 
 
123
 
    prj->reset_perspective_projection();
124
 
}
125
 
 
126
 
 
127
 
void StelObject::init_textures(void)
128
 
{
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");
133
 
}
134
 
 
135
 
void StelObject::delete_textures(void)
136
 
{
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;
141
 
}