Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/blink/src/world_entities/planet.cc @ 10642

Last change on this file since 10642 was 10432, checked in by patrick, 18 years ago

more on planets. no atmo

File size: 3.5 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->rotSpeedCloud = 0.0;
50  this->bClouds = false;
51
52  //this->materialPlanet->setIllum(20);
53  //this->materialPlanet->setAmbient(0.1, 0.1, 0.1);
54
55  if( root != NULL)
56    this->loadParams(root);
57
58  PrimitiveModel* model = new PrimitiveModel(PRIM_SPHERE, this->size, 50);
59  this->setModel(model);
60
61  this->cloudModel = new PrimitiveModel(PRIM_SPHERE, this->size + 1, 50);
62}
63
64
65/**
66 *  default destructor
67*/
68Planet::~Planet()
69{
70  PRINTF(5)("Deleting Planet\n");
71}
72
73
74void Planet::loadParams(const TiXmlElement* root)
75{
76  WorldEntity::loadParams(root);
77
78  LoadParam(root, "texture", this, Planet, setTexture)
79      .describe("Sets the materialPlanet on the Planet. The string must be the path relative to the data-dir, and without a trailing .jpg");
80
81    LoadParam(root, "size", this, Planet, setSize)
82      .describe("Sets the Size of the Planet (normally this should be 90% of the maximal viewing Distance).");
83
84  LoadParam(root, "cloud-texture", this, Planet, setCloudTexture)
85      .describe("Sets the cloud texture of the planet");
86
87  LoadParam(root, "cloud-rotation", this, Planet, setCloudRotation)
88      .describe("Sets the cloud rotation speed");
89}
90
91
92/**
93 *  Defines which textures should be loaded onto the Planet.
94 * @param textureName the top texture.
95*/
96void Planet::setTexture(const std::string& textureName)
97{
98  this->materialPlanet.setDiffuseMap(textureName);
99}
100
101
102/**
103 *  Defines which textures should be loaded onto the Planet.
104 * @param textureName the top texture.
105*/
106void Planet::setCloudTexture(const std::string& textureName)
107{
108//   this->materialCloud.setDiffuseMap(textureName);
109//   this->halo = new Billboard();
110//   this->halo->setTexture( textureName);
111//   this->halo->setSize(this->size + 5, this->size + 5);
112//   this->halo->setParent( this);
113  this->bClouds = true;
114}
115
116
117void Planet::setCloudRotation(float rotationSpeed)
118{
119  this->rotSpeedCloud = rotationSpeed;
120}
121
122/**
123 * @param size The new size of the Planet
124
125 * do not forget to rebuild the Planet after this.
126*/
127void Planet::setSize(float size)
128{
129  this->size = size;
130}
131
132
133void Planet::tick( float dt)
134{
135  if( dt != 0.)
136    this->shiftDir( Quaternion( this->rotSpeedPlanet * dt, Vector(1,0,0)));
137}
138
139
140/**
141 * draws the planet
142 */
143void Planet::draw() const
144{
145  // draw the clouds
146  this->materialPlanet.select();
147  WorldEntity::draw();
148
149//   if( this->bClouds)
150//   {
151//     glDisable(GL_LIGHTING);
152//     this->materialCloud.select();
153//     WorldEntity::draw(this->cloudModel);
154//     glEnable(GL_LIGHTING);
155//   }
156}
157
158
159
Note: See TracBrowser for help on using the repository browser.