Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

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

File size: 2.9 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{
[3429]55  PRINTF(3)("Deleting the SkySphere\n");
[3420]56  delete skyMaterial;
[3419]57  free(sphereObj);
58}
[3411]59
[3419]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{
[3429]66  PRINTF(1)("initializing the Skysphere with Material %s.\n", fileName);
[3420]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);
[3422]74  this->skyMaterial->setAmbient(1.0, 1.0, 1.0);
[3411]75}
76
[3416]77/**
[3420]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/**
[3416]96   \brief updates the position of the Skysphere
[3450]97   \param sphereCenter The 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{
[3422]114  glEnable(GL_TEXTURE_2D);
[3420]115  skyMaterial->select();
[3419]116  glPushMatrix();
117  glTranslatef(this->sphereCenter.x,this->sphereCenter.y,this->sphereCenter.z);
118 
[3420]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);
[3419]122 
[3420]123  gluSphere(sphereObj, sphereRadius, 20, 20);
[3419]124  glPopMatrix();
[3422]125  glDisable(GL_TEXTURE_2D);
126
[3411]127}
Note: See TracBrowser for help on using the repository browser.