update exe GUI build
This commit is contained in:
@@ -38,6 +38,12 @@ def resolve_viz_pose_path(path: str | Path | None = None) -> Path:
|
||||
Path.cwd() / raw,
|
||||
here.parents[2] / raw,
|
||||
]
|
||||
try:
|
||||
from app_paths import app_root
|
||||
|
||||
candidates.insert(0, app_root() / raw)
|
||||
except ImportError:
|
||||
pass
|
||||
for candidate in candidates:
|
||||
if candidate.is_file():
|
||||
return candidate.resolve()
|
||||
@@ -74,6 +80,79 @@ def camera_look_at_from_world_to_cam(
|
||||
return lookat, eye, up
|
||||
|
||||
|
||||
def default_look_at_view(
|
||||
mesh_vertices: np.ndarray,
|
||||
lookat: np.ndarray,
|
||||
) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
|
||||
"""Fallback look_at triple when no world_to_cam pose is available."""
|
||||
center = np.asarray(lookat, dtype=np.float64).reshape(3)
|
||||
extent = np.ptp(np.asarray(mesh_vertices, dtype=np.float64), axis=0)
|
||||
span = float(np.max(extent))
|
||||
eye = center + np.array([0.0, 0.0, span * 2.0], dtype=np.float64)
|
||||
up = np.array([0.0, 1.0, 0.0], dtype=np.float64)
|
||||
return center, eye, up
|
||||
|
||||
|
||||
def _rotation_matrix(axis: np.ndarray, angle_rad: float) -> np.ndarray:
|
||||
axis = np.asarray(axis, dtype=np.float64).reshape(3)
|
||||
norm = float(np.linalg.norm(axis))
|
||||
if norm < 1e-12:
|
||||
return np.eye(3, dtype=np.float64)
|
||||
axis = axis / norm
|
||||
x, y, z = axis
|
||||
cross = np.array(
|
||||
[[0.0, -z, y], [z, 0.0, -x], [-y, x, 0.0]],
|
||||
dtype=np.float64,
|
||||
)
|
||||
return np.eye(3, dtype=np.float64) + np.sin(angle_rad) * cross + (1.0 - np.cos(angle_rad)) * (cross @ cross)
|
||||
|
||||
|
||||
def orbit_eye_about_target(
|
||||
target: np.ndarray,
|
||||
eye: np.ndarray,
|
||||
up: np.ndarray,
|
||||
dx_deg: float,
|
||||
dy_deg: float,
|
||||
) -> tuple[np.ndarray, np.ndarray]:
|
||||
"""Orbit ``eye`` around ``target``; dx/dy are drag deltas in degrees."""
|
||||
target = np.asarray(target, dtype=np.float64).reshape(3)
|
||||
eye = np.asarray(eye, dtype=np.float64).reshape(3)
|
||||
up = np.asarray(up, dtype=np.float64).reshape(3)
|
||||
|
||||
offset = eye - target
|
||||
if float(np.linalg.norm(offset)) < 1e-9:
|
||||
offset = np.array([0.0, 0.0, 1.0], dtype=np.float64)
|
||||
|
||||
world_up = up.copy()
|
||||
if float(np.linalg.norm(world_up)) < 1e-9:
|
||||
world_up = np.array([0.0, 1.0, 0.0], dtype=np.float64)
|
||||
world_up /= np.linalg.norm(world_up)
|
||||
|
||||
if abs(dx_deg) > 1e-9:
|
||||
rot = _rotation_matrix(world_up, np.deg2rad(dx_deg))
|
||||
offset = rot @ offset
|
||||
up = rot @ up
|
||||
|
||||
forward = -offset
|
||||
forward_norm = float(np.linalg.norm(forward))
|
||||
if forward_norm > 1e-9:
|
||||
forward = forward / forward_norm
|
||||
right = np.cross(forward, up)
|
||||
right_norm = float(np.linalg.norm(right))
|
||||
if right_norm > 1e-9:
|
||||
right = right / right_norm
|
||||
if abs(dy_deg) > 1e-9:
|
||||
rot = _rotation_matrix(right, np.deg2rad(dy_deg))
|
||||
offset = rot @ offset
|
||||
up = rot @ up
|
||||
|
||||
new_eye = target + offset
|
||||
up_norm = float(np.linalg.norm(up))
|
||||
if up_norm > 1e-9:
|
||||
up = up / up_norm
|
||||
return new_eye, up
|
||||
|
||||
|
||||
def apply_view_from_world_to_cam(vis, world_to_cam: np.ndarray, *, lookat: np.ndarray) -> None:
|
||||
"""Apply Blender-exported world_to_cam as the Open3D default view."""
|
||||
world_to_cam = np.asarray(world_to_cam, dtype=np.float64)
|
||||
|
||||
Reference in New Issue
Block a user