diff --git a/configs/mesh-fitting-instantmesh.yaml b/configs/mesh-fitting-instantmesh.yaml index 17050cd..b9dbc43 100644 --- a/configs/mesh-fitting-instantmesh.yaml +++ b/configs/mesh-fitting-instantmesh.yaml @@ -60,8 +60,9 @@ system: shape_init: ??? shape_init_params: 1.0 radius: 1.0 # consistent with coarse - shape_init_mesh_up: "-z" + shape_init_mesh_up: "+z" shape_init_mesh_front: "+x" + is_instantmesh: true material_type: "no-material" material: n_output_dims: 3 diff --git a/threestudio/models/geometry/obj_mesh.py b/threestudio/models/geometry/obj_mesh.py index 3aeee29..a7cb1dd 100644 --- a/threestudio/models/geometry/obj_mesh.py +++ b/threestudio/models/geometry/obj_mesh.py @@ -18,6 +18,7 @@ class Config(BaseExplicitGeometry.Config): shape_init_params: Optional[Any] = None shape_init_mesh_up: str = "+z" shape_init_mesh_front: str = "+x" + is_instantmesh: bool = False cfg: Config @@ -43,6 +44,9 @@ def configure(self) -> None: # centroid = mesh.vertices.mean(0) # mesh.vertices = mesh.vertices - centroid + if self.cfg.is_instantmesh: + mesh.vertices = mesh.vertices @ np.array([[1, 0, 0], [0, 1, 0], [0, 0, -1]]) + # align to up-z and front-x dirs = ["+x", "+y", "+z", "-x", "-y", "-z"] dir2vec = { @@ -75,7 +79,7 @@ def configure(self) -> None: # scaling # scale = np.abs(mesh.vertices).max() # mesh.vertices = mesh.vertices / scale * self.cfg.shape_init_params - # mesh.vertices = np.dot(mesh2std, mesh.vertices.T).T + mesh.vertices = np.dot(mesh2std, mesh.vertices.T).T self.normal = torch.tensor(mesh.vertex_normals, dtype=torch.float32).to(self.device).contiguous()