POV-Ray : Newsgroups : povray.general : Hex in Pov-ray. Server Time
31 Jul 2024 16:27:03 EDT (-0400)
  Hex in Pov-ray. (Message 1 to 4 of 4)  
From: JS
Subject: Hex in Pov-ray.
Date: 3 Jan 2007 18:10:00
Message: <web.459c36d822a5f346188aeae70@news.povray.org>
Hi, all.

Maybe I've missed this, but could someone please tell me how I can use HEX
instead of decimal numbers for constants. I trying to use data to construct
3D models with hex values without having to convert them to decimal.

Thank you for your time.


Post a reply to this message

From: Chris B
Subject: Re: Hex in Pov-ray.
Date: 3 Jan 2007 19:28:57
Message: <459c4a49$1@news.povray.org>
"JS" <bos### [at] yahoocouk> wrote in message
news:web.459c36d822a5f346188aeae70@news.povray.org...
> Hi, all.
>
> Maybe I've missed this, but could someone please tell me how I can use HEX
> instead of decimal numbers for constants. I trying to use data to
> construct
> 3D models with hex values without having to convert them to decimal.
>
> Thank you for your time.
>

Hi,

I can't think of anything in POV-Ray that handles hexadecimal numbers.
Someone else may know better, but I'd say you'll have to convert them.
Here's a simple POV-Ray conversion macro that should enable you to use
hexadecimal numbers inline in your SDL.

#macro X2D(Hex)
  #local Digits = "0123456789ABCDEF";
  #local Hex = strupr(Hex);
  #local I = strlen(Hex);
  #local Decimal = 0;
  #local Factor = 1;
  #while (I>0)
     #local Character = substr(Hex,I,1);
     #local J = 0;
     #local Found = 0;
     #while (J<strlen(Digits))
        #if (strcmp(Character,substr(Digits,J+1,1))=0)
          #local Decimal = Decimal + J * Factor;
          #local Found = 1;
        #end
        #local J = J + 1;
     #end
     #if (!Found) #error concat("\nX2D - Character position ",str(I,3,0),
"of ",Hex," contains an invalid Hex character\n\n") #end
     #local Factor = Factor * 16;
     #local I = I-1;
  #end
  Decimal
#end

#declare MyValue = X2D("01F");

#debug concat("\nDecimal Value: ",str(MyValue,10,0),"\n\n")

Hope this helps,

Regards,
Chris B.


Post a reply to this message

From: JS
Subject: Re: Hex in Pov-ray.
Date: 3 Jan 2007 19:40:00
Message: <web.459c4be41a504e09188aeae70@news.povray.org>
"Chris B" <c_b### [at] btconnectcomnospam> wrote:
> "JS" <bos### [at] yahoocouk> wrote in message
> news:web.459c36d822a5f346188aeae70@news.povray.org...
> > Hi, all.
> >
> > Maybe I've missed this, but could someone please tell me how I can use HEX
> > instead of decimal numbers for constants. I trying to use data to
> > construct
> > 3D models with hex values without having to convert them to decimal.
> >
> > Thank you for your time.
> >
>
> Hi,
>
> I can't think of anything in POV-Ray that handles hexadecimal numbers.
> Someone else may know better, but I'd say you'll have to convert them.
> Here's a simple POV-Ray conversion macro that should enable you to use
> hexadecimal numbers inline in your SDL.
>
> #macro X2D(Hex)
>   #local Digits = "0123456789ABCDEF";
>   #local Hex = strupr(Hex);
>   #local I = strlen(Hex);
>   #local Decimal = 0;
>   #local Factor = 1;
>   #while (I>0)
>      #local Character = substr(Hex,I,1);
>      #local J = 0;
>      #local Found = 0;
>      #while (J<strlen(Digits))
>         #if (strcmp(Character,substr(Digits,J+1,1))=0)
>           #local Decimal = Decimal + J * Factor;
>           #local Found = 1;
>         #end
>         #local J = J + 1;
>      #end
>      #if (!Found) #error concat("nX2D - Character position ",str(I,3,0),
> "of ",Hex," contains an invalid Hex characternn") #end
>      #local Factor = Factor * 16;
>      #local I = I-1;
>   #end
>   Decimal
> #end
>
> #declare MyValue = X2D("01F");
>
> #debug concat("nDecimal Value: ",str(MyValue,10,0),"nn")
>
> Hope this helps,
>
> Regards,
> Chris B.

Thankyou, Chris B, I'll try it out. What about if hex support was added for
a future release of Pov-Ray?


Post a reply to this message

From: pan
Subject: Re: Hex in Pov-ray.
Date: 3 Jan 2007 23:20:39
Message: <459c8097$1@news.povray.org>
"JS" <bos### [at] yahoocouk> wrote in message 
news:web.459c36d822a5f346188aeae70@news.povray.org...
> Hi, all.
>
> Maybe I've missed this, but could someone please tell me how I 
> can use HEX
> instead of decimal numbers for constants. I trying to use data to 
> construct
> 3D models with hex values without having to convert them to 
> decimal.
>
> Thank you for your time.
>
>

http://news.povray.org/povray.text.scene-files/thread/%3Cweb.44184ac05017e713dbc416040@news.povray.org%3E/


Post a reply to this message

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