forked from blender/blender
BLEN-335: Export environment light #1
@ -56,7 +56,8 @@ void BlenderSceneDelegate::add_world(View3DShading *view3DShading, World *world)
|
|||||||
|
|
||||||
LOG(INFO) << "Add world: " << world_light_id;
|
LOG(INFO) << "Add world: " << world_light_id;
|
||||||
|
|
||||||
if (world_data.shading != view3DShading || world_data.world != world) {
|
if (world_data.shading != view3DShading || world_data.world != world ||
|
||||||
|
world_data.b_context != b_context) {
|
||||||
world_data = WorldData(view3DShading, world, b_context);
|
world_data = WorldData(view3DShading, world, b_context);
|
||||||
GetRenderIndex().InsertSprim(HdPrimTypeTokens->domeLight, this, world_light_id);
|
GetRenderIndex().InsertSprim(HdPrimTypeTokens->domeLight, this, world_light_id);
|
||||||
}
|
}
|
||||||
@ -253,7 +254,7 @@ void BlenderSceneDelegate::Populate(BL::Depsgraph &b_deps, BL::Context &b_cont)
|
|||||||
{
|
{
|
||||||
LOG(INFO) << "Populate " << is_populated;
|
LOG(INFO) << "Populate " << is_populated;
|
||||||
|
|
||||||
view3d = (View3D *)b_cont.space_data().ptr.data;;
|
view3d = (View3D *)b_cont.space_data().ptr.data;
|
||||||
b_depsgraph = &b_deps;
|
b_depsgraph = &b_deps;
|
||||||
b_context = &b_cont;
|
b_context = &b_cont;
|
||||||
|
|
||||||
|
@ -1,19 +1,24 @@
|
|||||||
/* SPDX-License-Identifier: Apache-2.0
|
/* SPDX-License-Identifier: Apache-2.0
|
||||||
* Copyright 2011-2022 Blender Foundation */
|
* Copyright 2011-2022 Blender Foundation */
|
||||||
|
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
#include <pxr/base/vt/array.h>
|
#include <pxr/base/vt/array.h>
|
||||||
#include <pxr/base/gf/vec2f.h>
|
#include <pxr/base/gf/vec2f.h>
|
||||||
#include <pxr/imaging/hd/light.h>
|
#include <pxr/imaging/hd/light.h>
|
||||||
#include <pxr/imaging/hd/tokens.h>
|
#include <pxr/imaging/hd/tokens.h>
|
||||||
#include <pxr/usd/usdLux/tokens.h>
|
#include <pxr/usd/usdLux/tokens.h>
|
||||||
|
|
||||||
|
#include "BKE_context.h"
|
||||||
#include "DNA_node_types.h"
|
#include "DNA_node_types.h"
|
||||||
#include "DNA_windowmanager_types.h"
|
#include "DNA_windowmanager_types.h"
|
||||||
#include "BKE_context.h"
|
|
||||||
#include "BKE_node.h"
|
#include "BKE_node.h"
|
||||||
#include "BKE_node_runtime.hh"
|
#include "BKE_node_runtime.hh"
|
||||||
#include "BKE_image.h"
|
#include "BKE_image.h"
|
||||||
#include "BKE_image_save.h"
|
#include "BKE_image_save.h"
|
||||||
|
#include "BKE_appdir.h"
|
||||||
#include "NOD_shader.h"
|
#include "NOD_shader.h"
|
||||||
#include "BLI_path_util.h"
|
#include "BLI_path_util.h"
|
||||||
|
|
||||||
@ -95,32 +100,52 @@ void WorldData::set_as_world()
|
|||||||
data[HdLightTokens->intensity] = strength[1];
|
data[HdLightTokens->intensity] = strength[1];
|
||||||
data[HdLightTokens->exposure] = 1.0f;
|
data[HdLightTokens->exposure] = 1.0f;
|
||||||
data[HdLightTokens->color] = GfVec3f(color[0], color[1], color[2]);
|
data[HdLightTokens->color] = GfVec3f(color[0], color[1], color[2]);
|
||||||
|
PyGILState_STATE gilstate;
|
||||||
|
gilstate = PyGILState_Ensure();
|
||||||
if (!color_input.directly_linked_links().is_empty()) {
|
if (!color_input.directly_linked_links().is_empty()) {
|
||||||
bNode *color_input_node = color_input.directly_linked_links()[0]->fromnode;
|
bNode *color_input_node = color_input.directly_linked_links()[0]->fromnode;
|
||||||
if (color_input_node->type == SH_NODE_TEX_IMAGE) {
|
if (color_input_node->type == SH_NODE_TEX_IMAGE) {
|
||||||
NodeTexImage *tex = static_cast<NodeTexImage *>(color_input_node->storage);
|
NodeTexImage *tex = static_cast<NodeTexImage *>(color_input_node->storage);
|
||||||
Image *ima = (Image *)color_input_node->id;
|
Image *ima = (Image *)color_input_node->id;
|
||||||
ReportList reports;
|
if (ima) {
|
||||||
ImageSaveOptions opts;
|
ReportList reports;
|
||||||
Main *bmain = CTX_data_main((bContext *)b_context->ptr.data);
|
ImageSaveOptions opts;
|
||||||
if (BKE_image_save_options_init(&opts,
|
Main *bmain = CTX_data_main((bContext *)b_context->ptr.data);
|
||||||
bmain,
|
if (BKE_image_save_options_init(&opts,
|
||||||
(Scene *)b_context->scene().ptr.data,
|
bmain,
|
||||||
ima,
|
CTX_data_scene((bContext *)b_context->ptr.data),
|
||||||
&tex->iuser,
|
ima,
|
||||||
true,
|
&tex->iuser,
|
||||||
false)) {
|
false,
|
||||||
STRNCPY(opts.filepath, "C:\\Users\\user\\Downloads\\test\\123_false.png");
|
false)) {
|
||||||
opts.im_format.imtype = R_IMF_IMTYPE_TIFF;
|
char tempfile[FILE_MAX];
|
||||||
BKE_image_save(&reports, bmain, ima, &tex->iuser, &opts);
|
string image_name;
|
||||||
|
|
||||||
data[HdLightTokens->textureFile] = SdfAssetPath(
|
if (ima->source == IMA_SRC_GENERATED) {
|
||||||
"C:\\Users\\user\\Desktop\\WUH6nAqWDDk.jpg",
|
image_name = strcat((ima->id.name + 2), ".png");
|
||||||
"C:\\Users\\user\\Desktop\\WUH6nAqWDDk.jpg");
|
}
|
||||||
|
else {
|
||||||
|
image_name = ima->filepath == NULL ?
|
||||||
|
std::filesystem::path(ima->filepath).filename().string() :
|
||||||
|
ima->id.name + 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
BLI_path_join(tempfile,
|
||||||
|
sizeof(tempfile),
|
||||||
|
BKE_tempdir_session(),
|
||||||
|
image_name.c_str());
|
||||||
|
STRNCPY(opts.filepath, tempfile);
|
||||||
|
opts.im_format.imtype = R_IMF_IMTYPE_PNG;
|
||||||
|
|
||||||
|
if (BKE_image_save(&reports, bmain, ima, &tex->iuser, &opts)) {
|
||||||
|
data[HdLightTokens->textureFile] = SdfAssetPath(tempfile, tempfile);
|
||||||
|
}
|
||||||
|
BKE_image_save_options_free(&opts);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
PyGILState_Release(gilstate);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
data[HdLightTokens->intensity] = 1.0f;
|
data[HdLightTokens->intensity] = 1.0f;
|
||||||
|
Loading…
Reference in New Issue
Block a user