diff options
author | Charles Flèche <charlesf> | 2022-03-23 19:45:34 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2022-03-23 22:06:12 +0300 |
commit | e7b1be52e00749c574355ec219888548a07cd1c9 (patch) | |
tree | 0f8dbeeb03b9cd89e9a14a50b1411bcb0679cfa1 /intern | |
parent | f5066d43ae572de929fea31cbc9e091e288b2435 (diff) |
Cycles: add Alembic procedural to Cycles standalone xml
Example:
<alembic filepath="/tmp/cube.abc" scale="1.45">
<object path="/Cube/Cube" />
</alembic>
Differential Revision: https://developer.blender.org/D14391
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/app/CMakeLists.txt | 10 | ||||
-rw-r--r-- | intern/cycles/app/cycles_xml.cpp | 31 |
2 files changed, 41 insertions, 0 deletions
diff --git a/intern/cycles/app/CMakeLists.txt b/intern/cycles/app/CMakeLists.txt index 3248ef0dcda..484d99c5ca7 100644 --- a/intern/cycles/app/CMakeLists.txt +++ b/intern/cycles/app/CMakeLists.txt @@ -22,6 +22,16 @@ set(LIBRARIES cycles_util ) +if(WITH_ALEMBIC) + add_definitions(-DWITH_ALEMBIC) + list(APPEND INC_SYS + ${ALEMBIC_INCLUDE_DIRS} + ) + list(APPEND LIB + ${ALEMBIC_LIBRARIES} + ) +endif() + if(WITH_CYCLES_OSL) list(APPEND LIBRARIES cycles_kernel_osl) endif() diff --git a/intern/cycles/app/cycles_xml.cpp b/intern/cycles/app/cycles_xml.cpp index 50a983022a3..723f4fd77b9 100644 --- a/intern/cycles/app/cycles_xml.cpp +++ b/intern/cycles/app/cycles_xml.cpp @@ -9,6 +9,7 @@ #include "graph/node_xml.h" +#include "scene/alembic.h" #include "scene/background.h" #include "scene/camera.h" #include "scene/film.h" @@ -192,6 +193,31 @@ static void xml_read_camera(XMLReadState &state, xml_node node) cam->update(state.scene); } +/* Alembic */ + +#ifdef WITH_ALEMBIC +static void xml_read_alembic(XMLReadState &state, xml_node graph_node) +{ + AlembicProcedural *proc = state.scene->create_node<AlembicProcedural>(); + xml_read_node(state, proc, graph_node); + + for (xml_node node = graph_node.first_child(); node; node = node.next_sibling()) { + if (string_iequals(node.name(), "object")) { + string path; + if (xml_read_string(&path, node, "path")) { + ustring object_path(path, 0); + AlembicObject *object = static_cast<AlembicObject *>( + proc->get_or_create_object(object_path)); + + array<Node *> used_shaders = object->get_used_shaders(); + used_shaders.push_back_slow(state.shader); + object->set_used_shaders(used_shaders); + } + } + } +} +#endif + /* Shader */ static void xml_read_shader_graph(XMLReadState &state, Shader *shader, xml_node graph_node) @@ -647,6 +673,11 @@ static void xml_read_scene(XMLReadState &state, xml_node scene_node) if (xml_read_string(&src, node, "src")) xml_read_include(state, src); } +#ifdef WITH_ALEMBIC + else if (string_iequals(node.name(), "alembic")) { + xml_read_alembic(state, node); + } +#endif else fprintf(stderr, "Unknown node \"%s\".\n", node.name()); } |