question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Then I am trying to scale a mesh Scene, it looks I have two issues:

  1. The order of the Scene Geometry is inverted
  2. The scale factor is off?

Using Pytorch3D

verts, faces, aux = load_obj(FILE_PATH)
device = torch.device("cuda:0")
faces_idx = faces.verts_idx.to(device)
verts = verts.to(device)
center = verts.mean(0)
verts = verts - center
scale = max(verts.abs().max(0)[0])
verts_Pytorch3D_scaled = verts / scale

mesh = trimesh.load_mesh(FILE_PATH)
verts_Trimesh_scaled = mesh.scaled(1.0/scale)

image

verts_Pytorch3D_scaled != verts_Trimesh_scaled??
image

Why is this happening? Would be possible to preserve the scaling factor and order?

What would be the best way to scale meshes in Trimesh Scene preserving order and with the right scale?

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mikedhcommented, Nov 10, 2022

Yeah the non-uniform scaling was just released yesterday: https://github.com/mikedh/trimesh/pull/1732

There was a weird caching bug and a backwards dot product preventing this from working, added a fix and test in the followup release #1742 which I’ll merge as soon as tests pass. I think this is close to working (PR’s welcome!):

In [1]: import trimesh
m 
In [2]: m = trimesh.load('models/cycloidal.3DXML')

In [3]: m.apply_transform(trimesh.transformations.random_rotation_matrix())
Out[3]: <trimesh.Scene(len(geometry)=13)>

In [4]: m.bounds[0]
Out[4]: array([-56.02267239, -40.44721501, -36.03040504])

In [5]: s = m.scaled(1/m.extents)

In [6]: s.extents
Out[6]: array([1.01144344, 1.0091659 , 1.        ])

In [7]: s.apply_translation(-s.bounds.mean(axis=0))
Out[7]: <trimesh.Scene(len(geometry)=72)>

In [8]: s.bounds
Out[8]: 
array([[-0.50572172, -0.50458295, -0.5       ],
       [ 0.50572172,  0.50458295,  0.5       ]])
1reaction
mikedhcommented, Nov 10, 2022

Hey, not sure what Pytorch is doing, but the current trimesh behavior seems like it’s not re-ordering or inverting for a simple example:

    s = trimesh.creation.box().scene()

    scaling = 1.0 / 3.0
    c = s.scaled(scaling)

    factor = (c.geometry['geometry_0'].vertices /
              s.geometry['geometry_0'].vertices)

    assert np.allclose(factor, scaling)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Scale issues in hydrological modelling: A review - Blöschl - 1995
Abstract A framework is provided for scaling and scale issues in hydrology. The first section gives some basic definitions. This is important as...
Read more >
Small-Scale Issue Committee - Colorado Secretary of State
A committee that raises or spends money between $200 and $5,000 to support or oppose ballot measures. This new type of Issue Committee...
Read more >
Windows scaling issues for high-DPI devices - Microsoft Support
Although these symptoms may be seen on a single monitor, they're more common when you use multiple monitors that vary in display resolution....
Read more >
Reality Converter scale issue | Apple Developer Forums
I don't know if this is an issue with Apple's Reality Converter app or Blender (I'm using 3.0 on the Mac), but when...
Read more >
Scale and Cross-Scale Dynamics - Ecology & Society
Cash, D. W., W. Adger, F. Berkes, P. Garden, L. Lebel, P. Olsson, L. Pritchard, and O. Young. 2006. Scale and cross-scale dynamics:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found