Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3193 in orxonox.OLD for orxonox/trunk


Ignore:
Timestamp:
Dec 16, 2004, 4:00:43 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk/src: merged importer into src again

Location:
orxonox/trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/array.cc

    r3185 r3193  
    6868  if (verbose >= 3)
    6969    printf ("Finalizing array. Length: %i\n", entryCount); 
    70   if ((array = (GLfloat*)malloc( entryCount* sizeof(GLfloat))) == NULL)
    71   //  if ((array = new GLfloat [entryCount]) == NULL)
     70  //  if ((array = (GLfloat*)malloc( entryCount* sizeof(GLfloat))) == NULL)
     71  if ((array = new GLfloat [entryCount]) == NULL)
    7272    printf ("could not allocate %i data Blocks\n", entryCount);
    7373  Entry* walker = firstEntry;
  • orxonox/trunk/src/array.h

    r3185 r3193  
    3131  void debug(void);
    3232 private:
     33  //! One entry of the Array
    3334  struct Entry
    3435  {
    35     GLfloat value;
    36     Entry* next;
     36    GLfloat value;  //!< The value of this Entry.
     37    Entry* next;    //!< Pointer to the Next entry.
    3738  };
    3839
    39   GLfloat* array;
    40   int entryCount;
    41   bool finalized;
    42   Entry* firstEntry;
    43   Entry* currentEntry;
     40  GLfloat* array;      //!< The array that will be produced when finalizing the Array.
     41  int entryCount;      //!< The count of Entries in this Array.
     42  bool finalized;      //!< If this variable is set to true, the Array can not be changed anymore. true if finalized, false else (initially).
     43  Entry* firstEntry;   //!< Pointer to the first Entry of this Array
     44  Entry* currentEntry; //!< Pointer to the current Entry of this Array. The one Entry we are working with.
    4445 
    4546 
  • orxonox/trunk/src/material.cc

    r3185 r3193  
    1515   TGA-code: borrowed from nehe-Tutorials
    1616
    17    ToDo:
    18    - free SDL-surface when deleting Material.
    19    - delete imgNameWithPath after use creation.
    2017*/
    2118
     
    3128using namespace std;
    3229
    33 
     30/**
     31   \brief creates a ned PathList.
     32   
     33   It is a good idea to use this as an initial List,
     34   because if you give on a name the Path will not be checked for its existence.
     35*/
    3436PathList::PathList()
    3537{
     
    3739  next = NULL;
    3840}
     41
     42/**
     43   \brief Creates a new PathList with a Name.
     44   \param pName the Name of The Path.
     45
     46   This function just adds the Path without checking if it exists.
     47*/
    3948PathList::PathList(char* pName)
    4049{
     
    4453}
    4554
     55/**
     56   \brief destroys a PathList
     57
     58   It does this by deleting the Name and then delete its preceding PathList.
     59*/
    4660PathList::~PathList()
    4761{
     
    5266}
    5367
     68/**
     69   \brief Adds a new Pathlist Element.
     70   \param pName
     71   
     72   Adding a Path automatically checks if the Path exists,
     73   and if it does not it will not add it to the List.
     74*/
    5475void PathList::addPath (char* pName)
    5576{
     
    476497}
    477498
     499/**
     500   \brief Loads a Texture to the openGL-environment.
     501   \param pImage The Image to load to openGL
     502   \param texture The Texture to apply it to.
     503*/
    478504bool Material::loadTexToGL (Image* pImage, GLuint* texture)
    479505{
  • orxonox/trunk/src/material.h

    r3185 r3193  
    22  \file material.h
    33  \brief Contains the Material Class that handles Material for 3D-Objects.
     4  \todo free SDL-surface when deleting Material.
     5  \todo delete imgNameWithPath after use creation.
    46*/
    57
    68#ifndef _MATERIAL_H
    79#define _MATERIAL_H
     10
     11
    812
    913extern int verbose; //!< will be obsolete soon.
     
    2933#endif /* HAVE_SDL_SDL_IMAGE_H */
    3034
     35//! Class to handle lists of paths.
     36/**
     37   \todo Ability to return Paths by itself.
     38
     39   It is simple to use, and good, for all PathList you want.
     40   just create a new Pathlist, and add Paths.
     41*/
    3142class PathList
    3243{
     
    3748  ~PathList();
    3849  void addPath (char* pName);
    39   char* pathName;
    40   PathList* next;
     50  char* pathName;          //!< The Name of the current Path.
     51  PathList* next;          //!< Pointer to the next Pathlist.
    4152};
    4253
     
    8192
    8293 private:
     94  //! Struct to handle Infos about an Image
    8395  struct Image
    8496  {
    85     int rowSpan;
    86     GLuint width;
    87     GLuint height;
    88     GLuint bpp;
    89     GLuint type;
    90     GLubyte *data;
     97    int rowSpan;    //!< The count of the rows this Image has.
     98    GLuint width;   //!< The width of the Image.
     99    GLuint height;  //!< The height of the Image.
     100    GLuint bpp;     //!< BitsPerPixel
     101    GLuint type;    //!< Type of the Image.
     102    GLubyte *data;  //!< The Image Data comes here! DANGER: uncompressed data.
    91103  };
    92104
    93105
    94   char* name;
    95   int illumModel;
    96   float diffuse [4];
    97   float ambient [4];
    98   float specular [4];
    99   float shininess;
    100   float transparency;
     106  char* name;        //!< The Name of the Material.
     107  int illumModel;    //!< The IlluminationModel is either flat or smooth.
     108  float diffuse [4]; //!< The diffuse color of the Material.
     109  float ambient [4]; //!< The ambient color of the Material.
     110  float specular [4];//!< The specular color of the Material.
     111  float shininess;   //!< The shininess of the Material.
     112  float transparency;//!< The transperency of the Material.
    101113
    102   static PathList* pathList;
     114  static PathList* pathList; //!< A pointer to the first element of Pathlist. This is static, because pathlists are global \todo copy this to the Globals.h or DataTank for deletion at the end.
    103115 
    104   GLuint diffuseTexture;
    105   GLuint ambientTexture;
    106   GLuint specularTexture;
     116  GLuint diffuseTexture; //!< The diffuse texture of the Material.
     117  GLuint ambientTexture; //!< The ambient texture of the Material.
     118  GLuint specularTexture;//!< The specular texture of the Material.
    107119 
    108   bool diffuseTextureSet;
    109   bool ambientTextureSet;
    110   bool specularTextureSet;
     120  bool diffuseTextureSet; //!< Chekcs if the diffuse texture is Set.
     121  bool ambientTextureSet; //!< Chekcs if the ambient texture is Set.
     122  bool specularTextureSet;//!< Chekcs if the specular texture is Set.
    111123
    112124  Material* nextMat; //!< pointer to the Next Material of the List. NULL if no next exists.
  • orxonox/trunk/src/object.cc

    r3185 r3193  
    2020
    2121/**
    22    \brief Creates a 3D-Object, but does not load any 3D-models
    23    pretty useless
     22   \brief Creates a 3D-Object, but does not load any 3D-models.
     23
     24   This Constructor is pretty useless, because why load no object in an object-loader??
    2425*/
    2526Object::Object ()
     
    3637
    3738/**
    38    \brief Crates a 3D-Object and loads in a File
     39   \brief Crates a 3D-Object and loads in a File.
    3940   \param fileName file to parse and load (must be a .obj file)
    4041*/
     
    6869
    6970/**
    70    \brief deletes an Object
     71   \brief deletes an Object.
     72
     73   Looks if any from object allocated space is still in use, and if so deleted it.
    7174*/
    7275Object::~Object()
     
    117120/**
    118121   \brief Draws the Object number groupNumber
     122   \param groupNumber The number of the group that will be displayed.
     123
    119124   It does this by just calling the List that must have been created earlier.
    120    \param groupNumber The number of the group that will be displayed.
    121125*/
    122126void Object::draw (int groupNumber) const
     
    152156/**
    153157   \brief Draws the Object with a specific groupName
     158   \param groupName The name of the group that will be displayed.
     159
    154160   It does this by just calling the List that must have been created earlier.
    155    \param groupName The name of the group that will be displayed.
    156161*/
    157162void Object::draw (char* groupName) const
     
    185190
    186191/**
    187     \brief initializes the Object
    188     This Function initializes all the needed arrays, Lists and clientStates
     192    \brief initializes the Object.
     193
     194    This Function initializes all the needed arrays, Lists and clientStates.
     195    It also defines default values.
    189196*/
    190197bool Object::initialize (void)
     
    214221/**
    215222   \brief initializes a new Group object
     223   \param group the group that should be initialized.
     224   \todo Maybe Group should be a Class, because it does a lot of stuff
     225   
    216226*/
    217227bool Object::initGroup(Group* group)
     
    231241/**
    232242   \brief initializes a new Face. (sets default Values)
     243   \param face The face to initialize
    233244*/
    234245bool Object::initFace (Face* face)
     
    285296
    286297/**
    287    \brief Cleans up all Faces starting from face.
    288    \param face the first face to clean
     298   \brief Cleans up all Faces starting from face until NULL is reached.
     299   \param face the first face to clean.
    289300*/
    290301bool Object::cleanupFace (Face* face)
     
    386397      BoxObject();
    387398      delete []fileName;
     399      OBJ_FILE->close();
    388400      return false;
    389401    }
     
    450462/**
    451463   \brief parses a group String
     464   \param groupString the new Group to create
     465
    452466   This function initializes a new Group.
    453467   With it you should be able to import .obj-files with more than one Objects inside.
    454    \param groupString the new Group to create
    455468*/
    456469bool Object::readGroup (char* groupString)
     
    476489/**
    477490   \brief parses a vertex-String
     491   \param vertexString The String that will be parsed.
     492
    478493   If a vertex line is found this function will inject it into the vertex-Array
    479    \param vertexString The String that will be parsed.
    480494*/
    481495bool Object::readVertex (char* vertexString)
     
    493507/**
    494508   \brief parses a face-string
     509   \param faceString The String that will be parsed.
     510
    495511   If a face line is found this function will add it to the glList.
    496512   The function makes a difference between QUADS and TRIANGLES, and will if changed re-open, set and re-close the gl-processe.
    497    \param faceString The String that will be parsed.
    498513*/
    499514bool Object::readFace (char* faceString)
     
    556571/**
    557572   \brief parses a vertexNormal-String
     573   \param normalString The String that will be parsed.
     574
    558575   If a vertexNormal line is found this function will inject it into the vertexNormal-Array
    559    \param normalString The String that will be parsed.
    560576*/
    561577bool Object::readVertexNormal (char* normalString)
     
    573589/**
    574590   \brief parses a vertexTextureCoordinate-String
    575    If a vertexTextureCoordinate line is found this function will inject it into the vertexTexture-Array
    576591   \param vTextureString The String that will be parsed.
     592
     593   If a vertexTextureCoordinate line is found,
     594   this function will inject it into the vertexTexture-Array
    577595*/
    578596bool Object::readVertexTexture (char* vTextureString)
     
    590608/**
    591609    \brief Function to read in a mtl File.
    592     this Function parses all Lines of an mtl File
    593610    \param mtlFile The .mtl file to read
     611
     612    This Function parses all Lines of an mtl File.
     613    The reason for it not to be in the materials-class is,
     614    that a material does not have to be able to read itself in from a File.
     615
    594616*/
    595617bool Object::readMtlLib (char* mtlFile)
     
    611633        printf ("unable to open file: %s\n", fileName);
    612634      delete []fileName;
     635      MTL_FILE->close();
    613636      return false;
    614637    }
     
    809832/**
    810833   \brief Adds a Face-element (one vertex of a face) with all its information.
     834   \param elem The FaceElement to add to the OpenGL-environment.
     835
    811836   It does this by searching:
    812837   1. The Vertex itself
     
    814839   3. The VertexTextureCoordinate
    815840   merging this information, the face will be drawn.
    816 
    817841*/
    818842bool Object::addGLElement (FaceElement* elem)
     
    832856/**
    833857   \brief A routine that is able to create normals.
     858
    834859   The algorithm does the following:
    835860   1. It calculates creates Vectors for each normale, and sets them to zero.
     
    912937/**
    913938   \brief Includes a default object
     939
    914940   This will inject a Cube, because this is the most basic object.
    915941*/
    916942void Object::BoxObject(void)
    917943{
    918   readVertex ("-0.500000 -0.500000 0.500000");
    919   readVertex ("0.500000 -0.500000 0.500000");
    920   readVertex ("-0.500000 0.500000 0.500000");
    921   readVertex ("0.500000 0.500000 0.500000");
    922   readVertex ("-0.500000 0.500000 -0.500000");
    923   readVertex ("0.500000 0.500000 -0.500000");
    924   readVertex ("-0.500000 -0.500000 -0.500000");
    925   readVertex ("0.500000 -0.500000 -0.500000");
    926 
    927   readVertexTexture ("0.000000 0.000000");
    928   readVertexTexture ("1.000000 0.000000");
    929   readVertexTexture ("0.000000 1.000000");
    930   readVertexTexture ("1.000000 1.000000");
    931   readVertexTexture ("0.000000 2.000000");
    932   readVertexTexture ("1.000000 2.000000");
    933   readVertexTexture ("0.000000 3.000000");
    934   readVertexTexture ("1.000000 3.000000");
    935   readVertexTexture ("0.000000 4.000000");
    936   readVertexTexture ("1.000000 4.000000");
    937   readVertexTexture ("2.000000 0.000000");
    938   readVertexTexture ("2.000000 1.000000");
    939   readVertexTexture ("-1.000000 0.000000");
    940   readVertexTexture ("-1.000000 1.000000");
    941 
    942   readVertexNormal ("0.000000 0.000000 1.000000");
    943   readVertexNormal ("0.000000 0.000000 1.000000");
    944   readVertexNormal ("0.000000 0.000000 1.000000");
    945   readVertexNormal ("0.000000 0.000000 1.000000");
    946   readVertexNormal ("0.000000 1.000000 0.000000");
    947   readVertexNormal ("0.000000 1.000000 0.000000");
    948   readVertexNormal ("0.000000 1.000000 0.000000");
    949   readVertexNormal ("0.000000 1.000000 0.000000");
    950   readVertexNormal ("0.000000 0.000000 -1.000000");
    951   readVertexNormal ("0.000000 0.000000 -1.000000");
    952   readVertexNormal ("0.000000 0.000000 -1.000000");
    953   readVertexNormal ("0.000000 0.000000 -1.000000");
    954   readVertexNormal ("0.000000 -1.000000 0.000000");
    955   readVertexNormal ("0.000000 -1.000000 0.000000");
    956   readVertexNormal ("0.000000 -1.000000 0.000000");
    957   readVertexNormal ("0.000000 -1.000000 0.000000");
    958   readVertexNormal ("1.000000 0.000000 0.000000");
    959   readVertexNormal ("1.000000 0.000000 0.000000");
    960   readVertexNormal ("1.000000 0.000000 0.000000");
    961   readVertexNormal ("1.000000 0.000000 0.000000");
    962   readVertexNormal ("-1.000000 0.000000 0.000000");
    963   readVertexNormal ("-1.000000 0.000000 0.000000");
    964   readVertexNormal ("-1.000000 0.000000 0.000000");
    965   readVertexNormal ("-1.000000 0.000000 0.000000");
     944  readVertex ("-0.5 -0.5 0.5");
     945  readVertex ("0.5 -0.5 0.5");
     946  readVertex ("-0.5 0.5 0.5");
     947  readVertex ("0.5 0.5 0.5");
     948  readVertex ("-0.5 0.5 -0.5");
     949  readVertex ("0.5 0.5 -0.5");
     950  readVertex ("-0.5 -0.5 -0.5");
     951  readVertex ("0.5 -0.5 -0.5");
     952
     953  readVertexTexture ("0.0 0.0");
     954  readVertexTexture ("1.0 0.0");
     955  readVertexTexture ("0.0 1.0");
     956  readVertexTexture ("1.0 1.0");
     957  readVertexTexture ("0.0 2.0");
     958  readVertexTexture ("1.0 2.0");
     959  readVertexTexture ("0.0 3.0");
     960  readVertexTexture ("1.0 3.0");
     961  readVertexTexture ("0.0 4.0");
     962  readVertexTexture ("1.0 4.0");
     963  readVertexTexture ("2.0 0.0");
     964  readVertexTexture ("2.0 1.0");
     965  readVertexTexture ("-1.0 0.0");
     966  readVertexTexture ("-1.0 1.0");
     967
     968  readVertexNormal ("0.0 0.0 1.0");
     969  readVertexNormal ("0.0 0.0 1.0");
     970  readVertexNormal ("0.0 0.0 1.0");
     971  readVertexNormal ("0.0 0.0 1.0");
     972  readVertexNormal ("0.0 1.0 0.0");
     973  readVertexNormal ("0.0 1.0 0.0");
     974  readVertexNormal ("0.0 1.0 0.0");
     975  readVertexNormal ("0.0 1.0 0.0");
     976  readVertexNormal ("0.0 0.0 -1.0");
     977  readVertexNormal ("0.0 0.0 -1.0");
     978  readVertexNormal ("0.0 0.0 -1.0");
     979  readVertexNormal ("0.0 0.0 -1.0");
     980  readVertexNormal ("0.0 -1.0 0.0");
     981  readVertexNormal ("0.0 -1.0 0.0");
     982  readVertexNormal ("0.0 -1.0 0.0");
     983  readVertexNormal ("0.0 -1.0 0.0");
     984  readVertexNormal ("1.0 0.0 0.0");
     985  readVertexNormal ("1.0 0.0 0.0");
     986  readVertexNormal ("1.0 0.0 0.0");
     987  readVertexNormal ("1.0 0.0 0.0");
     988  readVertexNormal ("-1.0 0.0 0.0");
     989  readVertexNormal ("-1.0 0.0 0.0");
     990  readVertexNormal ("-1.0 0.0 0.0");
     991  readVertexNormal ("-1.0 0.0 0.0");
    966992
    967993  /* normaleLess-testingMode
  • orxonox/trunk/src/object.h

    r3185 r3193  
    3535
    3636 private:
    37   struct FaceElement
     37  //! This is the placeholder of one Vertex beloning to a Face.
     38  struct FaceElement
    3839  {
    39     int vertexNumber;
    40     int normalNumber;
    41     int texCoordNumber;
    42     FaceElement* next;
     40    int vertexNumber;    //!< The number of the Vertex out of the Array* vertices, this vertex points to.
     41    int normalNumber;    //!< The number of the Normal out of the Array* normals, this vertex points to.
     42    int texCoordNumber;  //!< The number of the textureCoordinate out of the Array* vTexture, this vertex points to.
     43    FaceElement* next;   //!< Point to the next FaceElement in this List.
    4344  };
    4445
    45   //! Face
    46   struct Face
     46  //! This is the placeholder of a Face belonging to a Group of Faces.
     47  /**
     48     \todo take Material to a call for itself.
     49
     50     This can also be a Material-Change switch.
     51     That means if you want to change a Material inside of a group,
     52     you can create an empty face and apply a material to it, and the Importer will cahnge Colors
     53  */
     54  struct Face
    4755  {
    48     int vertexCount;
    49     FaceElement* firstElem;
     56    int vertexCount;        //!< The Count of vertices this Face has.
     57    FaceElement* firstElem; //!< Points to the first Vertex (FaceElement) of this Face.
    5058
    51     char* materialString;
     59    char* materialString;   //!< The Name of the Material to which to Change.
    5260
    53     Face* next;
    54   };
     61    Face* next;             //!< Pointer to the next Face.
     62  }; 
    5563
    56   //! Group to handle multiple Objects per obj-file
     64  //! Group to handle multiple Objects per obj-file.
    5765  struct Group
    5866  {
    59     char* name;
     67    char* name;         //!< the Name of the Group. this is an identifier, that can be accessed via the draw (char* name) function.
    6068
    61     GLuint listNumber;
    62     Face* firstFace;
    63     Face* currentFace;
    64     int faceMode;
    65     int faceCount;
     69    GLuint listNumber;  //!< The number of the GL-List this Group gets.
     70    Face* firstFace;    //!< The first Face in this group.
     71    Face* currentFace;  //!< The current Face in this Group (the one we are currently working with.)
     72    int faceMode;       //!< The Mode the Face is in: initially -1, 0 for FaceList opened, 1 for Material,  3 for triangle, 4 for Quad, 5+ for Poly \todo ENUM...
     73    int faceCount;      //!< The Number of Faces this Group holds.
    6674
    67     Group* next;
     75    Group* next;        //!< Pointer to the next Group.
    6876  };
    6977
    7078
    71   Array* vertices;
    72   int verticesCount;
    73   Array* colors;
    74   Array* normals;
    75   Array* vTexture;
     79  Array* vertices;      //!< The Array that handles the Vertices.
     80  int verticesCount;    //!< A global Counter for vertices.
     81  Array* normals;       //!< The Array that handles the Normals.
     82  Array* vTexture;      //!< The Array that handles the VertexTextureCoordinates.
    7683
    7784 
    78   Group* firstGroup; //!< the first of all groups.
    79   Group* currentGroup; //!< the currentGroup. this is the one we will work with.
    80   int groupCount;
     85  Group* firstGroup;    //!< The first of all groups.
     86  Group* currentGroup;  //!< The currentGroup. this is the one we will work with.
     87  int groupCount;       //!< The Count of Groups.
    8188
    82   Material* material;
    83   float scaleFactor;
     89  Material* material;   //!< Initial pointer to the Material. This can hold many materials, because Material can be added with Material::addMaterial(..)
     90  float scaleFactor;    //!< The Factor with which the Object hould be scaled. \todo maybe one wants to scale the Object after Initialisation
    8491
    85   char* objPath;
    86   char* objFileName;
    87   char* mtlFileName;
     92  char* objPath;        //!< The Path wher the obj and mtl-file are located.
     93  char* objFileName;    //!< The Name of the obj-file.
     94  char* mtlFileName;    //!< The Name of the mtl-file (parsed out of the obj-file)
    8895
    8996  bool initialize (void);
  • orxonox/trunk/src/stdincl.h

    r3184 r3193  
     1/*!
     2  \file stdincl.h
     3  \brief This file includes default headers that nearly every Class needs.
     4 
     5  no Class is defined here, but many headers to classes, and more general Headers like the openGL-header.
     6*/
    17
    28#ifndef STDINCL_H
    39#define STDINCL_H
    410
    5 #define null 0
     11#define null 0   //!< null
    612
    713#ifdef __WIN32__
Note: See TracChangeset for help on using the changeset viewer.