POV-Ray : Newsgroups : povray.general : Macro Problem Server Time
19 Apr 2024 08:21:06 EDT (-0400)
  Macro Problem (Message 11 to 19 of 19)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Bald Eagle
Subject: Re: Macro Problem
Date: 22 Apr 2018 18:10:00
Message: <web.5add0796ff561b5a5cafe28e0@news.povray.org>
"Thorsten Froehlich" <nomail@nomail> wrote:

> I would argue that the layered texture feature is defective by design. It is
> pretty much the only case where two blocks of the same kind without any wrapper
> have a special meaning.

I would agree.

Also, Sven, whenever you see something expected, another thing found instead,
then what you need to do is think about why POV-Ray is looking for, in this case
")".   This is a very valuable general debugging skill that will serve you well
in the future.

I think _one_ simple fix could be for Sven to wrap the layered texture in a
material {} definition, and then call the macro before trying to invoke the
texture{} ---> material{}.

Then he can do something like

MyBrownSimpleQuoVadis(x)   // "returns" a #declared CurrentMaterial
object {
PostsSideRailing
(0.725,0.30,0.60,4.50,0.65,1.5,0.02,-90.0,6.675,CurrentMaterial)
translate < -20.9, 0.0, 0.0 > }

I'm sure there are many more solution permutations.


Post a reply to this message

From: Sven Littkowski
Subject: Re: Macro Problem
Date: 22 Apr 2018 20:26:04
Message: <5add281c$1@news.povray.org>
The problem with layered textures and another texture on top of that, is
easy to bypass:

- creating a layered texture
- putting this layered texture on a declared (named) shape
- calling this object and applying now another texture to it

I believe, I did that a few times. Or something similar to this. Not the
perfect solution for all needs, but it works.

But what can be done about my real problem, the macro-macro situation?
Can any fix be done?

The suggestion to call first the texture macro and only afterwards the
object macro, would cause many, many, many more new code lines. If I can
avoid that, I would. Sounds like an urgent patch reason to me...

---
Diese E-Mail wurde von AVG auf Viren geprüft.
http://www.avg.com


Post a reply to this message

From: clipka
Subject: Re: Macro Problem
Date: 23 Apr 2018 11:27:08
Message: <5addfb4c$1@news.povray.org>
Am 23.04.2018 um 02:26 schrieb Sven Littkowski:

> But what can be done about my real problem, the macro-macro situation?
> Can any fix be done?
> 
> The suggestion to call first the texture macro and only afterwards the
> object macro, would cause many, many, many more new code lines. If I can
> avoid that, I would. Sounds like an urgent patch reason to me...

Yes, actually there's a way: You can move the assignment to a variable
into the macro itself, essentially using the following construct:

    #macro MyBrownSimpleQuoVadis(...)
      ...
      #local Result =
      #switch(...)
        #case(1)
          texture { ... }
          texture { ... }
        #break
        ...
      #end

      Result
    #end

    ...

    object {
    PostsSideRailing(..., MyBrownSimpleQuoVadis(x))
    ... }

This way, the `texture{...} texture{...}` followed by `#break` doesn't
technically occur in the context of the `PostsSideRailing` macro
invocation, but rather in the context of a `#local` assignment, where it
doesn't lead to a problem. In the context of the `PostsSideRailing`
macro invocation, all that's visible is the `Return` variable
identifier, which also is unproblematic.


I guess I can't repeat this too often: When writing a macro to construct
an individual texture, object, pigment or what-have-you, it is very good
practice to first assign the thing to a local variable (which I tend to
call `Result`), and then have the macro "emit" just that variable itself.


Post a reply to this message

From: Bald Eagle
Subject: Re: Macro Problem
Date: 23 Apr 2018 12:55:00
Message: <web.5ade0ee7ff561b5ac437ac910@news.povray.org>
So, essentially what you're saying is, when writing a macro to construct
an individual texture, object, pigment or what-have-you, it is very good
practice to first assign the thing to a local variable (which I tend to
call `Result`), and then have the macro "emit" just that variable itself?


Post a reply to this message

From: Sven Littkowski
Subject: Re: Macro Problem
Date: 23 Apr 2018 13:21:48
Message: <5ade162c$1@news.povray.org>
Sounds good! I will give a try. It is kinda new to me, I might need some
more practical help. But I am going ahead now and add the RESULT
variable, and will then find out how to use the RESULT variable inside
the object macro.

Thanks for this great advise.

---
Diese E-Mail wurde von AVG auf Viren geprüft.
http://www.avg.com


Post a reply to this message

From: clipka
Subject: Re: Macro Problem
Date: 23 Apr 2018 15:15:43
Message: <5ade30df$1@news.povray.org>
Am 23.04.2018 um 18:50 schrieb Bald Eagle:
> So, essentially what you're saying is, when writing a macro to construct
> an individual texture, object, pigment or what-have-you, it is very good
> practice to first assign the thing to a local variable (which I tend to
> call `Result`), and then have the macro "emit" just that variable itself?

Yes, when writing a macro to construct an individual texture, object,
pigment or what-have-you, it is very good practice to first assign the
thing to a local variable, and then have the macro "emit" just that
variable itself.

:)


Post a reply to this message

From: Sven Littkowski
Subject: Re: Macro Problem
Date: 24 Apr 2018 23:54:31
Message: <5adffbf7$1@news.povray.org>
Yes, that new construct really works. Interesting.

Thanks, Clipka.

---
Diese E-Mail wurde von AVG auf Viren geprüft.
http://www.avg.com


Post a reply to this message

From: Kenneth
Subject: Re: Macro Problem
Date: 27 Apr 2018 17:05:01
Message: <web.5ae38fb5ff561b5aa47873e10@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:

>
> And then there is the limitation of being unable to layer patterned
> textures on top of one another, which I find pretty... well, limiting.
>

Yes!! ;-)


Post a reply to this message

From: Sven Littkowski
Subject: Re: Macro Problem
Date: 28 Apr 2018 21:19:08
Message: <5ae51d8c@news.povray.org>
Yes!

---
Diese E-Mail wurde von AVG auf Viren geprüft.
http://www.avg.com


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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