[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" |
---|
[6524] | 31 | |
---|
| 32 | |
---|
| 33 | |
---|
[9357] | 34 | |
---|
[6524] | 35 | CREATE_FACTORY(Planet, CL_PLANET); |
---|
| 36 | |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | /** |
---|
| 40 | * initializes a skybox from a XmlElement |
---|
| 41 | */ |
---|
| 42 | Planet::Planet(const TiXmlElement* root) |
---|
| 43 | { |
---|
| 44 | this->setClassID(CL_PLANET, "Planet"); |
---|
| 45 | this->toList(OM_GROUP_01); |
---|
| 46 | |
---|
[6695] | 47 | //this->material->setIllum(20); |
---|
| 48 | //this->material->setAmbient(0.1, 0.1, 0.1); |
---|
[6524] | 49 | |
---|
[6695] | 50 | |
---|
| 51 | |
---|
| 52 | //st float radius, const unsigned int loops, const unsigned int segmentsPerLoop |
---|
| 53 | |
---|
[6524] | 54 | this->loadParams(root); |
---|
[6695] | 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); |
---|
[6524] | 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 | { |
---|
[6696] | 77 | WorldEntity::loadParams(root); |
---|
[6524] | 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 | */ |
---|
[7221] | 91 | void Planet::setTexture(const std::string& textureName) |
---|
[6524] | 92 | { |
---|
[7221] | 93 | this->material.setDiffuseMap(textureName); |
---|
[6524] | 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 | { |
---|
[7221] | 111 | this->material.select(); |
---|
[6524] | 112 | |
---|
[7919] | 113 | WorldEntity::draw(); |
---|
[6524] | 114 | } |
---|
| 115 | |
---|
| 116 | |
---|
| 117 | |
---|