Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/planet.cc @ 10429

Last change on this file since 10429 was 10424, checked in by patrick, 18 years ago

more on planet atmos, fading and track

File size: 3.2 KB
RevLine 
[6524]1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: Patrick Boenzli
13   co-programmer: ...
14*/
15
16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
17
18#include "planet.h"
19
[7193]20#include "util/loading/load_param.h"
21#include "util/loading/factory.h"
[6524]22#include "static_model.h"
23
24#include "material.h"
25#include "texture.h"
26
27#include "network_game_manager.h"
28#include "converter.h"
[6695]29#include "vertex_array_model.h"
30#include "primitive_model.h"
[6524]31
[9869]32#include "debug.h"
[6524]33
[10114]34
35ObjectListDefinition(Planet);
[9869]36CREATE_FACTORY(Planet);
[6524]37
[9406]38
[6524]39/**
40 *  initializes a skybox from a XmlElement
41*/
42Planet::Planet(const TiXmlElement* root)
43{
[9869]44  this->registerObject(this, Planet::_objectList);
[6524]45  this->toList(OM_GROUP_01);
46
[10391]47  this->rotSpeedPlanet = 0.0;
48  this->rotSpeedCloud = 0.0;
[10392]49  this->bClouds = false;
[10391]50
[10387]51  //this->materialPlanet->setIllum(20);
52  //this->materialPlanet->setAmbient(0.1, 0.1, 0.1);
[6524]53
[10387]54  if( root != NULL)
55    this->loadParams(root);
[6695]56
[10387]57  PrimitiveModel* model = new PrimitiveModel(PRIM_SPHERE, this->size, 50);
58  this->setModel(model);
[6695]59
[10424]60  this->cloudModel = new PrimitiveModel(PRIM_SPHERE, this->size + 1, 50);
[6524]61}
62
63
64/**
65 *  default destructor
66*/
67Planet::~Planet()
68{
69  PRINTF(5)("Deleting Planet\n");
70}
71
72
73void Planet::loadParams(const TiXmlElement* root)
74{
[6696]75  WorldEntity::loadParams(root);
[6524]76
77  LoadParam(root, "texture", this, Planet, setTexture)
[10387]78      .describe("Sets the materialPlanet on the Planet. The string must be the path relative to the data-dir, and without a trailing .jpg");
[6524]79
[10387]80  LoadParam(root, "cloud-texture", this, Planet, setCloudTexture)
81      .describe("Sets the cloud texture of the planet");
82
[10391]83  LoadParam(root, "cloud-rotation", this, Planet, setCloudRotation)
84      .describe("Sets the cloud rotation speed");
85
[6524]86  LoadParam(root, "size", this, Planet, setSize)
87      .describe("Sets the Size of the Planet (normally this should be 90% of the maximal viewing Distance).");
88}
89
90
91/**
92 *  Defines which textures should be loaded onto the Planet.
93 * @param textureName the top texture.
94*/
[7221]95void Planet::setTexture(const std::string& textureName)
[6524]96{
[10387]97  this->materialPlanet.setDiffuseMap(textureName);
[6524]98}
99
100
101/**
[10387]102 *  Defines which textures should be loaded onto the Planet.
103 * @param textureName the top texture.
104*/
105void Planet::setCloudTexture(const std::string& textureName)
106{
107  this->materialCloud.setDiffuseMap(textureName);
[10392]108  this->bClouds = true;
[10387]109}
110
111
[10391]112void Planet::setCloudRotation(float rotationSpeed)
113{
114  this->rotSpeedCloud = rotationSpeed;
115}
116
[10387]117/**
[6524]118 * @param size The new size of the Planet
119
120 * do not forget to rebuild the Planet after this.
121*/
122void Planet::setSize(float size)
123{
124  this->size = size;
125}
126
127
[10391]128void Planet::tick( float dt)
129{
130  if( dt != 0.)
131    this->shiftDir( Quaternion( this->rotSpeedPlanet * dt, Vector(1,0,0)));
132}
[6524]133
[10391]134
135/**
136 * draws the planet
137 */
[6524]138void Planet::draw() const
139{
[10391]140  // draw the clouds
[10387]141  this->materialPlanet.select();
[10391]142  WorldEntity::draw();
[6524]143
[10392]144  if( this->bClouds)
145  {
146    glDisable(GL_LIGHTING);
147    this->materialCloud.select();
148    WorldEntity::draw(this->cloudModel);
149    glEnable(GL_LIGHTING);
150  }
[6524]151}
152
153
154
Note: See TracBrowser for help on using the repository browser.