Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2851 in orxonox.OLD for orxonox/trunk


Ignore:
Timestamp:
Nov 14, 2004, 6:19:50 AM (20 years ago)
Author:
bensch
Message:

orxonox/trunk/importer: extended the draw function. Now you can draw one of the objects with the call to its name, or its number.

Location:
orxonox/trunk/importer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/importer/object.cc

    r2850 r2851  
    131131
    132132/**
    133    \brief Draws the Object
    134    It does this by just calling the List that must have been created earlier.
     133   \brief Draws the Objects of all Groups.
     134   It does this by just calling the Lists that must have been created earlier.
    135135*/
    136136void Object::draw (void)
    137137{
    138   if (verbose >=3)
    139     printf("drawing the 3D-Object\n");
     138  if (verbose >=2)
     139    printf("drawing the 3D-Objects\n");
    140140  Group* walker = firstGroup;
    141141  while (walker != NULL)
    142142    {
     143      if (verbose >= 3)
     144        printf ("Drawing object %s\n", walker->name);
    143145      glCallList (walker->listNumber);
    144146      walker = walker->nextGroup;
    145147    }
    146148}
     149
     150/**
     151   \brief Draws the Object number groupNumber
     152   It does this by just calling the List that must have been created earlier.
     153   \param groupNumber The number of the Group that will be displayed.
     154*/
     155void Object::draw (int groupNumber)
     156{
     157  if (verbose >=2)
     158    printf("drawing the requested 3D-Objects if found.\n");
     159  Group* walker = firstGroup;
     160  int counter = 0;
     161  while (walker != NULL)
     162    {
     163      if (counter == groupNumber)
     164        {
     165          if (verbose >= 2)
     166            printf ("Drawing object number %s named %s\n", counter, walker->name);
     167          glCallList (walker->listNumber);
     168          return;
     169        }
     170      ++counter;
     171      walker = walker->nextGroup;
     172    }
     173  if (verbose >= 2)
     174    printf("Object number %i in %s not Found.\n", groupNumber, objFileName);
     175  return;
     176
     177}
     178void Object::draw (char* groupName)
     179{
     180  if (verbose >=2)
     181    printf("drawing the requested 3D-Objects if found.\n");
     182  Group* walker = firstGroup;
     183  while (walker != NULL)
     184    {
     185      if (!strcmp(walker->name, groupName))
     186        {
     187          if (verbose >= 2)
     188            printf ("Drawing object %s\n", walker->name);
     189          glCallList (walker->listNumber);
     190          return;
     191        }
     192      walker = walker->nextGroup;
     193    }
     194  if (verbose >= 2)
     195    printf("Object Named %s in %s not Found.\n", groupName, objFileName);
     196  return;
     197}
     198
    147199
    148200/**
     
    154206    printf("Adding new Group\n");
    155207  group->faceMode = -1;
     208  group->name = "";
    156209  if ((group->listNumber = glGenLists(1)) == 0 )
    157210    {
     
    159212      return false;
    160213    }
    161 
     214 
    162215  if (groupCount == 0)
    163216    {
     
    429482  else
    430483    {
    431       currentGroup->name = groupString;
     484     
     485      currentGroup->name = new char [strlen(groupString)];     
     486      strcpy(currentGroup->name, groupString);
    432487    }
    433488}
  • orxonox/trunk/importer/object.h

    r2850 r2851  
    3232  bool finalize(void);
    3333  void draw (void);
    34 
    35 
     34  void draw (int groupNumber);
     35  void draw (char* groupName);
    3636
    3737 private:
Note: See TracChangeset for help on using the changeset viewer.