mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 01:07:57 -06:00
ModelInstance's full 3D transform set as default
This commit is contained in:
parent
fb6c1a885c
commit
059ab4a05c
20 changed files with 2 additions and 630 deletions
|
@ -97,15 +97,9 @@ static void extract_model_from_archive(
|
|||
const char *zero_tag = "<zero>";
|
||||
const char *zero_xml = strstr(scene_xml_data.data(), zero_tag);
|
||||
float trafo[3][4] = { 0 };
|
||||
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
||||
Vec3d instance_rotation = Vec3d::Zero();
|
||||
Vec3d instance_scaling_factor = Vec3d::Ones();
|
||||
Vec3d instance_offset = Vec3d::Zero();
|
||||
#else
|
||||
double instance_rotation = 0.;
|
||||
double instance_scaling_factor = 1.f;
|
||||
Vec2d instance_offset(0., 0.);
|
||||
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
||||
bool trafo_set = false;
|
||||
unsigned int group_id = (unsigned int)-1;
|
||||
unsigned int extruder_id = (unsigned int)-1;
|
||||
|
@ -128,19 +122,8 @@ static void extract_model_from_archive(
|
|||
"[%f, %f, %f]", scale, scale+1, scale+2) == 3 &&
|
||||
sscanf(zero_xml+strlen(zero_tag),
|
||||
"[%f, %f, %f]", zero, zero+1, zero+2) == 3) {
|
||||
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
||||
instance_scaling_factor = Vec3d((double)scale[0], (double)scale[1], (double)scale[2]);
|
||||
instance_rotation = Vec3d(-(double)rotation[0], -(double)rotation[1], -(double)rotation[2]);
|
||||
#else
|
||||
if (scale[0] == scale[1] && scale[1] == scale[2]) {
|
||||
instance_scaling_factor = scale[0];
|
||||
scale[0] = scale[1] = scale[2] = 1.;
|
||||
}
|
||||
if (rotation[0] == 0. && rotation[1] == 0.) {
|
||||
instance_rotation = -rotation[2];
|
||||
rotation[2] = 0.;
|
||||
}
|
||||
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
||||
Eigen::Matrix3f mat_rot, mat_scale, mat_trafo;
|
||||
mat_rot = Eigen::AngleAxisf(-rotation[2], Eigen::Vector3f::UnitZ()) *
|
||||
Eigen::AngleAxisf(-rotation[1], Eigen::Vector3f::UnitY()) *
|
||||
|
@ -151,15 +134,9 @@ static void extract_model_from_archive(
|
|||
for (size_t c = 0; c < 3; ++ c)
|
||||
trafo[r][c] += mat_trafo(r, c);
|
||||
}
|
||||
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
||||
instance_offset = Vec3d((double)(position[0] - zero[0]), (double)(position[1] - zero[1]), (double)(position[2] - zero[2]));
|
||||
// CHECK_ME -> Is the following correct ?
|
||||
trafo[2][3] = position[2] / (float)instance_scaling_factor(2);
|
||||
#else
|
||||
instance_offset(0) = position[0] - zero[0];
|
||||
instance_offset(1) = position[1] - zero[1];
|
||||
trafo[2][3] = position[2] / instance_scaling_factor;
|
||||
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
||||
trafo_set = true;
|
||||
}
|
||||
const char *group_tag = "<group>";
|
||||
|
@ -315,15 +292,9 @@ static void extract_model_from_archive(
|
|||
model_object = model->add_object(name, path, std::move(mesh));
|
||||
volume = model_object->volumes.front();
|
||||
ModelInstance *instance = model_object->add_instance();
|
||||
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
||||
instance->set_rotation(instance_rotation);
|
||||
instance->set_scaling_factor(instance_scaling_factor);
|
||||
instance->set_offset(instance_offset);
|
||||
#else
|
||||
instance->rotation = instance_rotation;
|
||||
instance->scaling_factor = instance_scaling_factor;
|
||||
instance->offset = instance_offset;
|
||||
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
||||
if (group_id != (size_t)-1)
|
||||
group_to_model_object[group_id] = model_object;
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue