Results 1 to 1 of 1

Thread: C++: Neat 3D Landscaping Class

  1. #1

    Thread Starter
    PowerPoster Halsafar's Avatar
    Join Date
    Jun 2004
    Location
    Saskatoon, SK
    Posts
    2,339

    C++: Neat 3D Landscaping Class

    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

    PHP Code:
            //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",500000500000,0);
        
    Land.AddVertice("Test",500000, -500001,0);
        
    Land.AddVertice("Test",-500000500000,1);
        
    Land.AddVertice("Test",-500000, -500001,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.
    Attached Files Attached Files
    "From what was there, and was meant to be, but not of that was faded away." - - Steve Damm

    "The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm

    "When you do things right, people won't be sure if you did anything at all." - - God from Futurama

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width