Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 4721 was 4597, checked in by bensch, 20 years ago

orxonox/trunk: setClassID implemented in all files

File size: 2.7 KB
Line 
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 "skysphere.h"
30#include "stdincl.h"
31
32#include "material.h"
33#include "vector.h"
34//#include "world_entity.h"
35
36
37using namespace std;
38
39/**
40   \brief Constructs a SkySphere and takes fileName as a map.
41   \param fileName the file to take as input for the skysphere
42*/
43Skysphere::Skysphere(char* fileName)
44{
45  this->setClassID(CL_SKYSPHERE, "SkySphere");
46
47  if (fileName == NULL)
48    this->initialize("pictures/sky-replace.jpg");
49  else
50    this->initialize(fileName);
51}
52
53
54/**
55   \brief default destructor
56*/
57Skysphere::~Skysphere()
58{
59  PRINTF(3)("Deleting the SkySphere\n");
60  delete this->skyMaterial;
61  free(this->sphereObj);
62}
63
64/**
65   \brief initializes the Skysphere.
66   \param fileName the file to take as input for the skysphere
67*/
68void Skysphere::initialize(char* fileName)
69{
70  PRINTF(1)("initializing the Skysphere with Material %s.\n", fileName);
71  this->sphereObj = gluNewQuadric();
72  this->setParentMode(PNODE_MOVEMENT);
73
74  gluQuadricTexture(this->sphereObj, GL_TRUE);
75  this->setRadius(1900.0);
76
77  this->skyMaterial = new Material("Sky");
78  this->setTexture(fileName);
79  this->skyMaterial->setIllum(3);
80  this->skyMaterial->setAmbient(1.0, 1.0, 1.0);
81}
82
83
84/**
85   \brief Defines which texture should be loaded onto the skysphere.
86   \param fileName The filename of the Texture
87*/
88void Skysphere::setTexture(char* fileName)
89{
90  this->skyMaterial->setDiffuseMap(fileName);
91}
92
93
94/**
95   \brief draws the Skysphere
96
97   This part is normally precessed in the "Painting Phase".
98*/
99void Skysphere::draw()
100{
101  glPushMatrix();
102  glMatrixMode(GL_MODELVIEW);
103  Vector r = this->getAbsCoor();
104  glTranslatef(r.x, r.y, r.z);
105
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);
109
110  skyMaterial->select();
111  gluSphere(this->sphereObj, this->sphereRadius, 20, 20);
112  glPopMatrix();
113}
114
115
116/**
117   \brief sets the Radius of the Sphere.
118   \param radius The Radius of The Sphere
119*/
120void Skysphere::setRadius(float radius)
121{
122  this->sphereRadius = radius;
123}
Note: See TracBrowser for help on using the repository browser.