コード例 #1
0
ファイル: MaterialBrowser.cpp プロジェクト: raedwulf/pipeline
MaterialBrowser::MaterialBrowser( const QString & title, QWidget * parent )
  : QDockWidget( title, parent )
{
  DP_VERIFY( dp::fx::EffectLibrary::instance()->loadEffects( "PreviewScene.xml" ) );

  setObjectName( title );
  setAcceptDrops( true );

  m_catalog = new QTreeWidget();
  m_catalog->setHeaderHidden( true );
  initMaterialCatalog( GetApp()->getPreferences()->getMaterialCatalogPath() );

  setWidget( m_catalog );
  connect( m_catalog, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(catalogItemCollapsed(QTreeWidgetItem*)) );
  connect( m_catalog, SIGNAL(itemExpanded(QTreeWidgetItem*)), this, SLOT(catalogItemExpanded(QTreeWidgetItem*)) );
  connect( m_catalog, SIGNAL(itemPressed(QTreeWidgetItem*,int)), this, SLOT(catalogItemPressed(QTreeWidgetItem*,int)) );
  connect( GetApp()->getPreferences(), SIGNAL(materialCatalogPathChanged(QString const&)), this, SLOT(materialCatalogPathChanged(QString const&)) );
}
コード例 #2
0
ファイル: CommandAddItem.cpp プロジェクト: getov/pipeline
bool remove( dp::sg::core::ObjectSharedPtr const& parent, dp::sg::core::ObjectSharedPtr const& child )
{
  switch( parent->getObjectCode() )
  {
    case dp::sg::core::OC_GEONODE :
      if ( child.isPtrTo<dp::sg::core::EffectData>() )
      {
        parent.staticCast<dp::sg::core::GeoNode>()->setMaterialEffect( dp::sg::core::EffectDataSharedPtr() );
      }
      else
      {
        DP_ASSERT( child.isPtrTo<dp::sg::core::Primitive>() );
        parent.staticCast<dp::sg::core::GeoNode>()->setPrimitive( dp::sg::core::PrimitiveSharedPtr() );
      }
      break;
    case dp::sg::core::OC_GROUP :
    case dp::sg::core::OC_LOD :
    case dp::sg::core::OC_SWITCH :
    case dp::sg::core::OC_TRANSFORM :
    case dp::sg::core::OC_BILLBOARD :
      if ( child.isPtrTo<dp::sg::core::Node>() )
      {
        parent.staticCast<dp::sg::core::Group>()->removeChild( child.staticCast<dp::sg::core::Node>() );
      }
      else
      {
        DP_ASSERT( child.isPtrTo<dp::sg::core::ClipPlane>() );
        parent.staticCast<dp::sg::core::Group>()->removeClipPlane( child.staticCast<dp::sg::core::ClipPlane>() );
      }
      break;
    case dp::sg::core::OC_PRIMITIVE :
      if ( child.isPtrTo<dp::sg::core::IndexSet>() )
      {
        parent.staticCast<dp::sg::core::Primitive>()->setIndexSet( dp::sg::core::IndexSetSharedPtr() );
      }
      else
      {
        DP_ASSERT( child.isPtrTo<dp::sg::core::VertexAttributeSet>() );
        parent.staticCast<dp::sg::core::Primitive>()->setVertexAttributeSet( dp::sg::core::VertexAttributeSetSharedPtr() );
      }
      break;
    case dp::sg::core::OC_EFFECT_DATA :
      DP_ASSERT( child.isPtrTo<dp::sg::core::ParameterGroupData>() );
      {
        dp::sg::core::ParameterGroupDataSharedPtr const& pgd = child.staticCast<dp::sg::core::ParameterGroupData>();
        dp::sg::core::EffectDataSharedPtr const& ed = parent.staticCast<dp::sg::core::EffectData>();
        dp::fx::SmartEffectSpec const & es = ed->getEffectSpec();
        DP_ASSERT( es->findParameterGroupSpec( pgd->getParameterGroupSpec() ) != es->endParameterGroupSpecs() );
        parent.staticCast<dp::sg::core::EffectData>()->setParameterGroupData( es->findParameterGroupSpec( pgd->getParameterGroupSpec() ), dp::sg::core::ParameterGroupDataSharedPtr() );
      }
      break;
    case dp::sg::core::OC_PARAMETER_GROUP_DATA :
      DP_ASSERT( child->getObjectCode() == dp::sg::core::OC_SAMPLER );
      {
        dp::sg::core::ParameterGroupDataSharedPtr const& pgd = parent.staticCast<dp::sg::core::ParameterGroupData>();
        const dp::fx::SmartParameterGroupSpec & pgs = pgd->getParameterGroupSpec();
        dp::fx::ParameterGroupSpec::iterator it = pgs->findParameterSpec( child.staticCast<dp::sg::core::Sampler>()->getName() );
        DP_ASSERT( it != pgs->endParameterSpecs() );
        pgd->setParameter( it, dp::sg::core::SamplerSharedPtr() );
      }
      break;
    case dp::sg::core::OC_PARALLELCAMERA :
    case dp::sg::core::OC_PERSPECTIVECAMERA :
    case dp::sg::core::OC_MATRIXCAMERA :
      DP_ASSERT( child->getObjectCode() == dp::sg::core::OC_LIGHT_SOURCE );
      parent.staticCast<dp::sg::core::Camera>()->removeHeadLight( child.staticCast<dp::sg::core::LightSource>() );
      break;
    case dp::sg::core::OC_SCENE :
      if ( child.isPtrTo<dp::sg::core::Camera>() )
      {
        DP_VERIFY( parent.staticCast<dp::sg::core::Scene>()->removeCamera( child.staticCast<dp::sg::core::Camera>() ) );
      }
      else
      {
        DP_ASSERT( child.isPtrTo<dp::sg::core::Node>() );
        parent.staticCast<dp::sg::core::Scene>()->setRootNode( dp::sg::core::NodeSharedPtr() );
      }
      break;
    default :
      DP_ASSERT( false );
      break;
  }

  GetApp()->outputStatistics();

  return true;
}
コード例 #3
0
void TextureTransfer::transfer( size_t index
                              , dp::gl::SmartTexture2D dstTexture
                              , dp::gl::SmartTexture2D srcTexture )
{
  //PROFILE( "Copy " );

#if 1

  if( !m_shadersInitialized )
  {
    constructComputeShaders();
  }
  size_t width  = dstTexture->getWidth();
  size_t height = dstTexture->getHeight();

  DP_ASSERT( width == srcTexture->getWidth() && height == srcTexture->getHeight() );

  size_t tilesX = (width  + m_tileWidth  - 1) / m_tileWidth;  // number of horizontal tiles
  size_t tilesY = (height + m_tileHeight - 1) / m_tileHeight; // number of vert1ical tiles
  size_t tilesXPerGpu = ( tilesX + m_maxIndex - 1 ) / m_maxIndex;

  dp::gl::RenderContextStack contextStack;

  contextStack.push( m_srcContext );

  if( m_srcContext == m_dstContext )
  {
    m_copyProgram->setImageTexture( "dstImg", dstTexture, GL_WRITE_ONLY );
    m_copyProgram->setImageTexture( "srcImg", srcTexture, GL_READ_ONLY );

    dp::gl::ProgramUseGuard pug( m_copyProgram );

    glUniform1i( 0, dp::util::checked_cast<GLint>(m_maxIndex) );
    glUniform1i( 1, dp::util::checked_cast<GLint>(index) );

    glDispatchCompute( dp::util::checked_cast<GLuint>(tilesXPerGpu), dp::util::checked_cast<GLuint>(tilesY), 1 );
  }
  else
  {
    size_t tmpTexWidth  = m_tileWidth * tilesXPerGpu;
    size_t tmpTexHeight = height;

    // compress the image data into src tmp texture
    dp::gl::SmartTexture2D srcTmpTexture = getTmpTexture( m_srcContext, tmpTexWidth, tmpTexHeight );
    m_compressProgram->setImageTexture( "tmp", srcTmpTexture, GL_WRITE_ONLY );
    m_compressProgram->setImageTexture( "srcImg", srcTexture, GL_READ_ONLY );
    {
      dp::gl::ProgramUseGuard pug( m_compressProgram );

      glUniform1i( 0, dp::util::checked_cast<GLint>(m_maxIndex) );
      glUniform1i( 1, dp::util::checked_cast<GLint>(index) );

      glDispatchCompute( dp::util::checked_cast<GLuint>(tilesXPerGpu), dp::util::checked_cast<GLuint>(tilesY), 1 );
    }

    contextStack.pop();

    contextStack.push( m_dstContext );
    dp::gl::SmartTexture2D dstTmpTexture = getTmpTexture( m_dstContext, tmpTexWidth, tmpTexHeight );

    // copy src into dst tmp texture
    GLuint idSrc = srcTmpTexture->getGLId();
    GLuint idDst = dstTmpTexture->getGLId();

    HGLRC hglrcSrc = m_srcContext->getHGLRC();
    HGLRC hglrcDst = m_dstContext->getHGLRC();


    {
      dp::util::ProfileEntry p("wglCopyImageSubDataNV");
      DP_VERIFY( wglCopyImageSubDataNV( hglrcSrc, idSrc, GL_TEXTURE_2D, 0, 0, 0, 0
        , hglrcDst, idDst, GL_TEXTURE_2D, 0, 0, 0, 0
        , dp::util::checked_cast<GLsizei>(tmpTexWidth)
        , dp::util::checked_cast<GLsizei>(tmpTexHeight)
        , 1 ) );
    }

    // decompress image data from dst tmp texture
    m_decompressProgram->setImageTexture( "dstImg", dstTexture, GL_WRITE_ONLY );
    m_decompressProgram->setImageTexture( "tmp", dstTmpTexture, GL_READ_ONLY );

    dp::gl::ProgramUseGuard pug( m_decompressProgram );

    glUniform1i( 0, dp::util::checked_cast<GLint>(m_maxIndex) );
    glUniform1i( 1, dp::util::checked_cast<GLint>(index) );

    glDispatchCompute( dp::util::checked_cast<GLuint>(tilesXPerGpu), dp::util::checked_cast<GLuint>(tilesY), 1 );
  }

  contextStack.pop();

#else

  // just copy the image, don't take the pattern into account (debug code)
  size_t width  = dstTexture->getWidth();
  size_t height = dstTexture->getHeight();

  GLuint idSrc = srcTexture->getGLId();
  GLuint idDst = dstTexture->getGLId();

  HGLRC hglrcSrc = m_srcContext->getHGLRC();
  HGLRC hglrcDst = m_dstContext->getHGLRC();

  wglCopyImageSubDataNV( hglrcSrc, idSrc, GL_TEXTURE_2D, 0, 0, 0, 0
                       , hglrcDst, idDst, GL_TEXTURE_2D, 0, 0, 0, 0
                       , dp::util::checked_cast<GLsizei>(width)
                       , dp::util::checked_cast<GLsizei>(height)
                       , 1 );

#endif
}
コード例 #4
0
ファイル: FileFinder.cpp プロジェクト: raedwulf/pipeline
 FileFinder::FileFinder( std::string const& path )
 {
   DP_VERIFY( addSearchPath( path ) );
 }
