POV-Ray : Newsgroups : povray.programming : Where can I find the reflected ray? Server Time
28 Jul 2024 10:25:05 EDT (-0400)
  Where can I find the reflected ray? (Message 5 to 14 of 14)  
<<< Previous 4 Messages Goto Initial 10 Messages
From: Wu Yang
Subject: Re: Where can I find the reflected ray?
Date: 13 Oct 2002 23:55:59
Message: <3daa404f@news.povray.org>
Is "box.pov" a scene with reflection. I do render it, but the reflect()
function is not called because I define an "ofstream" object "output" in
reflect() function. The exact code is "ofstream output("C:\\out.dat");".And
then render "box.pov",however, no "out.dat" formed. What's wrong?

Thanks a lot.
Best Regard
Wu Yang

"Christopher James Huff" <chr### [at] maccom> wrote in message
news:chr### [at] netplexaussieorg...
> In article <3da9eae1@news.povray.org>, "Wu Yang" <wya### [at] cswrightedu>
> wrote:
>
> > Thank you for your reply. Yes, I think that the reflect() will be called
> > when I run the program. Why this is not right?
>
> The Reflect() function will only be called when POV is computing
> reflection. Just running the program won't do that, you need to render a
> scene with reflection. This is so obvious I can't believe you would be
> doing otherwise, but you haven't given any indication of what exactly
> you are doing other than "running the program", which isn't enough.
>
>
> > I do modify what should be changed and build the project without
> > error. I define an "ofstream" object "output" by ofstream
> > output("C:\\out.dat"); and run the program, but no out.dat formed.
>
> *Where* do you create the file? What is the *exact* code you are using
> to create it and write the data? What is the scene file you are testing
> it with?
>
> --
> Christopher James Huff <cja### [at] earthlinknet>
> http://home.earthlink.net/~cjameshuff/
> POV-Ray TAG: chr### [at] tagpovrayorg
> http://tag.povray.org/


Post a reply to this message

