Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 3420 was 3420, checked in by bensch, 19 years ago

orxonox/trunk: skysphere: some new functionality.
now size and texture can be set externaly, but also get a default value:
radius: 200.0
texture: "../data/pictures/sky-replace.jpg"

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: ...
15
16
17    Created by Dave, this file is actually quite similar to player.cc and so is
18    skybox.h similar to player.h
19    With that said, things should be clear:)
20
21
22
23*/
24
25#include "importer/material.h"
26#include "skysphere.h"
27#include "stdincl.h"
28#include "vector.h"
29#include "world_entity.h"
30
31
32using namespace std;
33
34/**
35   \brief Standart Constructor
36*/
37Skysphere::Skysphere()
38{ 
39  initialize("../data/pictures/sky-replace.jpg");
40}
41
42/**
43   \brief Constructs a SkySphere and takes fileName as a map.
44   \param fileName the file to take as input for the skysphere
45*/
46Skysphere::Skysphere(char* fileName)
47{
48  initialize(fileName);
49}
50
51/**
52   \brief default destructor
53*/
54Skysphere::~Skysphere()
55{
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  this->sphereObj = gluNewQuadric();
67  gluQuadricTexture(this->sphereObj, GL_TRUE);
68  this->setRadius(250.0);
69
70  this->skyMaterial = new Material("Sky");
71  this->setTexture(fileName);
72  this->skyMaterial->setIllum(3);
73  this->skyMaterial->setAmbient(.5, .5, 1.0);
74}
75
76/**
77   \brief sets the Radius of the Sphere.
78   \param radius The Radius of The Sphere
79*/
80void Skysphere::setRadius(float radius)
81{
82  this->sphereRadius = radius;
83}
84
85/**
86   \brief Defines which texture should be loaded onto the skysphere.
87   \param fileName The filename of the Texture
88*/
89void Skysphere::setTexture(char* fileName)
90{
91  this->skyMaterial->setDiffuseMap(fileName);
92}
93
94/**
95   \brief updates the position of the Skysphere
96   \param x the x-coordinate of the Center of the Sphere
97   \param y the y-coordinate of the Center of the Sphere
98   \param z the z-coordinate of the Center of the Sphere
99   
100   This is normally done in the update-phase of world, so the Skysphere is always centered at the Camera.
101*/
102void Skysphere::updatePosition(Vector sphereCenter)
103{
104  this->sphereCenter = sphereCenter;
105}
106
107/**
108   \brief draws the Skysphere
109   
110   This part is normally precessed in the "Painting Phase".
111*/
112
113void Skysphere::draw()
114{
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}
126
127
Note: See TracBrowser for help on using the repository browser.