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 | this->destroy(); |
---|
60 | } |
---|
61 | |
---|
62 | void Skysphere::destroy(void) |
---|
63 | { |
---|
64 | |
---|
65 | PRINTF(3)("Deleting the SkySphere\n"); |
---|
66 | delete skyMaterial; |
---|
67 | free(sphereObj); |
---|
68 | |
---|
69 | static_cast<WorldEntity*>(this)->destroy(); |
---|
70 | } |
---|
71 | |
---|
72 | /** |
---|
73 | \brief initializes the Skysphere. |
---|
74 | \param fileName the file to take as input for the skysphere |
---|
75 | */ |
---|
76 | void Skysphere::initialize(char* fileName) |
---|
77 | { |
---|
78 | PRINTF(1)("initializing the Skysphere with Material %s.\n", fileName); |
---|
79 | this->sphereObj = gluNewQuadric(); |
---|
80 | gluQuadricTexture(this->sphereObj, GL_TRUE); |
---|
81 | this->setRadius(250.0); |
---|
82 | |
---|
83 | this->skyMaterial = new Material("Sky"); |
---|
84 | this->setTexture(fileName); |
---|
85 | this->skyMaterial->setIllum(3); |
---|
86 | this->skyMaterial->setAmbient(1.0, 1.0, 1.0); |
---|
87 | } |
---|
88 | |
---|
89 | |
---|
90 | /** |
---|
91 | \brief Defines which texture should be loaded onto the skysphere. |
---|
92 | \param fileName The filename of the Texture |
---|
93 | */ |
---|
94 | void Skysphere::setTexture(char* fileName) |
---|
95 | { |
---|
96 | this->skyMaterial->setDiffuseMap(fileName); |
---|
97 | } |
---|
98 | |
---|
99 | |
---|
100 | /** |
---|
101 | \brief draws the Skysphere |
---|
102 | |
---|
103 | This part is normally precessed in the "Painting Phase". |
---|
104 | */ |
---|
105 | void Skysphere::draw() |
---|
106 | { |
---|
107 | glPushMatrix(); |
---|
108 | glMatrixMode(GL_MODELVIEW); |
---|
109 | glTranslatef(this->absCoordinate.x, |
---|
110 | this->absCoordinate.y, |
---|
111 | this->absCoordinate.z); |
---|
112 | |
---|
113 | //glRotatef(-30, 1, 0, 0); |
---|
114 | //glRotatef(95.0f, 0.0f, 0.0f, 1.0f); |
---|
115 | //glRotatef(-250.0f, 0.0, 1.0f, 0.0f); |
---|
116 | |
---|
117 | skyMaterial->select(); |
---|
118 | gluSphere(sphereObj, sphereRadius, 20, 20); |
---|
119 | glPopMatrix(); |
---|
120 | } |
---|
121 | |
---|
122 | |
---|
123 | /** |
---|
124 | \brief sets the Radius of the Sphere. |
---|
125 | \param radius The Radius of The Sphere |
---|
126 | */ |
---|
127 | void Skysphere::setRadius(float radius) |
---|
128 | { |
---|
129 | this->sphereRadius = radius; |
---|
130 | } |
---|