POV-Ray : Newsgroups : povray.newusers : Macro Woes Server Time
5 Sep 2024 18:19:20 EDT (-0400)
  Macro Woes (Message 1 to 8 of 8)  
From: Ian Burgmyer
Subject: Macro Woes
Date: 29 Sep 1999 23:54:55
Message: <37f2df0f@news.povray.org>
I'm having serious problem with macros.  As most of you probably know, I
released an image from the output of my Sphere Spreader 2000.  It created a
sphere in the center with smaller ones going out in four directions.  Sorta.
You'll have to see it, it's on p.b.i.

Anyways, to my problem.  I am trying to have it rotate on every iteration.
However, not without serious problems.  Every time I compile my source (at
the bottom of this message) I get the following error:

-------------------------------
C:\My Documents\POV-Ray Sources\Mine!\Attempts\Sphere.pov:31: error: No
matching } in object, union found instead.

Returned from renderer (non-zero return value)
-------------------------------

You wouldn't believe the crap I went through trying to fix it :(

Any help would be GREATLY appreciated!  Also, please comment on my code
structure.  If it's messy, please tell me how I can fix it.  I really want
to improve at hand-coding.  Hell, maybe I'll just make macros ;)

--
This message brought to you by:
-=< Ian (the### [at] hotmailcom >=-

Please visit my site at spectere2000.cjb.net! :)

// POV-Ray Scene File
// Filename: Sphere.pov
// Date: v.1.0 - 9/21/99
// Author: Ian Burgmyer
//

#version 3.1

#include "textures.inc"

#declare SphereTexture = Ruby_Glass

#macro SphereMacro(Amount, StartSize, SizeDivide, RotationSpeed)
  #declare Counter = 0;
  #declare Pos = 0;
  #declare SizeNow = StartSize;
  #declare Rotation = 0 - RotationSpeed;

// Note: Some statements are commented out, as you can see.
// This is some code from the old macro that I didn't want to remove
// just in case. . . :(
  #while (Counter < Amount)
//    #if (Counter != 0)
      MakeSpheres()
//    #else

// ---
// The original purpose of the following statement was to save you
// 3 objects.
// --
//      sphere { <0,0,0>, StartSize texture{SphereTexture} }
//    #end
    #debug concat(str(Counter, 0, 0) + "th Loop")
    #declare Counter = Counter + 1;
  #end
#end

// This used to be in the above macro without a problem.
// I put it here and STILL have trouble :(
#macro MakeSpheres()
  union {
    #declare SizeNow = SizeNow / SizeDivide;
    #declare Pos = Pos+(SizeDivide*SizeNow);
    #declare Rotation = Rotation + RotationSpeed
    sphere { <0-Pos, 0+Pos, 0-Pos>, SizeNow texture{SphereTexture} }
    sphere { <0+Pos, 0+Pos, 0-Pos>, SizeNow texture{SphereTexture} }
    sphere { <0-Pos, 0-Pos, 0-Pos>, SizeNow texture{SphereTexture} }
    sphere { <0+Pos, 0-Pos, 0-Pos>, SizeNow texture{SphereTexture} }
    rotate <0, 0, Rotation> }
#end

global_settings
{
  assumed_gamma 2

  radiosity
  {
    count 250
  }
}

// -----------------
// Scene starts here
// -----------------

camera
{
  location  <0.0, 0, -12.0>
  direction 1.5*z
  right     4/3*x
  look_at   <0.0, 0.0,  0.0>
}

sky_sphere {
  pigment {
    gradient y
    color_map {
      [0.000 0.002 color rgb <0.05, 0.05, 0.3>
                   color rgb <0.05, 0.05, 0.5>]
      [0.002 0.200 color rgb <0.05, 0.05, 0.7>
                   color rgb <0.05, 0.05, 0.9>]
    }
    translate -1
  }
  pigment {
    bozo
    turbulence 0.65
    octaves 6
    omega 0.7
    lambda 2
    color_map {
      [0.0 0.1 color rgbt <0.85, 0.85, 0.85, 0>
               color rgbt <0.85, 0.85, 0.85, 0.1>]
      [0.1 0.3 color rgbt <0.85, 0.85, 0.85, 0.1>
               color rgbt <0.85, 0.85, 0.85, 0.333>]
      [0.3 0.6 color rgbt <0.85, 0.85, 0.85, 0.333>
               color rgbt <0.85, 0.85, 0.85, 0.667>]
      [0.6 0.8 color rgbt <0.85, 0.85, 0.85, 0.667>
               color rgbt <0.85, 0.85, 0.85, 1>]
      [0.8 0.9 color rgbt <0.85, 0.85, 0.85, 1>
               color rgbt <0.85, 0.85, 0.85, 1>]
      [0.9 1.0 color rgbt <0.85, 0.85, 0.85, 1>
               color rgbt <0.85, 0.85, 0.85, 1>]
    }
    scale <0.1, 0.2, 0.1>
  }
  rotate -135*x
}

