POV-Ray : Newsgroups : povray.advanced-users : Pixel position from 3D coordinates : Re: Pixel position from 3D coordinates Server Time
3 Jul 2024 04:45:34 EDT (-0400)
  Re: Pixel position from 3D coordinates  
From: Mark Weyer
Date: 25 Sep 2008 04:20:01
Message: <web.48db48343cca20e6fddaa4670@news.povray.org>
> Ok... I'll keep that in mind.  I'd thought about the AA, but was hoping it
> wouldn't cause problems.

As you are using image diffs, it won't if your pieces never overlap in
any game position (as long as you do not use jitter or such). I did not
think of diffs. If pieces are going to overlap, you will need to use an
alpha channel (with more than one bit).
My other comment on AA was based on my experience from a project, where
we can assume that sprites overlap rarely enough for us to be content
with a one bit alpha channel, aka bit mask.

> So... That solves my problem nicely.  I'm still curious though if there is a
> neat way to do it all within povray...
>
> Given a +W, +H, camera{} and an object{}, is it possible to print out the
> output-image pixel coordinates of the bounding box of the object?

First, assume your camera is

  camera {
    location 0
    direction z
    right A*x
    up B*y
  }

for some numbers A and B. Then the 3D coordinate <X,Y,Z> will be rendered
at the pixel ( (X/(A*Z)-1/2)*W , (1/2-Y/(B*Z))*H ). Your actual camera is
equivalent to one of this form with some rotates and translates applied.
Then, apply the inverses of these rotates and translates, in reverse order,
to the 3D coordinate beforehand.
How your camera is equivalent to one of the above form, I cannot tell, at
least not from the top of my head, because I never use angle or look_at.

> Anyway, Thanks Mark and others who responded.

Welcome.

  Mark Weyer


Post a reply to this message

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