Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/skysphere.cc @ 3469

Last change on this file since 3469 was 3450, checked in by bensch, 20 years ago

orxonox/trunk: doxygen-tags: player.cc/h p_node.cc/h base_entity.h skysphere.cc/h

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