|
Creating Valid Geometry
for Level exporting on trueSpace/gameSpace.
by Rodrigo Hernández (Kwizatz)
Introduction
Lots of people ask about why they can't just
export the game levels they have made on gameSpace or
trueSpace successfully, and many more have doubts about what
makes an object (called a brush on BSP terminology) legal or
illegal - this tutorial will try to explain those things, and
will show you some techniques to help you create valid
brushes. The tutorial is written from the point of view of
using the Aeon Games Mapper plug-in,
though some of the points about what makes geometry legal and
illegal will apply in general to level exporting with any
plug-in.
Why is the geometry illegal?
Well, it has to do with the BSP format
requirements and some other stuff, its true that not all
engines use BSP any more but some of it is still around, I
am really no expert on BSP, so if you want to learn a bit
more about it I recommend you read
BSP technical
details for dummies, it really helped me grasp some
concepts.
So, what makes a
brush illegal?
An object, block, or brush (I will refer to
these just as brushes from now on) is considered illegal if it
has more than 32 faces or more than 16 edges, if its concave
or if it has 2 or more coplanar faces, I will explain those
characteristics in detail.
No more than 32 faces?
A face, simply put is any of the flat surfaces
on a brush, for example in a cube each side of the cube would
be a face, a face can also be defined as any of the polygons
(a 2D shape) that form a polyhedron (a 3d shape), notice that
since the "smallest" polygon you can draw is a triangle, in
the cube example above you can have 2 faces (if you split each
square into 2 triangles) per side, but we will leave that for
later, for now just understand what a face is
.
You can see here the visible faces of a cube
marked with black lines:

By right clicking the Object Tool
in trueSpace/gameSpace you
will get the Object Info window, there you will be able to see
how many faces does your brush has:

Here you can see that the Cube has 6 faces,
and now that you know what a face is and how to find out how
many faces a brush has, all that you need to do is keep the
count under 32 for any given object.
No more than 16
edges?
Now that you know what a face is , it will be
easy for you to understand what an edge is, and edge, if you
have not figured it out already, is each one of the straight
lines that delimit the face, in our picture of the cube each
straight black line is an edge.

On this image I have highlighted each edge
with a different color, so its easy to spot them.
And now that you know what an edge is, you
know that you cant have more than 16 of them on each brush,
there is no easy way to know how many edges there are in a
brush in trueSpace/gameSpace, or at least not that I know off,
but the Mapper can easily spot if there are more than 16 edges
in an object and it will report it, so you can fix it.
Concave?
Brushes MUST be convex, a polygon is convex if
it doesn't have any dents, and its concave if it does have
dents, a classic example is Pac-Man, when the yellow dude
opens his mouth he is concave, when he closes it, he is
convex, here are some examples, excuse the bad drawing skills
:

Now, in 3D there is no concave or convex per
se, so the way to tell if a brush is convex or concave is to
check its faces, if all faces represent convex polygons, the
brush is said to be convex, if at least one face is concave,
the brush is said to be concave and hence, invalid. There is
no way to tell if a brush is concave in trueSpace/gameSpace
other than eyeballing it, but luckily again, the Mapper is
able to spot them and report the problems.
So, that's it, you just have to avoid concave
faces.
Coplanar faces?
Two faces are said to be coplanar if they
reside on the same imaginary plane, remember I said we would
leave the problem for having 2 faces per cube side?, well now
its the time.
When you triangulate a cube, you will get 2
triangles per side, each of those triangles is coplanar in
respect to the other, because they are in the same plane.

This cube if triangulated like that, will be
no good for exporting, the solution is to remove the edges
between the coplanar faces, you can do this manually or use
the "Remove Edges" tool found on the Mapper.
The way to find out if a face is coplanar to
another is to compare their normals, if two faces have the
same normal (or are between the acceptable range to consider
them the same), and they are adjacent to one another (they
share and edge), they are said to be coplanar.
Now that you know what a coplanar face is, you
can avoid them too .
Let's get to Work!
Now that you know what to avoid when modeling
a level in trueSpace or gameSpace, I am going to teach you
some techniques you can use to make your levels export at the
first try. Now, of course this is focused on exporting using
the Mapper, however the techniques should apply to pretty much
any other level exporter.
We will be building a door's frame or arc,
initially I was thinking about just a plain tube, but that was
too easy and boring, so I think this will be a lot more fun.
We won't get into texturing, because first, it would make the
tutorial way too long, and second, I will be explaining
texturing on a different tutorial, so we will pick up
texturing then. Finally, I will be adding a door to the frame,
but inside the game the door would not be functional unless
you set it as a door entity or somehow you program its
behavior on your own, if exported just as a brush (as we will
be doing here) the door will only work as decoration.
Enough babble, fire up your trueSpace or
gameSpace environment and proceed to Step 1:
Step 1:
Start by creating a simple cylinder with the cylinder
( ) tool:

