Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5865 in orxonox.OLD


Ignore:
Timestamp:
Dec 1, 2005, 11:00:49 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: sequence test

Location:
trunk/src
Files:
3 edited
1 copied

Legend:

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

    r5863 r5865  
    2929/**
    3030 *  Constructor for a Texture
    31 */
     31 */
    3232TextureSequence::TextureSequence(unsigned int count, ...)
    3333{
     
    4141
    4242/**
    43  *  Destructor of a TextureSequence
    44 
    45    Frees Data, and deletes the textures from GL
    46 */
     43 * Destructor of a TextureSequence
     44 *
     45 * Frees Data, and deletes the textures from GL
     46 */
    4747TextureSequence::~TextureSequence()
    4848{
     
    5454  }
    5555
     56  this->setTexture(0);
    5657  // delete all textures.
    5758  while(!this->textures.empty())
     
    6566
    6667/**
    67  * rebuilds all the textures from the Images stored in this FrameSequence
     68 * @brief rebuilds all the textures from the Images stored in this FrameSequence
    6869 */
    6970bool TextureSequence::rebuild()
     
    8586
    8687/**
    87  * loads an image Series
     88 * @brief loads an image Sequence
    8889 * @param count how many images to load to the TextureSequence
    8990 * @param ... the names of the Images to load
     
    99100
    100101/**
    101  * loads an image Series
     102 * @brief loads an image Sequence
    102103 * @param count how many images to load to the TextureSequence
    103104 * @param textures the names of the Images to load
     
    115116}
    116117
    117 
     118/**
     119 * @brief adds a new Frame to this Sequence (at the end)
     120 * @param imageName the Name of the Image to add
     121 * @returns true on success
     122 */
    118123bool TextureSequence::addFrame(const char* imageName)
    119124{
     
    129134
    130135/**
    131  * adds a new Frame at the end of the Sequence.
     136 * @brief adds a new Frame at the end of the Sequence.
    132137 * @param surface the Surface to add at the end of the Sequence.
    133138 */
     
    144149  }
    145150  this->setAlpha(hasAlpha);
     151  return true;
    146152}
     153
     154
     155
     156/**
     157 * moves to the n'th texture which can then be retrieved via the Texture function: this->getTexture()
     158 * @param frameNumber the n-th frame
     159 */
     160void TextureSequence::gotoFrame(unsigned int frameNumber)
     161{
     162  if (this->textures.size() > frameNumber)
     163    this->setTexture(this->textures[frameNumber]);
     164}
  • trunk/src/lib/graphics/importer/texture_sequence.h

    r5861 r5865  
    3232    virtual bool rebuild();
    3333
     34    /** @returns the count of frames in this sequence */
     35    inline unsigned int getFrameCount() const { return this->textures.size(); };
     36
     37    void gotoFrame(unsigned int frameNumber);
    3438    /** @returns The textureID of the Frame @param frameNumber the n-th frame this texture-series.  */
    35     inline GLuint getFrameTexture(unsigned int frameNumber) const { return this->textures[frameNumber]; };
     39    inline GLuint getFrameTexture(unsigned int frameNumber) const { return (this->textures.size()>frameNumber)?this->textures[frameNumber]:0; };
    3640    /** @returns The SDL_Surface of the image at Frame @param frameNumber the n-th frame of this image-seriers */
    37     const SDL_Surface* const getFrameImage(unsigned int frameNumber) const { return this->images[frameNumber]; };
     41    const SDL_Surface* const getFrameImage(unsigned int frameNumber) const { return (this->images.size()>frameNumber)?this->images[frameNumber]:NULL; };
    3842
    3943  private:
  • trunk/src/subprojects/importer/Makefile.am

    r5750 r5865  
    66importer_LDFLAGS = $(MWINDOWS)
    77
    8 bin_PROGRAMS = importer
     8bin_PROGRAMS = importer \
     9               multitex
    910
    1011importer_LDADD = $(MAINSRCDIR)/lib/event/libORXevent.a \
     
    3233                  $(MAINSRCDIR)/lib/util/color.cc \
    3334                  $(MAINSRCDIR)/lib/util/multi_type.cc \
     35                  $(MAINSRCDIR)/lib/util/executor/executor.cc \
    3436                  $(MAINSRCDIR)/util/loading/factory.cc
     37
     38
     39multitex_LDADD = $(MAINSRCDIR)/lib/event/libORXevent.a \
     40                 $(MAINSRCDIR)/lib/tinyxml/libtinyxml.a \
     41                 $(MAINSRCDIR)/lib/graphics/libORXgraphics.a \
     42                 $(MAINSRCDIR)/lib/shell/libORXshell.a \
     43                 $(MAINSRCDIR)/lib/sound/libORXsound.a \
     44                 $(MAINSRCDIR)/lib/graphics/importer/libORXimporter.a
     45
     46multitex_SOURCES= ../framework.cc \
     47                  multitex.cc \
     48                  $(MAINSRCDIR)/util/state.cc \
     49                  $(MAINSRCDIR)/world_entities/camera.cc \
     50                  $(MAINSRCDIR)/lib/lang/base_object.cc \
     51                  $(MAINSRCDIR)/lib/lang/class_list.cc \
     52                  $(MAINSRCDIR)/lib/math/vector.cc \
     53                  $(MAINSRCDIR)/util/loading/resource_manager.cc \
     54                  $(MAINSRCDIR)/lib/util/ini_parser.cc \
     55                  $(MAINSRCDIR)/lib/coord/p_node.cc \
     56                  $(MAINSRCDIR)/lib/coord/null_parent.cc \
     57                  $(MAINSRCDIR)/util/loading/load_param.cc \
     58                  $(MAINSRCDIR)/util/loading/load_param_description.cc \
     59                  $(MAINSRCDIR)/lib/util/helper_functions.cc \
     60                  $(MAINSRCDIR)/lib/util/substring.cc \
     61                  $(MAINSRCDIR)/lib/util/color.cc \
     62                  $(MAINSRCDIR)/lib/util/multi_type.cc \
     63                  $(MAINSRCDIR)/lib/util/executor/executor.cc \
     64                  $(MAINSRCDIR)/util/loading/factory.cc
  • trunk/src/subprojects/importer/multitex.cc

    r5857 r5865  
    2020#include "light.h"
    2121
     22#include "texture_sequence.h"
     23#include "material.h"
     24
    2225#include "objModel.h"
     26
    2327#include "primitive_model.h"
    2428#include <stdlib.h>
     
    2731
    2832Model* obj;
     33TextureSequence* seq;
     34Texture* test;
     35float counter = 0;
    2936
    3037void Framework::moduleInit(int argc, char** argv)
     
    3239  ResourceManager::getInstance()->addImageDir("./");
    3340
    34   for (int i = 0; i < argc; i++)
     41  seq = new TextureSequence();
     42  for (int i = 1; i < argc; i++)
    3543  {
     44    seq->addFrame(argv[i]);
    3645    printf("%s\n", argv[i]);
    3746  }
     47  test = new Texture(argv[1]);
     48
    3849  ResourceManager::getInstance()->addImageDir("");
    3950
    4051
    41   if (argc>=3)
    42     obj = new OBJModel (argv[1], atof(argv[2]));
    43   else if (argc>=2)
    44     obj = new OBJModel(argv[1]);
    45   else
    46     obj = new PrimitiveModel(PRIM_CYLINDER);
     52  obj = new PrimitiveModel(PRIM_CYLINDER);
    4753
    4854  ResourceManager::getInstance()->debug();
     
    6975void Framework::moduleTick(float dt)
    7076{
     77  counter+=dt;
    7178
     79  seq->gotoFrame((unsigned int)counter);
     80  if ((unsigned int)counter > seq->getFrameCount())
     81    counter = 0;
    7282}
    7383
    7484void Framework::moduleDraw(void) const
    7585{
     86  float diffuse[] = {1,1,1,1};
     87  float ambient[] = {1,0,0,1};
     88  float specular[] = {1,0,1,1};
     89  // setting diffuse color
     90  //  glColor3f (diffuse[0], diffuse[1], diffuse[2]);
     91  glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse);
     92
     93  // setting ambient color
     94  glMaterialfv(GL_FRONT, GL_AMBIENT, ambient);
     95
     96  // setting up Sprecular
     97  glMaterialfv(GL_FRONT, GL_SPECULAR, specular);
     98
     99  // setting up Shininess
     100  glMaterialf(GL_FRONT, GL_SHININESS, .4);
     101  glShadeModel(GL_SMOOTH);
     102
     103  glEnable(GL_TEXTURE_2D);
     104  glBindTexture(GL_TEXTURE_2D, seq->getTexture());
     105//  printf("Number = %d\n", seq->getTexture());
     106    /* This allows alpha blending of 2D textures with the scene */
     107//     if (seq->hasAlpha())
     108//     {
     109//       glEnable(GL_BLEND);
     110//       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     111//     }
     112
    76113  obj->draw();
    77114
Note: See TracChangeset for help on using the changeset viewer.