Sign in to follow this  
zyrolasting

Building walls in segments over an increment

Recommended Posts

zyrolasting    280
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 this post


Link to post
Share on other sites
Captain P    1092
Quote:
Original post by zyrolasting
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.

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 this post


Link to post
Share on other sites
zyrolasting    280
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 this post


Link to post
Share on other sites
Captain P    1092
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this