Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4415 in orxonox.OLD


Ignore:
Timestamp:
May 31, 2005, 9:12:33 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: added quick-animation for FAST, bad animations that suffice for the properties particles over time

Location:
orxonox/trunk/src
Files:
2 edited
2 copied

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/Makefile.am

    r4398 r4415  
    101101                 lib/graphics/particles/particle_system.cc \
    102102                 lib/graphics/particles/particle_emitter.cc \
     103                 lib/graphics/particles/quick_animation.cc \
    103104                 lib/lang/base_object.cc \
    104105                 lib/util/ini_parser.cc \
     
    179180                 lib/graphics/particles/particle_system.h \
    180181                 lib/graphics/particles/particle_emitter.h \
     182                 lib/graphics/particles/quick_animation.h \
    181183                 lib/lang/base_object.h \
    182184                 util/common/list.h \
  • orxonox/trunk/src/Makefile.in

    r4398 r4415  
    7474        material.$(OBJEXT) texture.$(OBJEXT) particle_engine.$(OBJEXT) \
    7575        particle_system.$(OBJEXT) particle_emitter.$(OBJEXT) \
    76         base_object.$(OBJEXT) ini_parser.$(OBJEXT) substring.$(OBJEXT) \
    77         vector.$(OBJEXT) curve.$(OBJEXT) glmenu_imagescreen.$(OBJEXT) \
     76        quick_animation.$(OBJEXT) base_object.$(OBJEXT) \
     77        ini_parser.$(OBJEXT) substring.$(OBJEXT) vector.$(OBJEXT) \
     78        curve.$(OBJEXT) glmenu_imagescreen.$(OBJEXT) \
    7879        benchmark.$(OBJEXT)
    7980orxonox_OBJECTS = $(am_orxonox_OBJECTS)
     
    112113@AMDEP_TRUE@    ./$(DEPDIR)/primitive_model.Po \
    113114@AMDEP_TRUE@    ./$(DEPDIR)/projectile.Po \
     115@AMDEP_TRUE@    ./$(DEPDIR)/quick_animation.Po \
    114116@AMDEP_TRUE@    ./$(DEPDIR)/resource_manager.Po \
    115117@AMDEP_TRUE@    ./$(DEPDIR)/satellite.Po ./$(DEPDIR)/skybox.Po \
     
    315317                 lib/graphics/particles/particle_system.cc \
    316318                 lib/graphics/particles/particle_emitter.cc \
     319                 lib/graphics/particles/quick_animation.cc \
    317320                 lib/lang/base_object.cc \
    318321                 lib/util/ini_parser.cc \
     
    393396                 lib/graphics/particles/particle_system.h \
    394397                 lib/graphics/particles/particle_emitter.h \
     398                 lib/graphics/particles/quick_animation.h \
    395399                 lib/lang/base_object.h \
    396400                 util/common/list.h \
     
    527531@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/primitive_model.Po@am__quote@
    528532@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/projectile.Po@am__quote@
     533@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/quick_animation.Po@am__quote@
    529534@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/resource_manager.Po@am__quote@
    530535@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/satellite.Po@am__quote@
     
    13941399@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    13951400@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o particle_emitter.obj `if test -f 'lib/graphics/particles/particle_emitter.cc'; then $(CYGPATH_W) 'lib/graphics/particles/particle_emitter.cc'; else $(CYGPATH_W) '$(srcdir)/lib/graphics/particles/particle_emitter.cc'; fi`
     1401
     1402quick_animation.o: lib/graphics/particles/quick_animation.cc
     1403@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT quick_animation.o -MD -MP -MF "$(DEPDIR)/quick_animation.Tpo" -c -o quick_animation.o `test -f 'lib/graphics/particles/quick_animation.cc' || echo '$(srcdir)/'`lib/graphics/particles/quick_animation.cc; \
     1404@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/quick_animation.Tpo" "$(DEPDIR)/quick_animation.Po"; else rm -f "$(DEPDIR)/quick_animation.Tpo"; exit 1; fi
     1405@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='lib/graphics/particles/quick_animation.cc' object='quick_animation.o' libtool=no @AMDEPBACKSLASH@
     1406@AMDEP_TRUE@@am__fastdepCXX_FALSE@      depfile='$(DEPDIR)/quick_animation.Po' tmpdepfile='$(DEPDIR)/quick_animation.TPo' @AMDEPBACKSLASH@
     1407@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1408@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o quick_animation.o `test -f 'lib/graphics/particles/quick_animation.cc' || echo '$(srcdir)/'`lib/graphics/particles/quick_animation.cc
     1409
     1410quick_animation.obj: lib/graphics/particles/quick_animation.cc
     1411@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT quick_animation.obj -MD -MP -MF "$(DEPDIR)/quick_animation.Tpo" -c -o quick_animation.obj `if test -f 'lib/graphics/particles/quick_animation.cc'; then $(CYGPATH_W) 'lib/graphics/particles/quick_animation.cc'; else $(CYGPATH_W) '$(srcdir)/lib/graphics/particles/quick_animation.cc'; fi`; \
     1412@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/quick_animation.Tpo" "$(DEPDIR)/quick_animation.Po"; else rm -f "$(DEPDIR)/quick_animation.Tpo"; exit 1; fi
     1413@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='lib/graphics/particles/quick_animation.cc' object='quick_animation.obj' libtool=no @AMDEPBACKSLASH@
     1414@AMDEP_TRUE@@am__fastdepCXX_FALSE@      depfile='$(DEPDIR)/quick_animation.Po' tmpdepfile='$(DEPDIR)/quick_animation.TPo' @AMDEPBACKSLASH@
     1415@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1416@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o quick_animation.obj `if test -f 'lib/graphics/particles/quick_animation.cc'; then $(CYGPATH_W) 'lib/graphics/particles/quick_animation.cc'; else $(CYGPATH_W) '$(srcdir)/lib/graphics/particles/quick_animation.cc'; fi`
    13961417
    13971418base_object.o: lib/lang/base_object.cc
  • orxonox/trunk/src/lib/graphics/particles/quick_animation.cc

    r4394 r4415  
    1616//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_
    1717
    18 #include "proto_class.h"
     18#include "quick_animation.h"
     19
     20#include "compiler.h"
     21#include "debug.h"
     22#ifndef NULL
     23#define NULL 0
     24#endif
     25
    1926
    2027using namespace std;
     
    2330/**
    2431   \brief standard constructor
    25    \todo this constructor is not jet implemented - do it
    2632*/
    27 ProtoClass::ProtoClass ()
     33QuickAnimation::QuickAnimation (float rangeStart, float valueStart, float rangeEnd, float valueEnd)
    2834{
    29    this->setClassID(CL_PROTO_ID, "ProtoClass");
     35   this->setClassName("QuickAnimation");
    3036
    31    /* If you make a new class, what is most probably the case when you write this file
    32       don't forget to:
    33        1. Add the new file new_class.cc to the ./src/Makefile.am
    34        2. Add the class identifier to ./src/class_list.h eg. CL_NEW_CLASS
    35 
    36       Advanced Topics:
    37       - if you want to let your object be managed via the ObjectManager make sure to read
    38         the object_manager.h header comments. You will use this most certanly only if you
    39         make many objects of your class, like a weapon bullet.
    40    */
     37   this->first = this->current = new QuickKeyFrame;
     38   this->current->positionStart = rangeStart;
     39   this->current->positionEnd = rangeEnd;
     40   this->current->valueStart = valueStart;
     41   this->current->valueEnd = valueEnd;
     42   this->current->next = NULL;
    4143}
    4244
     
    4648
    4749*/
    48 ProtoClass::~ProtoClass ()
     50QuickAnimation::~QuickAnimation ()
    4951{
    50   // delete what has to be deleted here
     52  this->current = this->first;
     53  QuickKeyFrame delKF;
     54 
     55  while (this->current != NULL)
     56    {
     57      this->first = this->current->next;
     58      delete this->current;
     59      this->current = this->first;
     60    }
     61
    5162}
     63
     64
     65void QuickAnimation::addEntry(float position, float value)
     66{
     67  this->current = this->first;
     68  if (position < this->current->positionStart)
     69    {
     70      this->current = new QuickKeyFrame;
     71
     72      this->current->positionStart = position;
     73      this->current->positionEnd = this->first->positionStart;
     74
     75      this->current->valueStart = value;
     76      this->current->valueEnd = this->first->valueStart;
     77     
     78      this->current->next = this->first;
     79      this->first = this->current;
     80    }
     81 
     82  while(this->current != NULL)
     83    {
     84      if (this->current->positionStart < position)
     85        {
     86          QuickKeyFrame* tmpKey = new QuickKeyFrame;
     87          tmpKey->positionStart = position;
     88          tmpKey->positionEnd = this->current->positionEnd;
     89          tmpKey->valueStart = value;
     90          tmpKey->valueEnd = this->current->valueEnd;
     91          tmpKey->next = this->current->next;
     92         
     93          this->current->positionEnd = tmpKey->positionStart;
     94          this->current->valueEnd = tmpKey->valueStart;
     95        }
     96    }
     97}
     98
     99
     100float QuickAnimation::getValue(float position)
     101{
     102  while (likely (this->current->positionStart > position || this->current->positionEnd < position))
     103    {
     104      if (likely(this->current->next != NULL))
     105        this->current = this->current->next;
     106      else
     107        {
     108          if (unlikely(this->first->positionStart > position))
     109            {
     110              PRINTF(2)("Position out of range. chose %f, min is: %f, max is\n", position, this->first->positionStart, this->current->positionEnd);
     111              return 0;
     112            }
     113          this->current = this->first;
     114        }
     115    }
     116  return this->current->valueStart + (this->current->positionEnd - position) *
     117    (this->current->valueEnd - this->current->valueStart) /
     118    (this->current->positionEnd - this->current->positionStart);
     119}
     120
  • orxonox/trunk/src/lib/graphics/particles/quick_animation.h

    r4394 r4415  
    11/*!
    2     \file proto_class.h
    3     \brief Definition of ...
     2    \file quick_animation.h
     3    \brief Definition of the QuickAnimation-class
    44
    55*/
    66
    7 #ifndef _PROTO_CLASS_H
    8 #define _PROTO_CLASS_H
     7#ifndef _QUICK_ANIMATION_H
     8#define _QUICK_ANIMATION_H
    99
    1010#include "base_object.h"
     
    1414
    1515
    16 //! A class for ...
    17 class ProtoClass : public BaseObject {
     16
     17//! A class for that linearely interpolates between multiple values.
     18/**
     19   to be quick this only has the capability to store very little date
     20
     21   this class is optimized for a raising value. eg. 100 particles sorted
     22   by age.
     23*/
     24class QuickAnimation : public BaseObject {
    1825
    1926 public:
    20   ProtoClass();
    21   virtual ~ProtoClass();
     27  //! a simple struct that stores keyframes for the QuickAnimation-Class.
     28  struct QuickKeyFrame
     29  {
     30    float valueStart;       //!< The starting value of this KeyFrame
     31    float valueEnd;         //!< The end value of this KeyFrame
     32    float positionStart;    //!< The starting position of this KeyFrame
     33    float positionEnd;      //!< The end position of thies KeyFrame
    2234
     35    QuickKeyFrame* next;    //!< The next Animation
     36  };
     37
     38  QuickAnimation(float rangeStart = 0.0, float valueStart = 0.0, float rangeEnd = 1.0, float valueEnd = 0.0);
     39  virtual ~QuickAnimation();
     40
     41  void addEntry(float position, float value);
     42
     43  float getValue(float position);
    2344
    2445 private:
     46  QuickKeyFrame* first;
     47  QuickKeyFrame* current;
    2548
    2649};
    2750
    28 #endif /* _PROTO_CLASS_H */
     51#endif /* _QUICK_ANIMATION_H */
Note: See TracChangeset for help on using the changeset viewer.