Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10406 was 10392, checked in by patrick, 18 years ago

better cloud options, clouds are optional now

File size: 3.2 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
32#include "debug.h"
33
34
35ObjectListDefinition(Planet);
36CREATE_FACTORY(Planet);
37
38
39/**
40 *  initializes a skybox from a XmlElement
41*/
42Planet::Planet(const TiXmlElement* root)
43{
44  this->registerObject(this, Planet::_objectList);
45  this->toList(OM_GROUP_01);
46
47  this->rotSpeedPlanet = 0.0;
48  this->rotSpeedCloud = 0.0;
49  this->bClouds = false;
50
51  //this->materialPlanet->setIllum(20);
52  //this->materialPlanet->setAmbient(0.1, 0.1, 0.1);
53
54  if( root != NULL)
55    this->loadParams(root);
56
57  PrimitiveModel* model = new PrimitiveModel(PRIM_SPHERE, this->size, 50);
58  this->setModel(model);
59
60  this->cloudModel = new PrimitiveModel(PRIM_SPHERE, this->size + 2, 50);
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, "cloud-texture", this, Planet, setCloudTexture)
81      .describe("Sets the cloud texture of the planet");
82
83  LoadParam(root, "cloud-rotation", this, Planet, setCloudRotation)
84      .describe("Sets the cloud rotation speed");
85
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*/
95void Planet::setTexture(const std::string& textureName)
96{
97  this->materialPlanet.setDiffuseMap(textureName);
98}
99
100
101/**
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);
108  this->bClouds = true;
109}
110
111
112void Planet::setCloudRotation(float rotationSpeed)
113{
114  this->rotSpeedCloud = rotationSpeed;
115}
116
117/**
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
128void Planet::tick( float dt)
129{
130  if( dt != 0.)
131    this->shiftDir( Quaternion( this->rotSpeedPlanet * dt, Vector(1,0,0)));
132}
133
134
135/**
136 * draws the planet
137 */
138void Planet::draw() const
139{
140  // draw the clouds
141  this->materialPlanet.select();
142  WorldEntity::draw();
143
144  if( this->bClouds)
145  {
146    glDisable(GL_LIGHTING);
147    this->materialCloud.select();
148    WorldEntity::draw(this->cloudModel);
149    glEnable(GL_LIGHTING);
150  }
151}
152
153
154
Note: See TracBrowser for help on using the repository browser.