home *** CD-ROM | disk | FTP | other *** search
/ Qu-ake / Qu-ake.iso / qu_ke / editor / 017 / ENTITY.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-11-15  |  3.0 KB  |  86 lines

  1. //=======================================================================//
  2. //ReadEntity - Reads all entities that are not made from a brush         //
  3. //             ie a platform has point coordinates and is handled        //
  4. //                seperately                                             //
  5. //Martian 11/13/96                                                       // 
  6. //Martian 11/15/96 - Reads all entities, brushes, and special brushes    //
  7. //                 - ie like platforms.  Not tested every possible       //
  8. //                 - speacial brush, that's up to you                    //
  9. //=======================================================================//
  10.  
  11. #include <stdio.h>
  12. #include <string.h> 
  13. #include <stdlib.h>
  14. #include "io.h"  
  15. #include "entity.h"
  16. #include "brush.h" 
  17.  
  18. void ReadEntity(char *token, int *scriptline, char *dat, int *location)
  19.  while (1)
  20.  {  
  21.  getentity:
  22.      if (!GetToken(TRUE, token, scriptline, dat, location))
  23.          break;
  24.      if ((strcmp (token, "}") )==0)
  25.         break; 
  26.     printf (">>read entity\n");    
  27.     
  28.     GetToken(FALSE, token, scriptline, dat, location);  //Entity which must be listed after classname
  29.     printf("\tEntity is: %s\n",token);
  30.          
  31.      GetToken(TRUE, token, scriptline, dat, location);    //origin should be first after classname identifier  
  32.      if ((strcmp (token, "{"))==0)                       //if not then it is a special brush like a platform
  33.         {   
  34.             ReadSpecialEntity(token,scriptline,dat,location);
  35.             goto getentity;             
  36.         }             
  37.      GetToken(FALSE, token, scriptline, dat, location);  //get origin information, needs to be converted to int to use
  38.     printf("\tOrigin is: %s\n",token); 
  39.     
  40.     GetToken(TRUE, token, scriptline, dat, location);   //check for additional attributes 
  41.     
  42.     if ((strcmp(token,"}"))!=0)
  43.         {
  44.             printf("\tOther Attributes: \n");
  45.             
  46.             while ((strcmp(token,"}"))!=0)             //loop and collect all attributes
  47.                 {   
  48.                     printf("\t\tattrib : %s",token);                           
  49.                     GetToken(FALSE, token, scriptline, dat, location);
  50.                     printf("\t%s\n",token);
  51.             
  52.                     GetToken(TRUE, token, scriptline, dat, location);                     
  53.                 } 
  54.             GetToken(TRUE, token, scriptline, dat, location);        
  55.         } 
  56.     else
  57.         {
  58.             GetToken(TRUE, token, scriptline, dat, location);
  59.         }             
  60.  }
  61.  
  62. }
  63.  
  64. void ReadSpecialEntity(char *token, int *scriptline, char *dat, int *location)
  65. {  
  66.  int i;
  67.     
  68.  printf (">>read special entity\n"); 
  69.  printf ("\t");
  70.  
  71.  ReadBrush (token, scriptline, dat, location);       
  72.  //Print out some key info//
  73.  printf("\tTexture %s\n",f->texture.texture);
  74.  printf("\tNumber of faces %i\n",numfaces); 
  75.  printf("\tWinding for each Face\n");
  76.  for (i=0 ; i<MAX_FACES ; i++)   
  77.      {
  78.           if (faces[i].w)
  79.             {         
  80.              printf("\t\tV (%Li)\n",faces[i].w);
  81.             }
  82.      }       
  83.   printf("\tBMINS (%Li %Li %Li)\n",bmins[0],bmins[1],bmins[2]);
  84.   printf("\tBMAXS (%Li %Li %Li)\n",bmaxs[0],bmaxs[1],bmaxs[2]);  
  85. }