Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3614 in orxonox.OLD for orxonox


Ignore:
Timestamp:
Mar 21, 2005, 2:25:10 PM (20 years ago)
Author:
patrick
Message:

orxonox/trunk: enhanced primitives, now more properties to set

Location:
orxonox/trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/story_entities/world.cc

    r3612 r3614  
    238238            Vector* es = new Vector (10, 5, 0);
    239239            Quaternion* qs = new Quaternion ();
    240             WorldEntity* pr = new Primitive(P_CUBE);
     240            WorldEntity* pr = new Primitive(P_CYLINDER);
    241241            pr->setName("primitive");
    242242            this->spawn(pr, this->localPlayer, es, qs, PNODE_MOVEMENT);
  • orxonox/trunk/src/world_entities/primitive.cc

    r3612 r3614  
    4040 
    4141  this->material = new Material("Sphere");
    42   //this->material->setDiffuseMap("../data/pictures/load_screen.jpg");
    4342  this->material->setIllum(3);
    4443  this->material->setAmbient(1, .5, 1);
     
    5453  free(this->object);
    5554}
     55
     56
     57/**
     58   \brief sets the form of the primitive body
     59   \param form (enumeration) from pForm
     60*/
     61void Primitive::setForm(pForm form)
     62{
     63  this->form = form;
     64}
     65
     66
     67/**
     68   \brief sets the size of the body
     69   \param size from [0..1]
     70*/
     71void Primitive::setSize(float size)
     72{
     73  if( size < 0 || size > 1)
     74    {
     75      PRINTF(1)("size must be value between 0 and 1 [0..1]. resetting it to 1\n");
     76      size = 1.0;
     77    }
     78  this->size = size;
     79}
     80
     81
     82/**
     83   \brief stets the material
     84   \param material to be set
     85*/
     86void Primitive::setMaterial(Material* material)
     87{
     88  if( material == NULL)
     89    {
     90      PRINTF(1)("material reference is NULL, returning without modifications\n");
     91      return;
     92    }
     93  this->material = material;
     94}
     95
     96
     97/**
     98   \brief sets the texture name
     99   \param path to the texture
     100
     101   eg: name could have following value: "../data/pictures/load_screen.jpg"
     102*/
     103void Primitive::setTexture(char* name)
     104{
     105  if( name == NULL )
     106    {
     107      PRINTF(1)("texture char reference is NULL, returning without modifications\n");
     108      return;
     109    }
     110  this->textureName = name;
     111  this->material->setDiffuseMap( name);
     112}
     113
    56114
    57115/**
     
    98156    {
    99157    case P_SPHERE:
    100       gluSphere(this->object, 1, 6, 6);
     158      gluSphere(this->object, 0.2, 6, 6);
    101159      break;
    102160    case P_CUBE:
  • orxonox/trunk/src/world_entities/primitive.h

    r3612 r3614  
    1717  virtual ~Primitive ();
    1818
     19  void setForm(pForm form);
     20  void setSize(float size);
     21  void setMaterial(Material* material);
     22  void setTexture(char* name);
     23 
     24
    1925  virtual void tick (float time);
    2026  virtual void hit (WorldEntity* weapon, Vector* loc);
    2127  virtual void collide (WorldEntity* other,  Uint32 ownhitflags, Uint32 otherhitflags);
     28  virtual void draw ();
    2229
    23   virtual void draw ();
    24   void glDrawCube();
    2530
    2631
    2732 private:
    28   GLUquadricObj *object; //!< the object to be rendered
    29   Material *material;    //!< A Material for the SkySphere.
     33  GLUquadricObj* object; //!< the object to be rendered
     34  Material* material;    //!< A Material for the SkySphere.
    3035  pForm form;
     36  char* textureName;
     37  float size;
    3138
     39  void glDrawCube();
    3240};
    3341
Note: See TracChangeset for help on using the changeset viewer.