|
|
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
|
|