POV-Ray : Newsgroups : povray.advanced-users : Problems with #default and #ifdef Server Time
30 Jul 2024 00:26:02 EDT (-0400)
  Problems with #default and #ifdef (Message 1 to 4 of 4)  
From: Nicolas Calimet
Subject: Problems with #default and #ifdef
Date: 21 Nov 2000 10:02:29
Message: <3A1A9FCC.278FA382@free.fr>
Hi,

	Long time ago I noticed POV-Ray 3.1g (UNIX) had problems when
using the following code. Should it be considered as a bug or am I
missing something ? Also I wonder why it's not possible to use a
material{} statement in #default{} (but only texture|pigment|finish|
normal as the docs say).

//-----------------------------------------------------------------
#version 3.1;

sphere{<0,0,5>,1 pigment{rgb 0}}

//#declare test = 1;
#ifdef(test) #render "\ntest\n" #end                       // works
#ifdef(test) #render str(test,0,6) #end                    // works
#ifdef(test) #declare a = test; #end                       // works
#ifdef(test) #declare t = texture{pigment{rgb test}} #end  // works

// all next stop on error due to unknown variables

#ifdef(test) #default{texture{pigment{rgb test}} #end

//#declare my_pig = pigment{rgb 1}
#ifdef(my_pig) #default{pigment{my_pig}} #end

//#declare my_finish = finish{reflection 0.5} #end
#ifdef(my_finish) #default{finish{my_finish}} #end

//#declare my_norm = normal{bumps 1}
#ifdef(my_norm) #default{normal{my_norm}}  #end

//#declare my_texture = texture{pigment{rgb 1}}
#ifdef(my_texture) #default{texture {my_texture}} #end
//-----------------------------------------------------------------


*** Nicolas Calimet
*** http://pov4grasp.free.fr


Post a reply to this message

From: Chris Colefax
Subject: Re: Problems with #default and #ifdef
Date: 21 Nov 2000 18:14:19
Message: <3a1b01cb@news.povray.org>
Nicolas Calimet <pov### [at] freefr> wrote:
> Long time ago I noticed POV-Ray 3.1g (UNIX) had problems when
> using the following code. Should it be considered as a bug or am I
> missing something ? Also I wonder why it's not possible to use a
> material{} statement in #default{} (but only texture|pigment|finish|
> normal as the docs say).

It would appear that the hash in front of default causes the parser to
execute the directive even though the definition test evaluates to false.
Removing the hashes from the default directives allows the file to work as
expected, e.g.:

   #ifdef (text) default {pigment {rgb test}} #end

In answer to your second question, I would imagine the default directive
uses a texture structure internally, rather than a material structure, as
this is what it was designed for.  A simple workaround, of course, is to
declare your own default material which you apply to all objects.


Post a reply to this message

From: Mark Wagner
Subject: Re: Problems with #default and #ifdef
Date: 21 Nov 2000 23:53:50
Message: <3a1b515e@news.povray.org>
Nicolas Calimet wrote in message <3A1A9FCC.278FA382@free.fr>...
>Also I wonder why it's not possible to use a
>material{} statement in #default{} (but only texture|pigment|finish|
>normal as the docs say).

This is because POV-Ray stores the default texture as a non-layered texture,
rather than as a material.

--
Mark


Post a reply to this message

From: Nicolas Calimet
Subject: Re: Problems with #default and #ifdef
Date: 22 Nov 2000 06:41:37
Message: <3A1BC235.90268B70@free.fr>
> It would appear that the hash in front of default causes the parser to
> execute the directive even though the definition test evaluates to false.

	So it definitely sounds like a bug... at least to me. I simply
don't know if someone reported it before, and if not, to mention it in
the proper group (maybe).

> Removing the hashes from the default directives allows the file to work as
> expected, e.g.: 
>    #ifdef (text) default {pigment {rgb test}} #end

	Ah, that's interesting. I should investigate the source code which
parses the `#` expressions. Okay, anyway this is a simple workaround, and
there are also many others.
	Thanks.


*** Nicolas Calimet
*** http://pov4grasp.free.fr


Post a reply to this message

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