コード例 #5
0
ファイル: SceneTree.cpp プロジェクト: JamesLinus/pipeline
      void SceneTree::removeObjectTreeIndex( ObjectTreeIndex index )
      {
        // initialize the trafo index for the trafo search with the parent's trafo index
        DP_ASSERT( index != m_objectTreeSentinel && "cannot remove root node" );

        // vector for stack-simulation to eliminate overhead of std::stack
        m_objectIndexStack.resize( m_objectTree.size() );
        size_t begin = 0;
        size_t end   = 0;

        // start traversal at index
        m_objectIndexStack[end] = index;
        ++end;

        while( begin != end )
        {
          ObjectTreeIndex currentIndex = m_objectIndexStack[begin];
          ++begin;
          ObjectTreeNode& current = m_objectTree[currentIndex];

          if ( std::dynamic_pointer_cast<dp::sg::core::LightSource>(m_objectTree[currentIndex].m_object) )
          {
            DP_VERIFY( m_lightSources.erase( currentIndex ) == 1 );
          }

          if ( m_objectTree[currentIndex].m_isDrawable )
          {
            notify( Event( currentIndex, m_objectTree[currentIndex], Event::Type::REMOVED) );
            m_objectTree[index].m_isDrawable = false;
          }

          current.m_clipPlaneGroup.reset();

          // detach current index from object observer
          m_objectObserver->detach( currentIndex );

          // TODO: add observer flag to specify which observers must be detached?
          std::map< ObjectTreeIndex, SwitchWeakPtr >::iterator itSwitch = m_objectTree.m_switchNodes.find( currentIndex );
          if ( itSwitch != m_objectTree.m_switchNodes.end() )
          {
            m_switchObserver->detach( currentIndex );
            m_objectTree.m_switchNodes.erase( itSwitch );
          }

          std::map< ObjectTreeIndex, LODWeakPtr >::iterator itLod = m_objectTree.m_LODs.find( currentIndex );
          if ( itLod != m_objectTree.m_LODs.end() )
          {
            m_objectTree.m_LODs.erase( itLod );
          }

          // check if a transform needs to be removed
          DP_ASSERT( current.m_parentIndex != ~0 );
          const ObjectTreeNode& curParent = m_objectTree[current.m_parentIndex];

          // only remove the topmost transforms below or at index (so transforms are only removed once)
          if (current.m_isTransform)
          {
            m_transformTree.removeTransform(current.m_transform);
          }
          else if (current.m_isBillboard)
          {
            m_transformTree.removeBillboard(current.m_transform);
          }

          current.m_object.reset();

          // insert all children into stack for further traversal
          ObjectTreeIndex child = current.m_firstChild;
          while( child != ~0 )
          {
            m_objectIndexStack[end] = child;
            ++end;
            child = m_objectTree[child].m_nextSibling;
          }
        }

        // delete the node and its children from the object tree
        m_objectTree.deleteNode( index );
      }
