Post by chrisd on May 13, 2019 0:32:14 GMT
I was looking at implementing a YAML parser to read in .yml files. I was also hoping to convert over to using YAML formatted files for the existing scenes I've already created instead of creating objects with code. Looking through the forums, it looks like fs implemented a parser based on one of his posts, but I haven't seen comments by anyone else indicating they have.
I'm using Java. I've found two libraries that appear to be actively maintained: SnakeYaml and YamlBeans.
Looking at the YAML files that are on the forums and in the book, it appears that they are not using features such as local or global tags for the type (e.g. !camera or !!com.raytracerchallenge.Camera), but rather an "add: camera" followed by the properties of a camera. And sometimes an "add:" seems to be a reference to a previously defined object, with changes presumably applied to a copy of the defined object.
The example files also use "define: standard-transform" to define a transform that can be applied, and then it can be used in the "value" field of another transform or or a transform field of an object. I might have expected YAML aliases to be used (&Name to define the alias, *Name to use it).
My best guess is that you are reading in the YAML into lists and maps of primitive types, almost treating a YAML parser as a scanner with additional code on top of it to read through that data structure to actually create the ray tracing objects in memory. Is that on the right path?
Thanks for any pointers you can give.