Creating boolean objects

Started by
8 comments, last by pedery 15 years, 10 months ago
Hi! I'm quite new to DirectX, but an avid programmer. Thus this may be a simple question, but I've looked online and haven't found a decent answer. We're trying to build walls with windows programatically. Any wall can have zero or more windows. A window is simply a rectangular hole in the wall. The window cannot be built using alpha techniques since that will cause problems with lighting and shadows later. 1) Does DirectX have a simple way to create boolean object, i.e. removing a segment from a mesh? 2) Can the above be created in a simple way? 3) What if we decide to have i.e. round windows in a wall? 4) Is there a simple way to smooth geometry i.e. by subdivision? Any answer to any question is welcome. Thanks! - Peder -
Advertisement
Nope. Direct3D is a rendering API - you give it triangles, it renders them. If you want to do CSG or anything like that, you'll have to use another API (Or write your own), and then pass the resulting triangle soup to D3D.

EDIT: As for point 4, I believe there's support for NURBS or something, but I don't think they'r every well supported (And I've never used them). Alteratively, if you're using D3D10, you could do subdivision in a geometry shader.
Given a "wall" mesh, there aren't any built-in DirectX functions to "carve" a portion of the mesh boolean-like or with clipping planes as you might in a modeling program.

To build something like that programmatically, you would probably have to program the vertices (and normals and tex coords,etc.) for a section of solid wall, add a wall below the opening (of the right shape and size), add a wall above the opening, etc. For rectangular windows, it wouldn't be difficult. For non-rectangular windows, you would need a routine for each shape, or (since you're an avid programmer - does that include designing and implementing algorithms?) a routine that would take a function or curve for the shape of the window and construct the below and above portions of the wall.

I don't do much programmatic mesh construction but (I believe) a Patch Mesh can be tesselated (up to 32 new vertices between existing vertices). You'd probably have to "smooth" them yourself, if you're asking about normal-based curves, etc.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

I've done a fair amount of mesh construction. It will be easy for one window, but once you add more than one it will get harder. I've done this for polygon's, and doing it with windows would be an extension of that algorithm. On the plus side, it should work for any type of window.

So in conclusion I could show you how to do it. I wouldn't call it simple, and it's a pretty slow algorithm as well, especially when the vertex count goes up.
Thanks for all answers. Yes, if you had some sample code that would be excellent. At this point I've looked at how 3D modelling programs does it, and they seem to subdivide the areas close to the window edges so that all edges keep on being shared by two triangles. Performance is not really an issue. This is for creating one render of a 2D image and my guess is that lighting, shading and shadows will have far more impact on performance than to calculate a few extra triangles.
Bare in mind that you can make or break performance based on efficient streaming of vertex data. Take a look at my results here for some examples of identical geometry being rendered in different ways.

But, as you correctly state, the lighting and pixel operations are typically much more heavyweight.

Quote:EDIT: As for point 4, I believe there's support for NURBS or something, but I don't think they'r every well supported (And I've never used them). Alteratively, if you're using D3D10, you could do subdivision in a geometry shader.
Technically true, but don't bother [smile] The fixed-function HOS features were mostly killed off my Carmack's preaching of stencil shadows and the D3D10 GS isn't really suited to HOS in practice (on paper, maybe just, but the actual hardware doesn't seem up to it)...

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

My source code will only work for polygons, and it's combined into the code that defines the borders of my base. So I'm going to make a video on YouTube, I'll get it up sometime tomorrow probably.
As per usual it isn't going as well as expected. The audio record didn't work, so I'm trying to dub it, I think I can get it tomorrow though.

edit: Google video is busy "processing" it, I don't know how long that takes.

edit: Google video screwed it up, I'm going to have to split the video up and submit it to youtube :P.
Maybe it's still processing it, but it's been a couple days.
http://video.google.com/videoplay?docid=-2218211311813678991
Two seconds of nothing.

[Edited by - Treb on June 25, 2008 2:56:14 PM]
Here's the YouTube link, the first one links to the second one.

Thanks for the video! It was very useful. I can think of a possible way to adopt this to work with boolean objects. Appreciate that you took the time to do this.


- Peder -

This topic is closed to new replies.

Advertisement