Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 8036 was 7840, checked in by bensch, 18 years ago

trunk: Elements that are supposed to be on the Background stay there:

Changed:
Element2D: render from - to - LAYERS
Render2D: Renders from - to - LAYERS
GraphicsEngine: new function drawBackgroundElements
ObjectManager: new List OM_BACKGROUND
Skybox/sphere: in OM_LIST OM_BACKGROUND

@patrick: do you like it too ??

File size: 2.7 KB
Line 
1/*
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
13   co-programmer: Benjamin Grauer
14
15   Created by Dave: this file is actually quite similar to player.cc and so is
16   skybox.h similar to player.h
17   With that said, things should be clear:)
18
19   Edited:
20   Bensch: more constructors, changeability, comments...
21   Patrick: giving it the common orxonox style, not much to do... good work Dave!
22
23*/
24
25#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
26
27
28#include "skysphere.h"
29#include "stdincl.h"
30
31#include "material.h"
32#include "debug.h"
33
34
35using namespace std;
36
37/**
38 *  Constructs a SkySphere and takes fileName as a map.
39 * @param fileName the file to take as input for the skysphere
40*/
41Skysphere::Skysphere(char* fileName)
42{
43  this->setClassID(CL_SKYSPHERE, "SkySphere");
44  this->toList(OM_BACKGROUND);
45  if (fileName == NULL)
46    this->initialize("pictures/sky-replace.jpg");
47  else
48    this->initialize(fileName);
49}
50
51
52/**
53 *  default destructor
54*/
55Skysphere::~Skysphere()
56{
57  PRINTF(3)("Deleting the SkySphere\n");
58  delete this->skyMaterial;
59  gluDeleteQuadric(this->sphereObj);
60}
61
62/**
63 *  initializes the Skysphere.
64 * @param fileName the file to take as input for the skysphere
65*/
66void Skysphere::initialize(char* fileName)
67{
68  PRINTF(1)("initializing the Skysphere with Material %s.\n", fileName);
69  this->sphereObj = gluNewQuadric();
70  this->setParentMode(PNODE_MOVEMENT);
71
72  gluQuadricTexture(this->sphereObj, GL_TRUE);
73  this->setRadius(1900.0);
74
75  this->skyMaterial = new Material("Sky");
76  this->setTexture(fileName);
77  this->skyMaterial->setIllum(3);
78  this->skyMaterial->setAmbient(1.0, 1.0, 1.0);
79}
80
81
82/**
83 *  Defines which texture should be loaded onto the skysphere.
84 * @param fileName The filename of the Texture
85*/
86void Skysphere::setTexture(char* fileName)
87{
88  this->skyMaterial->setDiffuseMap(fileName);
89}
90
91
92/**
93 *  draws the Skysphere
94
95   This part is normally precessed in the "Painting Phase".
96*/
97void Skysphere::draw() const
98{
99  glMatrixMode(GL_MODELVIEW);
100  glPushMatrix();
101
102  Vector r = this->getAbsCoor();
103  glTranslatef(r.x, r.y, r.z);
104
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);
108
109  skyMaterial->select();
110  gluSphere(this->sphereObj, this->sphereRadius, 20, 20);
111  glPopMatrix();
112}
113
114
115/**
116 *  sets the Radius of the Sphere.
117 * @param radius The Radius of The Sphere
118*/
119void Skysphere::setRadius(float radius)
120{
121  this->sphereRadius = radius;
122}
Note: See TracBrowser for help on using the repository browser.