Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/scriptimprovements/src/world_entities/planet.cc @ 10613

Last change on this file since 10613 was 10473, checked in by patrick, 18 years ago

more cameara bugs fixed

File size: 3.4 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
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, "size", this, Planet, setSize)
80      .describe("Sets the Size of the Planet (normally this should be 90% of the maximal viewing Distance).");
81
82  LoadParam(root, "cloud-texture", this, Planet, setCloudTexture)
83      .describe("Sets the cloud texture of the planet");
84
85  LoadParam(root, "cloud-rotation", this, Planet, setCloudRotation)
86      .describe("Sets the cloud rotation speed");
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//   this->halo = new Billboard();
108//   this->halo->setTexture( textureName);
109//   this->halo->setSize(this->size + 5, this->size + 5);
110//   this->halo->setParent( this);
111  this->bClouds = true;
112}
113
114
115void Planet::setCloudRotation(float rotationSpeed)
116{
117  this->rotSpeedCloud = rotationSpeed;
118}
119
120/**
121 * @param size The new size of the Planet
122
123 * do not forget to rebuild the Planet after this.
124*/
125void Planet::setSize(float size)
126{
127  this->size = size;
128}
129
130
131void Planet::tick( float dt)
132{
133  if( dt != 0.)
134    this->shiftDir( Quaternion( this->rotSpeedPlanet * dt, Vector(1,0,0)));
135}
136
137
138/**
139 * draws the planet
140 */
141void Planet::draw() const
142{
143  // draw the clouds
144  this->materialPlanet.select();
145  WorldEntity::draw();
146
147//   if( this->bClouds)
148//   {
149//     glDisable(GL_LIGHTING);
150//     this->materialCloud.select();
151//     WorldEntity::draw(this->cloudModel);
152//     glEnable(GL_LIGHTING);
153//   }
154}
155
156
157
Note: See TracBrowser for help on using the repository browser.