Main Page   Class Hierarchy   Compound List   Header Files   Compound Members  

ddgbbox.h

This is the verbatim text of the ddgbbox.h include file.
/*
    Copyright (C) 1997, 1998, 1999, 2000 by Alex Pfaffe
        (Digital Dawn Graphics Inc)
  
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.
  
    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.
  
    You should have received a copy of the GNU Library General Public
    License along with this library; if not, write to the Free
    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _ddgBBox_Class_
#define _ddgBBox_Class_

#include "math/ddgvec.h"
#include "math/ddggeom.h"

// Visibility data. 1 byte.
typedef unsigned char ddgClipFlags;
enum {
  DDGCF_LIN    = 1 << 0, 
  DDGCF_RIN    = 1 << 1, 
  DDGCF_TIN    = 1 << 2, 
  DDGCF_BIN    = 1 << 3, 
  DDGCF_NIN    = 1 << 4, 
  DDGCF_FIN    = 1 << 5, 
  DDGCF_ALLIN  = 1 << 6, 
  DDGCF_ALLOUT = 1 << 7  
};

#define DDGCF_VISIBILITY \
  (DDGCF_LIN | DDGCF_RIN | DDGCF_TIN | DDGCF_BIN | DDGCF_NIN | DDGCF_FIN)

// Visibility data. 3 bits.
typedef unsigned char ddgVisState;

class WEXP ddgBBox3 {
public:
        ddgVector3 min;
        ddgVector3 max;
        static short _corner[8][3];
        typedef enum { XLT, XGT, YLT, YGT, ZLT, ZGT } Split;
        ddgBBox3(float xc = 0.0, float xd = MAXFLOAT, 
           float yc = 0.0, float yd = MAXFLOAT, 
           float zc = 0.0, float zd = MAXFLOAT);
        ddgBBox3(const ddgVector3 &min, const ddgVector3 &max);
        void set(float xmin = -MAXFLOAT, float xmax = MAXFLOAT,
                     float ymin = -MAXFLOAT, float ymax = MAXFLOAT,
                     float zmin = -MAXFLOAT, float zmax = MAXFLOAT);
        void set(const ddgVector3 &pmin, const ddgVector3 &pmax)
        { min = pmin; max = pmax; }

        float minx( void ) { return min[0]; }
        float miny( void ) { return min[1]; }
        float minz( void ) { return min[2]; }
        float maxx( void ) { return max[0]; }
        float maxy( void ) { return max[1]; }
        float maxz( void ) { return max[2]; }

        void setx(float pmin, float pmax)
        {
          min[0] = pmin;
          max[0] = pmax;
        }
        void sety(float pmin, float pmax)
        {
          min[1] = pmin;
          max[1] = pmax;
        }
        void setz(float pmin, float pmax)
        {
          min[2] = pmin;
          max[2] = pmax;
        }
        void split(Split side, float value = 0 );
        float cornerx(int n);
        float cornery(int n);
        float cornerz(int n);
        void copy(ddgBBox3 *src);
        ddgVector3 centre(void)
        { return ( min + max ) * 0.5;}
        void move(ddgVector3 o)
        { min = min + &o; max = max + &o; }
        void scale(ddgVector3 s)
        {
                ddgVector3 c(min + max);
                c = c * 0.5;
                ddgVector3 d(c - min);
                d[0] *= s[0];
                d[1] *= s[1];
                d[2] *= s[2];
                min = c - d;
                max = c + d;
        }
        float distancesq( ddgVector3 *p);
        float distance( ddgVector3 *p) { return sqrtf(distancesq(p)); }
        bool intersect( ddgVector3 *p1, ddgVector3 *p2);
        bool intersect( ddgBBox3 *b );
        ddgVector3 size(void) { return max - min; }

    ddgClipFlags visibleSpace( ddgBBox3 b, float tanHalfFOV );

};

#endif

Generated at Sun Sep 17 19:27:51 2000 for Digital Dawn Graphics Toolkit by doxygen 0.49-991205 written by Dimitri van Heesch, © 1997-1999