POV-Ray : Newsgroups : povray.general : Round_Box-weirdness Server Time
26 Nov 2024 07:34:15 EST (-0500)
  Round_Box-weirdness (Message 1 to 6 of 6)  
From: Marco
Subject: Round_Box-weirdness
Date: 13 Feb 2011 09:30:00
Message: <web.4d57eaa9c85769096731f09e0@news.povray.org>
I hqve the ewirdest thing: I copied a Round_Box_Union, but cannot give it a
texture, like the round_box I copied it from. In the 2nd I get this error (note:
only in the 2nd one, not the first! ???)

Parse Error: Expected 'object or directive', texture found instead

#declare listBox=union{
        Round_Box_Union
(
        //<-7, 0.25, 6> <-1, 1.25, -7>, 0.2)
        <-7, 0.25, 6> <-1, 1.5, -7>, 0.2)
        texture {T_Gold_1A}
}

        Round_Box_Union
(
        //<-7, 0.25, 6> <-1, 1.25, -7>, 0.2)
        <-8.5, 0.25, 6> <-7.5, 1.25, -7>, 0.1)
        texture {T_Gold_1A}
}

This has worked before, before I added the 2nd Round_Box I did get a nicely
rendered
Round_Box, with fancy Gold_1A texture and all.


Post a reply to this message

From: Jim Holsenback
Subject: Re: Round_Box-weirdness
Date: 13 Feb 2011 11:47:17
Message: <4d580b15$1@news.povray.org>
On 02/13/2011 10:29 AM, Marco wrote:
> I hqve the ewirdest thing: I copied a Round_Box_Union, but cannot give it a
> texture, like the round_box I copied it from. In the 2nd I get this error (note:
> only in the 2nd one, not the first! ???)
> 
> Parse Error: Expected 'object or directive', texture found instead
> 
> #declare listBox=union{
>         Round_Box_Union
> (
>         //<-7, 0.25, 6> <-1, 1.25, -7>, 0.2)
>         <-7, 0.25, 6> <-1, 1.5, -7>, 0.2)
>         texture {T_Gold_1A}
> }
> 
>         Round_Box_Union
> (
>         //<-7, 0.25, 6> <-1, 1.25, -7>, 0.2)
>         <-8.5, 0.25, 6> <-7.5, 1.25, -7>, 0.1)
>         texture {T_Gold_1A}
> }
> 
> This has worked before, before I added the 2nd Round_Box I did get a nicely
> rendered
> Round_Box, with fancy Gold_1A texture and all.
> 
> 
> 
try this instead ...

#declare listBox =
union {
	object {
		Round_Box_Union (<-7, 0.25, 6>, <-1, 1.5, -7> 0.2)
		texture {T_Gold_1A}
		}
	object {
		Round_Box_Union (<-8.5, 0.25, 6>, <-7.5, 1.25, -7>, 0.1)
		texture {T_Gold_1A}
		}
	};


Post a reply to this message

From: Alain
Subject: Re: Round_Box-weirdness
Date: 13 Feb 2011 15:51:31
Message: <4d584453@news.povray.org>

> I hqve the ewirdest thing: I copied a Round_Box_Union, but cannot give it a
> texture, like the round_box I copied it from. In the 2nd I get this error (note:
> only in the 2nd one, not the first! ???)
>
> Parse Error: Expected 'object or directive', texture found instead
>
> #declare listBox=union{
>          Round_Box_Union
> (
>          //<-7, 0.25, 6>  <-1, 1.25, -7>, 0.2)
>          <-7, 0.25, 6>  <-1, 1.5, -7>, 0.2)
>          texture {T_Gold_1A}
> }
>
>          Round_Box_Union
> (
>          //<-7, 0.25, 6>  <-1, 1.25, -7>, 0.2)
>          <-8.5, 0.25, 6>  <-7.5, 1.25, -7>, 0.1)
>          texture {T_Gold_1A}
> }
>
> This has worked before, before I added the 2nd Round_Box I did get a nicely
> rendered
> Round_Box, with fancy Gold_1A texture and all.
>
>
>

just a single missing curly bracket "{" after the second round_box_union...


Alain


Post a reply to this message

