top of page

​​Chap 15/100: Terrain with MINI-MAP (First Version)

​

What I will Learn here?:

​On this tutorial ​​we will learn how to render into a texture and then render that pre rendered text​ure as a bitmap.

​

​

​

​

​

​

​

​

​

​

​

​

​

​

​

​

​

​

​

​Note:

Try "God Mode" F12 and check the 2D Frustrum View

​

​Let's check our current main source tree, except the LIBs:

​

Added source on White:

​

​│   Applicationclass.cpp
│   Applicationclass.h
│   counter.h
│   main.cpp
│   main.h
│
├───camera
│       cameraClass.cpp
│       cameraClass.h
│       frustumClass.cpp
│       frustumClass.h
​

│       lightClass.cpp
│       lightClass.h
│       positionClass.cpp
│       positionClass.h

│       RenderFrustumClass.cpp
│       RenderFrustumClass.h

│
├───game
│       playerClass.cpp
│       playerClass.h​
│
​

├───graphics

│       renderTextureClass.cpp
│       renderTextureClass.h

│       spriteClass.cpp
│       spriteClass.h
​

│       textClass.cpp
│       textClass.h
│       textFontClass.cpp
│       textFontClass.h
│
├───input
│       inputClass.cpp
│       inputClass.h
│
├───loader
│       objModelV2Class.cpp
│       objModelV2Class.h
│
├───shader
│       shaderClass.cpp
│       shaderClass.h
│

├───system
│       dx11Class.cpp
│       dx11class.h
│       SystemClass.cpp
│       SystemClass.h
│       xml_loader.cpp
│       xml_loader.h
​

│
​└───terrain
        bitmapclass.cpp
        bitmapclass.h
        Minimapclass.cpp
        Minimapclass.h

        quadtreeClass.cpp
        quadtreeClass.h
        terrainClass.cpp
        terrainClass.h
        terrainManagerClass.cpp
        terrainManagerClass.h

​

​​​(main.h) ​

- Set for Chapter 15

​

Initialization of Mini-map:

​​

​

We need also a new projection Matrix once we will not use a prespective view:

​

    // [15] MINIMAP
    //-----------------------------------------------------------------------------------------    

    #if TUTORIAL_CHAP >= 15

    if(!m_TerrainManager.m_MiniMap.Initialize(g_DirectX11, &m_TerrainManager.m_Terrain[m_TerrainManager.active_terrain],
                                (float)(m_TerrainManager.m_Terrain[m_TerrainManager.active_terrain].m_terrainWidth - 1),
                                (float)(m_TerrainManager.m_Terrain[m_TerrainManager.active_terrain].m_terrainHeight - 1)))
        {MyMessageBox(L"Could not initialize the MiniMap object");return false;}

    g_DirectX11->GetProjectionMiniMapMatrix(g_projectionMiniMapMatrix);
    #endif//

 

Update our position after movements update in mini-map also:​

​​

#if TUTORIAL_CHAP >= 15 && defined (SCENE_MINIMAP)
    //The position of the user on the mini-map will then be accurately reflected each frame.
    // Update the location of the camera on the mini map.
    // --------------------------------------------------------------------------------------------

    for (UINT i=0; i < HowManyPlayers; i++)
    {

        #if TUTORIAL_CHAP >= 90
        if (m_player[i]->p_player.online && m_player[i]->p_player.faction == m_player[g_NetID]->p_player.faction) //if player online and from our faction
        #endif

        {
            posX = m_Position[i]->m_positionX;
            posZ = m_Position[i]->m_positionZ;

            m_TerrainManager.m_MiniMap.PositionUpdate(i, posX, posZ);
            m_TerrainManager.m_MiniMap.m_pointRotation[i] = (int)m_Position[i]->m_rotationY; //need to update rotY
        }
    }
#endif//
​

​

Render the Mini-map:​

​

    // SPRITES: MINI MAP
    //----------------------------------------------------------------------------------------------------------------------

#if TUTORIAL_CHAP >= 15 && defined(SCENE_MINIMAP)
    IF_NOT_RETURN_FALSE ( m_TerrainManager.m_MiniMap.Render(pContext) );
#endif//

 

 

​

​​

​​​​Project Code:

​

http://woma.no-ip.org/woma/WoMA_PartII_Chap15.zip​

​​

​What's next?

On next tutorial we will see how to Render the Respective Mini-Map of this Big Map

bottom of page