Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8309 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Jun 11, 2006, 12:24:11 PM (18 years ago)
Author:
bensch
Message:

trunk: better texture-sequence

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/importer/md2Model.cc

    r8293 r8309  
    8989#define BULK_CONV( _ptr, _num )
    9090#define BULK_CONV16( _ptr, _num )
    91 #endif 
     91#endif
    9292
    9393/********************************************************************************
     
    103103  /* this creates the data container via ressource manager */
    104104  if (!modelFileName.empty())
    105     this->data = (MD2Data*)ResourceManager::getInstance()->load( 
     105    this->data = (MD2Data*)ResourceManager::getInstance()->load(
    106106                        modelFileName, MD2, RP_GAME, skinFileName, scale);
    107                        
    108         //When arriving here it is assumed that everything is in the correct byte order.       
     107
     108        //When arriving here it is assumed that everything is in the correct byte order.
    109109  if( unlikely(this->data == NULL))
    110110    PRINTF(0)("The model was not found, MD2Model Loader finished abnormaly. Update the data-repos\n");
     
    125125  this->pModelInfo.numNormals = 0;
    126126  this->pModelInfo.numTexCoor = this->data->numTexCoor;
    127        
     127
    128128  this->pModelInfo.pVertices = (float*)this->data->pVertices;
    129                
     129
    130130  this->pModelInfo.pNormals = NULL;
    131131
    132132  this->pModelInfo.pTexCoor = (float*)this->data->pTexCoor;
    133        
     133
    134134  // triangle conversion
    135135  this->pModelInfo.pTriangles = new sTriangleExt[this->data->numTriangles];
     
    388388  //PRINTF(0)("\n==========================| MD2Model::debug() |===\n");
    389389  PRINTF(0)("=  Model FileName:\t%s\n", this->data->fileName.c_str());
    390   PRINTF(0)("=  Skin FileName:\t%s\n", 
     390  PRINTF(0)("=  Skin FileName:\t%s\n",
    391391                this->data->skinFileName.c_str());
    392   PRINTF(0)("=  Size in Memory:\t%i Bytes\n", 
     392  PRINTF(0)("=  Size in Memory:\t%i Bytes\n",
    393393                this->data->header->frameSize * this->data->header->numFrames + 64); // 64bytes is the header size
    394394  PRINTF(0)("=  Number of Vertices:\t%i\n", this->data->header->numVertices);
     
    438438MD2Data::~MD2Data()
    439439{
    440   delete this->header;
     440/*  delete this->header;
    441441
    442442  delete [] this->pVertices;
    443443  delete [] this->pGLCommands;
    444444  delete [] this->pLightNormals;
    445   delete [] this->pTexCoor;
     445  delete [] this->pTexCoor;*/
    446446}
    447447
     
    508508  /* triangle list */
    509509  fseek(pFile, this->header->offsetTriangles, SEEK_SET);
    510   fread(this->pTriangles, sizeof(sTriangle), this->numTriangles, pFile);       
     510  fread(this->pTriangles, sizeof(sTriangle), this->numTriangles, pFile);
    511511        BULK_CONV16( this->pTriangles, this->numTriangles*sizeof(sTriangle)/2 );
    512512
  • trunk/src/lib/graphics/importer/texture_sequence.cc

    r8298 r8309  
    2020#include "debug.h"
    2121#include "graphics_engine.h"
     22#include <stdarg.h>
    2223
    2324#ifdef HAVE_SDL_IMAGE_H
     
    4041}
    4142
     43
    4244/**
    4345 * Destructor of a TextureSequence
     
    6668    this->textures.pop_back();
    6769  }
    68 }
    69 
    70 /**
    71  * @brief rebuilds all the textures from the Images stored in this FrameSequence
    72  */
    73 bool TextureSequence::rebuild()
    74 {
    75   PRINTF(3)("Reloading TextureSequence of %s '%s'\n", this->getClassName(), this->getName());
    76 
    77   for (unsigned int i = 0; i < this->textures.size(); i++)
    78   {
    79     if (glIsTexture(this->textures[i]))
    80     {
    81       glDeleteTextures(1, &this->textures[i]);
    82       this->textures[i] = 0;
    83     }
    84 
    85     if (this->images[i] != NULL)
    86       this->textures[i] = loadTexToGL(this->images[i]);
    87   }
    88   return true;
    8970}
    9071
     
    9778bool TextureSequence::loadImageSeries(unsigned int count, ...)
    9879{
     80  bool retVal = true;
    9981  va_list textureNameList;
    10082  va_start(textureNameList, count);
    10183
    102   return this->loadImageSeries(count, textureNameList);
    103 }
    104 
    105 /**
    106  * @brief loads an image Sequence
    107  * @param count how many images to load to the TextureSequence
    108  * @param textures the names of the Images to load
    109  * @returns true on success, false otherwise
    110  */
    111 bool TextureSequence::loadImageSeries(unsigned int count, va_list textures)
    112 {
    113   bool retVal = true;
    11484  for (unsigned int i = 0; i < count; i++)
    11585  {
    116     if( !this->addFrame(va_arg(textures, char*)))
     86    if( !this->addFrame(va_arg(textureNameList, char*)))
    11787      retVal = false;
    11888  }
     
    12090}
    12191
    122 bool TextureSequence::loadImageSeries(const std::string& imagePrefix, unsigned int from, unsigned int to, const std::string& extension)
     92
     93/**
     94 * @brief Loads an Image-Series into the TextureSequence.
     95 * @param imagePrefix The Prefix of the Image
     96 * @param from From which image
     97 * @param to To which image
     98 * @return true on success.
     99 *
     100 * @example to load the Files image_001.jpg, image_002.jpg, ... image_099.jpg
     101 * use loadImageSeries("image_###.jpg", 0, 99);
     102 * @note important is, that the count of ###'s is correct.
     103 */
     104bool TextureSequence::loadImageSeries(const std::string& imagePrefix, unsigned int from, unsigned int to)
    123105{
    124106  unsigned int index = 0;
     
    134116      frameSize++;
    135117    }
    136     _imagePrefix += "." + extension;
    137     printf("TESTING %s\n", _imagePrefix.c_str());
    138118
    139119    PRINTF(4)("Found %d '#'s in %s... searching for LOD's\n", frameSize, imagePrefix.c_str());
     
    150130}
    151131
     132
    152133/**
    153134 * @brief adds a new Frame to this Sequence (at the end)
     
    198179}
    199180
    200 /**
    201  * @brief moves to the n'th texture which can then be retrieved via the Texture function: this->getTexture()
    202  * @param frameNumber the n-th frame
    203  */
    204 /*void TextureSequence::gotoFrame(unsigned int frameNumber)
    205 {
    206   if (this->textures.size() > frameNumber)
    207     this->setTexture(this->textures[frameNumber]);
    208 }
    209 */
     181
     182
     183/**
     184 * @brief rebuilds all the textures from the Images stored in this FrameSequence
     185 */
     186bool TextureSequence::rebuild()
     187{
     188  PRINTF(3)("Reloading TextureSequence of %s '%s'\n", this->getClassName(), this->getName());
     189
     190  for (unsigned int i = 0; i < this->textures.size(); i++)
     191  {
     192    if (glIsTexture(this->textures[i]))
     193    {
     194      glDeleteTextures(1, &this->textures[i]);
     195      this->textures[i] = 0;
     196    }
     197
     198    if (this->images[i] != NULL)
     199      this->textures[i] = loadTexToGL(this->images[i]);
     200  }
     201  return true;
     202}
  • trunk/src/lib/graphics/importer/texture_sequence.h

    r8297 r8309  
    1010
    1111#include <vector>
    12 #include <stdarg.h>
    1312
    1413
     
    1817  public:
    1918    TextureSequence(unsigned int count = 0, ...);
    20   //  Texture(TEXTURE_TYPE type, int resolution);
     19    TextureSequence(const std::vector<std::string>*& textureNames);
     20    //  Texture(TEXTURE_TYPE type, int resolution);
    2121    virtual ~TextureSequence();
    2222
    2323    bool loadImageSeries(unsigned int count, ...);
    24     bool loadImageSeries(unsigned int count, va_list textureNames);
    25     bool loadImageSeries(const std::string& imagePrefix, unsigned int from, unsigned int to, const std::string& extension = "png");
     24    bool loadImageSeries(unsigned int count, std::vector<std::string>& textureNames);
     25    bool loadImageSeries(const std::string& imagePrefix, unsigned int from, unsigned int to);
    2626    bool addFrame(const std::string& image);
    2727    bool addFrame(SDL_Surface* surface);
  • trunk/src/lib/gui/gl/glgui_cursor.cc

    r8299 r8309  
    6868
    6969    this->seq = new TextureSequence();
    70     this->seq->loadImageSeries(ResourceManager::getInstance()->getDataDir() + "/maps/reap_mouse/reap_mouse_##", 0, 49, "tif");
     70    this->seq->loadImageSeries(ResourceManager::getInstance()->getDataDir() + "/maps/reap_mouse/reap_mouse_##.tif", 0, 49);
    7171
    7272    this->resize();
  • trunk/src/world_entities/movie_entity.cc

    r7221 r8309  
    120120    counter = (int)(fps * timer);
    121121
    122     if (counter >= media_container->getFrameCount())
     122    if ((int)counter >= media_container->getFrameCount())
    123123    {
    124124      timer = 0;
Note: See TracChangeset for help on using the changeset viewer.