POV-Ray : Newsgroups : povray.newusers : Simple CSG Question : Simple CSG Question Server Time
7 Jul 2024 08:36:42 EDT (-0400)
  Simple CSG Question  
From: Alan1961
Date: 8 Jan 2010 19:45:00
Message: <web.4b47d08648bffdc46fd8c88d0@news.povray.org>
I apologise if this has been covered many times before.

Is it possible to declare an object in such a way that when it is unioned with
another object(s) it carries a "hole" with it?   There may be a clever way of
doing this that I have missed, it must be a common enough situation for objects
intended for reuse... Doors, Windows etc .

For example declaring an object comprising of  a door Frame and a door slightly
ajar which when unioned with  a wall it also punches a hole in the wall.    I
appreciate I can do something like ...

union
{
        #declare Wall = box { <-3*m, 0*m, -5*cm>  < 1*m,  3*m,  5*cm>   pigment
{brick Grey, Orange scale 2}}
        #declare door1 = object{SingleDoor translate -0.5*m*x}
        object{door1}
        #declare door2 = object{SingleDoor translate -1.5*m*x}
        object{door2}
        difference
        {
                object{Wall}
                box{ min_extent(door1), max_extent(door1) }  //punch a hole!
                box{ min_extent(door2), max_extent(door2) }  //punch a hole!
        }
}
but this feels long winded to me, and I just want to make sure it is the best
approach that everyone uses for this situation.

Ideally I would like to be able to declare SingleDoor such that it also defines
the hole to be punched in the wall allowing the above to be replaced with
something like ...

union
{
        box { <-3*m, 0*m, -5*cm>  < 1*m,  3*m,  5*cm>   pigment {brick Grey,
Orange scale 2}}
        object{SingleDoorWithHole translate -0.5*m*x}
        object{SingleDoorWithHole translate -1.5*m*x}
}

I appreciate the semantics of my above idealised example could be/is confusing
and ambiguous with other objects in the union and is therefore probably not
possible or implemented, but again I just want to make sure I'm adopting the
best approach and that I've not missed any aspect of POV CSG type functionality
which makes this task easier, clearer or more concise.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.