top of page

​​Chap 5/100: XML CFG File Loader / Simple Terrain Ground​

What I will Learn here?:

​On this Chapter we will use a XML lib to load the 1st version of our configurations of the future menus.

We will also render the base or ground of our world for now.

​

​

​

​

​

​

​

​

​

​

​

​

​

​

​

​

​

​

​

​​Note:

This can be a possible the base of our virtual world.

​

​

​(XML_LIB/src) A very simple version xml lib to load and save an XML file.

​

(main.h) - CHANGES

- Set for Chapter 5

​

​​​​​(applicationClass.cpp)​ - CHANGES

​

​Main part of applicationClass

​

​​    //#############################################################################################################
    //      3D    
    //#############################################################################################################

    // 1. 3D RENDERING: SKY
    //----------------------------------------------------------------------------------------------------------------------
    //

    // 2. For demos only:

    //----------------------------------------------------------------------------------------------------------------------
#if (TUTORIAL_CHAP >= 4)  && defined (SCENE_OBJMODEL) //Note: CH7 become world sand
    for (float z=g_INIT_CAMZ+2; z < g_INIT_CAMZ+5; z++) {
        for (float x=g_INIT_CAMX-2; x <= g_INIT_CAMX+2; x++) {
            objModel.m_world._41 = 4*x;
            objModel.m_world._42 = 0;
            objModel.m_world._43 = 4*z;
            objModel.render(pContext);
        }
    }
#endif//

    // 3. 3D RENDERING: Terrain
    //----------------------------------------------------------------------------------------------------------------------
    //

    //#############################################################################################################
    //      2D    
    //#############################################################################################################

​

​

​

​​Our first texture Shader, very, very simple:

​

////////////////////////////////////////////////////////////////////////////////
// Filename: 005Texture.hlsl
////////////////////////////////////////////////////////////////////////////////

#include "000cbuffer.hlsl"

//////////////
// TYPEDEFS //
//////////////


// VERTEX:
struct VSIn
{
    float4 position : POSITION;

    float2 tex : TEXfdfdCOORD0;
};

// PIXEL:
struct PSIn
{
    float4 position : SV_POSITION;

    float2 tex : TEXCOORD0;
};

​​

/////////////
// GLOBALS //
/////////////

Texture2D shaderTexture;
SamplerState SampleType;

​////////////////////////////////////////////////////////////////////////////////
// Vertex Shader
////////////////////////////////////////////////////////////////////////////////

PSIn MyVertexShader004Color(VSIn input)
{
    PSIn output;
   
    input.position.w = 1.0f;                    // Change the position vector to be 4 units for proper matrix calculations.
    output.position = mul(input.position, WVP);    // Calculate the position of the vertex against the world, view, and projection matrices.
    output.tex = input.tex;    // Store the texture coordinates for the pixel shader.

 

    return output;
}

////////////////////////////////////////////////////////////////////////////////
// Pixel Shader
////////////////////////////////////////////////////////////////////////////////

float4 MyPixelShader004Color(PSIn input) : SV_TARGET
{

    float4 textureColor;

    if (hasTexture) {
        // Sample the pixel color from the texture using the sampler at this texture coordinate location.
        textureColor = shaderTexture.Sample(SampleType, input.tex);
    } else {
        textureColor = pixelColor;
    }
    return textureColor;

}

 

​

​

​To navigate on source code:

 

User: public

​

​

​

​

​

​

​

​

​

​

​

​

​

​

​

​

​

​

​

​

​

​

​

​│   Applicationclass.cpp
│   Applicationclass.h
│   counter.h
│   main.cpp
│   main.h
│
├───camera
│       cameraClass.cpp
│       cameraClass.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

​

​

​

​Project Code:

​

WoMA_Chap5.zip

​

​What's next?

Yes is true we have the ground, on next chapter we will see the bases for the input Keyboard and mouse.

We will attach the input to the positions and the position to the camera.

This will allow us to move in our infinite world ground.

bottom of page