• Advertisement

Archived

This topic is now archived and is closed to further replies.

Real-time CSG

This topic is 5147 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

Has anyone here attempted CSG in real-time? I saw a tech demo by Stan Melax of real-time CSG and was impressed by it''s speed, and am looking into doing it myself. I understand people always say use BSP trees for CSG, though I''m sure some sort of other tree would also give decent results if done properly. Has anyone got any tips or tricks for real-time CSG? Are there any common problems to be aware of?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
If you do not need the resulting mesh from a CSG operation but only want the visualization, it can be achieved using a multipass approach involving both depth and stencil buffer. If you google for realtime CSG I believe you can find an OpenGL implementation of the algorithm.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
i''ve been thinking about trying out real time CSG...

I found this but haven''t tested it out...

http://ciel.me.cmu.edu/soji/ysclass/ysclass.html

it''s a library and the blendshell seems like it would do the trick...


NAME:YsBlendShell
DEFINITION:
YSRESULT YsBlendShell
(YsShell &NEWSHELL,
const YsShell &SH0,
const YsShell &SH1,
YSBOOLEANOPERATION BOOL=YSBOOLBLEND);
RETURN:
YSOK Successfully blended
YSERR Failed
DESCRIPTION:
This function blends two shells, SH0 and SH1. Not only blending,
this function also can perform boolean operations, OR(UNION),
MINUS(DIFFERENCE) and AND(INTERSECTION).

You can specify the type of boolean operation by the parameter BOOL.
The value of BOOL can be chosen from:

YSBOOLBLEND
YSBOOLAND
YSBOOLOR
YSBOOLMINUS

YSBOOLBLEND just blends two shells. All intersecting polygons are
slashed along intersecting lines.

YSBOOLAND takes the intersecting part of two shells.

YSBOOLOR adds two shells into one shell. All unnecessary polygons
,those are inside the new shell, are eliminated.

YSBOOLMINUS will subtract SH1 from SH0.

All operations other than YSBOOLBLEND does not work if one or both
of two shells are not solid.

The result is set to NEWSHELL.




Share this post


Link to post
Share on other sites
Thanks for the replies. I need the resulting mesh not just the visualisation of it.

I''ll have to take a closer look at that YS class one, it certainly looks interesting.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Don''t know if you are still checking this...but I did get around to testing the YsClass...

Way too slow for real time...oh well, back to the drawing board...

Share this post


Link to post
Share on other sites
CSG sadly isn''t simply, but have you considered making the mesh changes with a thread in the background and faking the images via depth/stencil buffer while the mesh hasn''t been finalized yet.

I wrote functions for CSG once and that stuff definitely wasn''t real-time capable. As soon as CSG gets interesting - complex objects intersecting each other in non-trivial ways - you end up in a world of pain. Numerical inaccuracies, poly-counts beyond your worst fears.

As long as nobody puts a gun to my head and tells me "do it in CSG" I will try everything in my power to avoid it.

Share this post


Link to post
Share on other sites
Ideally the CSG operation would take place in 1 frame, but other less essential stuff could take place in the immediate frames after - such as detecting floating geometry or remaking the vertex and index arrays for rendering.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
http://john.slagel.com/Geomods.html

Share this post


Link to post
Share on other sites
I wonder if it could be sped up by somehow optimizing the process for pure CSG subtraction? It''s not often that we''re constructing things in our games

Share this post


Link to post
Share on other sites
Yeah, there are some simple but effective optimisations for pure subtraction, particularly the classification of the polygons during the splitting.

Technically, if you know the object being subtracted is made up of one connected mesh (floating geometry has been dealt with) then you can get rid of the ray classification part of things, since you know, that if a rocket hit an object, then it must have hit geometry, so if no intersections occur during the CSG, then you know the mesh is ''inside'' the explosion mesh, so completely delete the object.

Thats just one of a number of small things I''ve spotted.

Share this post


Link to post
Share on other sites
Yeah, but obviously with that it requires that you''ve split the world mesh up into non-exploded/exploded pieces beforehand (see your other thread ).

I''m just wondering if the format of the data, specifically, could be optimized for deletion.

Share this post


Link to post
Share on other sites
Yeah, my world is made up of two main types of objects - deformable and non-deformable. It isn''t made out of one large world mesh, but separate objects e.g. a house or pillar.

I know you mean optimise the data for CSG deletion, however, I believe that the data must have the same sort of flexibility and structure as any other CSG type - union etc. Because not only do you have to delete geometry, but you must also insert new geometry when splitting triangles - and this is the same in all CSG cases. It''s only the classification of triangles that determines what you keep and delete.

I haven''t found any really good data optimisations for deletion so far anyway

Share this post


Link to post
Share on other sites

  • Advertisement