 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Greetings.
I was reading about the Trace() feature inside the POV-Ray documentation,
but to be honest, I just cannot work it out. Who can help me understanding
it entirely? There are so many YXZ coordinates.
Maybe a small very simple sample scene could help me, with some truly
explaining words.
Thanks,
Sven
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Sven Littkowski <sve### [at] jamaica-focus com> wrote:
> Maybe a small very simple sample scene could help me, with some truly
> explaining words.
// Declare an object you want to trace:
#declare AnObject =
torus { 1, .5 pigment { rgb x } finish { specular .5 } };
// Let's "drop" cylinders on this object from above.
// First let's define the area inside which to "drop" cylinders
// (this covers the entire torus above viewed from above):
#declare MinX = -1.5;
#declare MaxX = 1.5;
#declare MinZ = -1.5;
#declare MaxZ = 1.5;
#declare DropHeight = 2;
#declare CylinderRadius = .015;
#declare NormalScale = .1;
// Now let's loop through all that area using regular steps:
#declare Normal = <0,0,0>;
#declare Step = .1;
#declare IndX = MinX;
#while(IndX <= MaxX)
#declare IndZ = MinZ;
#while(IndZ <= MaxZ)
// Now let's "drop" a cylinder onto the torus:
#declare Intersection =
trace(AnObject, <IndX, DropHeight, IndZ>, -y, Normal);
// The first parameter is the object to trace (ie. our torus).
// The second parameter is the starting point for the trace
// (like the point from which we "drop" our cylinder).
// The third parameter is the direction towards which we trace
// (ie. the direction towards which we "drop" the cyliner)
// The last parameter is the normal vector at the intersection point
// (this has two uses, as seen below).
// Now, a normal vector <0,0,0> is invalid and thus trace() uses that
// value to indicate that it did not intersect the object at all.
// Thus we have to check that it is not <0,0,0> before we crate the
// cylinder:
#if(vlength(Normal) > 0)
// Now we can create the cylinder at the intersection point.
// To keep things interesting, let's orientate the cylinder in
// the direction of the normal vector:
cylinder
{ Intersection, Intersection+Normal*NormalScale, CylinderRadius
pigment { rgb y }
finish { specular .5 }
}
#end
#declare IndZ = IndZ + Step;
#end
#declare IndX = IndX + Step;
#end
camera { location <0, 5, -5> look_at 0 angle 35 }
light_source { <100, 200, 0>, 1 }
object { AnObject }
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
An easy example :
you have an object, called Object...and you want to put another object at
the top of it, at the vertical of a <X,?,Z> point.
You can call it :
#declare coord=trace (Object,<X,100000,Z>,<0,-1,0>)
<X,1000,Z> is a point at the vertical of your object (take 100000 as high as
you wish, it must be higher than the heigh of your object)
<0,-1,0> is the down direction.
So Trace will shoot a ray from <X,10000,Y> downside and look if it hits your
object. If it does, it returns the intersection point. This point is the
coord where you want to put your new object.
For the 4 vectors version :
use as follows :
#declare coord=trace(Object,<X,100000,Z>,<0,-1,0>,norm)
it returns in coord the same vector than in the first example. It also
return the normal vector at this point in "norm"
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Hi Seb,
many thanks and my appreciation for your answer. I understand now the 3
vectors version.
But what is a 4 vectors version? What is the NORM doing and about?
Sven
"Mr Seb" <ban### [at] wanadoo fr> schrieb im Newsbeitrag
news:446cd71f@news.povray.org...
> For the 4 vectors version :
> use as follows :
> #declare coord=trace(Object,<X,100000,Z>,<0,-1,0>,norm)
> it returns in coord the same vector than in the first example. It also
> return the normal vector at this point in "norm"
>
>
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Thanks for your answer, Wrap.
I rendered your example but just get the torus. But nevertheless, with your
help and the help of Seb I do now understand a bit more of that trace
feature. Still not very sure about it. I have to make some tests now.
Thanks a lot!
Sven
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Sven Littkowski <sve### [at] jamaica-focus com> wrote:
> I rendered your example but just get the torus.
I can't even begin to fathom how that is possible.
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Hi Warp,
hmm, not sure how to work your "comment" out... :-)
Let me just give you the scene as I got it from you. Remember, I am an
absolute beginner if it comes to the trace function.
Best greetings,
Sven
"Warp" <war### [at] tag povray org> schrieb im Newsbeitrag
news:446d1c1c@news.povray.org...
> Sven Littkowski <sve### [at] jamaica-focus com> wrote:
>> I rendered your example but just get the torus.
>
> I can't even begin to fathom how that is possible.
>
> --
> - Warp
#version 3.5;
// Declare an object you want to trace:
#declare AnObject = torus
{
1.0, 0.5
pigment { rgb x }
finish { specular 0.5 }
}
// Let's "drop" cylinders on this object from above.
// First let's define the area inside which to "drop" cylinders
// (this covers the entire torus above viewed from above):
#declare MinX = -1.5;
#declare MaxX = 1.5;
#declare MinZ = -1.5;
#declare MaxZ = 1.5;
#declare DropHeight = 2;
#declare CylinderRadius = .015;
#declare NormalScale = .1;
// Now let's loop through all that area using regular steps:
#declare Normal = < 0.0, 0.0, 0.0 >;
#declare Step = 0.1;
#declare IndX = MinX;
#while(IndX <= MaxX)
#declare IndZ = MinZ;
#while(IndZ <= MaxZ)
// Now let's "drop" a cylinder onto the torus:
#declare Intersection = trace(AnObject < IndX, DropHeight, IndZ > -y,
Normal);
// The first parameter is the object to trace (ie. our torus).
// The second parameter is the starting point for the trace
// (like the point from which we "drop" our cylinder).
// The third parameter is the direction towards which we trace
// (ie. the direction towards which we "drop" the cyliner)
// The last parameter is the normal vector at the intersection point
// (this has two uses, as seen below).
// Now, a normal vector <0,0,0> is invalid and thus trace() uses that
// value to indicate that it did not intersect the object at all.
// Thus we have to check that it is not <0,0,0> before we crate the
// cylinder:
#if(vlength(Normal) > 0)
// Now we can create the cylinder at the intersection point.
// To keep things interesting, let's orientate the cylinder in
// the direction of the normal vector:
cylinder
{
Intersection, Intersection+Normal*NormalScale, CylinderRadius
pigment { rgb y }
finish { specular .5 }
}
#end
#declare IndZ = IndZ + Step;
#end
#declare IndX = IndX + Step;
#end
camera { location < 0.0, 5.0, -5.0 > look_at 0.0 angle 35 }
light_source { <100.0, 200.0, 0>, 1.0 }
object { AnObject }
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
> But what is a 4 vectors version? What is the NORM doing and about?
>
> Sven
The NORM is a Vector that represents the angle at which the ray being used
in the trace function hits the object.
--
#####-----#####-----#####
POV Tips and Hints at ...
http://povman.blogspot.com/
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Sven Littkowski <sve### [at] jamaica-focus com> wrote:
> hmm, not sure how to work your "comment" out... :-)
It means: I don't understand how it is possible that you are getting
just a torus. The scene creates a big bunch of cylinders besides the
torus so I cannot understand how it is possible.
Which version of POV-Ray are you using?
> Let me just give you the scene as I got it from you. Remember, I am an
> absolute beginner if it comes to the trace function.
> #version 3.5;
This wasn't in my scene.
> #declare Intersection = trace(AnObject < IndX, DropHeight, IndZ > -y,
There are missing commas there. Why did you remove them?
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp,
I am in shame! My life lost any sense, and my soul is now condemned for
10,000 eons! You was right, actually!
I have a habit: whe ever I see the source code of scenes written by others,
I at first transform it into my own way of writing (setting spaces aka
blanks, just a kind of re-formatting). Now, what happened: I changed the
formatting, and - you are so right - I removed commas. I usually don't use
commas often, but made the experience that this was not giving any trouble.
But here, it was leading to a somewhat different interpretion of the scene!
Not an error message, just a scene without cylinders (which is, as a result,
quite interesting).
I use for extensive testing the beta 12a version of POV-Ray.
I just replaced my formatting with your original, and it works! Sorry again,
Warp. And also: deep thanks for having taken so much time and good intention
to help! Please go on with that! :-)
Greetings,
Sven
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Well, NOW I understand. Thanks, Povman!
That means, the norm function actually could be used like a rotate < x, y, z
> command? And if so, where would be the point of rotation - would that
point be the point where the placable object hits via the trace command the
surface of the traced object, or would it be the placable objects natural
postion from its own X,Y,Z coordinates (as usual, otherwise)?
Hmmm, I guess, I have to look deeply into the given examples again. But I
also would appreciate easy answers...
Thanks a lot, Povman,
Sven
"POVMAN" <s### [at] a com> schrieb im Newsbeitrag news:446d891e$1@news.povray.org...
> The NORM is a Vector that represents the angle at which the ray being used
> in the trace function hits the object.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Sven Littkowski <sve### [at] jamaica-focus com> wrote:
> Now, what happened: I changed the
> formatting, and - you are so right - I removed commas. I usually don't use
> commas often, but made the experience that this was not giving any trouble.
You shouldn't remove commas because sometimes they are crucial.
"a -b" is *not* the same thing as "a, -b".
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Yes, exactly that I found out. The error was caused just in the trace
function. And because it is flexible with the amount of parameters. That
was, what broke my neck!
:-)
Sven
"Warp" <war### [at] tag povray org> schrieb im Newsbeitrag
news:446db9ae@news.povray.org...
> You shouldn't remove commas because sometimes they are crucial.
> "a -b" is *not* the same thing as "a, -b".
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Hmmm, I still don't succeed. I want to randomly place a number of green
cylinders onto the blob, just above and below the horizontal rectangular cut
in the blob (lower edge of the picture).
What exactly do I do wrong? Please see below a simplified scene code.
Sven
#version 3.5;
#include "colors.inc"
#declare MittelRumpf=blob
// 4er Frontgebilde
{
threshold 0.3
sphere { < 0.0, 0.0, 400.0 > 300.0, 1.5 }
cylinder { < -450.0, 0.0, 400.0 > < 450.0, 0.0, 400.0 > 300.0, 1.0 scale <
1.0, 1.0, 1.0 > }
// Großes Bugsegment
sphere { < 0.0, 0.0, 500.0 > 200.0, 1.0 }
cylinder { < -50.0, 0.0, 500.0 > < 50.0, 0.0, 500.0 > 600.0, 1.0 scale <
0.12, 1.0, 0.5 > }
// Großes Bugsegment
sphere { < 0.0, 0.0, 800.0 > 280.0, 1.0 scale < 1.0, 1.43, 1.0 > }
cylinder { < 0.0, -50.0, 500.0 > < 0.0, 50.00, 500.0 > 300.0, 1.0 }
scale < 1.0, 0.7, 1.0 >
}
#declare MitteFront=difference
{
object { MittelRumpf }
box { < -60.0, -400.0, -400.0 > < 60.0, 400.0, 1000.0 > } //
...........................................................................
Wegfall der vorderen Rumpfmitte
box { < -400.0, -400.0, 250.0 > < 400.0, 400.0, 550.0 > } //
...........................................................................
Wegfall der Mitte quer
box { < -200.0, -400.0, 400.0 > < 200.0, 400.0, 1000.0 > } //
..........................................................................
Wegfall der Mitte bis nach hinten
pigment { Red }
}
#declare MitteSeite=difference
{
object { MittelRumpf }
box { < -400.0, -400.0, -400.0 > < 400.0, 400.0, 650.0 > } //
..........................................................................
Wegfall der Mitte und von Vorne
box { < -150.0, -400.0, 400.0 > < 150.0, 400.0, 1000.0 > } //
..........................................................................
Wegfall der Mitte bis nach hinten
box { < 200.0, -400.0, 400.0 > < 400.0, 400.0, 1000.0 > } //
...........................................................................
Wegfall der hinteren Seite
box { < -400.0, -400.0, 400.0 > < -200.0, 400.0, 1000.0 > } //
.........................................................................
Wegfall der hinteren Seite
pigment { Red }
}
#declare MitteOben=difference
{
object { MittelRumpf }
box { < -400.0, -400.0, -400.0 > < -60.0, 400.0, 250.0 > }
box { < 60.0, -400.0, -400.0 > < 400.0, 400.0, 250.0 > }
box { < -400.0, -400.0, 550.0 > < -200.0, 400.0, 1000.0 > }
box { < 200.0, -400.0, 550.0 > < 400.0, 400.0, 1000.0 > }
box { < -400.0, -400.0, 650.0 > < -150.0, 400.0, 1000.0 > }
box { < 150.0, -400.0, 650.0 > < 400.0, 400.0, 1000.0 > }
pigment { Red }
}
#declare Basisrumpf=union
{
object { MitteFront }
object { MitteSeite }
object { MitteOben }
}
#declare SechseckSensor=cylinder
{
< 0.0, 0.0, 0.0 > < 0.0, 0.0, -5.0 > 5.0
pigment { Green }
}
#declare Mittelsegment=difference
{
union
{
object { Basisrumpf } //
#declare Runde=200;
#declare Next=seed(60);
#while(Runde<360)
#declare MyNext=rand(Next);
#declare Normal=< 0.0, 0.0, 0.0 >;
#declare MySurface=trace( Basisrumpf, < Runde, 40, 2000.0 >, < Runde,
40.0, 0.0 >, Normal );
#if(vlength(Normal)>0)
object { SechseckSensor scale < 1.0, 1.0, -1.0 > translate MySurface
scale < 1.0, 1.0, 1.0 > }
object { SechseckSensor scale < 1.0, 1.0, -1.0 > translate MySurface
scale < -1.0, 1.0, 1.0 > }
object { SechseckSensor scale < 1.0, 1.0, -1.0 > translate MySurface
scale < 1.0, -1.0, 1.0 > }
object { SechseckSensor scale < 1.0, 1.0, -1.0 > translate MySurface
scale < -1.0, -1.0, 1.0 > }
#end
#declare Runde=Runde+5+(10*MyNext);
#end
}
box { < -400.0, -400.0, 750.0 > < 400.0, 400.0, 1000.0 > pigment { Red } }
box { < -460.0, -20.0, 0.0 > < 460.0, 20.0, 800.0 > pigment { Red } }
}
camera
{
location < -400.0, 500.0, -1300.0 >
look_at < -500.0, 300.0, -500.0 >
}
light_source
{
< -1000000.0, -1000000.0, -5000.0 >
color rgb < 0.99, 0.80, 0.47 > *4
}
light_source
{
< -1000000.0, 1000000.0, 1000000.0 >
color rgb < 0.2, 0.2, 0.3 > *4
}
object { Mittelsegment rotate < 0.0, 180.0, 0.0 > }
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Sven Littkowski <sve### [at] jamaica-focus com> wrote:
> trace( Basisrumpf, < Runde, 40, 2000.0 >, < Runde, 40.0, 0.0 >, Normal );
Are you sure you read my example scene carefully?
More precisely, do you understand the difference between a point and
a direction vector?
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Yes, usually I do. But to be honest, the trace thing is new, I easily could
misunderstand, truly. If you look to the various "SF: Preview: Imperial
Carrier" postings inside´the "povray.binaries.images" newsgroup, you can see
what objects I do out of my mind (without any 3D editor).
But with your question you actually give me a hint, and I am looking now
again into the scene, in hope to discover that thinking error. Sometimes you
are so frustrated in finding out things, that you don't see the forest
because of the many trees.
Thanks, greetings,
Sven
"Warp" <war### [at] tag povray org> schrieb im Newsbeitrag
news:446dde57@news.povray.org...
> Sven Littkowski <sve### [at] jamaica-focus com> wrote:
>> trace( Basisrumpf, < Runde, 40, 2000.0 >, < Runde, 40.0, 0.0 >, Normal );
>
> Are you sure you read my example scene carefully?
>
> More precisely, do you understand the difference between a point and
> a direction vector?
>
> --
> - Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Hello Warp,
I got now (finally) your point. I thought I could define the location of the
ray more exactly to which location that ray is pointing to. I replaced it
now with a simple "-z" and it works. Thanks, Warp,
Sven
> More precisely, do you understand the difference between a point and
> a direction vector?
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Sven Littkowski" <sve### [at] jamaica-focus com> wrote:
> Hi Seb,
>
> many thanks and my appreciation for your answer. I understand now the 3
> vectors version.
>
> But what is a 4 vectors version? What is the NORM doing and about?
>
> Sven
Hi, Sven! I feel your pain--it took me awhile to understand trace( ) as
well. But it's certainly one of the *coolest* features of POV.
It may not be clear from the discussions so far that the 4th parameter--the
normal of the surface found at the traced intersection point--is optional.
You can leave it out. But if you do use it, you first have to #declare a
"dummy" value for it, the usual way being #declare my_norm = <0,0,0>. But
it could have any three vector values to begin with, because the trace
operation will "fill" it each time with its own found value. It took me
awhile to understand that myself. That is, unlike the values you SUPPLY to
the first three parameters, the 4th parameter actually GIVES BACK a vector
value for each trace "ray" shot, which can be used for other things. And
like Warp says, the found normal is VERY useful in finding out IF a trace
ray has actually hit your main object.. The idea behind #if (vlength
my_norm !=0) --that is, "not equal to zero"--is that, if a trace ray
doesn't hit your main object, trace returns a location of <0,0,0> AND
automatically fills the 4th parameter with <0,0,0>.The vlength (vector
length) of such a "vector" is zero. You can then make a simple #if...#else
block to keep your code from creating an object in such a case. (All such
objects would otherwise be placed one on top of the other, all at location
<0,0,0>.)
Ken W.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Kenneth" <kdw### [at] earthlink net> wrote:
> The idea behind #if (vlength my_norm !=0) ...
Sorry, that should have been #if (vlength (my_norm) !=0)
BTW, you could instead use #if (vlength (my_norm) = 0) and simply rearrange
the parts in your #if......#else block to get the same results.
Ken
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Sven Littkowski" <sve### [at] jamaica-focus com> wrote:
> That means, the norm function actually could be used like a rotate < x, y, z
> > command? And if so, where would be the point of rotation - would that
> point be the point where the placable object hits via the trace command the
> surface of the traced object, or would it be the placable objects natural
> postion from its own X,Y,Z coordinates (as usual, otherwise)?
Using the normal to try and rotate other already-created objects is not an
easy thing to accomplish. True, it can be used quite well the way Warp has
shown, when actually CREATING an object at the traced intersection point.
But the results of doing something like, say,
object{my_small_object
rotate my_norm*90 // to try and re-orient your small placed
// object according to the
// normal of the surface
translate traced_intersection_point // putting each small object onto the
// bigger traced object
}
doesn't work out the way you might think. It *looks* like it works, sort of,
but the rotational results are not correct. I personally tried all sorts of
trigonometric trickery with the normal, and finally found a way to do this
(see below.) But then I discovered the Point_At_Trans macro in
transforms.inc. With it, you can take any pre-created object -- made at the
origin--and rotate it using the my_norm vector. (It takes the +y vector
there and rotates it--and the object-- around to the my_norm vector.) Very
handy!!
My other way of doing it is this (using "dot notation" to pull out
individual vector values):
#declare x_degrees_reorient = degrees (atan2 (my_norm.y, my_norm.z));
#declare y_degrees_reorient = degrees (atan2 (my_norm.y, my_norm.x));
then rotate your pre-created object , while it's still at the origin, like
this:
rotate <90 - x_degrees_reorient, 0, z_degrees_reorient - 90)
then translate it to the traced location.
I can't guarantee that it has the EXACT same results as Point_At_Trans, but
it looks identical to me.
Ken W.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|
 |