Closed mmmovania closed 1 year ago
Yes.. this way seems not very optimized. I think a best approach are write any kinda of small 'API' interface to export some create scene functions. I can see that the 'api.cc' and 'api.h' files aren't update for this version. Maybe @mmp can add some comment or tip here about this.. :)
Meanwhile you have a few options to optimize a bit your code:
void ParamsSetFloat(ParsedParameter& param, std::string name, Float value) {
//-
param.name = name;
param.type = "float";
param.AddFloat(value);
}
void ParamsSetInt(ParsedParameter& param, std::string name, int value) {
//
param.name = name;
param.type = "integer";
param.AddInt(value);
}
Then you can use some like this to set each param per-type
ParsedParameterVector parsed; // reusable container after 'clear()'
//Camera params
std::unique_ptr< ParsedParameter> params(new ParsedParameter(loc)); // smart pointer to forget use 'delete'?
ParamsSetFloat(*params, "fov", 39.60);
parsed.push_back(params.get());
builder.Camera("perspective", parsed, loc);
parsed.clear();
I hope this help you a bit.. Cheers..
Thanks for your response @pbrt4bounty. Awaiting response from @mmp.
Sort of off topic, but possibly related... It might be worth linking to the user manual and scene description language definition in the README.md for this project.
Project: https://github.com/mmp/pbrt-v4
There is also the appendix
Also,
You might wish to just create a few polygon examples in the pbrt scenes page in order to provide some "training wheels" for new bees still getting started. Or suggest creating some as a prerequisite for your materials.
This comment is not necessarily an endorsement of any person place or thing in particular :)
@raymond-chetty good suggestion about the README and thanks for the heads up about the Disney cloud link--done.
The scene description interfaces aren't really designed to be used directly so they're a little clunky. You can go ahead and make your own parameter vectors and SceneEntity objects, or you can also create the underlying objects directly (i.e., if you want a sphere, call new Sphere
and pass the desired arguments to the constructor. That's used in some of the pbrt unit tests, for example.
I was wondering how one would go about setting up pbrt v4 through code without using the scene file? I tried looking at the documentation and user guide and https://pbrt.org/fileformat-v4 but I only saw pbrt scene file examples. I did find out by peeking into the pbrt v4 code that we can use the BasicScene/BasicSceneBuilder class to help in setting up the code as shown here: https://github.com/mmmovania/PBRTv4_Tests/blob/main/SimpleScene/SimpleScene/AdvancedScene.cpp but shouldnt there be a better way? Asking as I could not find anything in the docs or on the internet.