Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10049 was 9869, checked in by bensch, 18 years ago

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

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"
[3608]29
30#include "material.h"
[5511]31#include "debug.h"
[3411]32
[3608]33
[9869]34ObjectListDefinition(Skysphere);
[3411]35
[3416]36/**
[4836]37 *  Constructs a SkySphere and takes fileName as a map.
38 * @param fileName the file to take as input for the skysphere
[3419]39*/
40Skysphere::Skysphere(char* fileName)
41{
[9869]42  this->registerObject(this, Skysphere::_objectList);
[7840]43  this->toList(OM_BACKGROUND);
[3763]44  if (fileName == NULL)
[4094]45    this->initialize("pictures/sky-replace.jpg");
[3763]46  else
47    this->initialize(fileName);
[3411]48}
49
[3507]50
[3416]51/**
[4836]52 *  default destructor
[3416]53*/
[3411]54Skysphere::~Skysphere()
55{
[3429]56  PRINTF(3)("Deleting the SkySphere\n");
[3544]57  delete this->skyMaterial;
[5313]58  gluDeleteQuadric(this->sphereObj);
[3419]59}
[3411]60
[3419]61/**
[4836]62 *  initializes the Skysphere.
63 * @param fileName the file to take as input for the skysphere
[3419]64*/
65void Skysphere::initialize(char* fileName)
66{
[3429]67  PRINTF(1)("initializing the Skysphere with Material %s.\n", fileName);
[3420]68  this->sphereObj = gluNewQuadric();
[4444]69  this->setParentMode(PNODE_MOVEMENT);
[3763]70
[3420]71  gluQuadricTexture(this->sphereObj, GL_TRUE);
[3566]72  this->setRadius(1900.0);
[3420]73
74  this->skyMaterial = new Material("Sky");
75  this->setTexture(fileName);
76  this->skyMaterial->setIllum(3);
[3422]77  this->skyMaterial->setAmbient(1.0, 1.0, 1.0);
[3411]78}
79
[3484]80
[3416]81/**
[4836]82 *  Defines which texture should be loaded onto the skysphere.
83 * @param fileName The filename of the Texture
[3420]84*/
85void Skysphere::setTexture(char* fileName)
86{
87  this->skyMaterial->setDiffuseMap(fileName);
88}
89
[3484]90
[3420]91/**
[4836]92 *  draws the Skysphere
[4597]93
[3416]94   This part is normally precessed in the "Painting Phase".
95*/
[5500]96void Skysphere::draw() const
[3411]97{
[6778]98  glMatrixMode(GL_MODELVIEW);
[3419]99  glPushMatrix();
[6778]100
[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);
[4597]107
[3526]108  skyMaterial->select();
[3586]109  gluSphere(this->sphereObj, this->sphereRadius, 20, 20);
[3419]110  glPopMatrix();
[3411]111}
[3507]112
113
114/**
[4836]115 *  sets the Radius of the Sphere.
116 * @param radius The Radius of The Sphere
[3507]117*/
118void Skysphere::setRadius(float radius)
119{
120  this->sphereRadius = radius;
121}
Note: See TracBrowser for help on using the repository browser.