コード例 #6
0
ファイル: SceneTree.cpp プロジェクト: mtavenrath/pipeline
      void SceneTree::removeObjectTreeIndex( ObjectTreeIndex index )
      {
        // initialize the trafo index for the trafo search with the parent's trafo index
        DP_ASSERT( index != m_objectTreeSentinel && "cannot remove root node" );
        TransformTreeIndex trafoIndex = m_objectTree[m_objectTree[index].m_parentIndex].m_transformIndex;

        // vector for stack-simulation to eliminate overhead of std::stack
        m_objectIndexStack.resize( m_objectTree.size() );
        size_t begin = 0;
        size_t end   = 0;

        // start traversal at index
        m_objectIndexStack[end] = index;
        ++end;

        while( begin != end ) 
        {
          ObjectTreeIndex currentIndex = m_objectIndexStack[begin];
          ++begin;
          ObjectTreeNode& current = m_objectTree[currentIndex];

          if ( isPtrTo<LightSource>( m_objectTree[currentIndex].m_object ) )
          {
            DP_VERIFY( m_lightSources.erase( currentIndex ) == 1 );
          }

          drawableInstanceRemove( currentIndex );

          current.m_clipPlaneGroup.reset();

          // detach current index from object observer
          m_objectObserver->detach( currentIndex );

          // TODO: add observer flag to specify which observers must be detached?
          std::map< ObjectTreeIndex, SwitchWeakPtr >::iterator itSwitch = m_objectTree.m_switchNodes.find( currentIndex );
          if ( itSwitch != m_objectTree.m_switchNodes.end() )
          {
            m_switchObserver->detach( currentIndex );
            m_objectTree.m_switchNodes.erase( itSwitch );
          }

          std::map< ObjectTreeIndex, LODWeakPtr >::iterator itLod = m_objectTree.m_LODs.find( currentIndex );
          if ( itLod != m_objectTree.m_LODs.end() )
          {
            m_objectTree.m_LODs.erase( itLod );
          }

          // check if a transform needs to be removed
          DP_ASSERT( current.m_parentIndex != ~0 );
          const ObjectTreeNode& curParent = m_objectTree[current.m_parentIndex];
          // only remove the topmost transforms below or at index (so transforms are only removed once)
          if(  current.m_transformIndex != curParent.m_transformIndex // transform indices differ
            && curParent.m_transformIndex == trafoIndex )             // parent index is parent index of removal root
          {
            removeTransformTreeIndex( current.m_transformIndex );
          }

          current.m_object = nullptr;

          // insert all children into stack for further traversal
          ObjectTreeIndex child = current.m_firstChild;
          while( child != ~0 )
          {
            m_objectIndexStack[end] = child;
            ++end;
            child = m_objectTree[child].m_nextSibling;
          }
        }

        // delete the node and its children from the object tree
        m_objectTree.deleteNode( index );
      }