Exemple #1
0
//-----------------------------------------------------------------------------
//
// Scene update
//
//-----------------------------------------------------------------------------
void SampleScene::updateSphere( float radius)//, float center )
{
    Group            top_level_group = m_context["top_object"]-> getGroup();
    Transform        transform       = top_level_group->getChild<Transform>( 0 );
    GeometryGroup    geometrygroup   = transform->getChild<GeometryGroup>();
    GeometryInstance instance        = geometrygroup->getChild( 0 );
    Geometry         geometry          = instance->getGeometry();

    // Sphere
    //geometry["sphere"]->setFloat( center, 0, 0, radius );

    // Sphere Shell
    geometry["radius2"]->setFloat( radius );        // Set Radius
    //geometry["center"]->setFloat( center, 0, 0 );   // set center

    // Mark Dirty
    int childCount = top_level_group->getChildCount();
    for ( int i = 0; i < childCount; i++) {
        if( top_level_group->getChildType( i ) == RT_OBJECTTYPE_TRANSFORM ){
            transform = top_level_group->getChild<Transform>( i );
            geometrygroup = transform->getChild<GeometryGroup>();
        }else{
            geometrygroup = top_level_group->getChild<GeometryGroup>( i );
            //geometrygroup = transform->getChild<GeometryGroup>();
        }
        geometrygroup->getAcceleration()->markDirty();
    }
    top_level_group->getAcceleration()->markDirty();
}
Exemple #2
0
void SampleScene::updateMaterial( float refraction_index )
{
    Group            top_level_group = m_context["top_object"]-> getGroup();
    Transform        transform       = top_level_group->getChild<Transform>( 0 );
    GeometryGroup    geometrygroup   = transform->getChild<GeometryGroup>();
    GeometryInstance instance        = geometrygroup->getChild( 0 );
    Material         material        = instance->getMaterial( 0 );

    material["refraction_index"]->setFloat( refraction_index );
}