POV-Ray : Newsgroups : povray.newusers : Image maps and heightfields : Re: Image maps and heightfields Server Time
28 Jul 2024 16:30:47 EDT (-0400)
  Re: Image maps and heightfields  
From: Alain
Date: 21 Mar 2008 23:07:04
Message: <47e485e8$1@news.povray.org>
Corona688 nous apporta ses lumieres en ce 2008/03/21 20:43:
> I have an unusual problem -- image maps that are a different size and aspect
> ratio than the heightfield they match.
> 
> I have precise information on where they belong relative to the heightfield, and
> I can get them to fit with hardcoded values, but any sort of macro to fit it
> based on the information I have has eluded me for the last week.
> 
> Hence I politely ask for help creating a macro for the translations+rotations in
> the pigment section, like:
> 
> IMG_FIT(-0.5, +0.0,
>         +1.0, +1.0)
> 
> where the first two coordinates are the upper left corner of the imagemap
> relative to the heightfield, and the second two are the lower right.  Yes, part
> of the left side of the image would miss the heightfield, that is the idea.
The first two parameters are scaling factors.
The last two are *suposed* to be placement parameters, but not used.
> 
> My silly efforts so far, just so you know I've tried:
> 
> #macro IMGMAP_FIT(XSCALE, YSCALE, XOFF, YOFF)
>         rotate <90, 0, 0>           // Face up
>         translate<-0.5, -0.5, -0.5> // Center
>         scale <-XSCALE, 1, -YSCALE> // Resize
>         translate<(XSCALE-1)/2, 0, -(YSCALE-1)/2> // Relocate
> #end
> 
> 
> 
If you rewrite your macro with the provided values, you get:
----------------------------
rotate 90*x
translate -0.5
scale <-(-0.5),1,-0>// become: scale<0.5,1,1>
translate<(-0.5-1)/2,0,-(0-1)/2>//become: translate<-0.75,0,0.5>
-----------------------------
The net translation is: <-1.25,-0.5,0>

You want to scale the image relative to it's center. Use:
translate -0.5 //center around origin
scale<XSCALE,1,YSCALE> //scale it
translate 0.5 // return it to it's original position

Now, you want to place if acording to your offset
translate<XOFF,1,YOFF>

-- 
Alain
-------------------------------------------------
Adult, n.: One old enough to know better.


Post a reply to this message

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