I want to ask is it possible to make the overlapped part to be transparent in Graphics3D.
Graphics3D[{Brown, {Cuboid[{0, 0, 0}, {0.8, 0.1, 2}], Opacity[0],
White, Cuboid[{0.1, -0.001, 1.35}, {0.7, 0.101, 1.85}]}}]
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityI want to ask is it possible to make the overlapped part to be transparent in Graphics3D.
Graphics3D[{Brown, {Cuboid[{0, 0, 0}, {0.8, 0.1, 2}], Opacity[0],
White, Cuboid[{0.1, -0.001, 1.35}, {0.7, 0.101, 1.85}]}}]
You can also use RegionPlot3D
:
cuboid1 = {{0, 0, 0}, {0.8, 0.1, 2}};
cuboid2 = {{0.1`, -0.001`, 1.35`}, {0.7`, 0.101`, 1.85`}};
{cuboid1b, cuboid2b} = Insert[#, {x, y, z}, 2] & /@ {cuboid1, cuboid2};
{region, hole} = (And @@ Less @@@ Transpose@#) & /@ {cuboid1b, cuboid2b};
RegionPlot3D[region && Not[hole],{x, 0, 2}, {y, 0, 2}, {z, 0, 2},
PlotPoints -> 200, MaxRecursion -> 6, PlotStyle -> Brown, Mesh -> None,
Lighting -> "Neutral", Boxed -> False, Axes -> False]
One way to make transparent regions is to use RegionFunctions. For example, here are your two cubes and then the "symmetric difference" between them. This essentially removes the smaller one from the larger, and leaves a transparent window.
r1 = Cuboid[{0, 0, 0}, {0.8, 0.1, 2}];
r2 = Cuboid[{0.1, -0.001, 1.35}, {0.7, 0.101, 1.85}];
d = RegionSymmetricDifference[r1, r2]
Show[BoundaryDiscretizeRegion[d]]
Graphics3D[{Brown, {Cuboid[{0, 0, 0}, {0.8, 0.1, 2}], White, {Cuboid[{0.1, -0.001, 1.35}, {0.7, 0.101, 1.85}], Opacity[0]}}}, Lighting -> {{"Ambient", White}}]
$\endgroup$