Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10391 was 10391, checked in by patrick, 17 years ago

more on camera loading and many planet properties

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