Step 2:
Bring up the Object info window and set the
"Location" to 0,0,0 so the cylinder sits nicely right at the
center of the scene, leave the size on 2,2,2 meters, we will
be using meters because that's what I use, and most game
engines measure distances in meters, feel free to change to
whatever suits your preference, but keep in mind that this is
a door frame, keep it big enough to allow a person to pass
thru.

Step 3:
Create a new cylinder and set the location to 0,0,0
as well, but this time set the size to 1.5,1.5,3.0.

The 1.5 values represent the actual width of
the door, the 3 is just so the second cylinder extends quite a
bit over and under the first cylinder because we will be
applying a boolean on step 4.
Step 4:
Select the first cylinder and click the Boolean
subtract tool ( ), the
default parameters for the boolean are ok, but if you want to
change then right click the tool to do so, we will be changing
those later, for now leave them as they are.
Click the second cylinder, you will get the
following result:

if you get something different, perhaps you
forgot to select the first cylinder before
applying the boolean subtraction, hopefully, you should be
able to Undo and try again.
Step 5:
Having selected the resulting polyhedron, press the
triangulate tool ( ), switch
to the top view ( ) and zoom a
bit to you get a better picture of the donut
:

Step 6:
Go into point edit and using the Rectangle Selection
tool ( ) select half the tube
as shown below, make sure you have Backside checked on the
selection parameters, if you are not sure and you can't find
the window, just right click the Rectangle Selection tool
and the window will pop up.

Step 7:
Still in point edit mode, press the Separate selected
part of object tool ( ), this
will split the tube in two, press delete, we don't need the
lower half of the tube, you will end up with something like
this:

Step 8:
Change back to Perspective View ( ),
go into point edit mode and select the two faces generated by
the split, as you can see here:

Step 9:
Go back again to the Top View ( )
and press the Sweep tool ( ), our
frame starts to get some shape:

Step 10:
Still in point edit mode and having the 2 faces
selected, bring up the object info window, and click somewhere
in the window, anywhere, so the object info fills with the
data for the selected faces and not the whole object. Change
the Location Y value (which should be 0.500 if you have
faithfully followed my instructions) to say 2.000.

Note that you could had just used the bounding
box widget to drag the surfaces down, that's completely valid,
and if you prefer to do it that way its fine, however this way
we get tidy numbers instead of something like say 1.987,
notice how nicely the shape fits on the grid too .
Step 11:
Ok, the arch is done, but we now need to break the
geometry so it is completely valid, right now, this wont even
export, so start by hitting delete so the selection is
dropped, then using rectangular selection
(still inside point edit
mode), select one of the columns of our arch as follows:

And then just press the Separate selected part
of object tool ( ), that will
effectively break the geometry in 2 pieces, the column and the
rest of our arc, remember to have the backside check for the
selection tool, otherwise you would only select the face
facing you, and you won't get the desired results.
Step 12:
Now everything else left to do is pretty much repeat
the last step on all convex chunks you can find, try to split
the geometry always by the biggest convex piece there is, that
way you will end up with less brushes and the engine will have
an easier time doing its calculations, for example, we could
proceed to break each single triangle shaped block, but that
would give us twice the number of required blocks, so, instead
select each rhomboid shaped block as shown here:
And press the Separate selected part of object
tool .
Step 13:
Once you are done splitting the arch around, you
should end with the arch split like this:

I have given different colors to each block so
you can notice that they are now indeed different blocks,
there is still one problem to be solved before we can export
the arch, and that is, the coplanar faces on the rhomboid
brushes.
© 2003-2004 Rodrigo Hernández
All Rights Reserved
|