1 | |
---|
2 | /* |
---|
3 | orxonox - the future of 3D-vertical-scrollers |
---|
4 | |
---|
5 | Copyright (C) 2004 orx |
---|
6 | |
---|
7 | This program is free software; you can redistribute it and/or modify |
---|
8 | it under the terms of the GNU General Public License as published by |
---|
9 | the Free Software Foundation; either version 2, or (at your option) |
---|
10 | any later version. |
---|
11 | |
---|
12 | ### File Specific: |
---|
13 | main-programmer: David Gruetter |
---|
14 | co-programmer: Benjamin Grauer |
---|
15 | |
---|
16 | Created by Dave: this file is actually quite similar to player.cc and so is |
---|
17 | skybox.h similar to player.h |
---|
18 | With that said, things should be clear:) |
---|
19 | |
---|
20 | Edited: |
---|
21 | Bensch: more constructors, changeability, comments... |
---|
22 | Patrick: giving it the common orxonox style, not much to do... good work Dave! |
---|
23 | |
---|
24 | */ |
---|
25 | |
---|
26 | #include "material.h" |
---|
27 | #include "skysphere.h" |
---|
28 | #include "stdincl.h" |
---|
29 | #include "vector.h" |
---|
30 | #include "world_entity.h" |
---|
31 | |
---|
32 | |
---|
33 | using namespace std; |
---|
34 | |
---|
35 | /** |
---|
36 | \brief Standart Constructor |
---|
37 | */ |
---|
38 | Skysphere::Skysphere() |
---|
39 | { |
---|
40 | initialize("../data/pictures/sky-replace.jpg"); |
---|
41 | } |
---|
42 | |
---|
43 | |
---|
44 | /** |
---|
45 | \brief Constructs a SkySphere and takes fileName as a map. |
---|
46 | \param fileName the file to take as input for the skysphere |
---|
47 | */ |
---|
48 | Skysphere::Skysphere(char* fileName) |
---|
49 | { |
---|
50 | initialize(fileName); |
---|
51 | } |
---|
52 | |
---|
53 | |
---|
54 | /** |
---|
55 | \brief default destructor |
---|
56 | */ |
---|
57 | Skysphere::~Skysphere() |
---|
58 | { |
---|
59 | PRINTF(3)("Deleting the SkySphere\n"); |
---|
60 | delete this->skyMaterial; |
---|
61 | free(this->sphereObj); |
---|
62 | } |
---|
63 | |
---|
64 | /** |
---|
65 | \brief initializes the Skysphere. |
---|
66 | \param fileName the file to take as input for the skysphere |
---|
67 | */ |
---|
68 | void Skysphere::initialize(char* fileName) |
---|
69 | { |
---|
70 | PRINTF(1)("initializing the Skysphere with Material %s.\n", fileName); |
---|
71 | this->sphereObj = gluNewQuadric(); |
---|
72 | gluQuadricTexture(this->sphereObj, GL_TRUE); |
---|
73 | this->setRadius(250.0); |
---|
74 | |
---|
75 | this->skyMaterial = new Material("Sky"); |
---|
76 | this->setTexture(fileName); |
---|
77 | this->skyMaterial->setIllum(3); |
---|
78 | this->skyMaterial->setAmbient(1.0, 1.0, 1.0); |
---|
79 | } |
---|
80 | |
---|
81 | |
---|
82 | /** |
---|
83 | \brief Defines which texture should be loaded onto the skysphere. |
---|
84 | \param fileName The filename of the Texture |
---|
85 | */ |
---|
86 | void Skysphere::setTexture(char* fileName) |
---|
87 | { |
---|
88 | this->skyMaterial->setDiffuseMap(fileName); |
---|
89 | } |
---|
90 | |
---|
91 | |
---|
92 | /** |
---|
93 | \brief draws the Skysphere |
---|
94 | |
---|
95 | This part is normally precessed in the "Painting Phase". |
---|
96 | */ |
---|
97 | void Skysphere::draw() |
---|
98 | { |
---|
99 | glPushMatrix(); |
---|
100 | glMatrixMode(GL_MODELVIEW); |
---|
101 | glTranslatef(this->absCoordinate.x, |
---|
102 | this->absCoordinate.y, |
---|
103 | this->absCoordinate.z); |
---|
104 | |
---|
105 | //glRotatef(-30, 1, 0, 0); |
---|
106 | //glRotatef(95.0f, 0.0f, 0.0f, 1.0f); |
---|
107 | //glRotatef(-250.0f, 0.0, 1.0f, 0.0f); |
---|
108 | |
---|
109 | skyMaterial->select(); |
---|
110 | gluSphere(sphereObj, sphereRadius, 20, 20); |
---|
111 | glPopMatrix(); |
---|
112 | } |
---|
113 | |
---|
114 | |
---|
115 | /** |
---|
116 | \brief sets the Radius of the Sphere. |
---|
117 | \param radius The Radius of The Sphere |
---|
118 | */ |
---|
119 | void Skysphere::setRadius(float radius) |
---|
120 | { |
---|
121 | this->sphereRadius = radius; |
---|
122 | } |
---|