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 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY |
---|
27 | |
---|
28 | |
---|
29 | #include "skybox.h" |
---|
30 | #include "stdincl.h" |
---|
31 | |
---|
32 | #include "material.h" |
---|
33 | #include "vector.h" |
---|
34 | #include "resource_manager.h" |
---|
35 | #include "model.h" |
---|
36 | //#include "world_entity.h" |
---|
37 | |
---|
38 | |
---|
39 | using namespace std; |
---|
40 | |
---|
41 | /** |
---|
42 | \brief Constructs a SkyBox and takes fileName as a map. |
---|
43 | \param fileName the file to take as input for the SkyBox |
---|
44 | */ |
---|
45 | SkyBox::SkyBox(char* fileName) |
---|
46 | { |
---|
47 | this->setClassName("SkyBox"); |
---|
48 | |
---|
49 | |
---|
50 | this->model = (Model*)ResourceManager::getInstance()->load("cube", PRIM, RP_LEVEL); |
---|
51 | this->setMode(PNODE_MOVEMENT); |
---|
52 | |
---|
53 | this->setSize(1900.0); |
---|
54 | |
---|
55 | this->material = new Material("Sky"); |
---|
56 | if (fileName) |
---|
57 | this->setTexture(fileName); |
---|
58 | this->material->setIllum(3); |
---|
59 | this->material->setAmbient(1.0, 1.0, 1.0); |
---|
60 | |
---|
61 | } |
---|
62 | |
---|
63 | |
---|
64 | /** |
---|
65 | \brief default destructor |
---|
66 | */ |
---|
67 | SkyBox::~SkyBox() |
---|
68 | { |
---|
69 | PRINTF(3)("Deleting the SkyBox\n"); |
---|
70 | delete this->material; |
---|
71 | } |
---|
72 | |
---|
73 | |
---|
74 | /** |
---|
75 | \brief Defines which texture should be loaded onto the SkyBox. |
---|
76 | \param fileName The filename of the Texture |
---|
77 | */ |
---|
78 | void SkyBox::setTexture(char* fileName) |
---|
79 | { |
---|
80 | this->material->setDiffuseMap(fileName); |
---|
81 | } |
---|
82 | |
---|
83 | |
---|
84 | /** |
---|
85 | \brief draws the SkyBox |
---|
86 | |
---|
87 | This part is normally precessed in the "Painting Phase". |
---|
88 | */ |
---|
89 | void SkyBox::draw() |
---|
90 | { |
---|
91 | glPushMatrix(); |
---|
92 | glMatrixMode(GL_MODELVIEW); |
---|
93 | Vector r = this->getAbsCoor(); |
---|
94 | glTranslatef(r.x, r.y, r.z); |
---|
95 | |
---|
96 | this->material->select(); |
---|
97 | |
---|
98 | this->model->draw(); |
---|
99 | |
---|
100 | glPopMatrix(); |
---|
101 | } |
---|
102 | |
---|
103 | |
---|
104 | /** |
---|
105 | \brief sets the Radius of the Sphere. |
---|
106 | \param radius The Radius of The Sphere |
---|
107 | */ |
---|
108 | void SkyBox::setSize(float size) |
---|
109 | { |
---|
110 | this->size = size; |
---|
111 | } |
---|