light_source {<0.333, 0.333, -2>}

object { SphereMacro(15, 1, 1.5, 10)


Post a reply to this message

From: Jon A  Cruz
Subject: Re: Macro Woes
Date: 30 Sep 1999 02:28:49
Message: <37F30333.63C38A41@geocities.com>
Ian Burgmyer wrote:

> I'm having serious problem with macros.  As most of you probably know, I
> released an image from the output of my Sphere Spreader 2000.  It created a
> sphere in the center with smaller ones going out in four directions.  Sorta.
> You'll have to see it, it's on p.b.i.
>
> Anyways, to my problem.  I am trying to have it rotate on every iteration.
> However, not without serious problems.  Every time I compile my source (at
> the bottom of this message) I get the following error:
>

[SNIP]

> object { SphereMacro(15, 1, 1.5, 10)

That's the problem line. To my well trained programmer's eye (he he he, yeah
right) it is immediately appearent that something is amiss.

For proper coding & indention, it should look like this:

  object {
    SphereMacro(15, 1, 1.5, 10)
  }

Notice the lack of a closing parenthesis on your code? That's the give-away.
Now, we go back up where SphereMacro is defined and see...

yes. It's a macro, not a #declare.

Just change to this and all is well:

SphereMacro(15, 1, 1.5, 10)

No more 'object' needed.

Or, if you really want to use 'object', then just

#delcare anInstance = SphereMacro(15, 1, 1.5, 10)
object {
  anInstance
}


--
"My new computer's got the clocks, it rocks
But it was obsolete before I opened the box" - W.A.Y.


Post a reply to this message

From: Ian Burgmyer
Subject: Re: Macro Woes
Date: 30 Sep 1999 02:42:17
Message: <37f30649@news.povray.org>
Thank you *so* much!  Me stupid, no?

--
This message brought to you by:
-=< Ian (the### [at] hotmailcom >=-

Please visit my site at http://spectere2000.cjb.net! :)

Jon A. Cruz <jon### [at] geocitiescom> wrote in message
news:37F30333.63C38A41@geocities.com...
> Ian Burgmyer wrote:
>
> > I'm having serious problem with macros.  As most of you probably know, I
> > released an image from the output of my Sphere Spreader 2000.  It
created a
> > sphere in the center with smaller ones going out in four directions.
Sorta.
> > You'll have to see it, it's on p.b.i.
> >
> > Anyways, to my problem.  I am trying to have it rotate on every
iteration.
> > However, not without serious problems.  Every time I compile my source
(at
> > the bottom of this message) I get the following error:
> >
>
> [SNIP]
>
> > object { SphereMacro(15, 1, 1.5, 10)
>
> That's the problem line. To my well trained programmer's eye (he he he,
yeah
> right) it is immediately appearent that something is amiss.
>
> For proper coding & indention, it should look like this:
>
>   object {
>     SphereMacro(15, 1, 1.5, 10)
>   }
>
> Notice the lack of a closing parenthesis on your code? That's the
give-away.
> Now, we go back up where SphereMacro is defined and see...
>
> yes. It's a macro, not a #declare.
>
> Just change to this and all is well:
>
> SphereMacro(15, 1, 1.5, 10)
>
> No more 'object' needed.
>
> Or, if you really want to use 'object', then just
>
> #delcare anInstance = SphereMacro(15, 1, 1.5, 10)
> object {
>   anInstance
> }
>
>
> --
> "My new computer's got the clocks, it rocks
> But it was obsolete before I opened the box" - W.A.Y.
>
>
>


Post a reply to this message

From: Nieminen Juha
Subject: Re: Macro Woes
Date: 30 Sep 1999 03:32:40
Message: <37f31218@news.povray.org>
Jon A. Cruz <jon### [at] geocitiescom> wrote:
: Or, if you really want to use 'object', then just

: #delcare anInstance = SphereMacro(15, 1, 1.5, 10)
: object {
:   anInstance
: }

  What's wrong with

object { SphereMacro(15, 1, 1.5, 10) }

?

  It's shorter and as clear as using a previous #declare.
  It's easy to add transformations:

object
{ SphereMacro(15, 1, 1.5, 10)
  scale 10 translate -x*5
}


-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Jon A  Cruz
Subject: Re: Macro Woes
Date: 30 Sep 1999 03:57:12
Message: <37F317EA.3BBE25D1@geocities.com>
Nieminen Juha wrote:

> Jon A. Cruz <jon### [at] geocitiescom> wrote:
> : Or, if you really want to use 'object', then just
>
> : #delcare anInstance = SphereMacro(15, 1, 1.5, 10)
> : object {
> :   anInstance
> : }
>
>   What's wrong with
>
> object { SphereMacro(15, 1, 1.5, 10) }
>
> ?
>
>   It's shorter and as clear as using a previous #declare.
>   It's easy to add transformations:
>
> object
> { SphereMacro(15, 1, 1.5, 10)
>   scale 10 translate -x*5
> }
>

Well, the main thing wrong with "object { SphereMacro(15, 1, 1.5, 10) }" is
that at least with the way he has his macro defined, it will cause errors in
POV-Ray. The object needs the #declared to work.

But, if his macro were changed to create a single POV-Ray object, then it
could be used in such a case. At the moment it creates a set of objects, and
not a single object.

Well, I guess I'd better re-work things so that he can do the simple
object{} thing.

Here it is. Notice the extra "union {" added after the "just in case"
comment. And the closing "}" just before the last end. That's the main magic
to get it to work.

#macro SphereMacro(Amount, StartSize, SizeDivide, RotationSpeed)
  #local Counter = 0;
  #local Pos = 0;
  #local SizeNow = StartSize;
  #local Rotation = 0 - RotationSpeed;

// Note: Some statements are commented out, as you can see.
// This is some code from the old macro that I didn't want to remove
// just in case. . . :(
  union {
    #while (Counter < Amount)
//    #if (Counter != 0)
      union {
 #local SizeNow = SizeNow / SizeDivide;
 #local Pos = Pos+(SizeDivide*SizeNow);
 #local Rotation = Rotation + RotationSpeed;
 sphere { <0-Pos, 0+Pos, 0-Pos>, SizeNow texture{SphereTexture} }
 sphere { <0+Pos, 0+Pos, 0-Pos>, SizeNow texture{SphereTexture} }
 sphere { <0-Pos, 0-Pos, 0-Pos>, SizeNow texture{SphereTexture} }
 sphere { <0+Pos, 0-Pos, 0-Pos>, SizeNow texture{SphereTexture} }
 rotate <0, 0, Rotation>
      }
//    #else

// ---
// The original purpose of the following statement was to save you
// 3 objects.
// --
      sphere { <0,0,0>, StartSize texture{SphereTexture} }
//    #end
      #debug concat(str(Counter, 0, 0) + "th Loop")
      #declare Counter = Counter + 1;
    #end
  }
#end


--
"My new computer's got the clocks, it rocks
But it was obsolete before I opened the box" - W.A.Y.


Post a reply to this message

From: Nieminen Juha
Subject: Re: Macro Woes
Date: 30 Sep 1999 04:04:59
Message: <37f319ab@news.povray.org>
Jon A. Cruz <jon### [at] geocitiescom> wrote:
: Well, the main thing wrong with "object { SphereMacro(15, 1, 1.5, 10) }" is
: that at least with the way he has his macro defined, it will cause errors in
: POV-Ray. The object needs the #declared to work.

: But, if his macro were changed to create a single POV-Ray object, then it
: could be used in such a case. At the moment it creates a set of objects, and
: not a single object.

  I didn't notice that. But declaring will not help either. If the macro
creates several objects, only the first one will be the value of the
declared identifier. The rest will be part of the scene by themselves.
  This will show up clearly if you try to use the identifier in two places.

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Jon A  Cruz
Subject: Re: Macro Woes
Date: 30 Sep 1999 10:16:12
Message: <37F370BC.9CDEF480@geocities.com>
Nieminen Juha wrote:

> Jon A. Cruz <jon### [at] geocitiescom> wrote:
> : Well, the main thing wrong with "object { SphereMacro(15, 1, 1.5, 10) }" is
> : that at least with the way he has his macro defined, it will cause errors in
> : POV-Ray. The object needs the #declared to work.
>
> : But, if his macro were changed to create a single POV-Ray object, then it
> : could be used in such a case. At the moment it creates a set of objects, and
> : not a single object.
>
>   I didn't notice that. But declaring will not help either. If the macro
> creates several objects, only the first one will be the value of the
> declared identifier. The rest will be part of the scene by themselves.
>   This will show up clearly if you try to use the identifier in two places.

Well, declaring does help. but you're right on some of what is and is not
declared. The main thing is that for his scene, the #declare will work-around the
errors. With it things work; without it things don't.

But a more proper work-around would be

#declare anInstance = union {
  SphereMacro( 15, 1, 1.5, 10)
}
object {
  anInstance
}

But since we see that we are just adding the "union {" anyway, it makes sense to
place it up in the macro to begin with.

--
"My new computer's got the clocks, it rocks
But it was obsolete before I opened the box" - W.A.Y.


Post a reply to this message

From: Ian Burgmyer
Subject: Re: Macro Woes
Date: 30 Sep 1999 18:57:17
Message: <37f3eacd@news.povray.org>
Okay, I cleaned up the code quite a bit, and now there are no longer two
unions.  Only one in the MakeSphere() macro.

--
This message brought to you by:
-=< Ian (the### [at] hotmailcom >=-

Please visit my site at http://spectere2000.cjb.net! :)

Jon A. Cruz <jon### [at] geocitiescom> wrote in message
news:37F317EA.3BBE25D1@geocities.com...
> Here it is. Notice the extra "union {" added after the "just in case"
> comment. And the closing "}" just before the last end. That's the main
magic
> to get it to work.


Post a reply to this message

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