Fill with color intersection between two solid objects

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Fill with color intersection between two solid objects

Aleandro
Dear all,
Is is possible to fill with a given color the volume given by the
intersection between two solid 3D objects in OpenSCAD? For example, I would
like the intersection between the two spheres in the example to be in blue.

color([1,0,0,0.5]) translate([0.5,0,0]) sphere(1,$fn=100);
color([1,0,0,0.5]) translate([2,0,0]) sphere(1,$fn=100);


Tank you for your help.



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Fill with color intersection between two solid objects

nophead
Yes, sort of.

color("blue") intersection() {
    translate([0.5,0,0]) sphere(1,$fn=100);
    translate([2,0,0]) sphere(1,$fn=100);
}

color([1,0,0,0.5]) translate([0.5,0,0]) sphere(1,$fn=100);
color([1,0,0,0.5]) translate([2,0,0]) sphere(1,$fn=100);


On 2 May 2018 at 13:26, Aleandro <[hidden email]> wrote:
Dear all,
Is is possible to fill with a given color the volume given by the
intersection between two solid 3D objects in OpenSCAD? For example, I would
like the intersection between the two spheres in the example to be in blue.

color([1,0,0,0.5]) translate([0.5,0,0]) sphere(1,$fn=100);
color([1,0,0,0.5]) translate([2,0,0]) sphere(1,$fn=100);


Tank you for your help.



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Fill with color intersection between two solid objects

Aleandro
Thank you. This colors in blue only one of the two 'lenses' that form the
surface of the intersection. Is there a way to color the entire surface?

best,



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Fill with color intersection between two solid objects

nophead
The entire intersection is blue when viewed on its own. It shows up blue if you make the spheres more transparent.

The reason it looks different when viewed through one sphere compared to the other is the due to the lighting. When viewed from the side away from the light the blue is darker and doesn't show as well through the red.

Also you can only see one sphere through the other due to the order they are drawn.

On 2 May 2018 at 16:24, Aleandro <[hidden email]> wrote:
Thank you. This colors in blue only one of the two 'lenses' that form the
surface of the intersection. Is there a way to color the entire surface?

best,



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Fill with color intersection between two solid objects

runsun
In reply to this post by Aleandro
This might give you some visual idea:

module obj1() sphere(1,$fn=100);
module obj2() translate([1.5,0,0]) obj1();
module inter() intersection() {obj1();obj2(2);}

color("gold")
{
translate( [-0.3,0,0] )
     difference() {obj1();inter();}
translate( [0.3,0,0] )
     difference() {obj2();inter();}
 }
color("blue")inter();



-----

$  Runsun Pan, PhD $ libs: scadx , doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), editor of choice: CudaText  ( OpenSCAD lexer );&nbsp;$ Tips ;&nbsp;$ Snippets

--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
$ Runsun Pan, PhD
$ libs: scadx, doctest, faces(git), offline doc(git), runscad.py(2,git), editor of choice: CudaText ( OpenSCAD lexer); $ Tips; $ Snippets