drawObjects< posTrait, colTrait, sizeTrait, normalTrait, geoTrait > Struct Template Reference

Inheritance diagram for drawObjects< posTrait, colTrait, sizeTrait, normalTrait, geoTrait >:

osg::ParticlesDrawer

List of all members.

Public Member Functions

virtual void draw (Particles *part, DrawActionBase *action, UInt32 length)
virtual void drawIndexed (Particles *part, DrawActionBase *action, Int32 *index, UInt32 length)


Detailed Description

template<class posTrait, class colTrait, class sizeTrait, class normalTrait, class geoTrait>
struct drawObjects< posTrait, colTrait, sizeTrait, normalTrait, geoTrait >

Definition at line 1964 of file OSGParticles.cpp.


Member Function Documentation

template<class posTrait, class colTrait, class sizeTrait, class normalTrait, class geoTrait>
virtual void drawObjects< posTrait, colTrait, sizeTrait, normalTrait, geoTrait >::draw ( Particles part,
DrawActionBase action,
UInt32  length 
) [inline, virtual]

Implements osg::ParticlesDrawer.

Definition at line 1966 of file OSGParticles.cpp.

References osg::VectorInterface< ValueTypeT, StorageInterfaceT >::cross(), osg::ParticlesBase::getPositions(), osg::ParticlesBase::getSecPositions(), init(), osg::VectorInterface< ValueTypeT, StorageInterfaceT >::normalize(), and p.

01967     {
01968         // some variables for faster access
01969         GeoPositionsPtr pos = part->getPositions();
01970 
01971         // init traits
01972         typename geoTrait::dataType geoData;
01973         geoTrait::init(part, action, geoData);
01974 
01975         typename colTrait::dataType colData;
01976         colTrait::init(part, action, colData);
01977 
01978         typename sizeTrait::dataType sizeData;
01979         sizeTrait::init(part, action, sizeData);
01980 
01981         typename normalTrait::dataType normalData;
01982         normalTrait::init(part, action, normalData);
01983 
01984         typename posTrait::dataType posData, secPosData;
01985         posTrait::init(part, action, posData   , part->getPositions());
01986         posTrait::init(part, action, secPosData, part->getSecPositions());
01987         
01988         for(UInt32 i = 0; i < length; ++i)
01989         {
01990             if(geoTrait::particle (geoData,  i))
01991                 continue;
01992 
01993             if(colTrait::particle (colData,  i))
01994                 continue;
01995 
01996             if(sizeTrait::particle(sizeData, i))
01997                 continue;
01998 
01999             if(normalTrait::particle(normalData, i))
02000                 continue;
02001 
02002             if(posTrait::particle (posData,  i))
02003                 continue;
02004 
02005             if(posTrait::particle (secPosData,  i))
02006                 continue;
02007 
02008             // calc the coordinate system
02009             
02010             Pnt3f &p  = posTrait   ::position(posData   );
02011             Pnt3f &sp = posTrait   ::position(secPosData);
02012             Vec3f &n  = normalTrait::normal  (normalData);
02013            
02014             Vec3f dz(sp - p);
02015             dz.normalize();
02016 
02017             Vec3f dx(n.cross(dz));
02018             if(dx.isZero())
02019             {
02020                 dx=Vec3f(1,0,0).cross(dz);
02021                 if(dx.isZero())
02022                 {
02023                     dx=Vec3f(0,1,0).cross(dz);
02024                     if(dx.isZero())
02025                     {
02026                         dx=Vec3f(0,0,1).cross(dz);
02027                     }
02028                     else
02029                     {
02030                         dx.setValues(0,0,0);
02031                     }
02032                 }
02033             }
02034             dx.normalize();
02035 
02036             Vec3f dy(dx.cross(dz));
02037 
02038             // now draw the geometry;
02039             geoTrait::draw(geoData, p, sp, dx, dy, dz, 
02040                            sizeTrait::size(sizeData, i));
02041         }
02042         
02043         geoTrait::exit(part, action, geoData);
02044     }

template<class posTrait, class colTrait, class sizeTrait, class normalTrait, class geoTrait>
virtual void drawObjects< posTrait, colTrait, sizeTrait, normalTrait, geoTrait >::drawIndexed ( Particles part,
DrawActionBase action,
Int32 *  index,
UInt32  length 
) [inline, virtual]

Implements osg::ParticlesDrawer.

Definition at line 2046 of file OSGParticles.cpp.

References osg::VectorInterface< ValueTypeT, StorageInterfaceT >::cross(), osg::ParticlesBase::getPositions(), osg::ParticlesBase::getSecPositions(), init(), osg::VectorInterface< ValueTypeT, StorageInterfaceT >::normalize(), and p.

02048     {
02049         // some variables for faster access
02050         GeoPositionsPtr pos = part->getPositions();
02051 
02052         // init traits
02053         typename geoTrait::dataType geoData;
02054         geoTrait::init(part, action, geoData);
02055 
02056         typename colTrait::dataType colData;
02057         colTrait::init(part, action, colData);
02058 
02059         typename sizeTrait::dataType sizeData;
02060         sizeTrait::init(part, action, sizeData);
02061 
02062         typename normalTrait::dataType normalData;
02063         normalTrait::init(part, action, normalData);
02064 
02065         typename posTrait::dataType posData, secPosData;
02066         posTrait::init(part, action, posData   , part->getPositions());
02067         posTrait::init(part, action, secPosData, part->getSecPositions());
02068 
02069         Int32 i;
02070 
02071         for(UInt32 ii = 0; ii < length; ++ii)
02072         {
02073             i = index[ii];
02074 
02075             if(i < 0 || i > Int32(pos->getSize()))
02076                 continue;
02077 
02078             if(geoTrait::particle (geoData,  i))
02079                 continue;
02080 
02081             if(colTrait::particle (colData,  i))
02082                 continue;
02083 
02084             if(sizeTrait::particle(sizeData, i))
02085                 continue;
02086 
02087             if(normalTrait::particle(normalData, i))
02088                 continue;
02089 
02090             if(posTrait::particle (posData,  i))
02091                 continue;
02092 
02093             if(posTrait::particle (secPosData,  i))
02094                 continue;
02095 
02096             // calc the coordinate system
02097             
02098             Pnt3f &p  = posTrait   ::position(posData   );
02099             Pnt3f &sp = posTrait   ::position(secPosData);
02100             Vec3f &n  = normalTrait::normal  (normalData);
02101            
02102             Vec3f dz(sp - p);
02103             dz.normalize();
02104 
02105             Vec3f dx(n.cross(dz));
02106             if(dx.isZero())
02107             {
02108                 dx=Vec3f(1,0,0).cross(dz);
02109                 if(dx.isZero())
02110                 {
02111                     dx=Vec3f(0,1,0).cross(dz);
02112                     if(dx.isZero())
02113                     {
02114                         dx=Vec3f(0,0,1).cross(dz);
02115                     }
02116                     else
02117                     {
02118                         dx.setValues(0,0,0);
02119                     }
02120                 }
02121             }
02122             dx.normalize();
02123 
02124             Vec3f dy(dx.cross(dz));
02125 
02126             // now draw the geometry;
02127             geoTrait::draw(geoData, p, sp, dx, dy, dz, 
02128                            sizeTrait::size(sizeData, i));
02129         }
02130         
02131         geoTrait::exit(part, action, geoData);
02132     }


The documentation for this struct was generated from the following file:

Generated on Mon Mar 17 12:02:58 2008 for OpenSG by  doxygen 1.5.5