Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/skysphere.cc @ 5396

Last change on this file since 5396 was 5313, checked in by bensch, 19 years ago

orxonox/trunk: minor nicessity fixes. no real bugs traced → :(

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