POV-Ray : Newsgroups : povray.programming : Custom povray scene file reader (parse.cpp + tokenize.cpp) Server Time
2 May 2024 16:16:20 EDT (-0400)
  Custom povray scene file reader (parse.cpp + tokenize.cpp) (Message 1 to 8 of 8)  
From: human 2 0
Subject: Custom povray scene file reader (parse.cpp + tokenize.cpp)
Date: 4 Mar 2006 17:10:01
Message: <web.440a0f1066cd19ab674c36620@news.povray.org>
I want to make a povray scene file reader to convert the files to a
different format.  I thought I could do it from scratch, but I'm finding
little catches all over.  I've not studied lexers much.  I was just
thinking that writing a custom binary with povray's own parse.cpp and
tokenize.cpp would probably be the easiest solution, and have it print out
a list of obects or something like that.

Would this be easier for someone unfamiliar with the povray source code than
writing my own parser?  I code in Perl mostly but can read c++.


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Custom povray scene file reader (parse.cpp + tokenize.cpp)
Date: 4 Mar 2006 17:39:39
Message: <440a172b$1@news.povray.org>
human_2.0 wrote:
> I want to make a povray scene file reader to convert the files to a
> different format.  I thought I could do it from scratch, but I'm finding
> little catches all over.  I've not studied lexers much.  I was just
> thinking that writing a custom binary with povray's own parse.cpp and
> tokenize.cpp would probably be the easiest solution, and have it print out
> a list of obects or something like that.
> 
> Would this be easier for someone unfamiliar with the povray source code than
> writing my own parser?  I code in Perl mostly but can read c++.

Please read the POV-Ray license. You are prohibited to use POV-Ray source 
code outside POV-Ray. As such, you will have to write your own parser, 
however, I cannot see why you would want to write a parser that masters all 
features of POV-Ray. i.e. just for meshes a parser would be really easy to 
write though.

	Thorsten, POV-Team


Post a reply to this message

From: Christoph Hormann
Subject: Re: Custom povray scene file reader (parse.cpp + tokenize.cpp)
Date: 4 Mar 2006 18:00:03
Message: <dud652$h4n$1@chho.imagico.de>
human_2.0 wrote:
> I want to make a povray scene file reader to convert the files to a
> different format.  I thought I could do it from scratch, but I'm finding
> little catches all over.  I've not studied lexers much.  I was just
> thinking that writing a custom binary with povray's own parse.cpp and
> tokenize.cpp would probably be the easiest solution, and have it print out
> a list of obects or something like that.
> 
> Would this be easier for someone unfamiliar with the povray source code than
> writing my own parser?  I code in Perl mostly but can read c++.

See:

http://tag.povray.org/povQandT/filesQandT.html#povtootherformatsdifficulty

You would hardly have any advantage of using code from just parse.cpp 
and tokenize.cpp to write a POV-SDL reader - most parts of POV-Ray are 
needed for correctly interpreting a scene file.

The only practicable way to 'convert' a POV-Ray scene would be modifying 
POV-Ray itself to do so.

Christoph

-- 
POV-Ray tutorials, include files, Landscape of the week:
http://www.imagico.de/ (Last updated 31 Oct. 2005)
MegaPOV with mechanics simulation: http://megapov.inetart.net/


Post a reply to this message

From: human 2 0
Subject: Re: Custom povray scene file reader (parse.cpp + tokenize.cpp)
Date: 4 Mar 2006 18:55:01
Message: <web.440a2805b23fe0fa674c36620@news.povray.org>
> http://tag.povray.org/povQandT/filesQandT.html#povtootherformatsdifficulty
>
> You would hardly have any advantage of using code from just parse.cpp
> and tokenize.cpp to write a POV-SDL reader - most parts of POV-Ray are
> needed for correctly interpreting a scene file.
>
> The only practicable way to 'convert' a POV-Ray scene would be modifying
> POV-Ray itself to do so.

Hrm....  ok.  Modifying POV-Ray itself is certainly an interesting idea
(especially considering the license), but probably over my head right now.

I wont be converting everything in fact, certainly no variables or
expressions!  And I was actually not converting to another language, but
rather to commands to send to modo to create the same objects (boxes,
spheres, etc), or named macros (of objects) and implement them again for
modo.

Since I posted the topic I've been reading on lexers and it looks like I can
probably write one to handle what I need to do.  At least I know I'm not
wasting my time writing my own parser.  That is actually what I wanted to
know.

Thanks for the help!


Post a reply to this message

From: Christoph Hormann
Subject: Re: Custom povray scene file reader (parse.cpp + tokenize.cpp)
Date: 5 Mar 2006 04:35:03
Message: <dueb8o$j4j$1@chho.imagico.de>
human_2.0 wrote:
> 
> I wont be converting everything in fact, certainly no variables or
> expressions!  And I was actually not converting to another language, but
> rather to commands to send to modo to create the same objects (boxes,
> spheres, etc), or named macros (of objects) and implement them again for
> modo.

