当前位置: 首页>>代码示例>>C++>>正文


C++ Geode::getNodeMask方法代码示例

本文整理汇总了C++中osg::Geode::getNodeMask方法的典型用法代码示例。如果您正苦于以下问题:C++ Geode::getNodeMask方法的具体用法?C++ Geode::getNodeMask怎么用?C++ Geode::getNodeMask使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在osg::Geode的用法示例。


在下文中一共展示了Geode::getNodeMask方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: apply

void PhysicsVisitor::apply( osg::Geode& node )
{
    // retrieve the node mask which is used for physics material and later for other properies
    // only the first byte is relevant for pyhsics material description
    _attribute = node.getNodeMask() & 0xFF;

    // this means no need for building static collision geom
    //  this is not the same as MAT_NOCOL, as MAT_NOCOL collisions are detected
    if ( _attribute == Physics::NO_BUILD )
        return;

    // get the accumulated world matrix for this node
    osg::Matrixf  mat = computeLocalToWorld( getNodePath() );
    unsigned int numDrawables = node.getNumDrawables();
    for ( unsigned int cnt = 0; cnt < numDrawables; ++cnt )
    {
        osg::Drawable* p_drawable = node.getDrawable( cnt );
        osg::Geometry* p_geom     = p_drawable->asGeometry();
        // evaluate the geom and generate an appropriate collision geometry
        if ( p_geom )
        {
            osg::Array*      p_verts   = p_geom->getVertexArray();
            osg::IndexArray* p_indices = p_geom->getVertexIndices();
            unsigned int     numPrims  = p_geom->getNumPrimitiveSets();
            {
                for ( unsigned int primcnt = 0; primcnt < numPrims; ++primcnt )
                {
                    osg::PrimitiveSet* p_set = p_geom->getPrimitiveSet( primcnt );
                    switch( p_set->getMode() )
                    {
                        case osg::PrimitiveSet::POINTS:
                        case osg::PrimitiveSet::LINES:
                        case osg::PrimitiveSet::LINE_STRIP:
                        case osg::PrimitiveSet::LINE_LOOP:
                            return;

                        case osg::PrimitiveSet::TRIANGLES:
                            buildTrianlges( p_set, p_verts, mat, p_indices );
                            break;

                        case osg::PrimitiveSet::TRIANGLE_STRIP:
                            buildTrianlgeStrip( p_set, p_verts, mat, p_indices );
                            break;

                        case osg::PrimitiveSet::TRIANGLE_FAN:
                        case osg::PrimitiveSet::QUADS:
                        case osg::PrimitiveSet::QUAD_STRIP:
                        case osg::PrimitiveSet::POLYGON:

                        default:
                            log_error << "Physics Serializer: unsupported primitive set for physics geometry! currently only TRIANGLES and TRIANGLE_STRIP types are supported." << std::endl;
                    }
                }
            }
        }
    }
}
开发者ID:BackupTheBerlios,项目名称:yag2002-svn,代码行数:57,代码来源:physics_helpers.cpp

示例2: flags

void
FltExportVisitor::writeMesh( const osg::Geode& geode, const osg::Geometry& geom )
{
    enum DrawMode
    {
        SOLID_BACKFACE = 0,
        SOLID_NO_BACKFACE = 1,
        WIREFRAME_CLOSED = 2,
        WIREFRAME_NOT_CLOSED = 3,
        SURROUND_ALTERNATE_COLOR = 4,
        OMNIDIRECTIONAL_LIGHT = 8,
        UNIDIRECTIONAL_LIGHT = 9,
        BIDIRECTIONAL_LIGHT = 10
    };
    enum TemplateMode
    {
        FIXED_NO_ALPHA_BLENDING = 0,
        FIXED_ALPHA_BLENDING = 1,
        AXIAL_ROTATE_WITH_ALPHA_BLENDING = 2,
        POINT_ROTATE_WITH_ALPHA_BLENDING = 4
    };

    // const unsigned int TERRAIN_BIT      = 0x80000000u >> 0;
    //const unsigned int NO_COLOR_BIT     = 0x80000000u >> 1;
    //const unsigned int NO_ALT_COLOR_BIT = 0x80000000u >> 2;
    const unsigned int PACKED_COLOR_BIT = 0x80000000u >> 3;
    //const unsigned int FOOTPRINT_BIT    = 0x80000000u >> 4;    // Terrain culture cutout
    const unsigned int HIDDEN_BIT       = 0x80000000u >> 5;
    //const unsigned int ROOFLINE_BIT     = 0x80000000u >> 6;
    uint32 flags( PACKED_COLOR_BIT );
    if (geode.getNodeMask() == 0)
        flags |= HIDDEN_BIT;

    enum LightMode
    {
        FACE_COLOR = 0,
        VERTEX_COLOR = 1,
        FACE_COLOR_LIGHTING = 2,
        VERTEX_COLOR_LIGHTING = 3
    };
    int8 lightMode;
    osg::Vec4 packedColorRaw( 1., 1., 1., 1. );
    uint16 transparency( 0 );
    if (geom.getColorBinding() == osg::Geometry::BIND_PER_VERTEX)
    {
        if (isLit( geom ))
            lightMode = VERTEX_COLOR_LIGHTING;
        else
            lightMode = VERTEX_COLOR;
    }
    else
    {
        const osg::Vec4Array* c = dynamic_cast<const osg::Vec4Array*>( geom.getColorArray() );
        if (c && (c->size() > 0))
        {
            packedColorRaw = (*c)[0];
            transparency = flt::uint16((1. - packedColorRaw[3]) * (double)0xffff);
        }

        if (isLit( geom ))
            lightMode = FACE_COLOR_LIGHTING;
        else
            lightMode = FACE_COLOR;
    }
    uint32 packedColor;
    packedColor = (int)(packedColorRaw[3]*255) << 24 |
        (int)(packedColorRaw[2]*255) << 16 | (int)(packedColorRaw[1]*255) << 8 |
        (int)(packedColorRaw[0]*255);


    int8 drawType;
    osg::StateSet const* ss = getCurrentStateSet();

    {
        // Default to no facet culling
        drawType = SOLID_NO_BACKFACE;

        // If facet-culling isn't *dis*abled, check whether the CullFace mode is BACK
        if (ss->getMode(GL_CULL_FACE) & osg::StateAttribute::ON)
        {
            osg::CullFace const* cullFace = static_cast<osg::CullFace const*>(
                ss->getAttribute(osg::StateAttribute::CULLFACE) );
            if( cullFace->getMode() == osg::CullFace::BACK )
                drawType = SOLID_BACKFACE;

            // Note: OpenFlt can't handle FRONT or FRONT_AND_BACK settings, so ignore these(??)
        }
    }

    // Determine the material properties for the face
    int16 materialIndex( -1 );
    if (isLit( geom ))
    {
        osg::Material const* currMaterial = static_cast<osg::Material const*>(
            ss->getAttribute(osg::StateAttribute::MATERIAL) );
        materialIndex = _materialPalette->add(currMaterial);
    }

    // Get base texture
    int16 textureIndex( -1 );
//.........这里部分代码省略.........
开发者ID:BlitzMaxModules,项目名称:osg.mod,代码行数:101,代码来源:expGeometryRecords.cpp


注:本文中的osg::Geode::getNodeMask方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。