|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Dear all,
I would like to generate images like the ones in the right column at this link
http://www.micthemodel.org/pages/examples.html (Sorry but I can not post
attachment).
These images are in fact 2D slices of a 3D image that is a cube containing a set
of layered spheres. A layered sphere is a set of concentric spheres of different
colors. In my program (in fact, this is the visualisation of cement hydration
simulation), I have the coordinate and radius of the spheres and the color as
well.
My Povray file is (it gave bad images): #include and camera ... are excluded for
sake of simplicity:
For one three-layer sphere:
union{
sphere{
<71.1894,91.2060,31.1711>, 27.8285
texture{
pigment { color Red}
}
}
sphere{
<71.1894,91.2060,31.1711>, 30.0000
texture{
pigment { color Blue}
}
}
sphere{
<71.1894,91.2060,31.1711>, 31.1088
texture{
pigment { color Cyan}
}
}
}
Now, for the whole set of layered spheres, I did
union{
// the description for every spheres
}
------------------------------------------
With this one, I did see the spheres but just one color CYAN.
Could you please help me how to build a good image that shows different colors
for each layers.
To get 2D slice from the above, I make an intersection of the above with a
plane, but still got bad images.
I am looking forward to hearing your help.
Many thanks in advance.
Vinh Phu Nguyen
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"vinhphunguyen" <nvi### [at] gmailcom> wrote in message
news:web.48513efe78241c82b979a58c0@news.povray.org...
> Dear all,
>
> I would like to generate images like the ones in the right column at this
> link
> http://www.micthemodel.org/pages/examples.html (Sorry but I can not post
> attachment).
>
> These images are in fact 2D slices of a 3D image that is a cube containing
> a set
> of layered spheres. A layered sphere is a set of concentric spheres of
> different
> colors. In my program (in fact, this is the visualisation of cement
> hydration
> simulation), I have the coordinate and radius of the spheres and the color
> as
> well.
>
> ...
>
> With this one, I did see the spheres but just one color CYAN.
>
I think you need to do a couple of things.
Firstly, when you slice through, use the 'difference' CSG operation with the
'cutaway_textures' keyword, so that the slices through the objects retain
their original textures.
Secondly you need to difference the second largest sphere from the largest,
the 3rd largest from the second largest etc. Otherwise, when you slice
through the union of concentric spheres the section through the smaller
spheres produce concurrent surfaces with the larger spheres and most of the
surfaces won't display the colour you want. In fact you'll only get the
colour you want displaying properly for the outermost object.
Here's a simplified example:
camera {location <0,0,-1> look_at 0}
light_source { <0,0 ,-100>, rgb 1}
#declare MySpheres = union{
difference {
sphere{<0,0,0>, 0.3 pigment {color rgb <1,0,0>}}
sphere{<0,0,0>, 0.2 pigment {color rgb <0,1,0>}}
}
difference {
sphere{<0,0,0>, 0.2 pigment {color rgb <0,1,0>}}
sphere{<0,0,0>, 0.1 pigment {color rgb <0,0,1>}}
}
sphere{<0,0,0>, 0.1 pigment {color rgb <0,0,1>}}
}
difference {
object {MySpheres}
plane {z,0}
cutaway_textures
}
Regards,
Chris B.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Dear Chris,
Thank you very much for your help. It works well :-)
Best regards,
Vinh Phu
"Chris B" <nom### [at] nomailcom> wrote:
> "vinhphunguyen" <nvi### [at] gmailcom> wrote in message
> news:web.48513efe78241c82b979a58c0@news.povray.org...
> > Dear all,
> >
> > I would like to generate images like the ones in the right column at this
> > link
> > http://www.micthemodel.org/pages/examples.html (Sorry but I can not post
> > attachment).
> >
> > These images are in fact 2D slices of a 3D image that is a cube containing
> > a set
> > of layered spheres. A layered sphere is a set of concentric spheres of
> > different
> > colors. In my program (in fact, this is the visualisation of cement
> > hydration
> > simulation), I have the coordinate and radius of the spheres and the color
> > as
> > well.
> >
> > ...
> >
> > With this one, I did see the spheres but just one color CYAN.
> >
>
> I think you need to do a couple of things.
>
> Firstly, when you slice through, use the 'difference' CSG operation with the
> 'cutaway_textures' keyword, so that the slices through the objects retain
> their original textures.
>
> Secondly you need to difference the second largest sphere from the largest,
> the 3rd largest from the second largest etc. Otherwise, when you slice
> through the union of concentric spheres the section through the smaller
> spheres produce concurrent surfaces with the larger spheres and most of the
> surfaces won't display the colour you want. In fact you'll only get the
> colour you want displaying properly for the outermost object.
>
> Here's a simplified example:
>
> camera {location <0,0,-1> look_at 0}
> light_source { <0,0 ,-100>, rgb 1}
>
> #declare MySpheres = union{
> difference {
> sphere{<0,0,0>, 0.3 pigment {color rgb <1,0,0>}}
> sphere{<0,0,0>, 0.2 pigment {color rgb <0,1,0>}}
> }
> difference {
> sphere{<0,0,0>, 0.2 pigment {color rgb <0,1,0>}}
> sphere{<0,0,0>, 0.1 pigment {color rgb <0,0,1>}}
> }
> sphere{<0,0,0>, 0.1 pigment {color rgb <0,0,1>}}
> }
>
> difference {
> object {MySpheres}
> plane {z,0}
> cutaway_textures
> }
>
> Regards,
> Chris B.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Dear Chris,
I just found one case the code does not work well. Imagine that, taking your
simplified example, there is another layered sphere behind this one along z
axis (so that the plane z = 0 does not cut it) and shifted some units along x
axis. In this case, the slice image should not contain the second sphere.
Here is the code
camera {location <0,0,-3.5> look_at 0}
light_source { <0,0 ,-100>, rgb 1}
#declare grain1 = union{
difference {
sphere{<0,0,0>, 0.3 pigment {color rgb <1,0,0>}}
sphere{<0,0,0>, 0.2 pigment {color rgb <0,1,0>}}
}
difference {
sphere{<0,0,0>, 0.2 pigment {color rgb <0,1,0>}}
sphere{<0,0,0>, 0.1 pigment {color rgb <0,0,1>}}
}
sphere{<0,0,0>, 0.1 pigment {color rgb <0,0,1>}}
}
#declare grain2 = union{
difference {
sphere{<2,0,1>, 0.3 pigment {color rgb <1,0,0>}}
sphere{<2,0,1>, 0.2 pigment {color rgb <0,1,0>}}
}
difference {
sphere{<2,0,1>, 0.2 pigment {color rgb <0,1,0>}}
sphere{<2,0,1>, 0.1 pigment {color rgb <0,0,1>}}
}
sphere{<2,0,1>, 0.1 pigment {color rgb <0,0,1>}}
}
#declare grains = union{
object{grain1}
object{grain2}
}
difference {
object {grains}
plane {z,0}
cutaway_textures
}
------------------
I switched from difference operation to intersection, then the second sphere
disappeared but the first sphere showed only the outermost layer.
Could you help me to figure out this problem please?
Thanks a lot for your help.
Vinh Phu
"Chris B" <nom### [at] nomailcom> wrote:
> "vinhphunguyen" <nvi### [at] gmailcom> wrote in message
> news:web.48513efe78241c82b979a58c0@news.povray.org...
> > Dear all,
> >
> > I would like to generate images like the ones in the right column at this
> > link
> > http://www.micthemodel.org/pages/examples.html (Sorry but I can not post
> > attachment).
> >
> > These images are in fact 2D slices of a 3D image that is a cube containing
> > a set
> > of layered spheres. A layered sphere is a set of concentric spheres of
> > different
> > colors. In my program (in fact, this is the visualisation of cement
> > hydration
> > simulation), I have the coordinate and radius of the spheres and the color
> > as
> > well.
> >
> > ...
> >
> > With this one, I did see the spheres but just one color CYAN.
> >
>
> I think you need to do a couple of things.
>
> Firstly, when you slice through, use the 'difference' CSG operation with the
> 'cutaway_textures' keyword, so that the slices through the objects retain
> their original textures.
>
> Secondly you need to difference the second largest sphere from the largest,
> the 3rd largest from the second largest etc. Otherwise, when you slice
> through the union of concentric spheres the section through the smaller
> spheres produce concurrent surfaces with the larger spheres and most of the
> surfaces won't display the colour you want. In fact you'll only get the
> colour you want displaying properly for the outermost object.
>
> Here's a simplified example:
>
> camera {location <0,0,-1> look_at 0}
> light_source { <0,0 ,-100>, rgb 1}
>
> #declare MySpheres = union{
> difference {
> sphere{<0,0,0>, 0.3 pigment {color rgb <1,0,0>}}
> sphere{<0,0,0>, 0.2 pigment {color rgb <0,1,0>}}
> }
> difference {
> sphere{<0,0,0>, 0.2 pigment {color rgb <0,1,0>}}
> sphere{<0,0,0>, 0.1 pigment {color rgb <0,0,1>}}
> }
> sphere{<0,0,0>, 0.1 pigment {color rgb <0,0,1>}}
> }
>
> difference {
> object {MySpheres}
> plane {z,0}
> cutaway_textures
> }
>
> Regards,
> Chris B.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"vinhphunguyen" <nvi### [at] gmailcom> wrote in message
news:web.4852425d5fabdd0ab979a58c0@news.povray.org...
> I just found one case the code does not work well. Imagine that, taking
> your
> simplified example, there is another layered sphere behind this one along
> z
> axis (so that the plane z = 0 does not cut it) and shifted some units
> along x
> axis. In this case, the slice image should not contain the second sphere.
>
> ... snip ...
> #declare grain1 = union{
> difference {
> sphere{<0,0,0>, 0.3 pigment {color rgb <1,0,0>}}
> sphere{<0,0,0>, 0.2 pigment {color rgb <0,1,0>}}
> }
> ... snip ...
> #declare grain2 = union{
> difference {
> sphere{<2,0,1>, 0.3 pigment {color rgb <1,0,0>}}
> sphere{<2,0,1>, 0.2 pigment {color rgb <0,1,0>}}
> }
> ... snip ...
This is because you didn't incorporate the cube you mentioned in your first
posting, but you can do this as follows:
#declare grains = union{
object{grain1}
object{grain2}
}
// Add a concrete block around the grains,
// cutting holes where the grains occur.
#declare concreteblock = union{
difference {
box {-2,2 pigment {rgb 1}}
object{grains}
}
object{grains}
}
// Then cut away to expose the inside of the block
difference {
object {concreteblock}
plane {z,0}
cutaway_textures
}
>
> I switched from difference operation to intersection, then the second
> sphere
> disappeared but the first sphere showed only the outermost layer.
>
That sounds about right. Using 'intersection' in place of difference will
just give you the other half of whatever you do the difference/intersection
with. With the camera where it is, this would have given you the outside of
the first sphere and nothing of the second. With the changes above, an
intersection will give you the outside of the white box, unless you move the
camera to <0,0,3.5>, in which case you'll again see the cut surface, but
this time from the opposite side (so the other way round).
Another technique that may simplify this is to use an onion pattern with a
colour map to define each grain rather than actual concentric spheres. This
also enables you to do gradual colour transitions if you wish to.
#declare grain1 = sphere{<0,0,0>, 0.3
pigment {onion
color_map {
[0.0 color <0,0,1>]
[0.1 color <0,0,1>]
[0.1 color <0,1,0>]
[0.2 color <0,1,0>]
[0.2 color <1,0,0>]
[1.0 color <1,0,0>]
}
}
}
If you ever want two grains with the same colour pattern you can scale and
translate one you've already defined. For example:
#declare grain3 = object {grain1 scale 0.6 translate x}
Regards,
Chris B.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Hi Chris,
With your help, I obtained images that I am expecting.
Thanks a lot.
Regards,
Phu
"Chris B" <nom### [at] nomailcom> wrote:
> "vinhphunguyen" <nvi### [at] gmailcom> wrote in message
> news:web.4852425d5fabdd0ab979a58c0@news.povray.org...
> > I just found one case the code does not work well. Imagine that, taking
> > your
> > simplified example, there is another layered sphere behind this one along
> > z
> > axis (so that the plane z = 0 does not cut it) and shifted some units
> > along x
> > axis. In this case, the slice image should not contain the second sphere.
> >
> > ... snip ...
> > #declare grain1 = union{
> > difference {
> > sphere{<0,0,0>, 0.3 pigment {color rgb <1,0,0>}}
> > sphere{<0,0,0>, 0.2 pigment {color rgb <0,1,0>}}
> > }
> > ... snip ...
> > #declare grain2 = union{
> > difference {
> > sphere{<2,0,1>, 0.3 pigment {color rgb <1,0,0>}}
> > sphere{<2,0,1>, 0.2 pigment {color rgb <0,1,0>}}
> > }
> > ... snip ...
>
> This is because you didn't incorporate the cube you mentioned in your first
> posting, but you can do this as follows:
>
> #declare grains = union{
> object{grain1}
> object{grain2}
> }
>
> // Add a concrete block around the grains,
> // cutting holes where the grains occur.
> #declare concreteblock = union{
> difference {
> box {-2,2 pigment {rgb 1}}
> object{grains}
> }
> object{grains}
> }
>
> // Then cut away to expose the inside of the block
> difference {
> object {concreteblock}
> plane {z,0}
> cutaway_textures
> }
>
> >
> > I switched from difference operation to intersection, then the second
> > sphere
> > disappeared but the first sphere showed only the outermost layer.
> >
>
> That sounds about right. Using 'intersection' in place of difference will
> just give you the other half of whatever you do the difference/intersection
> with. With the camera where it is, this would have given you the outside of
> the first sphere and nothing of the second. With the changes above, an
> intersection will give you the outside of the white box, unless you move the
> camera to <0,0,3.5>, in which case you'll again see the cut surface, but
> this time from the opposite side (so the other way round).
>
> Another technique that may simplify this is to use an onion pattern with a
> colour map to define each grain rather than actual concentric spheres. This
> also enables you to do gradual colour transitions if you wish to.
>
> #declare grain1 = sphere{<0,0,0>, 0.3
> pigment {onion
> color_map {
> [0.0 color <0,0,1>]
> [0.1 color <0,0,1>]
> [0.1 color <0,1,0>]
> [0.2 color <0,1,0>]
> [0.2 color <1,0,0>]
> [1.0 color <1,0,0>]
> }
> }
> }
>
> If you ever want two grains with the same colour pattern you can scale and
> translate one you've already defined. For example:
>
> #declare grain3 = object {grain1 scale 0.6 translate x}
>
>
> Regards,
> Chris B.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Hi Chris,
I have two intersecting spheres as follows:
#declare sphere1=
sphere{ <0,0,0>, 5.0 pigment { color Red}}
#declare sphere2=
sphere{ <7,0,0>, 5.0 pigment { color Green}}
#declare grains=merge{
object{sphere1}
object{sphere2}
}
Therefore, the common region of these two spheres has mixed color (Red and
Green). However, I would like to have this intersection region Red colored,
instead. I have found a way to do this: using more CSG operations
#declare grains=union{
object{sphere1}
difference{
object{sphere2}
object{sphere1}
}
}
But I think that this way is time-consuming in case that I have thousand spheres
or even more. There exists another better way for this? If so, please show me
the way to go.
Thank you very much.
Vinh Phu
"vinhphunguyen" <nvi### [at] gmailcom> wrote:
> Hi Chris,
>
> With your help, I obtained images that I am expecting.
> Thanks a lot.
>
> Regards,
>
> Phu
>
> "Chris B" <nom### [at] nomailcom> wrote:
> > "vinhphunguyen" <nvi### [at] gmailcom> wrote in message
> > news:web.4852425d5fabdd0ab979a58c0@news.povray.org...
> > > I just found one case the code does not work well. Imagine that, taking
> > > your
> > > simplified example, there is another layered sphere behind this one along
> > > z
> > > axis (so that the plane z = 0 does not cut it) and shifted some units
> > > along x
> > > axis. In this case, the slice image should not contain the second sphere.
> > >
> > > ... snip ...
> > > #declare grain1 = union{
> > > difference {
> > > sphere{<0,0,0>, 0.3 pigment {color rgb <1,0,0>}}
> > > sphere{<0,0,0>, 0.2 pigment {color rgb <0,1,0>}}
> > > }
> > > ... snip ...
> > > #declare grain2 = union{
> > > difference {
> > > sphere{<2,0,1>, 0.3 pigment {color rgb <1,0,0>}}
> > > sphere{<2,0,1>, 0.2 pigment {color rgb <0,1,0>}}
> > > }
> > > ... snip ...
> >
> > This is because you didn't incorporate the cube you mentioned in your first
> > posting, but you can do this as follows:
> >
> > #declare grains = union{
> > object{grain1}
> > object{grain2}
> > }
> >
> > // Add a concrete block around the grains,
> > // cutting holes where the grains occur.
> > #declare concreteblock = union{
> > difference {
> > box {-2,2 pigment {rgb 1}}
> > object{grains}
> > }
> > object{grains}
> > }
> >
> > // Then cut away to expose the inside of the block
> > difference {
> > object {concreteblock}
> > plane {z,0}
> > cutaway_textures
> > }
> >
> > >
> > > I switched from difference operation to intersection, then the second
> > > sphere
> > > disappeared but the first sphere showed only the outermost layer.
> > >
> >
> > That sounds about right. Using 'intersection' in place of difference will
> > just give you the other half of whatever you do the difference/intersection
> > with. With the camera where it is, this would have given you the outside of
> > the first sphere and nothing of the second. With the changes above, an
> > intersection will give you the outside of the white box, unless you move the
> > camera to <0,0,3.5>, in which case you'll again see the cut surface, but
> > this time from the opposite side (so the other way round).
> >
> > Another technique that may simplify this is to use an onion pattern with a
> > colour map to define each grain rather than actual concentric spheres. This
> > also enables you to do gradual colour transitions if you wish to.
> >
> > #declare grain1 = sphere{<0,0,0>, 0.3
> > pigment {onion
> > color_map {
> > [0.0 color <0,0,1>]
> > [0.1 color <0,0,1>]
> > [0.1 color <0,1,0>]
> > [0.2 color <0,1,0>]
> > [0.2 color <1,0,0>]
> > [1.0 color <1,0,0>]
> > }
> > }
> > }
> >
> > If you ever want two grains with the same colour pattern you can scale and
> > translate one you've already defined. For example:
> >
> > #declare grain3 = object {grain1 scale 0.6 translate x}
> >
> >
> > Regards,
> > Chris B.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"vinhphunguyen" <nvi### [at] gmailcom> wrote in message
news:web.485a0fbd5fabdd0ab979a58c0@news.povray.org...
> Hi Chris,
>
> I have two intersecting spheres as follows:
>
> #declare sphere1=
> sphere{ <0,0,0>, 5.0 pigment { color Red}}
>
> #declare sphere2=
> sphere{ <7,0,0>, 5.0 pigment { color Green}}
>
>
> #declare grains=merge{
> object{sphere1}
> object{sphere2}
> }
>
> Therefore, the common region of these two spheres has mixed color (Red and
> Green). However, I would like to have this intersection region Red
> colored,
> instead. I have found a way to do this: using more CSG operations
>
> #declare grains=union{
> object{sphere1}
> difference{
> object{sphere2}
> object{sphere1}
> }
> }
>
> But I think that this way is time-consuming in case that I have thousand
> spheres
> or even more. There exists another better way for this? If so, please show
> me
> the way to go.
>
> Thank you very much.
>
> Vinh Phu
>
Well the obvious question is; If these represent grains in a solid
substance, shouldn't they be discrete 3D spheres? ie. why would there be
circumstances where the section through the substance would expose circles
that overlap?
Assuming though that this is not a problem in the circumstances you are
trying to emulate, then I've had the following 3 ideas (no perfect answers
spring to my mind):
1) There are alternative, more efficient ways to approximate this sort of
grainy effect using textures rather than defining actual 'grain' objects.
For example, I think you could use a color_map with a spotted pattern, zero
turbulence and transparency to give you a pattern of similarly coloured
spheres. The transparency would enable you to overlay several such textures,
each defined using a different color_map to give you overlapping spheres
where the top-most layer would take precedence. However, in your first post
you indicated that you had specific positions and radii that you wanted to
define, which would be problematic with the randomised nature of texture
patterns.
2) If the precise positions and radii are important, then you may be able to
work out ways of making it easier to code through knowledge of your dataset.
If you know that certain sets of spheres don't overlap you could build
different unions of spheres and subsequently 'difference' the unions. For
example, if you know that there are not any red spheres that overlap, you
can create a union of all red spheres and another for green. You can then
do:
#declare grains=union{
object{AllRedSpheres}
difference{
object{AllGreenSpheres}
object{AllRedSpheres}
}
}
3) It is also possible to specify locations for points that can be used in
textures using DF3 density files, although the precision of the locations is
limited by the resolution of the file you define. These files are most
frequently used within 'media', but can also be used in pigment definitions
along with colour maps. This is not something I've tried, so I don't know
whether this would achieve anything like what you need, but it may provide a
means of combining the two techniques above. ie. use a DF3 file to store the
positions of all of the red spheres and another one for all green spheres
and combine them as a layered texture. If this works it would probably be a
lot of effort and only worthwhile if you have a large number of similar
datasets that you need to visualise.
Regards,
Chris B.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
vinhphunguyen nous illumina en ce 2008-06-19 03:50 -->
> Hi Chris,
>
> I have two intersecting spheres as follows:
>
> #declare sphere1=
> sphere{ <0,0,0>, 5.0 pigment { color Red}}
>
>
> #declare sphere2=
> sphere{ <7,0,0>, 5.0 pigment { color Green}}
>
>
> #declare grains=merge{
> object{sphere1}
> object{sphere2}
> }
>
> Therefore, the common region of these two spheres has mixed color (Red and
> Green). However, I would like to have this intersection region Red colored,
> instead. I have found a way to do this: using more CSG operations
>
> #declare grains=union{
> object{sphere1}
> difference{
> object{sphere2}
> object{sphere1}
> }
> }
>
> But I think that this way is time-consuming in case that I have thousand spheres
> or even more. There exists another better way for this? If so, please show me
> the way to go.
>
> Thank you very much.
>
> Vinh Phu
>
>
Simple, remove the pigments from the two original spheres and apply the red
pigment to the complete CSG.
As your object is opaque, you should use union instead of merge. Merge is
usefull with transparent objects when you want to remove the internal surfaces.
It's also slower then the equivalent union.
--
Alain
-------------------------------------------------
For a people who are free, and who mean to remain so, a well-organized and
armed militia is their best security.
Thomas Jefferson
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|