# directx landscapes

This topic is 3896 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

i was wondering if anybody can help me. i want to load a landscape from an x file into my program, but i don't know how to find the coords of the grid. i need to know them so i can walk around and stuff. could anybody help me? i can give more info, but i don't know what i should give, so just tell me what i should give. i already had an object loaded from an x file, but i just want the landscape now and know where to find the coords

##### Share on other sites
To start out:

What do you load the x file into? A mesh?
Is the mesh rectangular (in the x-z plane ) or some non-rectangular shape?

Using a non-rectangular shape will be a bit more difficult than the method described below.

Assuming the x,z coordinates are the east/west-north/south locations (y is the terrain elevation at x,z coordinates):

If the mesh is fairly regular in shape, after you've loaded it in (presumably into something like a mesh from which you can access a vertex buffer), you can lock the vertex buffer, iterate through the buffer and calculate a bounding box by checking all the x and z coords and determining the minimum x & z values and the maximum x & z values. (You can check the min-max y values also if you don't know any of the terrain elevations) Unlock the buffer.

You now have a rectangle that surrounds the mesh.

You can now pick an eyept location somewhere inside that bounding rectangle. For instance, if the bounding rectangle is x from -100 to +100 and z from -200 to +500, pick x=0, z=0 as a starting location for your eyepoint.

To find the elevation at the eyept, determine the intersection of the mesh (say, with D3DXIntersect) with a direction ray of (0,-1,0) located at a position of ( eyept.x, 10000.0f, eyept.z ). The "10000.0f" is just some elevation that you know is above the mesh. Use something greater than the max Y value determined above if you need to.

Your location is now ( eyept.x, y_elev_at_xz, eyept.z ).

Is that getting you started in the right direction?

##### Share on other sites
yes thanks, that should help a lot

1. 1
2. 2
3. 3
4. 4
Rutin
17
5. 5

• 13
• 14
• 9
• 9
• 9
• ### Forum Statistics

• Total Topics
632927
• Total Posts
3009241
• ### Who's Online (See full list)

There are no registered users currently online

×