osgEarth 2.1.1
Classes | Public Member Functions | Protected Member Functions | Protected Attributes

seamless::Patch Class Reference

Inheritance diagram for seamless::Patch:

List of all members.

Classes

struct  Data

Public Member Functions

 Patch ()
 Patch (const Patch &rhs, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
 META_Node (seamless, Patch)
virtual void traverse (osg::NodeVisitor &nv)
virtual osg::BoundingSphere computeBound () const
virtual void resizeGLObjectBuffers (unsigned int maxSize)
virtual void releaseGLObjects (osg::State *=0) const
virtual void init ()
DatagetData ()
const DatagetData () const
void setData (Data *data)
void dirtyVertexData ()
float getPatchError (const osg::Vec3 &eye)
virtual float getEdgeError (const osg::Vec3 &eye, int edge)
void setPatchSet (PatchSet *patchSet)
PatchSetgetPatchSet () const
void setErrorThreshold (float threshold)
float getErrorThreshold () const

Protected Member Functions

 ~Patch ()

Protected Attributes

osg::ref_ptr< osg::Geode > _trile [2][4]
osg::ref_ptr< osg::Geode > _strip [4][4]
osg::ref_ptr< Data_data
osg::ref_ptr< PatchSet_patchSet
float _errorThreshold

Detailed Description

Definition at line 32 of file Patch.


Constructor & Destructor Documentation

seamless::Patch::Patch ( )

Definition at line 43 of file Patch.cpp.

    : _errorThreshold(.5f)
{
}
seamless::Patch::Patch ( const Patch rhs,
const osg::CopyOp &  copyop = osg::CopyOp::SHALLOW_COPY 
)
seamless::Patch::~Patch ( ) [protected]

Definition at line 63 of file Patch.cpp.

{
}

Member Function Documentation

BoundingSphere seamless::Patch::computeBound ( ) const [virtual]

Definition at line 262 of file Patch.cpp.

{
    BoundingSphere bsphere;
    if (!_trile[0][0].valid())
        return bsphere;
    BoundingBox bb;
    bb.init();
    for (int res = 0; res < 2; ++res)
        for (int i = 0; i < 4; ++i)
            bb.expandBy(_trile[res][i]->getBoundingBox());
    for (int strip = 0; strip < 4; ++strip)
        for (int i = 0; i < 4; ++i)
            bb.expandBy(_strip[strip][i]->getBoundingBox());
    if (!bb.valid())
        return bsphere;
    bsphere.expandBy(bb);
    return bsphere;
}
void seamless::Patch::dirtyVertexData ( )

Dirty vertex data. A convenience method.

Definition at line 90 of file Patch.cpp.

{
    Geometry::ArrayData& vdata = _data->vertexData;
    if (vdata.array.valid())
        vdata.array->dirty();
}
const Data* seamless::Patch::getData ( ) const [inline]

Definition at line 70 of file Patch.

{ return _data.get(); }
Data* seamless::Patch::getData ( ) [inline]

Definition at line 69 of file Patch.

{ return _data.get(); }

Here is the caller graph for this function:

float seamless::Patch::getEdgeError ( const osg::Vec3 &  eye,
int  edge 
) [virtual]

Reimplemented in seamless::GeoPatch.

Definition at line 208 of file Patch.cpp.

{
    Vec3 p1, p2;
    getEdge(this, p1, p2, edge);
    float len = (p2 - p1).length();
    Vec3 closestPt =  closestPointOnSegment(p1, p2, eye);
    float d = (closestPt - eye).length();
    return _patchSet->getPrecisionFactor() * len / d;
}

Here is the call graph for this function:

Here is the caller graph for this function:

float seamless::Patch::getErrorThreshold ( ) const [inline]

Definition at line 91 of file Patch.

{ return _errorThreshold; }
float seamless::Patch::getPatchError ( const osg::Vec3 &  eye)

Get patch error. This is the maximum of the edge errors.

Parameters:
eyeThe eyepoint in local coordinates.

Definition at line 218 of file Patch.cpp.

{
    float epsilon = getEdgeError(eye, 0);
    for (int i = 1; i < 4; ++i)
        epsilon = maximum(epsilon, getEdgeError(eye, i));
    return epsilon;
}

Here is the call graph for this function:

PatchSet * seamless::Patch::getPatchSet ( ) const

Definition at line 307 of file Patch.cpp.

{
    return _patchSet.get();
}

Here is the caller graph for this function:

void seamless::Patch::init ( ) [virtual]

Definition at line 133 of file Patch.cpp.

{
    for (int res = 0; res < 2; ++res)
    {
        for (int trile = 0; trile < 4; ++trile)
        {
            Geometry* geom = new Geometry;
            geom->setUseVertexBufferObjects(true);
            _data->setGeometryAttributes(geom);
            geom->addPrimitiveSet(_patchSet->trilePset[res][trile]);
            _trile[res][trile] = new Geode;
            _trile[res][trile]->addDrawable(geom);
        }
    }
    for (int j = 0; j < 4; ++j)
    {
        for (int i = 0; i < 4; ++i)
        {
            Geometry* geom = new Geometry;
            geom->setUseVertexBufferObjects(true);
            _data->setGeometryAttributes(geom);
            geom->addPrimitiveSet(_patchSet->stripPset[j][i]);
            _strip[j][i] = new Geode;
            _strip[j][i]->addDrawable(geom);
        }
    }
}

Here is the caller graph for this function:

seamless::Patch::META_Node ( seamless  ,
Patch   
)
void seamless::Patch::releaseGLObjects ( osg::State *  = 0) const [virtual]

Definition at line 292 of file Patch.cpp.

{
    Node::releaseGLObjects(state);
    if (!_trile[0][0].valid())
        return;
    for (int res = 0; res < 2; ++res)
        for (int i = 0; i < 4; ++i)
            _trile[res][i]->releaseGLObjects(state);
}
void seamless::Patch::resizeGLObjectBuffers ( unsigned int  maxSize) [virtual]

Definition at line 281 of file Patch.cpp.

{
    Node::resizeGLObjectBuffers(maxSize);

    if (!_trile[0][0].valid())
        return;
    for (int res = 0; res < 2; ++res)
        for (int i = 0; i < 4; ++i)
            _trile[res][i]->resizeGLObjectBuffers(maxSize);
}
void seamless::Patch::setData ( Data data) [inline]

Definition at line 71 of file Patch.

    {
        _data = data;
        init();
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void seamless::Patch::setErrorThreshold ( float  threshold) [inline]

Set error threshold between high and low resolution LOD. Default is .5.

Definition at line 90 of file Patch.

{ _errorThreshold = threshold; }
void seamless::Patch::setPatchSet ( PatchSet patchSet)

Definition at line 302 of file Patch.cpp.

{
    _patchSet = patchSet;
}

Here is the caller graph for this function:

virtual void seamless::Patch::traverse ( osg::NodeVisitor &  nv) [virtual]

Member Data Documentation

osg::ref_ptr<Data> seamless::Patch::_data [protected]

Definition at line 104 of file Patch.

Definition at line 106 of file Patch.

osg::ref_ptr<PatchSet> seamless::Patch::_patchSet [protected]

Definition at line 105 of file Patch.

osg::ref_ptr<osg::Geode> seamless::Patch::_strip[4][4] [protected]

Definition at line 103 of file Patch.

osg::ref_ptr<osg::Geode> seamless::Patch::_trile[2][4] [protected]

Definition at line 96 of file Patch.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines