Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9755 in orxonox.OLD for branches/new_class_id/src/lib


Ignore:
Timestamp:
Sep 17, 2006, 11:33:22 PM (18 years ago)
Author:
bensch
Message:

orxonox/new_class_id: some minor work… nothing too special, and nothing too big… tried to fix the PNode, and some documentations…

hmm… i also think of writing a book. maybe i will write the whole story as a Commit message :) so it is backed up. hehe

Location:
branches/new_class_id/src/lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/coord/p_node.cc

    r9715 r9755  
    7878PNode::~PNode ()
    7979{
    80   PRINTF(4)("delete %s::%s\n", this->getClassCName(), this->getCName());
     80  PRINTF(0)("delete %s::%s\n", this->getClassCName(), this->getCName());
     81  this->debugNode(0);
    8182  // remove the Node, delete it's children (if required).
    82   std::list<PNode*>::iterator deleteNode;
    83   unsigned int size;
    8483  while(!this->children.empty())
    8584  {
    86     deleteNode = this->children.begin();
    87     size = this->children.size();
     85    PNode* deleteNode = this->children.front();
    8886    if ((this->parentMode & PNODE_PROHIBIT_CHILD_DELETE) ||
    89         ((*deleteNode)->parentMode & PNODE_PROHIBIT_DELETE_WITH_PARENT))
     87        (deleteNode->parentMode & PNODE_PROHIBIT_DELETE_WITH_PARENT))
    9088    {
    91       if (this == PNode::nullParent && (*deleteNode)->parentMode & PNODE_REPARENT_TO_NULL)
     89      if (this == PNode::nullParent && deleteNode->parentMode & PNODE_REPARENT_TO_NULL)
    9290      {
    9391        PRINTF(4)("%s::%s deletes %s::%s\n",
    9492                  this->getClassCName(), this->getCName(),
    95                   (*deleteNode)->getClassCName(), (*deleteNode)->getCName());
    96         delete (*deleteNode);
     93                  deleteNode->getClassCName(), deleteNode->getCName());
     94        delete deleteNode;
    9795      }
    9896      else
     
    10098        PRINTF(4)("%s::%s reparents %s::%s\n",
    10199                  this->getClassCName(), this->getCName(),
    102                   (*deleteNode)->getClassCName(), (*deleteNode)->getCName());
    103         (*deleteNode)->reparent();
     100                  deleteNode->getClassCName(), deleteNode->getCName());
     101        deleteNode->reparent();
    104102      }
    105103    }
     
    108106      PRINTF(4)("%s::%s deletes PNode: %s::%s\n",
    109107                this->getClassCName(), this->getCName(),
    110                 (*deleteNode)->getClassCName(), (*deleteNode)->getCName());
    111       delete (*deleteNode);
     108                deleteNode->getClassCName(), deleteNode->getCName());
     109      delete deleteNode;
    112110    }
    113111  }
  • branches/new_class_id/src/lib/util/color.cc

    r8986 r9755  
    3030//! Black Color
    3131const Color Color::black(0,0,0,1);
    32 //! Orx Color
    33 const Color Color::orx(.2, .5, .7, .8);  //!< TODO Define the ORX-color :)
    34 
    35 
     32
     33/**
     34 * @brief slerps the Color in the HSV color space into the direction of c
     35 * @param c the Color to slerp to
     36 * @param v the Value to slerp 0 means stay at *this, 1 means at c.
     37 */
    3638void Color::slerpHSV(const Color& c, float v)
    3739{
     
    5254}
    5355
     56/**
     57 * @brief simple slerp wrapper.
     58 * @param from from this color
     59 * @param to to this one
     60 * @param v how much
     61 * @see void Color::slerpHSV(const Color& c, float v)
     62 */
    5463Color Color::slerpHSVColor(const Color& from, const Color& to, float v)
    5564{
     
    5968}
    6069
    61 
     70/**
     71 * @brief nice and simple debug output for the colors (colorless :) )
     72 */
    6273void Color::debug() const
    6374{
     
    214225
    215226
    216 // Needed by rgb2hsv()
     227/**
     228 * @returns the maximum of r g and a.
     229 * @param r Red.
     230 * @param g Green
     231 * @param b Blue
     232 */
    217233float Color::maxrgb(float r, float g, float b)
    218234{
     
    227243}
    228244
    229 
    230 // Needed by rgb2hsv()
     245/**
     246 * @returns the minimum of r g and a.
     247 * @param r Red.
     248 * @param g Green
     249 * @param b Blue
     250 */
    231251float Color::minrgb(float r,float g,float b)
    232252{
  • branches/new_class_id/src/lib/util/color.h

    r9656 r9755  
    1414#include "vector.h"
    1515
    16 //! a very abstract Class that helps transforming Colors into different Systems
     16//! A Class that handles Colors.
     17/**
     18 * A Color is a collection of 4 values:
     19 * <ul>
     20 *  <li>Red</li>
     21 *  <li>Green</li>
     22 *  <li>Blue</li>
     23 *  <li>Alpha</li>
     24 * </ul>
     25 * With these four values any color of the entire spectrum can be defined.
     26 *
     27 * By default a Color lies between 0 and 1 for each component.
     28 * for example [1,0,0,.5] means red and half visible.
     29 */
    1730class Color
    1831{
    1932public:
     33  /** @param r red, @param g green @param b blue @param a alpha @brief constructs a Color. */
    2034  Color(float r = 0.0f, float g = 0.0f, float b = 0.0f, float a = 1.0f) { _rgba[0] = r; _rgba[1] = g; _rgba[2] = b; _rgba[3] = a; };
     35  /** @param c Color @brief copy constructor */
    2136  Color(const Color& c) { _rgba[0] = c.r(); _rgba[1] = c.g(); _rgba[2] = c.b(); _rgba[3] = c.a(); }
    2237
     38  /** @param c the Color to set to this color @returns the copied color */
    2339  inline const Color& operator=(const Color& c) { _rgba[0] = c.r(); _rgba[1] = c.g(); _rgba[2] = c.b(); _rgba[3] = c.a(); return *this; };
     40  /** @param c the color to compare @returns true on match. @brief compares two colors */
    2441  inline bool operator==(const Color& c) const { return (r() == c.r() && g() == c.g() && b() == c.b() && a() == c.a()); };
    2542
     43  /** @returns the i'th Value of the Color @param i part of the color 0:r, 1:g, 2:b, 3:a */
    2644  inline float& operator[](unsigned int i) { return _rgba[i]; }
     45  /** @returns a Constant Value of the color. @param i part of the color 0:r, 1:g, 2:b, 3:a */
    2746  inline const float& operator[](unsigned int i) const { return _rgba[i]; }
    2847
     48  /** @returns the red part. */
    2949  inline float r() const { return _rgba[0]; }
     50  /** @returns the reference to the red part */
    3051  inline float& r() { return _rgba[0]; }
     52  /** @returns the green part. */
    3153  inline float g() const { return _rgba[1]; }
     54  /** @returns the reference to the green part */
    3255  inline float& g() { return _rgba[1]; }
     56  /** @returns the blue part */
    3357  inline float b() const { return _rgba[2]; }
     58  /** @returns the reference to the blue part */
    3459  inline float& b() { return _rgba[2]; }
     60  /** @returns the alpha part */
    3561  inline float a() const { return _rgba[3]; }
     62  /** @returns the reference to the alpha part */
    3663  inline float& a() { return _rgba[3]; }
    3764
    3865
    39 
    40 
     66  /** @param r red, @param g green @param b blue @param a alpha @brief sets the color. */
    4167  void setColor(float r = 0.0f, float g = 0.0f, float b = 0.0f, float a = 1.0f) { _rgba[0] = r; _rgba[1] = g; _rgba[2] = b; _rgba[3] = a; };
     68  /** @param c the color to set. @brief sets the color. */
    4269  void setColor(const Color& c) { r() = c.r();  g()= c.g(); b() = c.b(); a() = c.a(); };
    4370
     71  /** @returns the distance to the color @param c the color to calculate the distance to. */
    4472  inline float dist(const Color& c) const { return (sqrt((r()-c.r())*(r()-c.r()) + (g()-c.g())*(g()-c.g()) + (b()-c.b())*(b()-c.b()) + (a()-c.a())*(a()-c.a()))); }
    4573  /// Maths
     74  /** @param c the color to add to this one @returns the two added colors */
    4675  inline const Color& operator+=(const Color& c) { r()+=c.r(); g()+=c.g(); b()+=c.b(); a()+=c.a(); return *this; };
     76  /** @returns the result of the added colors @param c the color to add */
    4777  inline Color operator+(const Color& c) const { return Color(r()+c.r(), g()+c.g(), b()+c.b(), a()+c.a()); };
     78  /** @param c the color to substract to this one @returns the two substracted colors */
    4879  inline const Color& operator-=(const Color& c) { r()-=c.r(); g()-=c.g(); b()-=c.b(); a()-=c.a(); return *this; };
     80  /** @returns the result of the substracted colors @param c the color to substract */
    4981  inline Color operator-(const Color& c) const { return Color(r()-c.r(), g()-c.g(), b()-c.b(), a()-c.a()); };
     82  /** @param v the multiplier @returns the Color multiplied by v */
    5083  inline const Color& operator*=(float v) { r()*=v, g()*=v, b()*=v, a()*=v; return *this; };
     84  /** @param v the multiplier @returns a multiplied color */
    5185  inline Color operator*(float v) const { return Color(r()*v, g()*v, b()*v, a()*v); };
    5286
     87  /** @param c the color to slerp to @param v how much to slerp [0:1] @brief moves the color into the direction of another color */
    5388  void slerp(const Color& c, float v) { *this += (c - *this) * v; };
    5489  void slerpHSV(const Color& c, float v);
    55 
    5690  static Color slerpHSVColor(const Color& from, const Color& to, float v);
    5791
     
    75109  static const Color white;
    76110  static const Color black;
    77   static const Color orx;
    78111
    79112private:
    80   float       _rgba[4]; //!< Color Values
    81 
    82   /*  float       _r;     //!< Red Value.
    83   float       _g;     //!< Green Value.
    84   float       _b;     //!< Blue Value.
    85   float       _a;     //!< Alpha Value.*/
     113  float       _rgba[4]; //!< Color Values [r,g,b,a] (red green blue alpha)
    86114};
    87115
Note: See TracChangeset for help on using the changeset viewer.