Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6968 in orxonox.OLD for trunk/src/world_entities/environments


Ignore:
Timestamp:
Feb 1, 2006, 7:42:35 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: new entity

Location:
trunk/src/world_entities/environments
Files:
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/environments/movie_entity.cc

    r6967 r6968  
    1616#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
    1717
    18 #include "planet.h"
     18#include "movie_entity.h"
    1919
    2020#include "load_param.h"
     
    2222#include "static_model.h"
    2323
    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 
    3224using namespace std;
    3325
    3426
    35 CREATE_FACTORY(Planet, CL_PLANET);
     27CREATE_FACTORY(ModelEntity, CL_MODEL_ENTITY);
    3628
    3729
     
    4032 *  initializes a skybox from a XmlElement
    4133*/
    42 Planet::Planet(const TiXmlElement* root)
     34ModelEntity::ModelEntity(const TiXmlElement* root)
    4335{
    44   this->setClassID(CL_PLANET, "Planet");
    45   this->toList(OM_GROUP_01);
     36  this->setClassID(CL_MODEL_ENTITY, "ModelEntity");
     37  this->toList(OM_ENVIRON_NOTICK);
    4638
    47   this->material = new Material();
    48   //this->material->setIllum(20);
    49   //this->material->setAmbient(0.1, 0.1, 0.1);
    50 
    51 
    52 
    53       //st float radius, const unsigned int loops, const unsigned int segmentsPerLoop
    54 
    55   this->loadParams(root);
    56 
    57 //   VertexArrayModel* model = new VertexArrayModel();
    58 //   model->spiralSphere(this->size, 10, 10);
    59 //   this->setModel(model);
    60 //   model->debug();
    61 //
    62   PrimitiveModel* model = new PrimitiveModel(PRIM_SPHERE, this->size, 50);
    63   this->setModel(model);
     39  if (root != NULL)
     40    this->loadParams(root);
    6441}
    6542
     
    6845 *  default destructor
    6946*/
    70 Planet::~Planet()
     47ModelEntity::~ModelEntity()
    7148{
    72   PRINTF(5)("Deleting Planet\n");
    73   if( this->material)
    74     delete this->material;
    7549}
    7650
    7751
    78 void Planet::loadParams(const TiXmlElement* root)
    79 {
    80   WorldEntity::loadParams(root);
    81 
    82   LoadParam(root, "texture", this, Planet, setTexture)
    83       .describe("Sets the material on the Planet. The string must be the path relative to the data-dir, and without a trailing .jpg");
    84 
    85   LoadParam(root, "size", this, Planet, setSize)
    86       .describe("Sets the Size of the Planet (normally this should be 90% of the maximal viewing Distance).");
    87 }
    88 
    89 
    90 /**
    91  *  Defines which textures should be loaded onto the Planet.
    92  * @param textureName the top texture.
    93 */
    94 void Planet::setTexture(const char* textureName)
    95 {
    96   this->material->setDiffuseMap(textureName);
    97 }
    98 
    99 
    100 /**
    101  * @param size The new size of the Planet
    102 
    103  * do not forget to rebuild the Planet after this.
    104 */
    105 void Planet::setSize(float size)
    106 {
    107   this->size = size;
    108 }
    109 
    110 
    111 
    112 void Planet::draw() const
    113 {
    114   glMatrixMode(GL_MODELVIEW);
    115   glPushMatrix();
    116 
    117   glShadeModel(GL_SMOOTH);
    118 
    119   /* translate */
    120   glTranslatef (this->getAbsCoor ().x,
    121                 this->getAbsCoor ().y,
    122                 this->getAbsCoor ().z);
    123   Vector tmpRot = this->getAbsDir().getSpacialAxis();
    124   glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
    125 
    126   this->material->select();
    127 
    128 //   /WorldEntity::draw();
    129   this->getModel(0)->draw();
    130  // static_cast<VertexArrayModel*>(this->getModel(0))->debug();
    131 
    132   glPopMatrix();
    133 }
    134 
    135 
    136 
  • trunk/src/world_entities/environments/movie_entity.h

    r6967 r6968  
    11/*!
    2  * @file planet.h
    3  *  Definition of the Planet, that handles the Display of an atmosphere for orxonox.
     2 * @file movie_entity.h
     3 *  Definition of the ModelEntity, that handles the Display of an atmosphere for orxonox.
    44 */
    55
    6 #ifndef _PLANET_H
    7 #define _PLANET_H
     6#ifndef _MODEL_ENTITY_H
     7#define _MODEL_ENTITY_H
    88
    99/* INCLUDES */
     
    1111
    1212/* FORWARD DECLARATION */
    13 class Material;
    14 class Texture;
    1513
    16 //! A Class to handle a Planet
    17 class Planet : public WorldEntity
     14//! A Class to handle a ModelEntity
     15class ModelEntity : public WorldEntity
    1816{
    1917 public:
    20   Planet(const TiXmlElement* root);
     18  ModelEntity(const TiXmlElement* root);
    2119
    22   virtual ~Planet();
    23 
    24   virtual void loadParams(const TiXmlElement* root);
    25 
    26   void setSize(float size);
    27   /** assumes jpg as input-format */
    28   void setTexture(const char* textureName);
     20  virtual ~ModelEntity();
    2921
    3022
    31   virtual void draw() const;
     23  private:
     24
     25};
     26
     27#endif  /* _MODEL_ENTITY_H */
    3228
    3329
    3430
    35  private:
    36   Material*       material;        //!< Materials for the Planet. sorted by number (0-5) top, bottom, left, right, front, back
    37   Texture*        texture;         //!< Textures for the CubeMap.
    38 
    39   float           size;            //!< Size of the Planet. This should match the frustum maximum range.
    40   float           textureSize;     //!< this is the length of a texture (assumes a square texture)
    41   char*           textureName;     //!< Name of the Texture
    42 
    43 };
    44 
    45 #endif  /* _PLANET_H */
    46 
    47 
    48 
Note: See TracChangeset for help on using the changeset viewer.