forked from blender/blender
Export volumes from object modifier (quick effect) #62
@ -7,17 +7,14 @@
|
|||||||
#include <pxr/usd/usdHydra/tokens.h>
|
#include <pxr/usd/usdHydra/tokens.h>
|
||||||
#include <pxr/usd/usdVol/tokens.h>
|
#include <pxr/usd/usdVol/tokens.h>
|
||||||
#include <pxr/usdImaging/usdVolImaging/tokens.h>
|
#include <pxr/usdImaging/usdVolImaging/tokens.h>
|
||||||
#include <pxr/base/gf/matrix3d.h>
|
|
||||||
#include <pxr/base/gf/rotation.h>
|
|
||||||
|
|
||||||
#include "BKE_material.h"
|
#include "BKE_material.h"
|
||||||
#include "BKE_mesh.hh"
|
#include "BKE_mesh.hh"
|
||||||
#include "BKE_object.h"
|
|
||||||
#include "BKE_modifier.h"
|
#include "BKE_modifier.h"
|
||||||
|
#include "BKE_object.h"
|
||||||
#include "BKE_volume.h"
|
#include "BKE_volume.h"
|
||||||
#include "BLI_index_range.hh"
|
#include "BLI_index_range.hh"
|
||||||
#include "BLI_path_util.h"
|
#include "BLI_path_util.h"
|
||||||
#include "BLI_math_rotation.h"
|
|
||||||
#include "DNA_fluid_types.h"
|
#include "DNA_fluid_types.h"
|
||||||
#include "DNA_scene_types.h"
|
#include "DNA_scene_types.h"
|
||||||
#include "DNA_volume_types.h"
|
#include "DNA_volume_types.h"
|
||||||
@ -242,12 +239,13 @@ void VolumeData::init_from_volume()
|
|||||||
BKE_volume_unload(volume);
|
BKE_volume_unload(volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VolumeData::assign_volume_transform() {
|
void VolumeData::assign_volume_transform()
|
||||||
|
{
|
||||||
Object *object = (Object *)this->id;
|
Object *object = (Object *)this->id;
|
||||||
Mesh *mesh = BKE_object_to_mesh(nullptr, object, false);
|
Mesh *mesh = BKE_object_to_mesh(nullptr, object, false);
|
||||||
|
|
||||||
pxr::GfMatrix4d fixed_transform = pxr::GfMatrix4d(1.0f).SetScale(0.5) *
|
pxr::GfMatrix4d fixed_transform = pxr::GfMatrix4d(1.0f).SetScale(0.5) *
|
||||||
pxr::GfMatrix4d(1.0f).SetTranslate(pxr::GfVec3d(0.5));
|
pxr::GfMatrix4d(1.0f).SetTranslate(pxr::GfVec3d(0.5));
|
||||||
double det = fixed_transform.GetDeterminant();
|
double det = fixed_transform.GetDeterminant();
|
||||||
pxr::GfMatrix4d inversed = fixed_transform.GetInverse(&det);
|
pxr::GfMatrix4d inversed = fixed_transform.GetInverse(&det);
|
||||||
|
|
||||||
@ -264,13 +262,9 @@ void VolumeData::assign_volume_transform() {
|
|||||||
pxr::GfMatrix4d scale_matrix = pxr::GfMatrix4d(1.0f).SetScale(
|
pxr::GfMatrix4d scale_matrix = pxr::GfMatrix4d(1.0f).SetScale(
|
||||||
pxr::GfVec3d(scale[0], scale[1], scale[2]));
|
pxr::GfVec3d(scale[0], scale[1], scale[2]));
|
||||||
pxr::GfMatrix4d texture_trans = pxr::GfMatrix4d(1.0f).SetTranslate(pxr::GfVec3d(
|
pxr::GfMatrix4d texture_trans = pxr::GfMatrix4d(1.0f).SetTranslate(pxr::GfVec3d(
|
||||||
mesh->texspace_location[0],
|
mesh->texspace_location[0], mesh->texspace_location[1], mesh->texspace_location[2]));
|
||||||
mesh->texspace_location[1],
|
|
||||||
mesh->texspace_location[2]));
|
|
||||||
pxr::GfMatrix4d texture_scale = pxr::GfMatrix4d(1.0f).SetScale(
|
pxr::GfMatrix4d texture_scale = pxr::GfMatrix4d(1.0f).SetScale(
|
||||||
pxr::GfVec3d(mesh->texspace_size[0],
|
pxr::GfVec3d(mesh->texspace_size[0], mesh->texspace_size[1], mesh->texspace_size[2]));
|
||||||
mesh->texspace_size[1],
|
|
||||||
mesh->texspace_size[2]));
|
|
||||||
|
|
||||||
transform = scale_matrix * inversed * texture_scale * texture_trans * transform;
|
transform = scale_matrix * inversed * texture_scale * texture_trans * transform;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user