Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OSGSimpleGeometry.cpp File Reference

#include <stdlib.h>
#include <stdio.h>
#include "OSGConfig.h"
#include <OSGLog.h>
#include <OSGQuaternion.h>
#include <OSGSimpleMaterial.h>
#include <OSGTriangleIterator.h>
#include "OSGSimpleGeometry.h"

Go to the source code of this file.

Namespaces

namespace  osg

Material Access

MaterialPtr osg::getDefaultMaterial (void)
MaterialPtr osg::getDefaultUnlitMaterial (void)

Construction functions

NodePtr osg::makePlane (Real32 xsize, Real32 ysize, UInt16 hor, UInt16 vert)
GeometryPtr osg::makePlaneGeo (Real32 xsize, Real32 ysize, UInt16 hor, UInt16 vert)
NodePtr osg::makeCone (Real32 height, Real32 botradius, UInt16 sides, bool doSide, bool doBottom)
GeometryPtr osg::makeConeGeo (Real32 height, Real32 botradius, UInt16 sides, bool doSide, bool doBottom)
NodePtr osg::makeCylinder (Real32 height, Real32 radius, UInt16 sides, bool doSide, bool doTop, bool doBottom)
GeometryPtr osg::makeCylinderGeo (Real32 height, Real32 radius, UInt16 sides, bool doSide, bool doTop, bool doBottom)
NodePtr osg::makeConicalFrustum (Real32 height, Real32 topradius, Real32 botradius, UInt16 sides, bool doSide, bool doTop, bool doBottom)
GeometryPtr osg::makeConicalFrustumGeo (Real32 height, Real32 topradius, Real32 botradius, UInt16 sides, bool doSide, bool doTop, bool doBottom)
NodePtr osg::makeTorus (Real32 innerRadius, Real32 outerRadius, UInt16 sides, UInt16 rings)
GeometryPtr osg::makeTorusGeo (Real32 innerRadius, Real32 outerRadius, UInt16 sides, UInt16 rings)
NodePtr osg::makeSphere (UInt16 depth, Real32 radius)
GeometryPtr osg::makeSphereGeo (UInt16 depth, Real32 radius)
NodePtr osg::makeLatLongSphere (UInt16 latres, UInt16 longres, Real32 radius)
GeometryPtr osg::makeLatLongSphereGeo (UInt16 latres, UInt16 longres, Real32 radius)
NodePtr osg::makeBox (Real32 xsize, Real32 ysize, Real32 zsize, UInt16 hor, UInt16 vert, UInt16 depth)
GeometryPtr osg::makeBoxGeo (Real32 xsize, Real32 ysize, Real32 zsize, UInt16 hor, UInt16 vert, UInt16 depth)

Defines

#define X   .525731112119133606
#define Z   .850650808352039932

Functions

Real32 setVecLen (Vec3f &vec, Real32 length)
void addPoint (Pnt3f v, UInt32 index, Real32 radius, GeoPositions3f::StoredFieldType *p, GeoNormals3f::StoredFieldType *n, GeoTexCoords2f::StoredFieldType *tx)
void subdivideTriangle (UInt32 i1, UInt32 i2, UInt32 i3, Int32 depth, GeoPositions3f::StoredFieldType *p, GeoNormals3f::StoredFieldType *n, GeoTexCoords2f::StoredFieldType *tx, GeoIndicesUI32::StoredFieldType *i, UInt32 &z, Real32 radius)
GeoPositions3fPtr osg::makeGeoPositions3fPtr (UInt32 uiSize)
 some workaround functions for Windows problems
GeoIndicesUI32Ptr osg::makeGeoIndicesUI32Ptr (UInt32 uiSize)
GeoPLengthsPtr osg::makeGeoPLengthsPtr (UInt32 uiSize)
GeoPTypesPtr osg::makeGeoPTypesPtr (UInt32 uiSize)

Variables

static SimpleMaterialPtr _defaultMaterial
static SimpleMaterialPtr _defaultUnlitMaterial


Define Documentation

#define X   .525731112119133606
 

Referenced by osg::Slicer::getSlicingDirection(), and osg::makeSphereGeo().

#define Z   .850650808352039932
 