From: Wu Yang
Subject: Re: Where can I find the reflected ray?
Date: 14 Oct 2002 00:14:24
Message: <3daa44a0@news.povray.org>
The exact code I write in reflect() function:
/***************************************************************************
*
*                   lighting.cpp
*
......
#include <algorithm>
#include <fstream>
using namespace std;
......
static void Reflect(......)
{
  ofstream output("D:\\out.dat");
  ......


"Christopher James Huff" <chr### [at] maccom> wrote in message
news:chr### [at] netplexaussieorg...
> In article <3da9eae1@news.povray.org>, "Wu Yang" <wya### [at] cswrightedu>
> wrote:
>
> > Thank you for your reply. Yes, I think that the reflect() will be called
> > when I run the program. Why this is not right?
>
> The Reflect() function will only be called when POV is computing
> reflection. Just running the program won't do that, you need to render a
> scene with reflection. This is so obvious I can't believe you would be
> doing otherwise, but you haven't given any indication of what exactly
> you are doing other than "running the program", which isn't enough.
>
>
> > I do modify what should be changed and build the project without
> > error. I define an "ofstream" object "output" by ofstream
> > output("C:\\out.dat"); and run the program, but no out.dat formed.
>
> *Where* do you create the file? What is the *exact* code you are using
> to create it and write the data? What is the scene file you are testing
> it with?
>
> --
> Christopher James Huff <cja### [at] earthlinknet>
> http://home.earthlink.net/~cjameshuff/
> POV-Ray TAG: chr### [at] tagpovrayorg
> http://tag.povray.org/


Post a reply to this message

From: Warp
Subject: Re: Where can I find the reflected ray?
Date: 14 Oct 2002 02:03:04
Message: <3daa5e12@news.povray.org>
Wu Yang <wya### [at] cswrightedu> wrote:
> static void Reflect(......)
> {
>   ofstream output("D:\\out.dat");
>   ......

  This is not an answer to your question per se, but do you think that's
the best way to go?
  If you open the file for writing each time Reflect() is called, this
is not only inefficient (a system call for opening a file for writing can
be quite slow if done lots and lots of times) but you will also be destroying
any previous data which existed in the file (by default ofstream opens
the file for writing, not for appending, ie. if the file existed already,
it's clamped to 0 size).
  You should only open the file once in some initialization routine, not
every time Reflect() is called.

  And by the way, it's a good idea to check if opening the file succeeded.
Don't take the success for granted.

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: Christopher James Huff
Subject: Re: Where can I find the reflected ray?
Date: 14 Oct 2002 12:35:29
Message: <chrishuff-213708.12303114102002@netplex.aussie.org>
In article <3daa404f@news.povray.org>, "Wu Yang" <wya### [at] cswrightedu> 
wrote:

>    Is "box.pov" a scene with reflection.

No. It doesn't use reflection anywhere, which would be one reason no 
files are written. Actually looking at the scene might have helped... ;-)
I'd suggest you use one of the demo scenes in scenes/textures/finishes/, 
all of which do use reflection. And watch out, it could produce a huge 
amount of data. I don't know what you want it for, it might be best to 
make a very simple scene with one reflective shape to minimize the 
amount of reflection data.


> I do render it, but the reflect()
> function is not called because I define an "ofstream" object "output" in
> reflect() function. The exact code is "ofstream output("C:\\out.dat");".And
> then render "box.pov",however, no "out.dat" formed. What's wrong?

> static void Reflect(......)
> {
>   ofstream output("D:\\out.dat");

First, you are opening the file for every reflected ray. This will be 
very slow, it would be better to open it once, for a temporary hack like 
this it would be easiest to just use a global variable. Also, you are 
opening it in write mode, it will overwrite the previously written data 
every time, so you will never get a file with more than one entry. You 
need to either open it once or open it in append mode. Opening the file 
once in write mode and using a global variable for it would be the best 
way: it will be much faster, and if you use append mode you will have to 
remember to delete the data file before each render or it will just 
append to what it wrote in previous renders.

And finally, you didn't give all the code. This is just the code for 
opening a file, you didn't say how you are writing the data.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

From: Wu Yang
Subject: Re: Where can I find the reflected ray?
Date: 14 Oct 2002 13:56:07
Message: <3dab0537@news.povray.org>
Yes, I got it. Thank you very much. But I do not know why "box.pov" is
not a scene with reflection. I do see it. Why can I see it? The data for
displaying is what I want to get. Is it called light internsity?
   Actually, the code I post is the only code I wrote till now. I only want
to test if the reflect() function is called when I rend some pov file. Thank
you for your advice.

Best Regard
Wu Yang
"Christopher James Huff" <chr### [at] maccom> wrote in message
news:chr### [at] netplexaussieorg...
> In article <3daa404f@news.povray.org>, "Wu Yang" <wya### [at] cswrightedu>
> wrote:
>
> >    Is "box.pov" a scene with reflection.
>
> No. It doesn't use reflection anywhere, which would be one reason no
> files are written. Actually looking at the scene might have helped... ;-)
> I'd suggest you use one of the demo scenes in scenes/textures/finishes/,
> all of which do use reflection. And watch out, it could produce a huge
> amount of data. I don't know what you want it for, it might be best to
> make a very simple scene with one reflective shape to minimize the
> amount of reflection data.
>
>
> > I do render it, but the reflect()
> > function is not called because I define an "ofstream" object "output" in
> > reflect() function. The exact code is "ofstream
output("C:\\out.dat");".And
> > then render "box.pov",however, no "out.dat" formed. What's wrong?
>
> > static void Reflect(......)
> > {
> >   ofstream output("D:\\out.dat");
>
> First, you are opening the file for every reflected ray. This will be
> very slow, it would be better to open it once, for a temporary hack like
> this it would be easiest to just use a global variable. Also, you are
> opening it in write mode, it will overwrite the previously written data
> every time, so you will never get a file with more than one entry. You
> need to either open it once or open it in append mode. Opening the file
> once in write mode and using a global variable for it would be the best
> way: it will be much faster, and if you use append mode you will have to
> remember to delete the data file before each render or it will just
> append to what it wrote in previous renders.
>
> And finally, you didn't give all the code. This is just the code for
> opening a file, you didn't say how you are writing the data.
>
> --
> Christopher James Huff <cja### [at] earthlinknet>
> http://home.earthlink.net/~cjameshuff/
> POV-Ray TAG: chr### [at] tagpovrayorg
> http://tag.povray.org/


Post a reply to this message

From: Wu Yang
Subject: Re: Where can I find the reflected ray?
Date: 14 Oct 2002 13:58:40
Message: <3dab05d0@news.povray.org>
Yes, you are right.
Thanks a lot
Best Regard
Wu Yang
"Warp" <war### [at] tagpovrayorg> wrote in message
news:3daa5e12@news.povray.org...
> Wu Yang <wya### [at] cswrightedu> wrote:
> > static void Reflect(......)
> > {
> >   ofstream output("D:\\out.dat");
> >   ......
>
>   This is not an answer to your question per se, but do you think that's
> the best way to go?
>   If you open the file for writing each time Reflect() is called, this
> is not only inefficient (a system call for opening a file for writing can
> be quite slow if done lots and lots of times) but you will also be
destroying
> any previous data which existed in the file (by default ofstream opens
> the file for writing, not for appending, ie. if the file existed already,
> it's clamped to 0 size).
>   You should only open the file once in some initialization routine, not
> every time Reflect() is called.
>
>   And by the way, it's a good idea to check if opening the file succeeded.
> Don't take the success for granted.
>
> --
> #macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb
x]
> [1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
> -1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// -
Warp -


Post a reply to this message

From: Christopher James Huff
Subject: Re: Where can I find the reflected ray?
Date: 14 Oct 2002 15:44:17
Message: <chrishuff-6ABAFD.15392114102002@netplex.aussie.org>
In article <3dab0537@news.povray.org>, "Wu Yang" <wya### [at] cswrightedu> 
wrote:

>    Yes, I got it. Thank you very much. But I do not know why "box.pov" is
> not a scene with reflection. I do see it. Why can I see it?

Are you talking about the one in the standard example scenes? 
scenes/objects/box.pov? The one I have doesn't have any reflection. Did 
you modify it? Where do you see it?


> The data for displaying is what I want to get. Is it called light 
> internsity?

Data for displaying what? What exactly do you want?
The Reflect() function is called when POV computes a reflected ray. If 
the scene doesn't use reflection, it is never called. It has nothing to 
do with anything being displayed, other than being one step in the 
process of computing the final pixel color. Do you want the output 
image? That has nothing to do with reflection, and is a completely 
different part of the code.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

From: Wu Yang
Subject: Re: Where can I find the reflected ray?
Date: 14 Oct 2002 22:58:37
Message: <3dab845d@news.povray.org>
Yes, I want the output image data. What is the difference between the
output image data with the reflection data?
   The following is what I want to do:
   Suppose I put a radar in the camera position. Because the radar emit the
electromagnetic wave, so it also likes a light source. I want the data back
to the radar, that is to say, the camera position. I think that this is the
same data which I can see by render some pov file(output image data,
right?).

Thank you for your help
Best Regard
Wu Yang

"Christopher James Huff" <chr### [at] maccom> wrote in message
news:chr### [at] netplexaussieorg...
> In article <3dab0537@news.povray.org>, "Wu Yang" <wya### [at] cswrightedu>
> wrote:
>
> >    Yes, I got it. Thank you very much. But I do not know why "box.pov"
is
> > not a scene with reflection. I do see it. Why can I see it?
>
> Are you talking about the one in the standard example scenes?
> scenes/objects/box.pov? The one I have doesn't have any reflection. Did
> you modify it? Where do you see it?
>
>
> > The data for displaying is what I want to get. Is it called light
> > internsity?
>
> Data for displaying what? What exactly do you want?
> The Reflect() function is called when POV computes a reflected ray. If
> the scene doesn't use reflection, it is never called. It has nothing to
> do with anything being displayed, other than being one step in the
> process of computing the final pixel color. Do you want the output
> image? That has nothing to do with reflection, and is a completely
> different part of the code.
>
> --
> Christopher James Huff <cja### [at] earthlinknet>
> http://home.earthlink.net/~cjameshuff/
> POV-Ray TAG: chr### [at] tagpovrayorg
> http://tag.povray.org/


Post a reply to this message

From: Christopher James Huff
Subject: Re: Where can I find the reflected ray?
Date: 14 Oct 2002 23:34:01
Message: <chrishuff-645BD9.23290614102002@netplex.aussie.org>
In article <3dab845d@news.povray.org>, "Wu Yang" <wya### [at] cswrightedu> 
wrote:

>    Yes, I want the output image data. What is the difference between the
> output image data with the reflection data?
>    The following is what I want to do:
>    Suppose I put a radar in the camera position. Because the radar emit the
> electromagnetic wave, so it also likes a light source. I want the data back
> to the radar, that is to say, the camera position. I think that this is the
> same data which I can see by render some pov file(output image data,
> right?).

Ok, I think this is where our miscommunication is happening. When people 
speak of "reflection", they usually mean specular reflection, like a 
polished surface or a mirror. You seem to be looking for diffuse 
reflection, which is light scattered in all directions by a surface.
If you want diffuse reflection data per ray, you should modify Diffuse() 
in lighting.cpp. Maybe Diffuse_One_Light() too, I haven't looked very 
closely. If you just want the output image data, why not just use the 
output image?

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

From: Wu Yang
Subject: Re: Where can I find the reflected ray?
Date: 15 Oct 2002 00:48:28
Message: <3dab9e1c@news.povray.org>
I got it. Thank you very very much. But I confused with the Ray struct.
What I want is the ray intensity. Could you please tell me how can I get it?
Thanks a lot
Best Regard
Wu Yang

"Christopher James Huff" <chr### [at] maccom> wrote in message
news:chr### [at] netplexaussieorg...
> In article <3dab845d@news.povray.org>, "Wu Yang" <wya### [at] cswrightedu>
> wrote:
>
> >    Yes, I want the output image data. What is the difference between the
> > output image data with the reflection data?
> >    The following is what I want to do:
> >    Suppose I put a radar in the camera position. Because the radar emit
the
> > electromagnetic wave, so it also likes a light source. I want the data
back
> > to the radar, that is to say, the camera position. I think that this is
the
> > same data which I can see by render some pov file(output image data,
> > right?).
>
> Ok, I think this is where our miscommunication is happening. When people
> speak of "reflection", they usually mean specular reflection, like a
> polished surface or a mirror. You seem to be looking for diffuse
> reflection, which is light scattered in all directions by a surface.
> If you want diffuse reflection data per ray, you should modify Diffuse()
> in lighting.cpp. Maybe Diffuse_One_Light() too, I haven't looked very
> closely. If you just want the output image data, why not just use the
> output image?
>
> --
> Christopher James Huff <cja### [at] earthlinknet>
> http://home.earthlink.net/~cjameshuff/
> POV-Ray TAG: chr### [at] tagpovrayorg
> http://tag.povray.org/


Post a reply to this message

<<< Previous 4 Messages Goto Initial 10 Messages

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