[3411] | 1 | |
---|
[4597] | 2 | /* |
---|
[3416] | 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 |
---|
[4597] | 15 | |
---|
| 16 | Created by Dave: this file is actually quite similar to player.cc and so is |
---|
[3484] | 17 | skybox.h similar to player.h |
---|
| 18 | With that said, things should be clear:) |
---|
[4597] | 19 | |
---|
[3484] | 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 | /** |
---|
[4836] | 40 | * Constructs a SkySphere and takes fileName as a map. |
---|
| 41 | * @param fileName the file to take as input for the skysphere |
---|
[3419] | 42 | */ |
---|
| 43 | Skysphere::Skysphere(char* fileName) |
---|
| 44 | { |
---|
[4597] | 45 | this->setClassID(CL_SKYSPHERE, "SkySphere"); |
---|
| 46 | |
---|
[3763] | 47 | if (fileName == NULL) |
---|
[4094] | 48 | this->initialize("pictures/sky-replace.jpg"); |
---|
[3763] | 49 | else |
---|
| 50 | this->initialize(fileName); |
---|
[3411] | 51 | } |
---|
| 52 | |
---|
[3507] | 53 | |
---|
[3416] | 54 | /** |
---|
[4836] | 55 | * default destructor |
---|
[3416] | 56 | */ |
---|
[3411] | 57 | Skysphere::~Skysphere() |
---|
| 58 | { |
---|
[3429] | 59 | PRINTF(3)("Deleting the SkySphere\n"); |
---|
[3544] | 60 | delete this->skyMaterial; |
---|
| 61 | free(this->sphereObj); |
---|
[3419] | 62 | } |
---|
[3411] | 63 | |
---|
[3419] | 64 | /** |
---|
[4836] | 65 | * initializes the Skysphere. |
---|
| 66 | * @param fileName the file to take as input for the skysphere |
---|
[3419] | 67 | */ |
---|
| 68 | void Skysphere::initialize(char* fileName) |
---|
| 69 | { |
---|
[3429] | 70 | PRINTF(1)("initializing the Skysphere with Material %s.\n", fileName); |
---|
[3420] | 71 | this->sphereObj = gluNewQuadric(); |
---|
[4444] | 72 | this->setParentMode(PNODE_MOVEMENT); |
---|
[3763] | 73 | |
---|
[3420] | 74 | gluQuadricTexture(this->sphereObj, GL_TRUE); |
---|
[3566] | 75 | this->setRadius(1900.0); |
---|
[3420] | 76 | |
---|
| 77 | this->skyMaterial = new Material("Sky"); |
---|
| 78 | this->setTexture(fileName); |
---|
| 79 | this->skyMaterial->setIllum(3); |
---|
[3422] | 80 | this->skyMaterial->setAmbient(1.0, 1.0, 1.0); |
---|
[3411] | 81 | } |
---|
| 82 | |
---|
[3484] | 83 | |
---|
[3416] | 84 | /** |
---|
[4836] | 85 | * Defines which texture should be loaded onto the skysphere. |
---|
| 86 | * @param fileName The filename of the Texture |
---|
[3420] | 87 | */ |
---|
| 88 | void Skysphere::setTexture(char* fileName) |
---|
| 89 | { |
---|
| 90 | this->skyMaterial->setDiffuseMap(fileName); |
---|
| 91 | } |
---|
| 92 | |
---|
[3484] | 93 | |
---|
[3420] | 94 | /** |
---|
[4836] | 95 | * draws the Skysphere |
---|
[4597] | 96 | |
---|
[3416] | 97 | This part is normally precessed in the "Painting Phase". |
---|
| 98 | */ |
---|
[3411] | 99 | void Skysphere::draw() |
---|
| 100 | { |
---|
[3419] | 101 | glPushMatrix(); |
---|
[3526] | 102 | glMatrixMode(GL_MODELVIEW); |
---|
[3607] | 103 | Vector r = this->getAbsCoor(); |
---|
| 104 | glTranslatef(r.x, r.y, r.z); |
---|
[3502] | 105 | |
---|
[3507] | 106 | //glRotatef(-30, 1, 0, 0); |
---|
| 107 | //glRotatef(95.0f, 0.0f, 0.0f, 1.0f); |
---|
| 108 | //glRotatef(-250.0f, 0.0, 1.0f, 0.0f); |
---|
[4597] | 109 | |
---|
[3526] | 110 | skyMaterial->select(); |
---|
[3586] | 111 | gluSphere(this->sphereObj, this->sphereRadius, 20, 20); |
---|
[3419] | 112 | glPopMatrix(); |
---|
[3411] | 113 | } |
---|
[3507] | 114 | |
---|
| 115 | |
---|
| 116 | /** |
---|
[4836] | 117 | * sets the Radius of the Sphere. |
---|
| 118 | * @param radius The Radius of The Sphere |
---|
[3507] | 119 | */ |
---|
| 120 | void Skysphere::setRadius(float radius) |
---|
| 121 | { |
---|
| 122 | this->sphereRadius = radius; |
---|
| 123 | } |
---|