Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 3532 was 3531, checked in by bensch, 21 years ago

orxonox/trunk: all WorldEntities/PWodes now destroy all date they alocate.

this is done with a virtual destructor:
if PNode is deleted it calls for the delete of the virtual destructor, and deletes the data of it.

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