In this tutorial we will adding more geometry details to our scene we will build a little city
             
 

 

----TUTORIAL 7---

Adding More Polygons to our Scene

You will Need The NemoX engine Get it Here

download the Visual Basic Source code here

we'll use the same BaseCode as the Previous tutorial.

Summary

 

1. Setting Up our world

2. Game Loop Modification

 

In this demo we will make a simple city scene with a road crossed from the south to the north, 5 buildings and 2 other roads

 

1. Setting Up our world

We have only to add more code on the buildgeometry procedure to do that we will use some basic polygon

construction code offered by the Nemo_mesh class.

To Add the geometry data to our Mesh class we do it in 3 steps:

 

                                           Step 1:Texture creation

          We have to pass the textures we want to use for the mapping:

        function to use   :Mesh.Add_Texture (texturefile)

           return and integer that indicate the Texture index in the current texture Pool

         example in our builgeometry sub we use this:

        Mesh.Add_Texture (App.Path + "\Relief_8.jpg")          'texture index=0 
        Mesh.Add_Texture (App.Path + "\textures\facade2.jpg")  'texture index=1
       

       
        Mesh.Add_Texture App.Path + "\textures\street.JPG"     'texture index=2
        Mesh.Add_Texture App.Path + "\textures\street2.JPG"    'texture index=3
        Mesh.Add_Texture (App.Path + "\textures\kerb2.jpg")    'texture index=4
        Mesh.Add_Texture (App.Path + "\textures\kerb.jpg")     'texture index=5
          
        Mesh.Add_Texture (App.Path + "\textures\square.JPG")   'texture index=6
   
        Mesh.Add_Texture App.Path + "\textures\cement.JPG"     'texture index=7
       
        Mesh.Add_Texture App.Path + "\textures\road_t03.jpg"   'texture index=8
       

        Mesh.Add_Texture App.Path + "\textures\Asfalto1.bmp"   'texture index=9
        Mesh.Add_Texture App.Path + "\textures\pierres.JPG"    'texture index=10

        Mesh.Add_Texture App.Path + "\textures\win2.JPG"       'texture index=11
        Mesh.Add_Texture App.Path + "\textures\windows.JPG"       'texture index=12
       
        Mesh.Add_Texture App.Path + "\textures\StoreSd.BMP"     'texture index=13

 

 

                        Step 2:Vertex buffering

          The Nemo_Mesh class allow to add many simple polygon to the mesh built-in vertex buffer:

   here is a list of the methods:

        Mesh.Add_Box  
        Mesh.Add_Cilynder
        Mesh.Add_Cone
        Mesh.Add_CorridorBlock
        Mesh.Add_Sphere
        Mesh.Add_Stairs
        Mesh.Add_Vertex
        Mesh.Add_VertexEX
        Mesh.Add_VertexFromPoly
        Mesh.Add_VertexFromPolys
        Mesh.Add_WallBack
        Mesh.Add_WallFloor
        Mesh.Add_WallFront
        Mesh.Add_WallLeft
        Mesh.Add_WallRight
        Mesh.Add_WallRoof
In this tutorial we use only :
        Mesh.Add_WallBack
        Mesh.Add_WallFloor
        Mesh.Add_WallFront
        Mesh.Add_WallLeft
        Mesh.Add_WallRight
        Mesh.Add_WallRoof
 and    Mesh.Add_Box  to add vertex for a simple cubebox based tower
 
To make the towers in that demo we use this code:
       'add building 1    Bottomleft position     UpperRight position   Texture ID for each face
        Mesh.Add_Box Tool.Vector(-500, 0, 0), Tool.Vector(0, 500, 500), 1, 1, 1, 1, 1, 1
        
         

 

 

             Step 3:Polygon classification

         To classify each vertice we have to call the Mesh class subroutines Mesh.BuilMesh

                                      

                                      Mesh.BuilMesh 'this will make and classify polygons,building bounding box and Frustculling objects.

 

2.Game Loop Modification

'this sub is the main loop for a game or 3d apllication
Sub gameLoop()
            'loop untill player press 'ESCAPE'
           
    Do
           
               '=====Keyboard handler can be added here
               Call GetKey 'go to the previous tutorial for details
               DoEvents
              
              
              
               'start the 3d renderer
               Nemo.Begin3D
                     '===============ADD game rendering mrthod here
              
              
               'render the sky
               Sky.RenderSky

              

               
              
               'draw our city here
               Mesh.Render

                            

              
               LENS.Render

              
              
              
              
               'show the FPS at pixel(5,10) color White
               Nemo.Draw_Text "FPS:" + Str(Nemo.Framesperseconde), 5, 10, &HFFFF0000
 
               Nemo.End3D
               'end the 3d renderer
           
            'check the player keyPressed
    Loop Until Nemo.Get_KeyPress(NEMO_KEY_ESCAPE)
           
           
    Call EndGame 'go to the previous tutorial for details

End Sub

Here is a screenshot for our tutorial project

download the Visual Basic Source code here

See you in the next Tutorial.....sincerly Polaris..Don't forget Any Bugs detected mailMe

 

    The PreviousTutorial 6 :Adding Lensflare and glow effect

The Next Tutorial 8 :handle with Collision detection