Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/trackManager/src/world_entities/skysphere.cc @ 3542

Last change on this file since 3542 was 3519, checked in by bensch, 20 years ago

orxonox/branches/trackManager: merged trunk back to trackManager (again)
merged with command:
svn merge ../trunk/ trackManager/ -r 3498:HEAD
no conflicts

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#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  PRINTF(3)("Deleting the SkySphere\n");
60  delete skyMaterial;
61  free(sphereObj);
62}
63
64
65/**
66   \brief initializes the Skysphere.
67   \param fileName the file to take as input for the skysphere
68*/
69void Skysphere::initialize(char* fileName)
70{
71  PRINTF(1)("initializing the Skysphere with Material %s.\n", fileName);
72  this->sphereObj = gluNewQuadric();
73  gluQuadricTexture(this->sphereObj, GL_TRUE);
74  this->setRadius(250.0);
75
76  this->skyMaterial = new Material("Sky");
77  this->setTexture(fileName);
78  this->skyMaterial->setIllum(3);
79  this->skyMaterial->setAmbient(1.0, 1.0, 1.0);
80}
81
82
83/**
84   \brief Defines which texture should be loaded onto the skysphere.
85   \param fileName The filename of the Texture
86*/
87void Skysphere::setTexture(char* fileName)
88{
89  this->skyMaterial->setDiffuseMap(fileName);
90}
91
92
93/**
94   \brief draws the Skysphere
95   
96   This part is normally precessed in the "Painting Phase".
97*/
98void Skysphere::draw()
99{
100  glEnable(GL_TEXTURE_2D);
101  skyMaterial->select();
102  glPushMatrix();
103  glTranslatef(this->absCoordinate.x,
104               this->absCoordinate.y,
105               this->absCoordinate.z);
106
107  //glRotatef(-30, 1, 0, 0);
108  //glRotatef(95.0f, 0.0f, 0.0f, 1.0f);
109  //glRotatef(-250.0f, 0.0, 1.0f, 0.0f);
110 
111  gluSphere(sphereObj, sphereRadius, 20, 20);
112  glPopMatrix();
113  glDisable(GL_TEXTURE_2D);
114}
115
116
117/**
118   \brief sets the Radius of the Sphere.
119   \param radius The Radius of The Sphere
120*/
121void Skysphere::setRadius(float radius)
122{
123  this->sphereRadius = radius;
124}
Note: See TracBrowser for help on using the repository browser.