void ParticleRendererComponent::initialize()
{
    if( !d->item )
    {
        d->item = GluonGraphics::Engine::instance()->createItem( "default" );
    }

    if( d->material )
    {
        Asset* materialAsset = qobject_cast<Asset*>( d->material->parent() );
        if( materialAsset )
            materialAsset->load();

        Asset* texture = 0;
        if( d->material->property( "texture0" ).type() == QVariant::String )
        {
            QString theName( d->material->property( "texture0" ).toString() );
            QString theObjectName = GluonObject::nameToObjectName( theName );
            texture = gameProject()->findChild<Asset*>( theObjectName );
            if( !texture )
                debug( QString( "Texture failed to load - attempted to load texture named %1 (searched for %2)" ).arg( theName ).arg( theObjectName ) );
        }
        else
            texture = qobject_cast<Asset*>( GluonCore::GluonObjectFactory::instance()->wrappedObject( d->material->property( "texture0" ) ) );

        if( texture )
            texture->load();
        d->item->setMaterialInstance( d->material );
    }
}
Example #2
0
void BeamRendererComponent::Private::loadMaterial( GluonGraphics::MaterialInstance* material )
{
    Asset* materialAsset = qobject_cast<Asset*>( material->parent() );
    if( materialAsset )
        materialAsset->load();

    Asset* texture = Game::instance()->gameProject()->findChild<Asset*>( material->property( "texture0" ).toString() );
    if( texture )
        texture->load();
}
void CameraControllerComponent::initialize()
{
    if( !d->camera )
        d->camera = new GluonGraphics::Camera();

    if( d->active )
    {
        GluonGraphics::Engine::instance()->setActiveCamera( d->camera );
    }

    if( !d->material )
    {
        d->material = GluonGraphics::Engine::instance()->mainRenderTarget()->materialInstance();
    }
    else
    {
        Asset* materialAsset = qobject_cast<Asset*>( d->material->parent() );
        if( materialAsset )
            materialAsset->load();
        if( GluonGraphics::Engine::instance()->mainRenderTarget() )
            GluonGraphics::Engine::instance()->mainRenderTarget()->setMaterialInstance( d->material );
        else
            debug( QString( "Warning: there is no main RenderTarget set!" ) );
    }

    d->camera->frustrum()->setOrthoAdjusted( d->visibleArea, GluonGraphics::Engine::instance()->currentViewport()->aspectRatio(), d->nearPlane, d->farPlane );
}
Example #4
0
Asset* AssetSystem::get(const char* pFileName)
{
	Asset* pAsset = addPending(pFileName);
	if (pAsset && !pAsset->getLoaded())
	{
	  pAsset->load();
	}
	
	return pAsset;
}
Example #5
0
void AssetSystem::loadPending()
{
  // Can't cache the element count here because loading may cause
  // new assets to be added to the table.
  for (int x = 0; x < mLoadedAssetTable.getElementCount(); x++)
  {
    Asset* asset = mLoadedAssetTable.get(x);
    if (!asset->getLoaded())
    {
      asset->load();
    }
  }
}