0 registered members (),
1,459
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
real-time constructive solid geometry
#304551
01/08/10 19:04
01/08/10 19:04
|
Joined: Jan 2010
Posts: 44 Galati, Romania
CItrok
OP
Newbie
|
OP
Newbie
Joined: Jan 2010
Posts: 44
Galati, Romania
|
I am newbie. I need to build a small application to demonstrate real-time constructive solid geometry between two models. So, I want to subtract one basic model from another (boolean difference). Let's say I want to subtract a cylinder from a box to create a box with a cylindrical hole in it. The cylinder is moved by me in the game. IS this possible in lite-C enviroment? In order to be more explicit concerning boolean subtraction see http://en.wikipedia.org/wiki/Constructive_solid_geometryThank you guys.
|
|
|
Re: real-time constructive solid geometry
[Re: CItrok]
#304552
01/08/10 19:17
01/08/10 19:17
|
Joined: Mar 2009
Posts: 40
DR_Black
Newbie
|
Newbie
Joined: Mar 2009
Posts: 40
|
Another similar question asked in other thread and people argue around.
I think it is possible via shaders. I meat you can fake it using shaders .So instead of building real boolean difference you can use a shader to fake it.
I am not a shader expert so i cant go further.
every body got some dues in life to pay
|
|
|
Re: real-time constructive solid geometry
[Re: DR_Black]
#304556
01/08/10 19:44
01/08/10 19:44
|
Joined: Apr 2008
Posts: 235 TEXCOORD3
Foxfire
Member
|
Member
Joined: Apr 2008
Posts: 235
TEXCOORD3
|
this can be done but is relatively complicated.
Also, doing this with primitives is different from models - heres how to do it with primitives, including rendering in GS:
first, you need a sort class to store data: as you read on wikepedia, CSG can be represented by various primitives connected to each other via boolean arithmetic (+ or -).
so, in lite-c we don't have classes, but we can use variables instead. so, for your example, we would store data for a cube and a cylinder and "link" them together (in C++ you could just make a shape class that has another Shape variable inside), lite-c you'll have to play around :\
when rendering, you have 2 choices - represent your geometry as polygons via dynamically created data, or render s-curves or dots/lines with d3d_draw.
for the first, we can use a recursive subdivision routine that will base its starting values on the intersection points between the two shapes. Check our ray-line intersection equations for this. So, you will create a list of vertices by analyzing each point on the parent shape. if the said point is intersecting with the child shape, you replace the intersection volume location with the equation for the child shape and continue. The result will be a highly tesselated model that will render via draw_begin and sending the vertices as a vertex buffer to d3d. you could also render each vertex as a point for an easier way of showing the mesh without too much directX knowledge.
if you need more specifics, contact me - I know my explanation is a bit confusing - I don't have enough room or time right now to explain in even more detail.
ps, intersecting 2 models can be done in the same way but using ray-polygon intersection and testing every polygon against the sample point (its slow but this is the easiest way to implement).
-Mike-
http://www.groundtacticsgame.com/Alienware m17x R Custom laptop specs: Intel Core 2 Extreme Quad CPU Q9300 2x Nvidia 280GTX 2GB vram 6GB ddr3 memory@ 1333Mhz 512GB SSD 1200p 17' screen runs Crysis Warhead on max settings at 1200p at 90 fps
|
|
|
Re: real-time constructive solid geometry
[Re: Foxfire]
#304561
01/08/10 20:28
01/08/10 20:28
|
Joined: Mar 2009
Posts: 40
DR_Black
Newbie
|
Newbie
Joined: Mar 2009
Posts: 40
|
I am so confused foxfire. I didt mean geometry modification via complex vertex shaders. I mean if there is way not to really do it but make it appear like that using a view-dependent method. i have no exact idea how should it be. but i think its possible. let me give you a deeper plan: we have two objects (models) one to be subtracted(B) and one as knife(B) firs we render (A) to stencil buffer then using stencil buffer we render (B) on screen with flip normals, so til now we have rendered B with fliped normals only on pixels were A and B are overlaping (interrelate). Then we render Last B once again using stencil buffer but instead of screen we use stencil buffer as render target. finally we render A using stencil buffer on screen. after all we have a rendered total screen. A and B are: 1-B is not rendered but in interrelate areas it is rendered whit fliped normals 2-A is rendered but in interrelate areas it is not rendered
it may have some problems specially with texture and UVs. I think it may work but i dont know how to implement it. i hope you understand my approach.
every body got some dues in life to pay
|
|
|
Re: real-time constructive solid geometry
[Re: CItrok]
#304580
01/08/10 22:39
01/08/10 22:39
|
Joined: Apr 2008
Posts: 235 TEXCOORD3
Foxfire
Member
|
Member
Joined: Apr 2008
Posts: 235
TEXCOORD3
|
yeah, I'm talking about just CSG as an algorithm and how to basically build a procedural model to render - it doesn't need any shaders or anything - this is done on the CPU. You can render it by just making a vertex buffer based on the 3d points and their neighbors.
anyway - I can help you in person, just add me on msn =]
-Mike-
http://www.groundtacticsgame.com/Alienware m17x R Custom laptop specs: Intel Core 2 Extreme Quad CPU Q9300 2x Nvidia 280GTX 2GB vram 6GB ddr3 memory@ 1333Mhz 512GB SSD 1200p 17' screen runs Crysis Warhead on max settings at 1200p at 90 fps
|
|
|
Re: real-time constructive solid geometry
[Re: Foxfire]
#304581
01/08/10 22:41
01/08/10 22:41
|
Joined: Apr 2008
Posts: 235 TEXCOORD3
Foxfire
Member
|
Member
Joined: Apr 2008
Posts: 235
TEXCOORD3
|
oh, and DR-Black, that is a clever idea for real-time CSG. but i think he wants to actually do single calculations and store the result. Either way I know how to do it. Dr-Black, feel free to add me on msn too - we can colaborate (the 3 of us) to figure out a working implementation in GS. -Mike-
http://www.groundtacticsgame.com/Alienware m17x R Custom laptop specs: Intel Core 2 Extreme Quad CPU Q9300 2x Nvidia 280GTX 2GB vram 6GB ddr3 memory@ 1333Mhz 512GB SSD 1200p 17' screen runs Crysis Warhead on max settings at 1200p at 90 fps
|
|
|
|