Main Page   Class Hierarchy   Compound List   Header Files   Compound Members  

ddgfacet.h

This is the verbatim text of the ddgfacet.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 _ddgFacet_Class_
#define _ddgFacet_Class_

#include "math/ddgvec.h"
#include "struct/ddgnode.h"
#include "util/ddgerror.h"

// This class stores static information needed to perform
// spherical classification and uses this to perform culling
// operations.
// Algorithm to optimize backface culling of large polygon sets.
// Define a static array of the normal vectors (sN) of an icosahedron.
// This represents and evenly spaced set of normals (20) in R3.
// Enumerate sN in such a way that vectors i and (i+10)%20 = <0,0,0> holds
// true. Two vector pointing in opposite directions.
//
// Preprocessing step for each triangle in the polyset:
// Calculate the normal tN and find out in which sector sN the triangle should
// be associated with based on the minimum angle between tN and sN.
// Add triangle t into the appropriate category.
//
// Memory overhead 20 arrays with a combined storage space of n integer
// indices into the triangle array.
//
// At runtime determine which sector most faces the camera and render the
// fixed set of arrays which are associated with that sector.
// For icosahedron
#include "render/ddgvbuf.h"
class WEXP ddgFacetSet : public ddgDLNode {
    typedef ddgDLNode super;
    friend class ddgClippedFacetSet;
        static ddgVector3 _icovertices[12];
        static int     _icopolygons[20][3];
        unsigned int   _pcount;
        bool subdivide( ddgVector3 v1, ddgVector3 v2, ddgVector3 v3, long depth);
        unsigned int    _levels;
        ddgVector3       *_vertices;
public:
        ddgFacetSet(unsigned int l = 0) : _vertices(0),_levels(l),_pcount(0) {  }
        ~ddgFacetSet();
        bool init(ddgContext *ctx);
        bool draw(ddgContext *ctx);
        unsigned int count(void) { return _pcount; }
};

class WEXP ddgClippedFacetSet : public ddgFacetSet {
    typedef ddgFacetSet super;
        bool            *_on;
        ddgVector3              *_centre;
        float           _faceAngle;
        float           _clipAngle;
        float           _visAngle;

public:
        ddgClippedFacetSet(unsigned int l = 0) : ddgFacetSet(l), _on(0),_centre(0) { }
        ~ddgClippedFacetSet();
        bool init(ddgContext *ctx);
        bool draw(ddgContext *ctx);
        bool active(int i)  { return _on[i]; }
        unsigned char classify( ddgVector3 v);
        bool clipVisibleSet(ddgContext *ctx );
        void setFacet( unsigned int i, bool a )
                { ddgAssert(i<count()); _on[i] = a; }
};
#endif

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