How to render a scene with multiple hierarchy objects in DirectX11?












0















This might sound a dumb question but I am trying to understand the basics of 3d game programming and wanted to know this thing.



I have looked at the samples here https://code.msdn.microsoft.com/Direct3D-Tutorial-Win32-829979ef and I get it how each object's vertices and indexes to those vertices are stored in vertex buffer and index buffer respectively.



What I want to understand is how would I render a scene where I have multiple objects ? How should the vertex and index buffers be set? And how should a draw called be implemented ?



A reference or an example will help please.










share|improve this question


















  • 1





    Take a look at DirectX Tool Kit and in particular the Model / ModelMesh / ModelMeshPart classes for an example. The docs are in the wiki

    – Chuck Walbourn
    Nov 8 '18 at 20:12













  • @ChuckWalbourn thanks for your response

    – Monku
    Nov 9 '18 at 16:11
















0















This might sound a dumb question but I am trying to understand the basics of 3d game programming and wanted to know this thing.



I have looked at the samples here https://code.msdn.microsoft.com/Direct3D-Tutorial-Win32-829979ef and I get it how each object's vertices and indexes to those vertices are stored in vertex buffer and index buffer respectively.



What I want to understand is how would I render a scene where I have multiple objects ? How should the vertex and index buffers be set? And how should a draw called be implemented ?



A reference or an example will help please.










share|improve this question


















  • 1





    Take a look at DirectX Tool Kit and in particular the Model / ModelMesh / ModelMeshPart classes for an example. The docs are in the wiki

    – Chuck Walbourn
    Nov 8 '18 at 20:12













  • @ChuckWalbourn thanks for your response

    – Monku
    Nov 9 '18 at 16:11














0












0








0








This might sound a dumb question but I am trying to understand the basics of 3d game programming and wanted to know this thing.



I have looked at the samples here https://code.msdn.microsoft.com/Direct3D-Tutorial-Win32-829979ef and I get it how each object's vertices and indexes to those vertices are stored in vertex buffer and index buffer respectively.



What I want to understand is how would I render a scene where I have multiple objects ? How should the vertex and index buffers be set? And how should a draw called be implemented ?



A reference or an example will help please.










share|improve this question














This might sound a dumb question but I am trying to understand the basics of 3d game programming and wanted to know this thing.



I have looked at the samples here https://code.msdn.microsoft.com/Direct3D-Tutorial-Win32-829979ef and I get it how each object's vertices and indexes to those vertices are stored in vertex buffer and index buffer respectively.



What I want to understand is how would I render a scene where I have multiple objects ? How should the vertex and index buffers be set? And how should a draw called be implemented ?



A reference or an example will help please.







directx directx-11






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 8 '18 at 17:43









MonkuMonku

73511223




73511223








  • 1





    Take a look at DirectX Tool Kit and in particular the Model / ModelMesh / ModelMeshPart classes for an example. The docs are in the wiki

    – Chuck Walbourn
    Nov 8 '18 at 20:12













  • @ChuckWalbourn thanks for your response

    – Monku
    Nov 9 '18 at 16:11














  • 1





    Take a look at DirectX Tool Kit and in particular the Model / ModelMesh / ModelMeshPart classes for an example. The docs are in the wiki

    – Chuck Walbourn
    Nov 8 '18 at 20:12













  • @ChuckWalbourn thanks for your response

    – Monku
    Nov 9 '18 at 16:11








1




1





Take a look at DirectX Tool Kit and in particular the Model / ModelMesh / ModelMeshPart classes for an example. The docs are in the wiki

– Chuck Walbourn
Nov 8 '18 at 20:12







Take a look at DirectX Tool Kit and in particular the Model / ModelMesh / ModelMeshPart classes for an example. The docs are in the wiki

– Chuck Walbourn
Nov 8 '18 at 20:12















@ChuckWalbourn thanks for your response

– Monku
Nov 9 '18 at 16:11





@ChuckWalbourn thanks for your response

– Monku
Nov 9 '18 at 16:11












1 Answer
1






active

oldest

votes


















1














To elaborate on Chuck's link, the process by which you will render multiple objects will vary depending on the architecture you choose to use.



Every model is divided into a number sections equal to the number of textures/material combinations it has. Each of these sections consists of a unique texture/material combination and will have its own vertex/index buffer pair.



