Custom Geometry

Blitz3D Forums/Blitz3D Programming/Custom Geometry

Chroma(Posted 2006) [#1]
I've been slaving over how to allow the user to create unique rooms in my dungeon editor. At first it was just square rooms, and then I changed to creating pieces of room that were assembled like Legos. It finally hit me on the way to McDonalds (my boy is a Mario nut and had to have the new Mario toys...).

The goal is to allow custom room design where the floor is dragged out and then the walls are dragged up. I can do that now no problem with a simple square room. I also want the user to be able to create custom room shapes. So here's my idea.

A text file that contains XYZ vertice coordinates for the floor only, all plotted on a 10x10 grid where 0,0 is in the lower left hand corner. The person would define the vertice number ie "v1" followed by the XYZ coordinate. It might look like this:

v1:0,0,0
v2:0,0,10
v3:10,0,10
v4:10,0,0

Then they would follow it up with the actual way the floor looks by connecting the vertices.

connect:v1,v2,v3,v4

All the player is doing it creating a floorplan shape and then connecting the dots to give it the correct outline. Then that script is loaded in and the flat object is made and then walls raised up.

Keep in mind this method is mainly for people who want to create a custom room but have never or never will touch a 3d modeler.


jfk EO-11110(Posted 2006) [#2]
souns like sketchup. Here's another approach: assuming all the vertices of the floor are located somewhere on the outline of the floor (I think that's possible with every shape) then all you have to do is create a clone of every vertex, then translate it to the ceil, then add a triangle using this vertex, it's clone and one "clockwise neighbour" vertex.

Some suggestions:
It would also give you much more freedom if you allow the user to deform any vertex manually, with a truely intuitive and effective interface. Plus, a triangle division tool that will split any wanted triangle in 3 triangles. Plus an edge rotation tool.

Probably I'd concentrate on primitives rather than on CSG, because CSG tends to fragment things unneccessarily. Imagine a room with 4 cylindric columns, each with 12 facettes. With CSP boolean addition they will shatter the floor and ceil in a few hundred tris, where four simple (uncapped) cylinders in a cube would serve the same purpose and leave the floor/ceil at 4 Triangles only.


Chroma(Posted 2006) [#3]

Here's another approach:



That's exactly the approach I'm referring to. Let the user define the floor shape. Then make the walls by duplicating the vertices and letting the user set the wall height then connecting the floor and ceiling vertices.

The only bad aspect in that way is what if you wanna put a descending staircase in the middle of the floor or a pit trap.

So maybe some floor primitives that the user pieces together. That will allow for holes in the floor.

I'll post a pic to show ya what I mean.


Chroma(Posted 2006) [#4]
I could have it where the floor is always segmented in 10x10 so the user can add floor stuff later. Well I'm in no hurry so I'm hoping a sound method will pop up soon. I really would like to have user defined floor shapes but I'd have to do CSG-like stuff to get holes in the floor for stairs, traps etc (which I don't want to do).

One method would be a set of 2d floor primitives that snap together. Build the room floor shape then run it thru a function where it finds all vertices that lie on the edge and just build the walls up from there.

EDIT: well another idea just hit me. Have a bunch of preset rooms to choose from but also have it so you can create a custom room from the floor primitives.



And the basic floor primitives:



John Blackledge(Posted 2006) [#5]
I've seen the results of editors that - as you say - split the floor into a thousand pieces, and it's laughable. Chroma, try to avoid this, I personally don't mind columns etc that sit on or pass thru the floor.


IPete2(Posted 2006) [#6]
Chroma,

Although people may never have to touch a modeller you aren't going to expect people to write this floorplan textfile out by hand are you?

It wouldn't be too difficult to create a small prog with an interface to do that job. I certainly woudn't want to make the textfile manually.

Just a thought as it was not clear in the above, just how you were going to allow users to achieve this.

IPete2.


Chroma(Posted 2006) [#7]
Well, not anymore I guess now that you put it that way haha.

I'm still deciding on how to do this. I think what may be easiest is to put in fake, "plane only" CSG. Where you can comebine rooms simply by dragging them over each other. Columns wouldn't be including so the only fragmenting would be in quads.

Basically the user will select the corner shape (square, angled, or round). Then drag out a part of the room. Then if they want an L-shape you would drag the other leg of the room making sure it intersects where you want them to be joined. Then run any surfaces that intersect through a function to copy the surface info, destroy them, then recreate the surfaces with the new info but keeping both rooms as separate surfaces.