Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3612 in orxonox.OLD for orxonox


Ignore:
Timestamp:
Mar 21, 2005, 1:14:14 PM (20 years ago)
Author:
patrick
Message:

orxonox/trunk: implemented a primitive class, it is able to render cubes, spheres, cylinders and disks. yet not so mutch customizeable.

Location:
orxonox/trunk/src
Files:
3 edited

Legend:

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

    r3608 r3612  
    238238            Vector* es = new Vector (10, 5, 0);
    239239            Quaternion* qs = new Quaternion ();
    240             WorldEntity* pr = new Primitive(PSPHERE);
     240            WorldEntity* pr = new Primitive(P_CUBE);
    241241            pr->setName("primitive");
    242242            this->spawn(pr, this->localPlayer, es, qs, PNODE_MOVEMENT);
     
    290290            Vector* es = new Vector (20, 0, 0);
    291291            Quaternion* qs = new Quaternion ();
    292             WorldEntity* pr = new Primitive(PSPHERE);
     292            WorldEntity* pr = new Primitive(P_SPHERE);
    293293            pr->setName("primitive");
    294294            this->spawn(pr, this->localPlayer, es, qs, PNODE_ROTATE_AND_MOVE);
  • orxonox/trunk/src/world_entities/primitive.cc

    r3608 r3612  
    3131   \brief standard constructor
    3232*/
    33 Primitive::Primitive (PRIMITIVE_FORM form) : WorldEntity()
     33Primitive::Primitive (pForm form) : WorldEntity()
    3434{
    35   //this->model = new OBJModel("../data/models/fighter.obj");
    36   //this->model = new OBJModel("");
     35  this->form = form;
    3736  this->object = gluNewQuadric();
    3837 
     38  gluQuadricNormals(this->object, GLU_SMOOTH);
    3939  gluQuadricTexture(this->object, GL_TRUE);
    40 
     40 
    4141  this->material = new Material("Sphere");
    4242  //this->material->setDiffuseMap("../data/pictures/load_screen.jpg");
    4343  this->material->setIllum(3);
    4444  this->material->setAmbient(1, .5, 1);
    45   Vector* v = new Vector();
    46 
    4745}
    4846
     
    9694  //glMultMatrixf((float*)matrix);
    9795  this->material->select();
    98   gluSphere(this->object, 1, 6, 6);
    99   //gluCylinder(this->object, 1, 1, 2, 6, 6);
    100   //gluDisk(this->object, 1, 2, 6, 6);
     96 
     97  switch( this->form)
     98    {
     99    case P_SPHERE:
     100      gluSphere(this->object, 1, 6, 6);
     101      break;
     102    case P_CUBE:
     103      this->glDrawCube();
     104      break;
     105    case P_CYLINDER:
     106      gluCylinder(this->object, 1, 1, 2, 6, 6);
     107      break;
     108    case P_DISK:
     109      gluDisk(this->object, 1, 2, 6, 6);
     110      break;
     111    default:
     112      break;
     113    }
    101114
    102115  glPopMatrix();
    103116}
    104117
     118
     119void Primitive::glDrawCube()                           
     120{
     121  glBegin(GL_QUADS);                   
     122  glNormal3f( 0.0f, 0.0f, 1.0f);       
     123  glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);
     124  glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);
     125  glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f,  1.0f);
     126  glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f,  1.0f);
     127
     128  glNormal3f( 0.0f, 0.0f,-1.0f);       
     129  glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
     130  glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);
     131  glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);
     132  glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
     133
     134  glNormal3f( 0.0f, 1.0f, 0.0f);       
     135  glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);
     136  glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f,  1.0f,  1.0f);
     137  glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f,  1.0f,  1.0f);
     138  glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);
     139
     140  glNormal3f( 0.0f,-1.0f, 0.0f);
     141  glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
     142  glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
     143  glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);
     144  glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);
     145
     146  glNormal3f( 1.0f, 0.0f, 0.0f);
     147  glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
     148  glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);
     149  glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f,  1.0f,  1.0f);
     150  glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);
     151
     152  glNormal3f(-1.0f, 0.0f, 0.0f);
     153  glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
     154  glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);
     155  glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f,  1.0f,  1.0f);
     156  glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);
     157  glEnd();
     158}
  • orxonox/trunk/src/world_entities/primitive.h

    r3608 r3612  
    55#include "glincl.h"
    66
    7 typedef enum PRIMITIVE_FORM {PSPHERE = 0, PCUBE, PSQUARE};
     7typedef enum pForm {P_SPHERE = 0, P_CUBE, P_CYLINDER, P_DISK};
    88
    99class Material;
    10 
    1110
    1211class Primitive : public WorldEntity
     
    1514
    1615 public:
    17   Primitive (PRIMITIVE_FORM form);
     16  Primitive (pForm form);
    1817  virtual ~Primitive ();
    1918
     
    2120  virtual void hit (WorldEntity* weapon, Vector* loc);
    2221  virtual void collide (WorldEntity* other,  Uint32 ownhitflags, Uint32 otherhitflags);
     22
    2323  virtual void draw ();
     24  void glDrawCube();
     25
    2426
    2527 private:
    2628  GLUquadricObj *object; //!< the object to be rendered
    2729  Material *material;    //!< A Material for the SkySphere.
     30  pForm form;
    2831
    2932};
Note: See TracChangeset for help on using the changeset viewer.