The reason for this is because the HLSL is primarily designed to operate on a single texture and material at a time. You bind the vertex and index buffers of a single section to the pipeline along with the corresponding texture/material, perform a draw call on it, then bind the buffers/texture/material for the next section until the whole model has been rendered.



The cool part is that you only need to load a model once. As long as you have the information for that model, you can create instances of the model using the same data but different position matricies. This lets you create hundreds or thousands of copies of an object.



My scratch codeed engine handles models like this: during initialization, a model manager class is used to load in all the different models I use and store each unique model into a model class. I then take a pointer to the model class and feed it into scenery managers which give information on what contexts the model appears in. When I populate the game world with scenery, my game tile uses a scenery list class to handle a list of instance structures and render lists. The instance structure holds information such as position/scale/orientation, an AABB, and a pointer to the model class. Each frame, I frustum cull the scenery and populate the render lists with only the instance structures of potentially visible objects and produce an instance buffer for each list to contain the positional information. Then, I can loop through each render list, assign the appropriate buffers and textures, and draw indexed instanced() to render all the copies of the model section.



I'm not sure how my process compares to other engines, but it should serve as a reasonable example of how you might handle multiple objects and then multiple instances of objects. The levels of abstraction I have in my process were chosen due to how my engine works (random world generation). The exact method you use will vary based on your application.



Here is a basic diagram showing a fairly bare-bones set up:
enter image description here






