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, 19 years ago

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

File size: 2.8 KB
RevLine 
[3411]1
[3416]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
[3421]14   co-programmer: Benjamin Grauer
[3416]15
[3421]16    Created by Dave: this file is actually quite similar to player.cc and so is
[3411]17    skybox.h similar to player.h
18    With that said, things should be clear:)
19
[3421]20    Edited by Bensch: more constructors, changeability, comments...
[3411]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
[3416]33/**
34   \brief Standart Constructor
35*/
[3411]36Skysphere::Skysphere()
37{ 
[3419]38  initialize("../data/pictures/sky-replace.jpg");
39}
[3411]40
[3419]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);
[3411]48}
49
[3416]50/**
51   \brief default destructor
52*/
[3411]53Skysphere::~Skysphere()
54{
[3420]55  delete skyMaterial;
[3419]56  free(sphereObj);
57}
[3411]58
[3419]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{
[3420]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);
[3411]73}
74
[3416]75/**
[3420]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/**
[3416]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
[3419]98   
[3416]99   This is normally done in the update-phase of world, so the Skysphere is always centered at the Camera.
100*/
[3419]101void Skysphere::updatePosition(Vector sphereCenter)
[3411]102{
[3419]103  this->sphereCenter = sphereCenter;
[3411]104}
105
[3416]106/**
107   \brief draws the Skysphere
[3419]108   
[3416]109   This part is normally precessed in the "Painting Phase".
110*/
[3419]111
[3411]112void Skysphere::draw()
113{
[3420]114  skyMaterial->select();
[3419]115  glPushMatrix();
116  glTranslatef(this->sphereCenter.x,this->sphereCenter.y,this->sphereCenter.z);
117 
[3420]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);
[3419]121 
[3420]122  gluSphere(sphereObj, sphereRadius, 20, 20);
[3419]123  glPopMatrix();
[3411]124}
125
126
Note: See TracBrowser for help on using the repository browser.