POV-Ray : Newsgroups : povray.general : example uses of min_extent() max_extent() Server Time
4 Nov 2024 17:35:15 EST (-0500)
  example uses of min_extent() max_extent() (Message 1 to 6 of 6)  
From: wyleu
Subject: example uses of min_extent() max_extent()
Date: 12 Sep 2008 15:15:00
Message: <web.48cabe91268a637d46cc72450@news.povray.org>
I've been modeling in visual python www.vpython.org but am keen to render using
more complex control. I also wish to place labels onto objects into the field.
So I am outputing my models to be rendered by pov-ray using povexport.py.
I then wish to replace the labels over the top of the image with external
compositing because I have frequently changing values I wish to place into a
non moving rendered image.

On consulting the FAQ I read the following:

"How can I find the size of a text object / center text / justify text?"

You can use the min_extent() and max_extent() functions (new in POV-Ray 3.5) to
get the corners of the bounding box of any object. While this is sometimes not
the actual size of the object, for text objects this should be fairly accurate,
enough to do alignment of the text object.

I believe this will allow me to return the bounding box for POV-RAY rendered
objects.

My questions are therefore.

How do I specify that an particular object or group of objects returns the
appropriate variables?

and,

How are variable from a POV-RAY command line render returned to a calling
programme?

I have search on Google fro min_extent, max_extent and POV-RAY but can't find
anything that aren't restatements of the FAQ.


Post a reply to this message

From: wyleu
Subject: Re: example uses of min_extent() max_extent()
Date: 12 Sep 2008 15:50:00
Message: <web.48cac6e54994ba3d46cc72450@news.povray.org>
As always the posting of the question very qickly leads to an answer

#declare Sphere =
sphere {
  <0,0,0>, 1
  pigment { rgb <1,0,0> }
}
#declare Min = min_extent ( Sphere );
#declare Max = max_extent ( Sphere );
object { Sphere }
box {
    Min, Max
    pigment { rgbf <1,1,1,0.5> }
}



However this is a bounding box of an object, can I extract the co-ordinates of
the bounding box as it's projected onto the viewing plane so I can provide
these as co-ordinates to a function like html ISMAP and USEMAP to allow
hypertext like functions from web background pages?


Post a reply to this message

From: Reactor
Subject: Re: example uses of min_extent() max_extent()
Date: 12 Sep 2008 15:50:01
Message: <web.48cac7984994ba3dd04f05110@news.povray.org>
"wyleu" <nomail@nomail> wrote:

> My questions are therefore.
>
> How do I specify that an particular object or group of objects returns the
> appropriate variables?
>
> and,
>
> How are variable from a POV-RAY command line render returned to a calling
> programme?
>
> I have search on Google fro min_extent, max_extent and POV-RAY but can't find
> anything that aren't restatements of the FAQ.


The documentation for min_extent and max_extent provide simple examples for
their use here:
http://www.povray.org/documentation/view/3.6.1/229/

In your case, it would probably be something more like:

#declare MyText =
text
{
    ttf             // font type (only TrueType format for now)
    "cour.ttf",     // Microsoft Windows-format TrueType font file name
    "Hello World",  // the string to create
    .25,            // the extrusion depth
    0               // inter-character spacing
scale 2
}


#declare TextMin  = min_extent( MyText );
#declare TextMax  = max_extent( MyText );
#declare TextSize = TextMax - TextMin;


object
{
    MyText
    translate -TextSize / 2 // center object according to bounding box
}



As for returning values, this can be done if commands are specified in the ini
file, documentation here:
http://www.povray.org/documentation/view/3.6.1/221/

From what you've described, it sounds like you want variables from within the
scene returned to the calling program.  From my understanding, this cannot be
done directly, but can still be accomplished by using the file I/O directives
( http://www.povray.org/documentation/view/3.6.1/238/ ) to write the scene
variables to a file, then use a post scene command to call the program with
that   file (or, alternatively, when POV-ray returns after exiting, that
program can open the text file that POV has written).


  HTH
-Reactor


Post a reply to this message

From: Nicolas Alvarez
Subject: Re: example uses of min_extent() max_extent()
Date: 12 Sep 2008 16:29:42
Message: <48cad135@news.povray.org>
wyleu wrote:
> However this is a bounding box of an object, can I extract the
> co-ordinates of the bounding box as it's projected onto the viewing plane
> so I can provide these as co-ordinates to a function like html ISMAP and
> USEMAP to allow hypertext like functions from web background pages?

No, you can't.

However, you can render an alternate image putting solid colors on objects;
either ambient 1 and no lights, or Quality=0 setting (+q0); and no
antialias; then it would be relatively easy to post-process that image and
find the rectangle that fully fits the solid-colored area.


Post a reply to this message

From: Mike Williams
Subject: Re: example uses of min_extent() max_extent()
Date: 12 Sep 2008 20:11:16
Message: <6jUlK1AcUwyIFwPI@econym.demon.co.uk>
Wasn't it wyleu who wrote:
>As always the posting of the question very qickly leads to an answer
>
>#declare Sphere =
>sphere {
>  <0,0,0>, 1
>  pigment { rgb <1,0,0> }
>}
>#declare Min = min_extent ( Sphere );
>#declare Max = max_extent ( Sphere );
>object { Sphere }
>box {
>    Min, Max
>    pigment { rgbf <1,1,1,0.5> }
>}
>
>
>
>However this is a bounding box of an object, can I extract the co-ordinates of
>the bounding box as it's projected onto the viewing plane so I can provide
>these as co-ordinates to a function like html ISMAP and USEMAP to allow
>hypertext like functions from web background pages?


Be aware that min_extent and max_extent doesn't always produce efficient 
bounds for an object if there's awkward CSG going on. POV will produce a 
slab that is guaranteed to contain the object, but there's no guarantee 
that it will fit snugly.

Consider this:

#declare Object = difference {
   sphere { <0,0,0>, 1}
   box {<-2,-2,-2><0.7,2,2>}
   pigment { rgb <1,0,0> }
}
#declare Min = min_extent ( Object );
#declare Max = max_extent ( Object );
object { Object }

box {
     Min, Max
     pigment { rgbf <1,1,1,0.5> }
}

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Nicolas George
Subject: Broken folding with the web interface (was: example uses of min_extent() max_extent())
Date: 13 Sep 2008 03:36:27
Message: <48cb6d7b$1@news.povray.org>
"wyleu"  wrote in message
<web.48cabe91268a637d46cc72450@news.povray.org>:
> X-User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.8.1.16) Gecko/20080702
Iceweasel/2.0.0.16 (Debian-2.0.0.16-0
> etch1)

This header line, produced by the web interface, is wrong. If folding needs
to occur inside a header, the extra lines must start with a space character.
The message, as it is, is very poorly displayed in some newsreader.

(Sorry, wyleu, this has nothing to do with your question, but your message
was the first I found since I identified the problem.)


Post a reply to this message

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