share|improve this answer

























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53213380%2fhow-to-render-a-scene-with-multiple-hierarchy-objects-in-directx11%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    To elaborate on Chuck's link, the process by which you will render multiple objects will vary depending on the architecture you choose to use.



    Every model is divided into a number sections equal to the number of textures/material combinations it has. Each of these sections consists of a unique texture/material combination and will have its own vertex/index buffer pair.



    The reason for this is because the HLSL is primarily designed to operate on a single texture and material at a time. You bind the vertex and index buffers of a single section to the pipeline along with the corresponding texture/material, perform a draw call on it, then bind the buffers/texture/material for the next section until the whole model has been rendered.



    The cool part is that you only need to load a model once. As long as you have the information for that model, you can create instances of the model using the same data but different position matricies. This lets you create hundreds or thousands of copies of an object.



    My scratch codeed engine handles models like this: during initialization, a model manager class is used to load in all the different models I use and store each unique model into a model class. I then take a pointer to the model class and feed it into scenery managers which give information on what contexts the model appears in. When I populate the game world with scenery, my game tile uses a scenery list class to handle a list of instance structures and render lists. The instance structure holds information such as position/scale/orientation, an AABB, and a pointer to the model class. Each frame, I frustum cull the scenery and populate the render lists with only the instance structures of potentially visible objects and produce an instance buffer for each list to contain the positional information. Then, I can loop through each render list, assign the appropriate buffers and textures, and draw indexed instanced() to render all the copies of the model section.



    I'm not sure how my process compares to other engines, but it should serve as a reasonable example of how you might handle multiple objects and then multiple instances of objects. The levels of abstraction I have in my process were chosen due to how my engine works (random world generation). The exact method you use will vary based on your application.



    Here is a basic diagram showing a fairly bare-bones set up:
    enter image description here






    share|improve this answer






























      1














      To elaborate on Chuck's link, the process by which you will render multiple objects will vary depending on the architecture you choose to use.



      Every model is divided into a number sections equal to the number of textures/material combinations it has. Each of these sections consists of a unique texture/material combination and will have its own vertex/index buffer pair.



      The reason for this is because the HLSL is primarily designed to operate on a single texture and material at a time. You bind the vertex and index buffers of a single section to the pipeline along with the corresponding texture/material, perform a draw call on it, then bind the buffers/texture/material for the next section until the whole model has been rendered.



      The cool part is that you only need to load a model once. As long as you have the information for that model, you can create instances of the model using the same data but different position matricies. This lets you create hundreds or thousands of copies of an object.



      My scratch codeed engine handles models like this: during initialization, a model manager class is used to load in all the different models I use and store each unique model into a model class. I then take a pointer to the model class and feed it into scenery managers which give information on what contexts the model appears in. When I populate the game world with scenery, my game tile uses a scenery list class to handle a list of instance structures and render lists. The instance structure holds information such as position/scale/orientation, an AABB, and a pointer to the model class. Each frame, I frustum cull the scenery and populate the render lists with only the instance structures of potentially visible objects and produce an instance buffer for each list to contain the positional information. Then, I can loop through each render list, assign the appropriate buffers and textures, and draw indexed instanced() to render all the copies of the model section.



      I'm not sure how my process compares to other engines, but it should serve as a reasonable example of how you might handle multiple objects and then multiple instances of objects. The levels of abstraction I have in my process were chosen due to how my engine works (random world generation). The exact method you use will vary based on your application.



      Here is a basic diagram showing a fairly bare-bones set up:
      enter image description here






      share|improve this answer




























        1












        1








        1







        To elaborate on Chuck's link, the process by which you will render multiple objects will vary depending on the architecture you choose to use.



        Every model is divided into a number sections equal to the number of textures/material combinations it has. Each of these sections consists of a unique texture/material combination and will have its own vertex/index buffer pair.



        The reason for this is because the HLSL is primarily designed to operate on a single texture and material at a time. You bind the vertex and index buffers of a single section to the pipeline along with the corresponding texture/material, perform a draw call on it, then bind the buffers/texture/material for the next section until the whole model has been rendered.



        The cool part is that you only need to load a model once. As long as you have the information for that model, you can create instances of the model using the same data but different position matricies. This lets you create hundreds or thousands of copies of an object.



        My scratch codeed engine handles models like this: during initialization, a model manager class is used to load in all the different models I use and store each unique model into a model class. I then take a pointer to the model class and feed it into scenery managers which give information on what contexts the model appears in. When I populate the game world with scenery, my game tile uses a scenery list class to handle a list of instance structures and render lists. The instance structure holds information such as position/scale/orientation, an AABB, and a pointer to the model class. Each frame, I frustum cull the scenery and populate the render lists with only the instance structures of potentially visible objects and produce an instance buffer for each list to contain the positional information. Then, I can loop through each render list, assign the appropriate buffers and textures, and draw indexed instanced() to render all the copies of the model section.



        I'm not sure how my process compares to other engines, but it should serve as a reasonable example of how you might handle multiple objects and then multiple instances of objects. The levels of abstraction I have in my process were chosen due to how my engine works (random world generation). The exact method you use will vary based on your application.



        Here is a basic diagram showing a fairly bare-bones set up:
        enter image description here






        share|improve this answer















        To elaborate on Chuck's link, the process by which you will render multiple objects will vary depending on the architecture you choose to use.



        Every model is divided into a number sections equal to the number of textures/material combinations it has. Each of these sections consists of a unique texture/material combination and will have its own vertex/index buffer pair.



        The reason for this is because the HLSL is primarily designed to operate on a single texture and material at a time. You bind the vertex and index buffers of a single section to the pipeline along with the corresponding texture/material, perform a draw call on it, then bind the buffers/texture/material for the next section until the whole model has been rendered.



        The cool part is that you only need to load a model once. As long as you have the information for that model, you can create instances of the model using the same data but different position matricies. This lets you create hundreds or thousands of copies of an object.



        My scratch codeed engine handles models like this: during initialization, a model manager class is used to load in all the different models I use and store each unique model into a model class. I then take a pointer to the model class and feed it into scenery managers which give information on what contexts the model appears in. When I populate the game world with scenery, my game tile uses a scenery list class to handle a list of instance structures and render lists. The instance structure holds information such as position/scale/orientation, an AABB, and a pointer to the model class. Each frame, I frustum cull the scenery and populate the render lists with only the instance structures of potentially visible objects and produce an instance buffer for each list to contain the positional information. Then, I can loop through each render list, assign the appropriate buffers and textures, and draw indexed instanced() to render all the copies of the model section.



        I'm not sure how my process compares to other engines, but it should serve as a reasonable example of how you might handle multiple objects and then multiple instances of objects. The levels of abstraction I have in my process were chosen due to how my engine works (random world generation). The exact method you use will vary based on your application.



        Here is a basic diagram showing a fairly bare-bones set up:
        enter image description here







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 18 '18 at 23:11

























        answered Nov 18 '18 at 20:03









        GaleRazorwindGaleRazorwind

        896




        896
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53213380%2fhow-to-render-a-scene-with-multiple-hierarchy-objects-in-directx11%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            Xamarin.form Move up view when keyboard appear

            Post-Redirect-Get with Spring WebFlux and Thymeleaf

            Anylogic : not able to use stopDelay()