That's not the point - you won't even be able to convert a simple scene:

#declare fn_rad=
   function {
     pattern { granite }
   }

#declare Obj=box{-1,1}
#declare Norm=<0,0,0>;
#declare Start=<1.5,2,1>;
#declare Pos=trace(Obj, Start, -Start, Norm );

sphere { Pos, fn_rad(Pos.x, Pos.y, Pos.z) }

Christoph

-- 
POV-Ray tutorials, include files, Landscape of the week:
http://www.imagico.de/ (Last updated 31 Oct. 2005)
MegaPOV with mechanics simulation: http://megapov.inetart.net/


Post a reply to this message

From: human 2 0
Subject: Re: Custom povray scene file reader (parse.cpp + tokenize.cpp)
Date: 5 Mar 2006 16:50:00
Message: <web.440b5ca9b23fe0fa674c36620@news.povray.org>
Christoph Hormann <chr### [at] gmxde> wrote:
> human_2.0 wrote:
> >
> > I wont be converting everything in fact, certainly no variables or
> > expressions!  And I was actually not converting to another language, but
> > rather to commands to send to modo to create the same objects (boxes,
> > spheres, etc), or named macros (of objects) and implement them again for
> > modo.
>
> That's not the point - you won't even be able to convert a simple scene:
>
> #declare fn_rad=
>    function {
>      pattern { granite }
>    }
>
> #declare Obj=box{-1,1}
> #declare Norm=<0,0,0>;
> #declare Start=<1.5,2,1>;
> #declare Pos=trace(Obj, Start, -Start, Norm );
>
> sphere { Pos, fn_rad(Pos.x, Pos.y, Pos.z) }

True, except the files I want to convert are include files and use nothing
but objects and unions.  They return objects which are then translated and
rotated to the correct position in the scene.  I'm already parsing
simplifed versions of the include files, but obviously my parser isn't
strong enough for the actual syntax posibilities.

Anyway, it isn't that I don't like POV-Ray.  It is just that I've tried to
do some animated robot IK and the math is too much, so I'm whimping out and
I'm going to do that stuff in a GUI modeler (I'm on Mac and I don't believe
there is anything I can use to make my POV-Ray IK easier, and I really want
motion blur, and I know MegaPOV has it, but it doesn't work for my include
files, and I know about Targa averager, but I want something perhaps more
smooth for quick camera jerks or fast object movement).  I'm not going to
quit using POV-Ray either anyway.


Post a reply to this message

From: Ken and Timi Cecka
Subject: Re: Custom povray scene file reader (parse.cpp + tokenize.cpp)
Date: 7 Mar 2006 22:28:03
Message: <440e4f43@news.povray.org>
human_2.0 wrote:

> I want to make a povray scene file reader to convert the files to a
> different format.  I thought I could do it from scratch, but I'm finding
> little catches all over.  I've not studied lexers much.  I was just
> thinking that writing a custom binary with povray's own parse.cpp and
> tokenize.cpp would probably be the easiest solution, and have it print out
> a list of obects or something like that.
> 
> Would this be easier for someone unfamiliar with the povray source code
> than
> writing my own parser?  I code in Perl mostly but can read c++.

A number of years ago, Christian Vogelgsang announced an independent pov
parser which he called libparpov, and released along with a povray to
renderman converter utility.  The original page is gone, but you can find
an archive of it on the wayback machine:

http://web.archive.org/web/*/http://www9.informatik.uni-erlangen.de/~cnvogelg/pov2rib/index.html

The February 2, 2002 link seems to be the last working copy.

Christian's parser was written using PCCTS (the Purdue Compiler Creation
Toolset), and implemented most or all of the Pov 3.0 SDL.  Note that 3.0
did not include macros.

I've recently been working on writing my own parser using ANTLR (the modern
incarnation of PCCTS), and have it far enough along to handle all the
language directives (macros, declares, includes, etc).  I've only
implemented a handful of object types and basic pigments in the core
language so far though as I'm focusing on getting them working in my end
application before I finish off the parser.

If you can't get the original libparpov working, I can send you a snapshot
of some of my ANTLR code, but it will probably require more effort since I
haven't really packaged it up as a standalone library yet (nor is it
complete).

Ken


Post a reply to this message

From: Warp
Subject: Re: Custom povray scene file reader (parse.cpp + tokenize.cpp)
Date: 19 Mar 2006 22:36:42
Message: <441e2349@news.povray.org>
human_2.0 <jam### [at] nospam-magnusviricom> wrote:
> I'm already parsing
> simplifed versions of the include files, but obviously my parser isn't
> strong enough for the actual syntax posibilities.

  Just make a modified version of POV-Ray (aka. patch) which complies with
POV-Ray's usage license. You will save yourself a lot of trouble.

-- 
                                                          - Warp


Post a reply to this message

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