osgEarth 2.1.1
Defines | Functions | Variables

/home/cube/sources/osgearth/src/osgEarthDrivers/engine_droam/AMRGeometry.cpp File Reference

#include "Common"
#include "AMRGeometry"
#include <osg/State>
#include <osg/Uniform>
#include <osgEarth/Notify>
#include "AMRShaders.h"
Include dependency graph for AMRGeometry.cpp:

Go to the source code of this file.

Defines

#define LC   "[AMRGeometry] "
#define SET_UNIFORM(X, Y, Z)   _stateSet->getOrCreateUniform( X , Y )->set( Z )

Functions

static void toBarycentric (const osg::Vec3 &p1, const osg::Vec3 &p2, const osg::Vec3 &p3, const osg::Vec3 &in, osg::Vec3 &outVert, osg::Vec2 &outTex)

Variables

static int s_numTemplates = 0

Define Documentation

#define LC   "[AMRGeometry] "

Definition at line 25 of file AMRGeometry.cpp.

#define SET_UNIFORM (   X,
  Y,
 
)    _stateSet->getOrCreateUniform( X , Y )->set( Z )

Definition at line 41 of file AMRGeometry.cpp.


Function Documentation

static void toBarycentric ( const osg::Vec3 &  p1,
const osg::Vec3 &  p2,
const osg::Vec3 &  p3,
const osg::Vec3 &  in,
osg::Vec3 &  outVert,
osg::Vec2 &  outTex 
) [static]

Definition at line 170 of file AMRGeometry.cpp.

{
    //from: http://forums.cgsociety.org/archive/index.php/t-275372.html
    osg::Vec3 
        v1 = in - p1,
        v2 = in - p2,
        v3 = in - p3;

    double 
        area1 = 0.5 * (v2 ^ v3).length(),
        area2 = 0.5 * (v1 ^ v3).length(),
        area3 = 0.5 * (v1 ^ v2).length();

    double fullArea = area1 + area2 + area3;

    double u = area1/fullArea;
    double v = area2/fullArea;
    double w = area3/fullArea; 

    outVert.set( u, v, w );

    // tex coords
    osg::Vec2 t1( p1.x(), p1.y() );
    osg::Vec2 t2( p2.x(), p2.y() );
    osg::Vec2 t3( p3.x(), p3.y() );
    outTex = t1*w + t2*v + t3*u;
}

Here is the caller graph for this function:


Variable Documentation

int s_numTemplates = 0 [static]

Definition at line 274 of file AMRGeometry.cpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines