Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 3517 was 3498, checked in by bensch, 20 years ago

orxonox/branches/trackManager: merged trunk back to tracManager R3440:3497 → 3498
merged with command:
svn merge ../trunk/ trackManager/ -r 3430:HEAD
conflicts resolved in favor of the Trunk

File size: 2.9 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   \brief Constructs a SkySphere and takes fileName as a map.
45   \param fileName the file to take as input for the skysphere
46*/
47Skysphere::Skysphere(char* fileName)
48{
49  initialize(fileName);
50}
51
52/**
53   \brief default destructor
54*/
55Skysphere::~Skysphere()
56{
57  PRINTF(3)("Deleting the SkySphere\n");
58  delete skyMaterial;
59  free(sphereObj);
60}
61
62/**
63   \brief 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  gluQuadricTexture(this->sphereObj, GL_TRUE);
71  this->setRadius(250.0);
72
73  this->skyMaterial = new Material("Sky");
74  this->setTexture(fileName);
75  this->skyMaterial->setIllum(3);
76  this->skyMaterial->setAmbient(1.0, 1.0, 1.0);
77}
78
79
80/**
81   \brief sets the Radius of the Sphere.
82   \param radius The Radius of The Sphere
83*/
84void Skysphere::setRadius(float radius)
85{
86  this->sphereRadius = radius;
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 updates the position of the Skysphere
102   \param sphereCenter The coordinate of the Center of the Sphere
103   
104   This is normally done in the update-phase of world, so the Skysphere is always centered at the Camera.
105*/
106void Skysphere::updatePosition(Vector sphereCenter)
107{
108  this->sphereCenter = sphereCenter;
109}
110
111
112/**
113   \brief draws the Skysphere
114   
115   This part is normally precessed in the "Painting Phase".
116*/
117void Skysphere::draw()
118{
119  glEnable(GL_TEXTURE_2D);
120  skyMaterial->select();
121  glPushMatrix();
122  glTranslatef(this->sphereCenter.x,this->sphereCenter.y,this->sphereCenter.z);
123 
124  glRotatef(-30, 1, 0, 0);
125  glRotatef(95.0f, 0.0f, 0.0f, 1.0f);
126  glRotatef(-250.0f, 0.0, 1.0f, 0.0f);
127 
128  gluSphere(sphereObj, sphereRadius, 20, 20);
129  glPopMatrix();
130  glDisable(GL_TEXTURE_2D);
131}
Note: See TracBrowser for help on using the repository browser.