POV-Ray : Newsgroups : povray.advanced-users : Pixel Mapping Server Time
29 Jun 2024 02:00:09 EDT (-0400)
  Pixel Mapping (Message 1 to 8 of 8)  
From: Captain Jack
Subject: Pixel Mapping
Date: 2 Nov 2009 10:22:27
Message: <4aeef933$1@news.povray.org>
Is there a formula somewhere already worked out where I can plug in the 
parameters to a camera object and an arbitray point in space, and determine 
which is the nearest pixel corresponding to it in the image plane? Ideally, 
I'd like to be able to do it with SDL inside a scene. I know that I can't 
extract certain things from the camera object, but I don't have a problem 
with loading them into variables first, then accessing them after the camera 
declaration.

More specifically, this is (ideally) the sort of thing I want to do:

----------------------------------------
#declare Camera_Type = 1; // Perspective
#declare Camera_Location = 6*y-12*z;
#declare Camera_Look_At = 0*x;
#declare Camera_Right = image_width/image_height*x;
#declare Camera_Up = y;
#declare Camera_Angle = 45;

camera {
    // Use vars above
}

#macro PixelAt(Point_Vector)
    // Code goes here that takes that point and the camera
    // settings, and calculates a 2D vector that corresponds
    // to the nearest pixel in the output.
#end
----------------------------------------

A couple of the things I want to be able to do with it are to generate 
images that occupy specific portions of the screen, and to be able to map a 
"hot point" of a moving object in an animtion to apply other effects in 
other software.

I've done some digging in the source code, but I haven't figured it out yet. 
If somebody knows which source file and which functions I should be looking 
at, that would be helpful as well.

Thanks in advance,
Jack


Post a reply to this message

From: Christian Froeschlin
Subject: Re: Pixel Mapping
Date: 2 Nov 2009 11:18:30
Message: <4aef0656$1@news.povray.org>
Captain Jack wrote:

> A couple of the things I want to be able to do with it are to 
> generate images that occupy specific portions of the screen, and to 
> be  able to map a "hot point" of a moving object in an animtion to 
> apply other effects in other software.

You might wish to have a look at screen.inc. It should help with
the first part of your problem and provide a framework for writing
a 3d to 2d projection macro.


Post a reply to this message

From: Captain Jack
Subject: Re: Pixel Mapping
Date: 2 Nov 2009 11:30:50
Message: <4aef093a$1@news.povray.org>
"Christian Froeschlin" <chr### [at] chrfrde> wrote in message 
news:4aef0656$1@news.povray.org...
> Captain Jack wrote:
>
>> A couple of the things I want to be able to do with it are to generate 
>> images that occupy specific portions of the screen, and to be  able to 
>> map a "hot point" of a moving object in an animtion to apply other 
>> effects in other software.
>
> You might wish to have a look at screen.inc. It should help with
> the first part of your problem and provide a framework for writing
> a 3d to 2d projection macro.

Thanks... I was so busy looking through the POV source I didn't think to 
look in the scene files.


Post a reply to this message

From: SharkD
Subject: Re: Pixel Mapping
Date: 12 Nov 2009 17:11:39
Message: <4afc881b@news.povray.org>
On 11/2/2009 11:18 AM, Christian Froeschlin wrote:
> Captain Jack wrote:
>
>> A couple of the things I want to be able to do with it are to generate
>> images that occupy specific portions of the screen, and to be able to
>> map a "hot point" of a moving object in an animtion to apply other
>> effects in other software.
>
> You might wish to have a look at screen.inc. It should help with
> the first part of your problem and provide a framework for writing
> a 3d to 2d projection macro.

It only works with the perspective camera. :(

I'll see if I can fix it.

Mike


Post a reply to this message

From: Captain Jack
Subject: Re: Pixel Mapping
Date: 13 Nov 2009 09:55:10
Message: <4afd734e$1@news.povray.org>
"SharkD" <mik### [at] gmailcom> wrote in message 
news:4afc881b@news.povray.org...
> On 11/2/2009 11:18 AM, Christian Froeschlin wrote:
>> Captain Jack wrote:
>>
>>> A couple of the things I want to be able to do with it are to generate
>>> images that occupy specific portions of the screen, and to be able to
>>> map a "hot point" of a moving object in an animtion to apply other
>>> effects in other software.
>>
>> You might wish to have a look at screen.inc. It should help with
>> the first part of your problem and provide a framework for writing
>> a 3d to 2d projection macro.
>
> It only works with the perspective camera. :(
>
> I'll see if I can fix it.
>
> Mike

That'd be great... it seems like it should be a simple thing, I don't know 
why I'm having so much trouble with it.

Historically, though, every time I think something should be easy, it turns 
out that I've completely missed the subtelties of the problem. :D

--
Jack


Post a reply to this message

From: SharkD
Subject: Re: Pixel Mapping
Date: 13 Nov 2009 22:41:22
Message: <4afe26e2$1@news.povray.org>
On 11/13/2009 9:56 AM, Captain Jack wrote:
> That'd be great... it seems like it should be a simple thing, I don't know
> why I'm having so much trouble with it.
>
> Historically, though, every time I think something should be easy, it turns
> out that I've completely missed the subtelties of the problem. :D
>
> --
> Jack

See p.b.s-f for the new file.

What I did was make the current script work with orthographic cameras. 
It does *not* calculate on-screen pixel coordinates. I'm not sure how to 
go about that.

Mike


Post a reply to this message

From: SharkD
Subject: Re: Pixel Mapping
Date: 15 Nov 2009 18:47:30
Message: <4b009312$1@news.povray.org>
On 11/13/2009 9:56 AM, Captain Jack wrote:
> That'd be great... it seems like it should be a simple thing, I don't know
> why I'm having so much trouble with it.
>
> Historically, though, every time I think something should be easy, it turns
> out that I've completely missed the subtelties of the problem. :D
>
> --
> Jack

I've been working on a macro that can be used with "screen.inc" to get 
the screen coordinates. It is based on this thread:

http://news.povray.org/povray.advanced-users/thread/%3Cweb.48d9c9c6b4e5a4f9220734020@news.povray.org%3E/

The results aren't accurate however. Not sure what the problem is.

Mike



//BEGIN MACRO
#macro Get_Screen_Position(Loc)
	#declare Screen_Position = vinv_transform(Loc, Camera_Transform);
	#declare Screen_Position = <1/2 + 
Screen_Position.x/vlength(CamR)/Screen_Position.z, 1/2 - 
Screen_Position.y/vlength(CamU)/Screen_Position.z, 0,>;
	#declare Screen_Position = Screen_Position * <image_width, 
image_height, 0,>;
#end
//END MACRO


Post a reply to this message

From: SharkD
Subject: Re: Pixel Mapping
Date: 15 Nov 2009 21:52:09
Message: <4b00be59$1@news.povray.org>
On 11/15/2009 6:47 PM, SharkD wrote:
> I've been working on a macro that can be used with "screen.inc" to get
> the screen coordinates. It is based on this thread:
>
>
http://news.povray.org/povray.advanced-users/thread/%3Cweb.48d9c9c6b4e5a4f9220734020@news.povray.org%3E/
>
>
> The results aren't accurate however. Not sure what the problem is.
>
> Mike

OK, I managed to figure it out. I'll upload the entire script to the 
thread I started in p.b.s-f

Mike


Post a reply to this message

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