/* 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 _ddgContext_Class #define _ddgContext_Class #include "util/ddg.h" #include "math/ddgmatrx.h" #include "math/ddgbbox.h" #include "math/ddgchull.h" #include "struct/ddgcntrl.h" class ddgClock; class ddgPath; class WEXP ddgContext { public: enum Mode{ ALL=0, CLIPPING, NOTEXT, FLAT, MINIMAL }; enum Quality{ NONE, DEBUG, LOW, MEDIUM, HIGH }; private: Mode _mode; Quality _quality; ddgClock *_clock; float _tanHalfFOV; ddgMatrix4 _mm; ddgMatrix4 _mmi; ddgMatrix4 _pm; bool _dirty:1; ddgControl *_control; float _fov; float _aspect; ddgBBox3 _clipbox; ddgPlane3 *_frustrum3d; unsigned int _frame; ddgPath *_path; bool _record; ddgVector3 _forward; ddgVector3 _up; ddgVector3 _right; ddgCHull3 _rootHull; ddgPlane2 *_frustrum2d; ddgCHull2 _topDownWedge; bool _levelView; bool _calcInvertedMatrix; public: ddgContext(Mode m = ALL, Quality q = MEDIUM, ddgControl *ctrl = NULL, ddgClock *cl = NULL); ~ddgContext(void); ddgClock *clock(void) { return _clock; } Mode mode(void) { return _mode; } Quality quality(void) { return _quality; } void mode (Mode m) { _mode = m; } void quality(Quality q) { _quality = q; } void clock(ddgClock *c) { _clock = c; } ddgCHull3 *rootHull(void) { return &_rootHull; } ddgCHull2 *topDownWedge(void) { return &_topDownWedge; } bool update(void); void nearfar (float n, float f) { _clipbox.setz(n,f); _dirty = true; } void fov( float f) { _fov = f; _tanHalfFOV = tan(ddgAngle::degtorad(_fov/2.0)); _dirty = true; } float fov( void ) { return _fov; } void aspect( float a) { _aspect = a; _dirty = true; } float aspect( void ) { return _aspect; } float tanHalfFOV( void ) { return _tanHalfFOV; } ddgControl *control(void) { return _control; } void control( ddgControl *c ) { _control = c; } void clipbox( ddgBBox3 *b) { _clipbox.set( b->min, b->max); _dirty = true; } ddgBBox3 *clipbox( void ) { return &_clipbox; } ddgInside clip( ddgBBox3 *bbox); ddgVector3 *up( void) { return &_up; } void up( ddgVector3* u) { _up.set( u); _dirty = true; } void forward( ddgVector3* f) { _forward.set( f); _dirty = true; } ddgVector3 *forward( void) { return &_forward; } void right( ddgVector3* r) { _right.set( r); _dirty = true; } ddgVector3 *right( void) { return &_right; } bool init(void); bool visible( ddgBBox3 * bbox ); void transform( ddgVector3 vin, ddgVector3 *vout ); bool visible( ddgVector3 vin ); bool dirty( void ) { return _dirty; } void clean( void ) { _dirty = false; } void extractPlanesFromMatrix(ddgPlane3 planes[6]); void updateClippingInfo(void); bool levelView( void ) { return _levelView; } ddgPlane3 *frustrum(void) { return _frustrum3d; } ddgMatrix4 *transformation(void) { return &_mm; } ddgMatrix4 *itransformation(void); ddgMatrix4 *projection(void) { return &_pm; } void path( ddgPath* p, bool r = false, unsigned int f = 0) { _path = p; _record = r; _frame = f; } unsigned int frame(void) { return _frame; } bool ssdistance( ddgVector3 *p1, ddgVector3 *p2, ddgVector3 *normal, bool pixels = false); float ssdistance2( ddgVector3 *p1, ddgVector3 *p2); void extractPlanes( ddgPlane3 planes[6]); void frameNext(void) { _frame++; } }; #endif