[3411] | 1 | |
---|
[3416] | 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 |
---|
[3421] | 14 | co-programmer: Benjamin Grauer |
---|
[3484] | 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! |
---|
[3416] | 23 | |
---|
[3411] | 24 | */ |
---|
| 25 | |
---|
[3590] | 26 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY |
---|
| 27 | |
---|
[3608] | 28 | |
---|
[3411] | 29 | #include "skysphere.h" |
---|
| 30 | #include "stdincl.h" |
---|
[3608] | 31 | |
---|
| 32 | #include "material.h" |
---|
[3411] | 33 | #include "vector.h" |
---|
[3608] | 34 | //#include "world_entity.h" |
---|
[3411] | 35 | |
---|
[3608] | 36 | |
---|
[3411] | 37 | using namespace std; |
---|
| 38 | |
---|
[3416] | 39 | /** |
---|
[3419] | 40 | \brief Constructs a SkySphere and takes fileName as a map. |
---|
| 41 | \param fileName the file to take as input for the skysphere |
---|
| 42 | */ |
---|
| 43 | Skysphere::Skysphere(char* fileName) |
---|
| 44 | { |
---|
[3763] | 45 | if (fileName == NULL) |
---|
| 46 | this->initialize("../data/pictures/sky-replace.jpg"); |
---|
| 47 | else |
---|
| 48 | this->initialize(fileName); |
---|
[3411] | 49 | } |
---|
| 50 | |
---|
[3507] | 51 | |
---|
[3416] | 52 | /** |
---|
| 53 | \brief default destructor |
---|
| 54 | */ |
---|
[3411] | 55 | Skysphere::~Skysphere() |
---|
| 56 | { |
---|
[3429] | 57 | PRINTF(3)("Deleting the SkySphere\n"); |
---|
[3544] | 58 | delete this->skyMaterial; |
---|
| 59 | free(this->sphereObj); |
---|
[3419] | 60 | } |
---|
[3411] | 61 | |
---|
[3419] | 62 | /** |
---|
| 63 | \brief initializes the Skysphere. |
---|
| 64 | \param fileName the file to take as input for the skysphere |
---|
| 65 | */ |
---|
| 66 | void Skysphere::initialize(char* fileName) |
---|
| 67 | { |
---|
[3429] | 68 | PRINTF(1)("initializing the Skysphere with Material %s.\n", fileName); |
---|
[3420] | 69 | this->sphereObj = gluNewQuadric(); |
---|
[3763] | 70 | this->setMode(PNODE_MOVEMENT); |
---|
| 71 | |
---|
[3420] | 72 | gluQuadricTexture(this->sphereObj, GL_TRUE); |
---|
[3566] | 73 | this->setRadius(1900.0); |
---|
[3420] | 74 | |
---|
| 75 | this->skyMaterial = new Material("Sky"); |
---|
| 76 | this->setTexture(fileName); |
---|
| 77 | this->skyMaterial->setIllum(3); |
---|
[3422] | 78 | this->skyMaterial->setAmbient(1.0, 1.0, 1.0); |
---|
[3411] | 79 | } |
---|
| 80 | |
---|
[3484] | 81 | |
---|
[3416] | 82 | /** |
---|
[3420] | 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 | |
---|
[3484] | 91 | |
---|
[3420] | 92 | /** |
---|
[3416] | 93 | \brief draws the Skysphere |
---|
[3419] | 94 | |
---|
[3416] | 95 | This part is normally precessed in the "Painting Phase". |
---|
| 96 | */ |
---|
[3411] | 97 | void Skysphere::draw() |
---|
| 98 | { |
---|
[3419] | 99 | glPushMatrix(); |
---|
[3526] | 100 | glMatrixMode(GL_MODELVIEW); |
---|
[3607] | 101 | Vector r = this->getAbsCoor(); |
---|
| 102 | glTranslatef(r.x, r.y, r.z); |
---|
[3502] | 103 | |
---|
[3507] | 104 | //glRotatef(-30, 1, 0, 0); |
---|
| 105 | //glRotatef(95.0f, 0.0f, 0.0f, 1.0f); |
---|
| 106 | //glRotatef(-250.0f, 0.0, 1.0f, 0.0f); |
---|
[3419] | 107 | |
---|
[3526] | 108 | skyMaterial->select(); |
---|
[3586] | 109 | gluSphere(this->sphereObj, this->sphereRadius, 20, 20); |
---|
[3419] | 110 | glPopMatrix(); |
---|
[3411] | 111 | } |
---|
[3507] | 112 | |
---|
| 113 | |
---|
| 114 | /** |
---|
| 115 | \brief sets the Radius of the Sphere. |
---|
| 116 | \param radius The Radius of The Sphere |
---|
| 117 | */ |
---|
| 118 | void Skysphere::setRadius(float radius) |
---|
| 119 | { |
---|
| 120 | this->sphereRadius = radius; |
---|
| 121 | } |
---|