Open karkinos-krakatoa opened 8 years ago
Hi there, thanks!
It's been a while since I looked into this source code, but basically, the file format is binary and record-based. I don't have a formal specification, but here is the gist of it:
1) It starts with a RenderParams
structure (see renderer.hpp
) which defines the width, height in pixels and number of samples for the scene.
2) Then, follow any number of Entities, which consist of an EntityHeader
(see renderer.cpp
) with an EntityType
(the general type of the object, e.g. a light, a material, a primitive) and a subtype
(e.g. if it's a primitive, it could be a triangle or sphere).
3) The data in the file after the header depends on the entity type and subtype, and can be understood by following the source code. For instance, if the entity is a primitive, we call GetPrimitive
with the subtype as a parameter, this will read two 32-bit integers from the file after the header (see primitive.cpp
) which are the primitive's material and/or light. Then, if the subtype is Triangle, then the triangle.cpp
file shows that the data after that consists of three vertices, in X-Y-Z float format (the reason the Primitive constructor is called first is because Triangle inherits from Primitive).
(the exception is for the ColorSystem
type, which has no data after the header; the color system is directly determined by the subtype
field in the header, see line 71 of renderer.cpp
)
Records are appended into an array for each type (so one array for lights, one array for materials, one array for primitives, etc...) as they are read in, and the different types of entities refer to one another via hardcoded indices inside these arrays; these indices were all calculated and set when the scene was constructed.
The format itself is pretty poorly designed all things considered, although it did get the job done. In my opinion it was a mistake and I should have used an existing text-based format, like I did in my later renderers. But at least it isn't too hard to decipher.
Feel free to ask if you have any further questions :) it should not be very hard to implement a standalone parser for these scene files, I'd say the difficulty would be about the same as implementing a basic OBJ loader.
Another maybe easier way to get the data out is to just put some printf/std::cout anywhere the file is read from, rebuild and run the renderer on a scene file, then you will naturally see the flow of data being read from the file and parsed into the renderer's memory!
Thanks for replying so quickly.I think you have made it clear enough.Truth is I had an idea on how to create a new scene file.I just wanted to compare it to yours and make sure I was using the right temperature and material values as well as correct obj loading.I just wanted to have something to compare it to.To know my materials and light are working as intended.Your code is well-commented.So I am learning a lot from it.Even more than most books on the subject.Anyways thank you very much.Will contact you if I am still facing issues.I am still learning about Rendering.....So please be patient with me.Lol.Thanks again.
Oh ok !!!! Cool.I think that will help. Thanks.Going to try it tday.
Your Renderer is great ! Is making me learn a lot.Please can we have at least one raw description of a scene file ? A readable one(with the actual text) .I would really like to know the exact format of the Scene Items and their respective values.It will really help me decipher a problem.You can use the Lucy/Ajax Scene for example.Thank You ! :)