/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. ### File Specific: main-programmer: Patrick Boenzli co-programmer: ... */ #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY #include "planet.h" #include "load_param.h" #include "factory.h" #include "static_model.h" #include "material.h" #include "texture.h" #include "network_game_manager.h" #include "converter.h" using namespace std; CREATE_FACTORY(Planet, CL_PLANET); /** * initializes a skybox from a XmlElement */ Planet::Planet(const TiXmlElement* root) { this->setClassID(CL_PLANET, "Planet"); this->toList(OM_GROUP_01); this->material = new Material(); this->material->setIllum(10); this->loadParams(root); } /** * default destructor */ Planet::~Planet() { PRINTF(5)("Deleting Planet\n"); if( this->material) delete this->material; } void Planet::loadParams(const TiXmlElement* root) { static_cast(this)->loadParams(root); LoadParam(root, "texture", this, Planet, setTexture) .describe("Sets the material on the Planet. The string must be the path relative to the data-dir, and without a trailing .jpg"); LoadParam(root, "size", this, Planet, setSize) .describe("Sets the Size of the Planet (normally this should be 90% of the maximal viewing Distance)."); } /** * Defines which textures should be loaded onto the Planet. * @param textureName the top texture. */ void Planet::setTexture(const char* textureName) { this->material->setDiffuseMap(textureName); } /** * @param size The new size of the Planet * do not forget to rebuild the Planet after this. */ void Planet::setSize(float size) { this->size = size; } void Planet::draw() const { glMatrixMode(GL_MODELVIEW); glPushMatrix(); /* translate */ glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z); this->material->select(); Vector c; double r = this->size; int n = 200; int method = 1; double theta1 = 0; double theta2 = 2 * M_PI; double phi1 = -M_PI/2.0; double phi2 = M_PI/2.0; int i,j; double jdivn,j1divn,idivn,dosdivn,unodivn=1/(double)n,ndiv2=(double)n/2,t1,t2,t3,cost1,cost2,cte1,cte3; cte3 = (theta2-theta1)/n; cte1 = (phi2-phi1)/ndiv2; dosdivn = 2*unodivn; Vector e,p,e2,p2; t2=phi1; cost2=cos(phi1); j1divn=0; for (j=0;j