# Building walls in segments over an increment

## Recommended Posts

I made a simple wall mesh to start practicing 3D level design. I want to make it so that I can use a for loop to place the walls over an incrementing distance over X Y or Z so that they line up well. Nothing difficult in context, just duplicate a segment to make a wall of desired length. My issue is finding a solid method for finding what distance to increment over. I don't want to get too technical on say, finding the one vertex on the end of the model. I am using Maya 2008, and would it be safe for me to assume that one unit on the grid in Maya's 3D space (Or even any 3D modeler?) is equivalent to one unit in 3D space in DirectX? If it is, I think I don't need anything else except advice for how to better the method. If not... Then I guess I would like to know a good method to find the farthest point to one end of my mesh. If it comes to that, please lay it on me easy. Any math in relation to these topics are still weak fields for me.

##### Share on other sites
Quote:
 Original post by zyrolastingI don't want to get too technical on say, finding the one vertex on the end of the model. I am using Maya 2008, and would it be safe for me to assume that one unit on the grid in Maya's 3D space (Or even any 3D modeler?) is equivalent to one unit in 3D space in DirectX? If it is, I think I don't need anything else except advice for how to better the method.

One unit is one unit, yes.

Quote:
 If not... Then I guess I would like to know a good method to find the farthest point to one end of my mesh. If it comes to that, please lay it on me easy. Any math in relation to these topics are still weak fields for me.

It's rather simple math, really. What you're looking for here is the mesh' axis-aligned bounding box. Just loop through the x-coordinates and find the smallest and largest ones to get the left and right side of your box. Loop through the y-coordinates to find the front and back, loop through the z-coordinates to find the top and bottom (depending on how your axis are set up).

##### Share on other sites
Understood, except for where exactly the end on this bounding box is. Are they defined automatically? Is it (The beginning or end of any side of the box) stored in a data member when I load an .X file?

All my question is: When I run the for loop, just where do I get the end condition from? I've heard the term AABB before, but can you please clarify?

##### Share on other sites
A 3D axis-aligned box consists of 8 vertices, but you'll notice that they all have values in common: the 4 vertices on the left side all have the same value for their x-component, the 4 other vertices have another value for their x-component. The same goes for the y and z components.

By looping through your meshes vertices, you can find these values. With these values, you have all the info you need: you can construct the above 8 vertices from them, but you can also easily determine how wide, high and deep the box is: take the difference between the two x values and that's your meshes width.

Whether or not the .x file format stores a bounding box, I don't know, but with the above information, you can easily create the bounding box for yourself.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
627741
• Total Posts
2978887

• 10
• 10
• 21
• 14
• 14