File: sun.c

package info (click to toggle)
ssystem 1.6-17
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny
  • size: 1,452 kB
  • ctags: 211
  • sloc: ansic: 2,487; yacc: 227; makefile: 96; lex: 89
file content (52 lines) | stat: -rw-r--r-- 1,642 bytes parent folder | download | duplicates (4)
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
/*
    ssystem 1.6
    Copyright (C) 1997-1999  Raul Alonso <amil@las.es>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include "ssystem.h"

void SunBillBoard( void )
{
 double x[4],y[4],z[4];
 double alfa,beta;
 int i;
 
#define SIZE RADIUSSCALE(109.0)
 
 x[0]=x[3]=y[0]=y[1]=SIZE;
 x[1]=x[2]=y[2]=y[3]=-SIZE;
 z[0]=z[1]=z[2]=z[3]=0.0;

/* BILLBOARDING effect, rotates sun tile so it shows always the same face and
   angle to camera */
 alfa=atan2(camz,camx)-PI/2.0;
 beta=atan2(camy,sqrt(camx*camx+camz*camz));
 for (i=0;i<4;i++) {
	Rotation(beta,1.0,0.0,0.0,&x[i],&y[i],&z[i]);
 	Rotation(alfa,0.0,1.0,0.0,&x[i],&y[i],&z[i]);
 } 	
 
 glEnable(GL_BLEND);
 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
 glBegin(GL_QUADS);
 glTexCoord2f(0.0,0.0);  glVertex3f(x[0],y[0],z[0]);
 glTexCoord2f(0.0,1.0);  glVertex3f(x[1],y[1],z[1]); 
 glTexCoord2f(1.0,1.0);  glVertex3f(x[2],y[2],z[2]); 
 glTexCoord2f(1.0,0.0);  glVertex3f(x[3],y[3],z[3]); 
 glEnd();
 glDisable(GL_BLEND);
}