POV-Ray : Newsgroups : povray.general : Some more image to POV stuff in exchange for a good name Server Time
12 Jul 2025 18:14:55 EDT (-0400)
  Some more image to POV stuff in exchange for a good name (Message 13 to 19 of 19)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Ilya Razmanov
Subject: Re: Some more image to POV stuff in exchange for a good name
Date: 3 Jan 2025 10:38:25
Message: <67780471$1@news.povray.org>
On 24.12.2024 18:03, Bald Eagle wrote:

> So what you do is this:
> 
> #if (input_file_name = "MySceneFile.inc")
> 
>     Camera
>     Lights
>     whatever else
> 
> #end
> 
> Then rest of your scene is _just_ the include file.

Well, don't quite like this solution since it's not immune to simple 
file rename. But I started to think (yes, following comrade major 
scheme) and eventually and inevitably came to conclusion that

#declare extension = substr(input_file_name, strlen(input_file_name) - 3, 4)

#debug extension

shows me

.pov

and even subsequent

#if (extension = ".pov")
   #debug "Match!\n"
#end

says "Match!"

Combining it with your suggestion, I guess I can produce files that work 
as a whole scene when they are .pov, and as include after renaming to .inc

But this is not confirmed experimentally yet ;-)

-- 
Ilyich the Toad
https://dnyarri.github.io/


Post a reply to this message

From: Bald Eagle
Subject: Re: Some more image to POV stuff in exchange for a good name
Date: 3 Jan 2025 10:55:00
Message: <web.677807f5b095aa55327467e125979125@news.povray.org>
Ilya Razmanov <ily### [at] gmailcom> wrote:

> Well, don't quite like this solution since it's not immune to simple
> file rename.

It ought to be.

Write a tiny .pov file that outputs the value of input_file_name to the debug
stream.   Rename the file.  Render it again.

Since you're opening the file as the main .pov file, that's what input_file_name
gets defined as.

If you write another .pov file that INCLUDES the first .pov file, then it's the
main file that gets its filename assigned to input_file_name.

That's why this ought to be a good solution for you.

Just try it - you'll see.

- BW


Post a reply to this message

From: Ilya Razmanov
Subject: Re: Some more image to POV stuff in exchange for a good name
Date: 3 Jan 2025 11:28:37
Message: <67781035$1@news.povray.org>
On 03.01.2025 18:53, Bald Eagle wrote:
> 
> If you write another .pov file that INCLUDES the first .pov file, then it's the
> main file that gets its filename assigned to input_file_name.

Yep, already tried my idea with extensions out - oops, it seems like 
.inc file gets extension from master file, which is .pov, so my idea 
with extensions doesn't work. Guess it was just too beautiful for this 
world...

-- 
Ilyich the Toad
https://dnyarri.github.io/


Post a reply to this message

From: Ilya Razmanov
Subject: Re: Some more image to POV stuff in exchange for a good name
Date: 3 Jan 2025 12:42:47
Message: <67782197$1@news.povray.org>
On 03.01.2025 18:53, Bald Eagle wrote:
> 
> That's why this ought to be a good solution for you.
> 

...on the other hand, I still may use extension trick to make 
self-rendering .inc as you suggested, but reacting to extension only 
rather that a whole file name...

-- 
Ilyich the Toad
https://dnyarri.github.io/


Post a reply to this message

From: Leroy
Subject: Re: Some more image to POV stuff in exchange for a good name
Date: 3 Jan 2025 14:45:00
Message: <web.67783d99b095aa5536bcdbf3f712fc00@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> Ilya Razmanov <ily### [at] gmailcom> wrote:
>
> Found it.
>
https://news.povray.org/povray.general/message/%3CXnsAC0E5196CA622seed7%40news.povray.org%3E/#%3CXnsAC0E5196CA622seed
7%
> 40news.povray.org%3E
>
> So what you do is this:
>
> #if (input_file_name = "MySceneFile.inc")
>
>    Camera
>    Lights
>    whatever else
>
> #end
>
> Then rest of your scene is _just_ the include file.
>
> That way, if you're including your file in another file, it doesn't run the
> extra scene setup code.
> But if you're running it as a standalone file, you obviously need the scene
> setup stuff to render anything - and so it's all right there.
>
> - BW

That works alright. But, I've use this for a long time

#ifndef(Get)
 do what ever
#end

Then define 'Get' in the calling file. This works even if you change the name of
 the inc file. Which I do often when I'm testing ideas.
I really should use the 'input_file_name' test more.
Have fun!


Post a reply to this message

From: Ilya Razmanov
Subject: Re: Some more image to POV stuff in exchange for a good name
Date: 3 Jan 2025 16:19:01
Message: <67785445$1@news.povray.org>
On 03.01.2025 22:42, Leroy wrote:

> That works alright. But, I've use this for a long time
> 
> #ifndef(Get)
>   do what ever
> #end

LOL. That's too simple to think of it ;-)))


-- 
Ilyich the Toad
https://dnyarri.github.io/


Post a reply to this message

From: Alain Martel
Subject: Re: Some more image to POV stuff in exchange for a good name
Date: 3 Jan 2025 16:28:35
Message: <67785683@news.povray.org>
Le 2025-01-03 à 16:19, Ilya Razmanov a écrit :
> On 03.01.2025 22:42, Leroy wrote:
> 
>> That works alright. But, I've use this for a long time
>>
>> #ifndef(Get)
>>   do what ever
>> #end
> 
> LOL. That's too simple to think of it ;-)))
> 
> 

The includes from the distribution use a trick like that.

#ifndef(Flag)
#declare Flag=version;
  do include stuff
#end

This prevent parsing the include multiple times if it get formally 
included and included by another include.


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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