forked from blender/blender
Export volumes from object modifier (quick effect) #62
@ -11,6 +11,7 @@
|
||||
#include <pxr/base/gf/rotation.h>
|
||||
|
||||
#include "BKE_material.h"
|
||||
#include "BKE_mesh.hh"
|
||||
#include "BKE_object.h"
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_volume.h"
|
||||
@ -243,6 +244,8 @@ void VolumeData::init_from_volume()
|
||||
|
||||
void VolumeData::assign_volume_transform() {
|
||||
Object *object = (Object *)this->id;
|
||||
Mesh *mesh = BKE_object_to_mesh(nullptr, object, false);
|
||||
|
||||
auto mod = pxr::GfMatrix4d(1.0f).SetScale(0.5) *
|
||||
pxr::GfMatrix4d(1.0f).SetTranslate(pxr::GfVec3d(0.5));
|
||||
auto det = mod.GetDeterminant();
|
||||
@ -259,7 +262,15 @@ void VolumeData::assign_volume_transform() {
|
||||
scale[2] = 0.5f / object->scale[2];
|
||||
}
|
||||
auto scale_matrix = pxr::GfMatrix4d(1.0f).SetScale(pxr::GfVec3d(scale[0], scale[1], scale[2]));
|
||||
transform = scale_matrix * inversed * transform;
|
||||
auto texture_trans = pxr::GfMatrix4d(1.0f).SetTranslate(pxr::GfVec3d(mesh->texspace_location[0],
|
||||
mesh->texspace_location[1],
|
||||
mesh->texspace_location[2]));
|
||||
auto texture_scale = pxr::GfMatrix4d(1.0f).SetScale(pxr::GfVec3d(mesh->texspace_size[0],
|
||||
mesh->texspace_size[1],
|
||||
mesh->texspace_size[2]));
|
||||
transform = scale_matrix * inversed * texture_scale * texture_trans * transform;
|
||||
|
||||
BKE_object_to_mesh_clear(object);
|
||||
}
|
||||
|
||||
} // namespace blender::render::hydra
|
||||
|
Loading…
Reference in New Issue
Block a user