POV-Ray : Newsgroups : povray.advanced-users : HF_ macro question. Server Time
25 Nov 2024 12:41:36 EST (-0500)
  HF_ macro question. (Message 1 to 6 of 6)  
From: normdoering
Subject: HF_ macro question.
Date: 7 Nov 2002 23:30:04
Message: <web.3dcb3c88902ebc51ccdab82b0@news.povray.org>
This may be a newbie type question, but here goes:

I'm trying to use the HF_ functions in shapes.inc to generate a mesh from a
small .png file.

I simply added a new funtion to the example file given in the include files
demo. When I did, I got an error.



//==============================

#declare MyFunction = function{pattern {bumps scale 0.2}}
 // MyFunction above works...

#declare MyTest = function
 { pigment
   { image_map
     {png "testHF.png"
      map_type 0 interpolate 2
     }
    }
  } // <- this replacement produces an error.
    // shapes.inc pops up and marks the bit of code named above


object {
   HF_Square
    ( MyTest, // MyFunction was here, but I replaced it.
      off,
      off,
      <60,60>,
      on,
      "",
      <0.0, 0.1, 0.0>,
      <1.5, 0.5, 1.5>
    )
   texture {
      pigment {color rgb 1}
      finish {ShinyFinish}
   }
   translate <-3.0, 0.0,-3.2>
}

// ===========
// The error that happens pops up shapes.inc and a line in the
// HFCreate_() macro gets marked. See note below.
// ====
  #local J = 1;
   #while (J<=xRes)
      #local K = 1;
      #while (K<=zRes)
         PArr[J][K],   // <-- this code gets highlited in yellow
         #declare K = K+1;
      #end
      #declare J = J+1;
   #end

//====================================

What do I do to get an image file used as a function?
normdoering


Post a reply to this message

From: Marc-Hendrik Bremer
Subject: Re: HF_ macro question.
Date: 8 Nov 2002 03:05:12
Message: <3dcb7038@news.povray.org>
"normdoering" <nor### [at] yahoocom> schrieb im Newsbeitrag
news:web.3dcb3c88902ebc51ccdab82b0@news.povray.org...
> //==============================
>
> #declare MyFunction = function{pattern {bumps scale 0.2}}
>  // MyFunction above works...
>

As a pattern, this function returns a float value.

> #declare MyTest = function
>  { pigment
>    { image_map
>      {png "testHF.png"
>       map_type 0 interpolate 2
>      }
>     }
>   } // <- this replacement produces an error.
>     // shapes.inc pops up and marks the bit of code named above
>

As a pigment, this function returns a vector. Pov can handle
vector-functions only in special cases, therefor you have to convert the
output to a float value.

Try:

#declare MyTest=function{MyTest(x,y,z).hf}

(it's difficult to find but the dot-operators are explained in the docs
somewhere)

Hth,

Marc-Hendrik


Post a reply to this message

From: normdoering
Subject: Re: HF_ macro question.
Date: 8 Nov 2002 06:05:04
Message: <web.3dcb996edf16341f89ebea3f0@news.povray.org>
Marc-Hendrik Bremer wrote:
>"normdoering" <nor### [at] yahoocom> schrieb im Newsbeitrag
>news:web.3dcb3c88902ebc51ccdab82b0[at]news.povray.org...
>> //==============================
>>
>> #declare MyFunction = function{pattern {bumps scale 0.2}}
>>  // MyFunction above works...
>>
>
>As a pattern, this function returns a float value.
>
>> #declare MyTest = function
>>  { pigment
>>    { image_map
>>      {png "testHF.png"
>>       map_type 0 interpolate 2
>>      }
>>     }
>>   } // <- this replacement produces an error.
>>     // shapes.inc pops up and marks the bit of code named above
>>
>
>As a pigment, this function returns a vector. Pov can handle
>vector-functions only in special cases, therefor you have to convert the
>output to a float value.
>
>Try:
>
>#declare MyTest=function{MyTest(x,y,z).hf}
>
>(it's difficult to find but the dot-operators are explained in the docs
>somewhere)
>
>Hth,
>
>Marc-Hendrik
>

Thanks! I never would have figured that one out without help. Don't know
enough about the internal workings of pov yet.

normdoering


Post a reply to this message

From: normdoering
Subject: Re: HF_ macro question.
Date: 8 Nov 2002 07:20:04
Message: <web.3dcbab07df16341f5c65a5ba0@news.povray.org>
normdoering wrote:
>Marc-Hendrik Bremer wrote:
>>"normdoering" <nor### [at] yahoocom> schrieb im Newsbeitrag
>>news:web.3dcb3c88902ebc51ccdab82b0[at]news.povray.org...
>>> //==============================
>>>
>>> #declare MyFunction = function{pattern {bumps scale 0.2}}
>>>  // MyFunction above works...
>>>
>>
>>As a pattern, this function returns a float value.
>>
>>> #declare MyTest = function
>>>  { pigment
>>>    { image_map
>>>      {png "testHF.png"
>>>       map_type 0 interpolate 2
>>>      }
>>>     }
>>>   } // <- this replacement produces an error.
>>>     // shapes.inc pops up and marks the bit of code named above
>>>
>>
>>As a pigment, this function returns a vector. Pov can handle
>>vector-functions only in special cases, therefor you have to convert the
>>output to a float value.
>>
>>Try:
>>
>>#declare MyTest=function{MyTest(x,y,z).hf}
>>
>>(it's difficult to find but the dot-operators are explained in the docs
>>somewhere)
>>
>>Hth,
>>
>>Marc-Hendrik
>>
>
>Thanks! I never would have figured that one out without help. Don't know
>enough about the internal workings of pov yet.
>
>normdoering
>

I spoke too soon. Adding your line of code got rid of the error, but the
image doesn't appear on the "height field." All I get is a flat rectangle.

normdoering


Post a reply to this message

From: Warp
Subject: Re: HF_ macro question.
Date: 8 Nov 2002 10:12:36
Message: <3dcbd464@news.povray.org>
This is at least the fifth place where you ask this same question.

  Posting a question once is usually enough.

-- 
#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: normdoering
Subject: Re: HF_ macro question.
Date: 8 Nov 2002 17:10:03
Message: <web.3dcc3593df16341f55d3e9910@news.povray.org>
Warp wrote:
>  This is at least the fifth place where you ask this same question.
>
>  Posting a question once is usually enough.
>
>#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
>-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -
>

Sorry, I was frustrated and wanted an answer fast.

At any rate -- some additional information:

Dot operators are mentioned in the section on isosurfaces (at tail end of
section 6.5.4.2) and there's more than .hf -- there's .grey (which works as
well for grey scales) and .red, .green, .blue, and .transmit -- which means
there is even more creative potential for this kind of macro.

normdoering


Post a reply to this message

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