Referenced by osg::Slicer::getSlicingDirection(), osg::TransformationMatrix< ValueTypeT >::log(), osg::TransformationMatrix< ValueTypeT >::logOf(), and osg::makeSphereGeo().


Function Documentation

Real32 setVecLen Vec3f vec,
Real32  length
 

Definition at line 683 of file OSGSimpleGeometry.cpp.

References osg::VectorInterface< ValueTypeT, StorageInterfaceT >::length().

Referenced by osg::makeSphereGeo().

00684 {
00685     Real32 len = vec.length();
00686     if(len == 0.0) 
00687     {
00688         len = 1;
00689     } 
00690     else 
00691     {
00692         len = length / len;
00693     }
00694     vec *= len;
00695     
00696     return length;
00697 }

void addPoint Pnt3f  v,
UInt32  index,
Real32  radius,
GeoPositions3f::StoredFieldType *  p,
GeoNormals3f::StoredFieldType *  n,
GeoTexCoords2f::StoredFieldType *  tx
 

Definition at line 699 of file OSGSimpleGeometry.cpp.

References osg::Eps, osg::VectorInterface< ValueTypeT, StorageInterfaceT >::normalize(), osg::osgacos(), osg::osgatan2(), and osg::Pi.

Referenced by subdivideTriangle().

00703 {
00704     Vec3f norm(v[0], v[1], v[2]);
00705 
00706     norm.normalize();
00707     n->push_back(norm);
00708 
00709     Pnt3f pnt(radius * norm);
00710     p->push_back(pnt);
00711 
00712     Vec2f texCoord;
00713 
00714     // Theta -> v
00715     texCoord[1] = (Pi - osgacos(norm[1])) / Pi;
00716 
00717     // Phi -> u
00718     Real32 phi = osgatan2(-norm[2], norm[0]);
00719 
00720     if (phi <= -Eps)
00721         phi += (2 * Pi);
00722     phi /= (2 * Pi);
00723 
00724     texCoord[0] = phi;
00725 
00726     tx->push_back(texCoord);
00727 }

void subdivideTriangle UInt32  i1,
UInt32  i2,
UInt32  i3,
Int32  depth,
GeoPositions3f::StoredFieldType *  p,
GeoNormals3f::StoredFieldType *  n,
GeoTexCoords2f::StoredFieldType *  tx,
GeoIndicesUI32::StoredFieldType *  i,
UInt32 z,
Real32  radius
 

Definition at line 729 of file OSGSimpleGeometry.cpp.

References addPoint().

Referenced by osg::makeSphereGeo().

00738 {   
00739     if (depth == 0) 
00740     {
00741         i->push_back(i1);
00742         i->push_back(i1);
00743         i->push_back(i2);
00744         i->push_back(i2);
00745         i->push_back(i3);
00746         i->push_back(i3);
00747                             
00748         return;         
00749     }
00750 
00751     Pnt3f v1 = (*p)[i1],
00752           v2 = (*p)[i2],
00753           v3 = (*p)[i3];
00754     Pnt3f v12, v23, v31;
00755 
00756     v12 = v1 + (v2 - v1) * .5f;
00757     v23 = v2 + (v3 - v2) * .5f;
00758     v31 = v3 + (v1 - v3) * .5f;
00759     
00760     v12 /= 2.0f;
00761     v23 /= 2.0f;
00762     v31 /= 2.0f;
00763     
00764     UInt32 i12 = z++, i23 = z++, i31 = z++;
00765 
00766     addPoint(v12,i12,radius,p,n,tx);
00767     addPoint(v23,i23,radius,p,n,tx);
00768     addPoint(v31,i31,radius,p,n,tx);
00769     
00770     subdivideTriangle( i1, i12, i31, depth - 1, p,n,tx,i, z, radius);
00771     subdivideTriangle( i2, i23, i12, depth - 1, p,n,tx,i, z, radius);
00772     subdivideTriangle( i3, i31, i23, depth - 1, p,n,tx,i, z, radius);
00773     subdivideTriangle(i12, i23, i31, depth - 1, p,n,tx,i, z, radius);
00774 }


Generated on Thu Aug 25 04:12:22 2005 for OpenSG by  doxygen 1.4.3