# VBForums CodeBank > CodeBank - C++ >  C++: Neat 3D Landscaping Class

## Halsafar

This is a very basic 3D LANDSCAPING class.  It allows manual vertice allocation and indexing of at max 65535 land segments per instance.  A Segment acts more like a piece of land, like a hill, the ground, a crater.  There are a few things I still need to impliment like the ability to change what type of DrawPrimite ShapeStyle is used (triangle strip, list, etc)

The class is attached, but an example of how to use it is shown below.

This class is more advanced than I posted, but the basic idea here is down, and if someone wrote a map_loading routine to load data from a text file, this class would really come in handy



```

        //Pass an initialized Device3D into the class
        //You can create without the pass, and pass later usin a func inside
    LandScape Land(Device3D);
//Create a segment with a unique ID
    Land.CreateSegment("Test");

//"Segment Name, VerticePosX,Y,Z, tileU, tileV
    Land.AddVertice("Test",50000, 0, 50000, 0,0);
    Land.AddVertice("Test",50000, 0, -50000, 1,0);
    Land.AddVertice("Test",-50000, 0, 50000, 0,1);
    Land.AddVertice("Test",-50000, 0, -50000, 1,1);
    
    Land.AddIndex("Test",0);
    Land.AddIndex("Test",1);
    Land.AddIndex("Test",2);
    Land.AddIndex("Test",3);

    Land.Update("Test");
    Land.AddTexture("Test",Textures[26]);

  //Create a tiny little basic hill
    Land.CreateSegment("Hill");

    Land.AddVertice("Hill", 1000,10,-50000,0,0);
    Land.AddVertice("Hill", 1000,1000,-55000,1,0);
    Land.AddVertice("Hill", 0,10,-50000,0,1);
    Land.AddVertice("Hill", 0,-1000,-55000,0,0);
    
    Land.AddIndex("Hill",0);
    Land.AddIndex("Hill",1);
    Land.AddIndex("Hill",2);
    Land.AddIndex("Hill",3);
    
    Land.Update("Hill");
    Land.AddTexture("Hill", Textures[26]);

  //This will render every segment.  This will be advanced to render
  // only active marked segments, and allow z-ordering etc..
  Land.Render(); 



```

Note:
This is not a class implimentatin, just a header.
So it is compiled with whatever it is included in, not seperate. 
This is why some things must be met:

To compile this and use it you will need knowledge of Dx7
You will also need to somewhere have the proper includes 
#include <ddraw.h>
#include <d3d.h>

Also to use the string and vectors within
#include <string>
#include <vector>
using namespace std;

Otherwise I know this is portable to any project which has met the above requirements.  In fact, all you really need to use this is an initialized 3D Device in Dx7.  

Now, for some reason there are linking errors if the two functions declared outside the header are not qualified with __forceinline.
Do not ask me why, I have never had that problem happen before.  But it won't compiler elsewise.  Maybe someone can assist.  But because of this I believe this class will work only in VC.

I just felt like posting something, I have a whole game engine written, but I am not prepared to give it all away as one yet.

Expecting some feedback.

DirectX9 Version coming as soon as I get a better video card.

----------

