Tiling sides of 3D triangle

Started by
1 comment, last by mcguile25 18 years, 5 months ago
Howdy. I'm trying to create a 3D ramp mesh class (imagine a block of cheese cut in half like a 3D triangle) for my game, which will allow players to walk up it, obviously. I wanted to do it with custom vertices and not with a model from 3D studio or whatever. Anyway, here's my dilemma. I'm having trouble trying to create the vertices for the left and right sides of the ramp. The left and right sides are triangles, and they are the only non-rectangular pieces of the ramp (the ramp being rectangular as well as the back and bottom faces). Now let's say I want a ramp that's 3 quads high and 5 deep. We can disregard the width for the problem in question. How do you tile this? Tiling a rectangular grid like a wall or flat ground is easy. You simply do a double for loop over the width and depth (for the ground for example) and create 2 triangles for each quad. The number of triangles would be num quads across * num quads deep * 2. Ok that's easy enough. Now how do I go about trying to tile an arbitrary sized triangle and not a rectangle? I want my ramps to be any height and depth (to make them as steep as I want). Maybe I'm trying too hard or been working on this too long and hopefully there's an easy solution. Thanks for the help and it's greatly appreciated :)
Advertisement
If I understand you correctly you simply want to create a wedge with 6 vertices. When you say 3 quads high and 5 deep I'm a little unsure of what you want. If you always want it to be a simple ramp you'll only ever need 3 quads and 2 tris.

if you want to create a ramp thats 3 units high and 5 units deep i'd suggest beginning at the origin for simplicity. Create a vertex at the orign, create another 5 units along the x axis and another 5 units above that so you have 3 verts.

(0, 0, 0), (5, 0, 0), (5, 0, 3)

now offset these along the y axis by the width you want

(0, W, 0), (5, W, 0), (5, W, 3)

and create 2 tris using each of those set of points(sides) and the rest can be quads.
Sorry, let me rephrase. Say I want to make a ramp 3x3x3, that's 3 wide, high, and deep. However, what I am doing is I am _tiling_ each of the 5 faces of the wedge with textured quads (I don't want to stretch a texture across the whole width and height and depth of the ramp faces). So, for the left triangle, which is what face my question is about, I'd have to tile quads 3 deep and 3 high on that left face. So I'm basically tiling quads onto a triangle, in which I might end up with clipped quads anywhere at the hypotenuse of that triangle. Just wondering the best way to approach creating these vertices for arbitrary depth and height :)

This topic is closed to new replies.

Advertisement