-
-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Brainstorm libf3d API #52
Comments
Ignoring completelly how libf3d and f3d are currently implemented, let's consider the fonctionnality we want to provide as a lib. Features:
Restrictions:
inputs @Meakk ? |
I agree, VTK should be a private dependency of libf3d. |
So trying to link it with current implementation, we could have the following rough public API
|
Here are my inputs. f3d::window w = f3d::createWindow(f3d::context ctx); // create window (external, native, android ...)
w.addFile("/path/file.vtp"); // add a file
w.addFolder("/path"); // add all the files in folder
w.setActiveFile(int index); // set the active file
w.setOption("key", "value"); // configure all options using this function (parse the value string inside the function)
w.clear(); // remove all files
w.render(); // render the scene
w.saveTofile("/path/image.png"); // save the rendered image
w.setKeyCallBack([](int keyCode, int modifier) {
// do something
});
w.setMouseCallBack([](float dx, float dy, int button) {
// do something
});
w.setMotionCallBack([](float whatever) {
// do something on Android
}); It also means that the interactor should be moved to the executable, but it makes sense to me. |
I think it would be better to separate loading data and rendering data. here is a proposition: f3d::options opt;
opt.setOption("key", "value"); // configure all options using this function (parse the value string inside the function)
f3d::loader load;
load.setOptions(opt);
load.addFile("/path/file.vtp"); // add a file
load.addFolder("/path"); // add all the files in folder
load.setActiveFile(int index); // set the active file
f3d::interactor interact
interact.setKeyCallBack([](int keyCode, int modifier) {
// do something
});
interact.setMouseCallBack([](float dx, float dy, int button) {
// do something
});
interact.setMotionCallBack([](float whatever) {
// do something on Android
});
f3d::window win (f3d::context ctx); // create window (external, native, android ...)
win.setOptions(opt)
win.setLoader(load);
win.setInteractor(interact);
win.render(); // render the scene
win.saveTofile("/path/image.png"); // save the rendered image I dont really care about C bindings, python bindings would be much more important imo. |
@mwestphal I like it! Regarding bindings, we will need Java bindings too for Android. I will take care of it, don't worry 😛 |
Great ! Lets focus on this one when we find the time. We may want to merge into a dedicated branch until it stabilize. |
I still think providing C functions can be useful, for C programmers of course, but it will make other bindings easier, like Rust for instance: https://stackoverflow.com/questions/52923460/how-to-call-a-c-dynamic-library-from-rust |
Interesting. |
Hi, I'm also interested by C functions 😃 Given I write my SketchUp plugins in Ruby, I could use Fiddle to call |
Haha, nice screenshot 👍 |
- Separate F3DLoader in F3DLoader and F3DStarter for f3d-app#52 - Remove all mention of F3DOptions from F3DLoader - Make --no-render F3DStarter specifc and not an actual option - Separate F3DLoader::loadFile in multiple methods - Improve testing for right/left key
Discussed API moving forward f3d::options opt;
opt.setOption("key", "value"); // configure all options using this function (parse the value string inside the function)
f3d::window win (f3d::context ctx); // create window (external, native, android ...)
f3d::loader load;
load.setOptions(opt);
load.setWindow(win);
load.addFile("/path/file.vtp"); // add a file
load.addFolder("/path"); // add all the files in folder
load.setActiveFile(int index); // set the active file
f3d::interactor interact
interact.setMouseCallBack([](float dx, float dy, int button) {
// do something
});
interact.setMotionCallBack([](float whatever) {
// do something on Android
});
win.setInteractor(interact);
win.render(); // render the scene
win.saveTofile("/path/image.png"); // save the rendered image
interact.loop(); |
@mwestphal Once model is loaded and rendered, could we access renderer then change things in real time? For instance: win.render(); // render the scene
ren = win.getRenderer();
cam = ren.getActiveCamera();
cam.setPosition(float x, float y, float z); |
Yes, any options will be changeable dynamically when all is implemented. |
So a very early version of the API is now in master, I'll try to update the issue to identify the remaining work. |
@Meakk updated with your suggestions |
Here is how it looks now:
|
For anyone following this. We are close to completion of the first version of the API. stay tuned. |
not needed |
not needed |
Not needed, for now |
Doc item in their own issue: #48 |
All items have been adressed, closing. |
In the context of f3d-app#52 , Introduce a first element, f3d::options and start using it when possible without refactoring the whole of F3D for now. TODO in other PRs: - doc - F3DLoader refacto - options names f3d-app#32
- Separate F3DLoader in F3DLoader and F3DStarter for f3d-app#52 - Remove all mention of F3DOptions from F3DLoader - Make --no-render F3DStarter specifc and not an actual option - Separate F3DLoader::loadFile in multiple methods - Improve testing for right/left key
libf3d was introduced in !259 (closed), let's brainstorm a stable API for it.
Tasklist:
libf3d
F3D
Doc
The text was updated successfully, but these errors were encountered: