| 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 |  | 
|---|
| 35 | ObjectListDefinition(Planet); | 
|---|
| 36 | CREATE_FACTORY(Planet); | 
|---|
| 37 |  | 
|---|
| 38 |  | 
|---|
| 39 | /** | 
|---|
| 40 | *  initializes a skybox from a XmlElement | 
|---|
| 41 | */ | 
|---|
| 42 | Planet::Planet(const TiXmlElement* root) | 
|---|
| 43 | { | 
|---|
| 44 | this->registerObject(this, Planet::_objectList); | 
|---|
| 45 | this->toList(OM_GROUP_01); | 
|---|
| 46 |  | 
|---|
| 47 | //this->material->setIllum(20); | 
|---|
| 48 | //this->material->setAmbient(0.1, 0.1, 0.1); | 
|---|
| 49 |  | 
|---|
| 50 |  | 
|---|
| 51 |  | 
|---|
| 52 | //st float radius, const unsigned int loops, const unsigned int segmentsPerLoop | 
|---|
| 53 |  | 
|---|
| 54 | this->loadParams(root); | 
|---|
| 55 |  | 
|---|
| 56 | //   VertexArrayModel* model = new VertexArrayModel(); | 
|---|
| 57 | //   model->spiralSphere(this->size, 10, 10); | 
|---|
| 58 | //   this->setModel(model); | 
|---|
| 59 | //   model->debug(); | 
|---|
| 60 | // | 
|---|
| 61 | PrimitiveModel* model = new PrimitiveModel(PRIM_SPHERE, this->size, 50); | 
|---|
| 62 | this->setModel(model); | 
|---|
| 63 | } | 
|---|
| 64 |  | 
|---|
| 65 |  | 
|---|
| 66 | /** | 
|---|
| 67 | *  default destructor | 
|---|
| 68 | */ | 
|---|
| 69 | Planet::~Planet() | 
|---|
| 70 | { | 
|---|
| 71 | PRINTF(5)("Deleting Planet\n"); | 
|---|
| 72 | } | 
|---|
| 73 |  | 
|---|
| 74 |  | 
|---|
| 75 | void Planet::loadParams(const TiXmlElement* root) | 
|---|
| 76 | { | 
|---|
| 77 | WorldEntity::loadParams(root); | 
|---|
| 78 |  | 
|---|
| 79 | LoadParam(root, "texture", this, Planet, setTexture) | 
|---|
| 80 | .describe("Sets the material on the Planet. The string must be the path relative to the data-dir, and without a trailing .jpg"); | 
|---|
| 81 |  | 
|---|
| 82 | LoadParam(root, "size", this, Planet, setSize) | 
|---|
| 83 | .describe("Sets the Size of the Planet (normally this should be 90% of the maximal viewing Distance)."); | 
|---|
| 84 | } | 
|---|
| 85 |  | 
|---|
| 86 |  | 
|---|
| 87 | /** | 
|---|
| 88 | *  Defines which textures should be loaded onto the Planet. | 
|---|
| 89 | * @param textureName the top texture. | 
|---|
| 90 | */ | 
|---|
| 91 | void Planet::setTexture(const std::string& textureName) | 
|---|
| 92 | { | 
|---|
| 93 | this->material.setDiffuseMap(textureName); | 
|---|
| 94 | } | 
|---|
| 95 |  | 
|---|
| 96 |  | 
|---|
| 97 | /** | 
|---|
| 98 | * @param size The new size of the Planet | 
|---|
| 99 |  | 
|---|
| 100 | * do not forget to rebuild the Planet after this. | 
|---|
| 101 | */ | 
|---|
| 102 | void Planet::setSize(float size) | 
|---|
| 103 | { | 
|---|
| 104 | this->size = size; | 
|---|
| 105 | } | 
|---|
| 106 |  | 
|---|
| 107 |  | 
|---|
| 108 |  | 
|---|
| 109 | void Planet::draw() const | 
|---|
| 110 | { | 
|---|
| 111 | this->material.select(); | 
|---|
| 112 |  | 
|---|
| 113 | WorldEntity::draw(); | 
|---|
| 114 | } | 
|---|
| 115 |  | 
|---|
| 116 |  | 
|---|
| 117 |  | 
|---|