Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: Makefile-fix (do not know if it works)

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 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  delete skyMaterial;
56  free(sphereObj);
57}
58
59/**
60   \brief initializes the Skysphere.
61   \param fileName the file to take as input for the skysphere
62*/
63void Skysphere::initialize(char* fileName)
64{
65  this->sphereObj = gluNewQuadric();
66  gluQuadricTexture(this->sphereObj, GL_TRUE);
67  this->setRadius(250.0);
68
69  this->skyMaterial = new Material("Sky");
70  this->setTexture(fileName);
71  this->skyMaterial->setIllum(3);
72  this->skyMaterial->setAmbient(.5, .5, 1.0);
73}
74
75/**
76   \brief sets the Radius of the Sphere.
77   \param radius The Radius of The Sphere
78*/
79void Skysphere::setRadius(float radius)
80{
81  this->sphereRadius = radius;
82}
83
84/**
85   \brief Defines which texture should be loaded onto the skysphere.
86   \param fileName The filename of the Texture
87*/
88void Skysphere::setTexture(char* fileName)
89{
90  this->skyMaterial->setDiffuseMap(fileName);
91}
92
93/**
94   \brief updates the position of the Skysphere
95   \param x the x-coordinate of the Center of the Sphere
96   \param y the y-coordinate of the Center of the Sphere
97   \param z the z-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  skyMaterial->select();
115  glPushMatrix();
116  glTranslatef(this->sphereCenter.x,this->sphereCenter.y,this->sphereCenter.z);
117 
118  glRotatef(-30, 1, 0, 0);
119  glRotatef(95.0f, 0.0f, 0.0f, 1.0f);
120  glRotatef(-250.0f, 0.0, 1.0f, 0.0f);
121 
122  gluSphere(sphereObj, sphereRadius, 20, 20);
123  glPopMatrix();
124}
125
126
Note: See TracBrowser for help on using the repository browser.