void UrhoRenderer::Load()
{
    SceneAPI* scene = framework->Scene();
    scene->RegisterComponentFactory(ComponentFactoryPtr(new GenericComponentFactory<Placeable>()));
    scene->RegisterComponentFactory(ComponentFactoryPtr(new GenericComponentFactory<Mesh>()));
    scene->RegisterComponentFactory(ComponentFactoryPtr(new GenericComponentFactory<Camera>()));
    scene->RegisterComponentFactory(ComponentFactoryPtr(new GenericComponentFactory<Light>()));
    scene->RegisterComponentFactory(ComponentFactoryPtr(new GenericComponentFactory<AnimationController>()));
    scene->RegisterComponentFactory(ComponentFactoryPtr(new GenericComponentFactory<EnvironmentLight>()));
    scene->RegisterComponentFactory(ComponentFactoryPtr(new GenericComponentFactory<Terrain>()));
    scene->RegisterComponentFactory(ComponentFactoryPtr(new GenericComponentFactory<Sky>()));
    scene->RegisterComponentFactory(ComponentFactoryPtr(new GenericComponentFactory<ParticleSystem>));
    scene->RegisterComponentFactory(ComponentFactoryPtr(new GenericComponentFactory<Fog>));
    scene->RegisterComponentFactory(ComponentFactoryPtr(new GenericComponentFactory<WaterPlane>));

    /// \todo Check and add new supported texture extensions
    StringList textureExtensions;
    textureExtensions.Push(".crn"); // CRN to DDS decompression implemented in TextureAsset
    textureExtensions.Push(".dds");
    textureExtensions.Push(".png");
    textureExtensions.Push(".jpeg");
    textureExtensions.Push(".jpg");
    textureExtensions.Push(".gif");
    textureExtensions.Push(".bmp");
    textureExtensions.Push(".tga");
    textureExtensions.Push(".psd");

    framework->Asset()->RegisterAssetTypeFactory(AssetTypeFactoryPtr(new GenericAssetFactory<UrhoMeshAsset>("UrhoMesh", ".mdl")));
    framework->Asset()->RegisterAssetTypeFactory(AssetTypeFactoryPtr(new GenericAssetFactory<OgreMeshAsset>("OgreMesh", ".mesh")));
    framework->Asset()->RegisterAssetTypeFactory(AssetTypeFactoryPtr(new GenericAssetFactory<OgreMaterialAsset>("OgreMaterial", ".material")));
    framework->Asset()->RegisterAssetTypeFactory(AssetTypeFactoryPtr(new GenericAssetFactory<OgreSkeletonAsset>("OgreSkeleton", ".skeleton")));
    framework->Asset()->RegisterAssetTypeFactory(AssetTypeFactoryPtr(new GenericAssetFactory<OgreParticleAsset>("OgreParticle", ".particle")));
    framework->Asset()->RegisterAssetTypeFactory(AssetTypeFactoryPtr(new GenericAssetFactory<TextureAsset>("Texture", textureExtensions)));
}
Beispiel #2
0
UiAPI::UiAPI(Foundation::Framework *owner_) :
    owner(owner_),
    mainWindow(0),
    graphicsView(0),
    graphicsScene(0)
{
    if (owner->IsHeadless())
        return;
    
    mainWindow = new UiMainWindow(owner);
    mainWindow->setAutoFillBackground(false);
    //mainWindow->setUpdatesEnabled(false);

    // Apply the Naali main window icon. 
    // Note: this will only affect to a icon at main window left top corner.
    //       The application thumbnail icon must be set by adding icon resource
    //       to viewer project
    QIcon icon("./data/ui/images/icon/naali_logo_32px_RC1.ico");
    mainWindow->setWindowIcon(icon);

    graphicsView = new UiGraphicsView(mainWindow);

    ///\todo Memory leak below, see very end of ~Renderer() for comments.

    // QMainWindow has a layout by default. It will not let you set another.
    // Leave this check here if the window type changes to for example QWidget so we dont crash then.
    if (!mainWindow->layout())
        mainWindow->setLayout(new QVBoxLayout());
    mainWindow->layout()->setMargin(0);
    mainWindow->layout()->setContentsMargins(0,0,0,0);
    mainWindow->layout()->addWidget(graphicsView);

    viewportWidget = new SuppressedPaintWidget();
    graphicsView->setViewport(viewportWidget);
    viewportWidget->setAttribute(Qt::WA_DontShowOnScreen, true);
    viewportWidget->setGeometry(0, 0, graphicsView->width(), graphicsView->height());
    viewportWidget->setContentsMargins(0,0,0,0);

    mainWindow->setContentsMargins(0,0,0,0);
    graphicsView->setContentsMargins(0,0,0,0);
    
    graphicsView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    graphicsView->horizontalScrollBar()->setValue(0);
    graphicsView->horizontalScrollBar()->setRange(0, 0);

    graphicsView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    graphicsView->verticalScrollBar()->setValue(0);
    graphicsView->verticalScrollBar()->setRange(0, 0);

    graphicsScene = new QGraphicsScene(this);

    graphicsView->setScene(graphicsScene);
    graphicsView->scene()->setSceneRect(graphicsView->rect());
    connect(graphicsScene, SIGNAL(changed(const QList<QRectF> &)), graphicsView, SLOT(HandleSceneChanged(const QList<QRectF> &))); 
    connect(graphicsScene, SIGNAL(sceneRectChanged(const QRectF &)), SLOT(OnSceneRectChanged(const QRectF &)));

    connect(mainWindow, SIGNAL(WindowResizeEvent(int,int)), graphicsView, SLOT(Resize(int,int))); 

    mainWindow->LoadWindowSettingsFromFile();
    graphicsView->Resize(mainWindow->width(), mainWindow->height());

    // Unfortunate hack we have to do, will mess up the splash screen for a moment.
    // Reason why we need to show/hide hack is qt makes the QWidget::winId() valid on first show event.
    // This means we need to have a valid win id before ogre is loaded and the winid is passet to its renderer to paint into.
    mainWindow->show();
    mainWindow->hide();

    /// Do a full repaint of the view now that we've shown it.
    graphicsView->MarkViewUndirty();

    owner_->Asset()->RegisterAssetTypeFactory(AssetTypeFactoryPtr(new GenericAssetFactory<QtUiAsset>("QtUiFile")));

    connect(mainWindow, SIGNAL(WindowCloseEvent()), owner, SLOT(Exit()));
}
Beispiel #3
0
 void PythonScriptModule::Load()
 {
     /// \todo This should print a error as PythonScriptModule::Load might have done this already! How to avoid?
     framework_->Scene()->RegisterComponentFactory(ComponentFactoryPtr(new GenericComponentFactory<EC_Script>));
     framework_->Asset()->RegisterAssetTypeFactory(AssetTypeFactoryPtr(new ScriptAssetFactory()));
 }