Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10771 was 10653, checked in by snellen, 18 years ago

planet rotation now xml-loadable

File size: 3.7 KB
Line 
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
20#include "util/loading/load_param.h"
21#include "util/loading/factory.h"
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"
29#include "vertex_array_model.h"
30#include "primitive_model.h"
31#include "effects/billboard.h"
32
33#include "debug.h"
34
35
36ObjectListDefinition(Planet);
37CREATE_FACTORY(Planet);
38
39
40/**
41 *  initializes a skybox from a XmlElement
42*/
43Planet::Planet(const TiXmlElement* root)
44{
45  this->registerObject(this, Planet::_objectList);
46  this->toList(OM_GROUP_01);
47
48  this->rotSpeedPlanet = 0.0;
49  this->rotVecPlanet = Vector(0,1,0);
50  this->rotSpeedCloud = 0.0;
51  this->bClouds = false;
52
53  //this->materialPlanet->setIllum(20);
54  //this->materialPlanet->setAmbient(0.1, 0.1, 0.1);
55
56  if( root != NULL)
57    this->loadParams(root);
58
59  PrimitiveModel* model = new PrimitiveModel(PRIM_SPHERE, this->size, 50);
60  this->setModel(model);
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{
75  WorldEntity::loadParams(root);
76
77  LoadParam(root, "texture", this, Planet, setTexture)
78      .describe("Sets the materialPlanet on the Planet. The string must be the path relative to the data-dir, and without a trailing .jpg");
79
80    LoadParam(root, "size", this, Planet, setSize)
81      .describe("Sets the Size of the Planet (normally this should be 90% of the maximal viewing Distance).");
82
83  LoadParam(root, "cloud-texture", this, Planet, setCloudTexture)
84      .describe("Sets the cloud texture of the planet");
85
86  LoadParam(root, "cloud-rotation", this, Planet, setCloudRotation)
87      .describe("Sets the cloud rotation speed");
88 
89  LoadParam(root, "planet-rotation-speed", this, Planet, setPlanetRotationSpeed)
90      .describe("Sets the planet rotation speed");
91 
92  LoadParam(root, "planet-rotation-axis", this, Planet, setPlanetRotationAxis)
93      .describe("Sets the planet rotation axis");
94}
95
96
97/**
98 *  Defines which textures should be loaded onto the Planet.
99 * @param textureName the top texture.
100*/
101void Planet::setTexture(const std::string& textureName)
102{
103  this->materialPlanet.setDiffuseMap(textureName);
104}
105
106
107/**
108 *  Defines which textures should be loaded onto the Planet.
109 * @param textureName the top texture.
110*/
111void Planet::setCloudTexture(const std::string& textureName)
112{
113//   this->materialCloud.setDiffuseMap(textureName);
114//   this->halo = new Billboard();
115//   this->halo->setTexture( textureName);
116//   this->halo->setSize(this->size + 5, this->size + 5);
117//   this->halo->setParent( this);
118  this->bClouds = true;
119}
120
121
122void Planet::setCloudRotation(float rotationSpeed)
123{
124  this->rotSpeedCloud = rotationSpeed;
125}
126
127/**
128 * @param size The new size of the Planet
129
130 * do not forget to rebuild the Planet after this.
131*/
132void Planet::setSize(float size)
133{
134  this->size = size;
135}
136
137
138void Planet::tick( float dt)
139{
140  if( dt != 0.)
141    this->shiftDir( Quaternion( this->rotSpeedPlanet * dt, this->rotVecPlanet));
142}
143
144
145/**
146 * draws the planet
147 */
148void Planet::draw() const
149{
150  // draw the clouds
151  this->materialPlanet.select();
152  WorldEntity::draw();
153
154//   if( this->bClouds)
155//   {
156//     glDisable(GL_LIGHTING);
157//     this->materialCloud.select();
158//     WorldEntity::draw(this->cloudModel);
159//     glEnable(GL_LIGHTING);
160//   }
161}
162
163
164
Note: See TracBrowser for help on using the repository browser.