Jump to content
  • Advertisement
Sign in to follow this  
pedery

Creating boolean objects

This topic is 3822 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 -

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites
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]

Share this post


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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!