Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

planet rotation now xml-loadable

File size: 3.7 KB
RevLine 
[6524]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
[7193]20#include "util/loading/load_param.h"
21#include "util/loading/factory.h"
[6524]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"
[6695]29#include "vertex_array_model.h"
30#include "primitive_model.h"
[10432]31#include "effects/billboard.h"
[6524]32
[9869]33#include "debug.h"
[6524]34
[10114]35
36ObjectListDefinition(Planet);
[9869]37CREATE_FACTORY(Planet);
[6524]38
[9406]39
[6524]40/**
41 *  initializes a skybox from a XmlElement
42*/
43Planet::Planet(const TiXmlElement* root)
44{
[9869]45  this->registerObject(this, Planet::_objectList);
[6524]46  this->toList(OM_GROUP_01);
47
[10391]48  this->rotSpeedPlanet = 0.0;
[10653]49  this->rotVecPlanet = Vector(0,1,0);
[10391]50  this->rotSpeedCloud = 0.0;
[10392]51  this->bClouds = false;
[10391]52
[10387]53  //this->materialPlanet->setIllum(20);
54  //this->materialPlanet->setAmbient(0.1, 0.1, 0.1);
[6524]55
[10387]56  if( root != NULL)
57    this->loadParams(root);
[6695]58
[10387]59  PrimitiveModel* model = new PrimitiveModel(PRIM_SPHERE, this->size, 50);
60  this->setModel(model);
[6524]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{
[6696]75  WorldEntity::loadParams(root);
[6524]76
77  LoadParam(root, "texture", this, Planet, setTexture)
[10387]78      .describe("Sets the materialPlanet on the Planet. The string must be the path relative to the data-dir, and without a trailing .jpg");
[6524]79
[10432]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
[10387]83  LoadParam(root, "cloud-texture", this, Planet, setCloudTexture)
84      .describe("Sets the cloud texture of the planet");
85
[10391]86  LoadParam(root, "cloud-rotation", this, Planet, setCloudRotation)
87      .describe("Sets the cloud rotation speed");
[10653]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");
[6524]94}
95
96
97/**
98 *  Defines which textures should be loaded onto the Planet.
99 * @param textureName the top texture.
100*/
[7221]101void Planet::setTexture(const std::string& textureName)
[6524]102{
[10387]103  this->materialPlanet.setDiffuseMap(textureName);
[6524]104}
105
106
107/**
[10387]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{
[10432]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);
[10392]118  this->bClouds = true;
[10387]119}
120
121
[10391]122void Planet::setCloudRotation(float rotationSpeed)
123{
124  this->rotSpeedCloud = rotationSpeed;
125}
126
[10387]127/**
[6524]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
[10391]138void Planet::tick( float dt)
139{
140  if( dt != 0.)
[10653]141    this->shiftDir( Quaternion( this->rotSpeedPlanet * dt, this->rotVecPlanet));
[10391]142}
[6524]143
[10391]144
145/**
146 * draws the planet
147 */
[6524]148void Planet::draw() const
149{
[10391]150  // draw the clouds
[10387]151  this->materialPlanet.select();
[10391]152  WorldEntity::draw();
[6524]153
[10432]154//   if( this->bClouds)
155//   {
156//     glDisable(GL_LIGHTING);
157//     this->materialCloud.select();
158//     WorldEntity::draw(this->cloudModel);
159//     glEnable(GL_LIGHTING);
160//   }
[6524]161}
162
163
164
Note: See TracBrowser for help on using the repository browser.