void StaticMeshVisual::setDiffuseTexture(size_t index, const std::string& texture)
{
    assert(index < m_VisualEntities.size());

    Components::StaticMeshComponent& sm = m_World.getEntity<Components::StaticMeshComponent>(m_VisualEntities[index]);

    Handle::TextureHandle tx = m_World.getTextureAllocator().loadTextureVDF(m_World.getEngine()->getVDFSIndex(), texture);

    // Check load
    if (!tx.isValid())
        return;

    sm.m_Texture = tx;
}
Beispiel #2
0
    void showSplash()
    {
        float view[16];
        float proj[16];

        bx::mtxIdentity(view);
        bx::mtxOrtho(proj, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 100.0f);



        bgfx::setViewRect(1, 0, 0, (uint16_t)getWindowWidth(), (uint16_t)getWindowHeight());

        // Set view and projection matrix for view 0.
        bgfx::setViewTransform(1, NULL, proj);


        bgfx::touch(0);

#if BX_PLATFORM_ANDROID

#else
        Textures::TextureAllocator alloc(&m_pEngine->getVDFSIndex());
        Handle::TextureHandle txh = alloc.loadTextureVDF("STARTSCREEN.TGA");

        if(!txh.isValid())
            return;

        Textures::Texture& texture = alloc.getTexture(txh);
        bgfx::frame();

        bgfx::setState(BGFX_STATE_DEFAULT);
        const Render::RenderConfig& cfg = m_pEngine->getDefaultRenderSystem().getConfig();
        bgfx::setTexture(0, cfg.uniforms.diffuseTexture, texture.m_TextureHandle);
        renderScreenSpaceQuad(1, cfg.programs.fullscreenQuadProgram, 0.0f, 0.0f, 1280.0f, 720.0f);
#endif


        bgfx::dbgTextPrintf(0, 1, 0x4f, "Loading...");
        bgfx::frame();
    }
Beispiel #3
0
UI::Hud::Hud(Engine::BaseEngine& e)
    : View(e)
{
    Textures::TextureAllocator& alloc = m_Engine.getEngineTextureAlloc();

    m_pHealthBar = new BarView(m_Engine);
    m_pManaBar = new BarView(m_Engine);
    m_pEnemyHealthBar = new BarView(m_Engine);
    m_pDialogBox = new DialogBox(m_Engine);
    m_pDialogBox->setHidden(true);
    m_pPrintScreenMessageView = new PrintScreenMessages(m_Engine);
    m_pClock = new TextView(m_Engine);
    m_pLoadingScreen = new LoadingScreen(m_Engine);
    m_pLoadingScreen->setHidden(true);
    m_pConsoleBox = new ConsoleBox(m_Engine);
    m_pConsoleBox->setHidden(true);
    m_pMenuBackground = new ImageView(m_Engine);
    m_pMenuBackground->setHidden(true);
    m_pMenuBackground->setRelativeSize(false);
    m_pIntroduceChapterView = new IntroduceChapterView(m_Engine);
    m_pIntroduceChapterView->setHidden(true);

    addChild(m_pHealthBar);
    addChild(m_pManaBar);
    addChild(m_pEnemyHealthBar);
    addChild(m_pDialogBox);
    addChild(m_pPrintScreenMessageView);
    addChild(m_pClock);
    addChild(m_pLoadingScreen);
    addChild(m_pMenuBackground);
    addChild(m_pConsoleBox);
    addChild(m_pIntroduceChapterView);

    // Initialize status bars
    {
        m_GameplayHudElements.push_back(m_pManaBar);
        //m_GameplayHudElements.push_back(m_pEnemyHealthBar);
        m_GameplayHudElements.push_back(m_pClock);
        m_GameplayHudElements.push_back(m_pHealthBar);

        // Background shown when there is no world loaded
        Handle::TextureHandle hBackground = alloc.loadTextureVDF("STARTSCREEN.TGA");
        m_pMenuBackground->setImage(hBackground);
        m_pMenuBackground->setSize(Math::float2(1, 1));

        Handle::TextureHandle hBarBackground = alloc.loadTextureVDF("BAR_BACK.TGA");
        Handle::TextureHandle hBarHealth = alloc.loadTextureVDF("BAR_HEALTH.TGA");
        Handle::TextureHandle hBarMana = alloc.loadTextureVDF("BAR_MANA.TGA");

        if (hBarMana.isValid() && hBarHealth.isValid() && hBarBackground.isValid())
        {
            // Images
            m_pHealthBar->setBackgroundImage(hBarBackground);
            m_pManaBar->setBackgroundImage(hBarBackground);
            m_pEnemyHealthBar->setBackgroundImage(hBarBackground);

            m_pHealthBar->setBarImage(hBarHealth);
            m_pManaBar->setBarImage(hBarMana);
            m_pEnemyHealthBar->setBarImage(hBarHealth);

            // Alignment
            m_pHealthBar->setAlignment(A_BottomLeft);
            m_pManaBar->setAlignment(A_BottomRight);
            m_pEnemyHealthBar->setAlignment(A_TopCenter);

            // Size
            Math::float2 barSize = Math::float2(0.6f, 0.6f);
            m_pHealthBar->setSize(barSize);
            m_pManaBar->setSize(barSize);
            m_pEnemyHealthBar->setSize(barSize);

            // Position
            m_pHealthBar->setTranslation(Math::float2(0.01f, 0.99f));
            m_pManaBar->setTranslation(Math::float2(0.99f, 0.99f));
            m_pEnemyHealthBar->setTranslation(Math::float2(0.5f, 0.01f));

            m_pEnemyHealthBar->setHidden(true);
        }
    }

    // Initialize clock
    {
        m_pClock->setTranslation(Math::float2(0.99f, 0.01f));
        m_pClock->setAlignment(A_TopRight);
    }

    setupKeyBindings();
}