From: clipka
Subject: Re: Round_Box-weirdness
Date: 13 Feb 2011 20:12:58
Message: <4d58819a$1@news.povray.org>
Am 13.02.2011 15:29, schrieb Marco:
> I hqve the ewirdest thing: I copied a Round_Box_Union, but cannot give it a
> texture, like the round_box I copied it from. In the 2nd I get this error (note:
> only in the 2nd one, not the first! ???)
>
> Parse Error: Expected 'object or directive', texture found instead
>
> #declare listBox=union{
>          Round_Box_Union
> (
>          //<-7, 0.25, 6>  <-1, 1.25, -7>, 0.2)
>          <-7, 0.25, 6>  <-1, 1.5, -7>, 0.2)
>          texture {T_Gold_1A}
> }
>
>          Round_Box_Union
> (
>          //<-7, 0.25, 6>  <-1, 1.25, -7>, 0.2)
>          <-8.5, 0.25, 6>  <-7.5, 1.25, -7>, 0.1)
>          texture {T_Gold_1A}
> }
>
> This has worked before, before I added the 2nd Round_Box I did get a nicely
> rendered
> Round_Box, with fancy Gold_1A texture and all.

Jim already posted the proper solution; to understand what is happening, 
let's reformat your code to better see the structure (which is always a 
good idea when you get errors you don't understand):

#declare listBox = union {
     Round_Box_Union(<-7, 0.25, 6>  <-1, 1.5, -7>, 0.2)
     texture {T_Gold_1A}
     Round_Box_Union(<-8.5, 0.25, 6>  <-7.5, 1.25, -7>, 0.1)
     texture {T_Gold_1A}
}

Now recall that the Round_Box_Union macro evaluates to a union itself, 
so here's an outline of what your code evaluates to:

#declare listBox = union {
     union {...}
     texture {T_Gold_1A}
     union {...}
     texture {T_Gold_1A}
}

As you can see, the texture statements doen't pertain to each individual 
rounded box union - they pertain to your whole listBox union instead. 
Which is obviously not what you intended to do.

In this case, where the textures are identical, the solution is trivial: 
Just remove the first texture statement. However, if you need one of the 
boxes to have a different texture, you'll have to apply the textures to 
the individual boxes.

Obviously you can't add the textures to the Round_Box_Union in a 
straightforward way, as that's a macro. However, if you first assign the 
macro results to an identifier, the solution should be pretty obvious:

#declare MyRoundedBox1 = Round_Box_Union(...)
#declare MyRoundedBox2 = Round_Box_Union(...)
#declare listBox = union {
   object { MyRoundedBox1 texture {...} }
   object { MyRoundedBox2 texture {...} }
}

And, as Jim already demonstrated, the object statement doesn't 
necessarily require an identifier; you can instead insert full-fledged 
object descriptions there, e.g.:

object { sphere {...} ... }

This of course is pretty useless for verbatim object descriptions, but 
is pretty useful when using macros that expand to a full object 
description - as in your case:

#declare listBox = union {
   object { Round_Box_Union(...) texture {...} }
   object { Round_Box_Union(...) texture {...} }
}


Post a reply to this message

From: Slime
Subject: Re: Round_Box-weirdness
Date: 13 Feb 2011 21:37:47
Message: <4d58957b$1@news.povray.org>
> Jim already posted the proper solution; to understand what is
 > happening, let's reformat your code to better see the structure
 > (which is always a good idea when you get errors you don't
 > understand):

I agree that code formatting is important. However, when you reformatted 
it, you actually removed the error! (Thus underscoring how easy it is to 
overlook errors in poorly formatted code.)

The original code was this:

#declare listBox=union{
         Round_Box_Union
(
         //<-7, 0.25, 6> <-1, 1.25, -7>, 0.2)
         <-7, 0.25, 6> <-1, 1.5, -7>, 0.2)
         texture {T_Gold_1A}
}

         Round_Box_Union
(
         //<-7, 0.25, 6> <-1, 1.25, -7>, 0.2)
         <-8.5, 0.25, 6> <-7.5, 1.25, -7>, 0.1)
         texture {T_Gold_1A}
}


If we carefully reformat it, we get:

#declare listBox = union
{
     Round_Box_Union( <-7, 0.25, 6> <-1, 1.5, -7>, 0.2 )
     texture { T_Gold_1A }
}

Round_Box_Union( <-8.5, 0.25, 6> <-7.5, 1.25, -7>, 0.1 )
texture { T_Gold_1A }

}


See the problem now? Look how obvious it becomes with proper indentation!

  - Slime


Post a reply to this message

From: Jim Holsenback
Subject: Re: Round_Box-weirdness
Date: 14 Feb 2011 08:07:12
Message: <4d592900$1@news.povray.org>
On 02/13/2011 10:37 PM, Slime wrote:
> Look how obvious it becomes with proper indentation!
> 
>  - Slime

yep ... without fail it's usually cures my syntax woes ;-)


Post a reply to this message

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