Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 7707 was 7221, checked in by bensch, 19 years ago

orxonox/trunk: merged the std-branche back, it runs on windows and Linux

svn merge https://svn.orxonox.net/orxonox/branches/std . -r7202:HEAD

File size: 2.8 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"
[6524]31
32using namespace std;
33
34
35CREATE_FACTORY(Planet, CL_PLANET);
36
37
38
39/**
40 *  initializes a skybox from a XmlElement
41*/
42Planet::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*/
69Planet::~Planet()
70{
71  PRINTF(5)("Deleting Planet\n");
72}
73
74
75void 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]91void 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*/
102void Planet::setSize(float size)
103{
104  this->size = size;
105}
106
107
108
109void Planet::draw() const
110{
111  glMatrixMode(GL_MODELVIEW);
112  glPushMatrix();
113
[6695]114  glShadeModel(GL_SMOOTH);
115
[6524]116  /* translate */
117  glTranslatef (this->getAbsCoor ().x,
118                this->getAbsCoor ().y,
119                this->getAbsCoor ().z);
[6912]120  Vector tmpRot = this->getAbsDir().getSpacialAxis();
121  glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
[6524]122
[7221]123  this->material.select();
[6524]124
[6695]125//   /WorldEntity::draw();
126  this->getModel(0)->draw();
127 // static_cast<VertexArrayModel*>(this->getModel(0))->debug();
[6780]128
129  glPopMatrix();
[6524]130}
131
132
133
Note: See TracBrowser for help on using the repository browser.