Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

removed the segfault for npcs, adding clouds to planets

File size: 2.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
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->materialPlanet->setIllum(20);
48  //this->materialPlanet->setAmbient(0.1, 0.1, 0.1);
49
50  if( root != NULL)
51    this->loadParams(root);
52
53  PrimitiveModel* model = new PrimitiveModel(PRIM_SPHERE, this->size, 50);
54  this->setModel(model);
55
56
57
58}
59
60
61/**
62 *  default destructor
63*/
64Planet::~Planet()
65{
66  PRINTF(5)("Deleting Planet\n");
67}
68
69
70void Planet::loadParams(const TiXmlElement* root)
71{
72  WorldEntity::loadParams(root);
73
74  LoadParam(root, "texture", this, Planet, setTexture)
75      .describe("Sets the materialPlanet on the Planet. The string must be the path relative to the data-dir, and without a trailing .jpg");
76
77  LoadParam(root, "cloud-texture", this, Planet, setCloudTexture)
78      .describe("Sets the cloud texture of the planet");
79
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}
83
84
85/**
86 *  Defines which textures should be loaded onto the Planet.
87 * @param textureName the top texture.
88*/
89void Planet::setTexture(const std::string& textureName)
90{
91  this->materialPlanet.setDiffuseMap(textureName);
92}
93
94
95/**
96 *  Defines which textures should be loaded onto the Planet.
97 * @param textureName the top texture.
98*/
99void Planet::setCloudTexture(const std::string& textureName)
100{
101  this->materialCloud.setDiffuseMap(textureName);
102}
103
104
105/**
106 * @param size The new size of the Planet
107
108 * do not forget to rebuild the Planet after this.
109*/
110void Planet::setSize(float size)
111{
112  this->size = size;
113}
114
115
116
117void Planet::draw() const
118{
119  this->materialPlanet.select();
120
121  WorldEntity::draw();
122}
123
124
125
Note: See TracBrowser for help on using the repository browser.