From e7b1be52e00749c574355ec219888548a07cd1c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles=20Fl=C3=A8che?= Date: Wed, 23 Mar 2022 17:45:34 +0100 Subject: [PATCH] Cycles: add Alembic procedural to Cycles standalone xml Example: Differential Revision: https://developer.blender.org/D14391 --- intern/cycles/app/CMakeLists.txt | 10 ++++++++++ intern/cycles/app/cycles_xml.cpp | 31 +++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) 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(); + 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( + proc->get_or_create_object(object_path)); + + array 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()); }