Skip to content

Latest commit

 

History

History
732 lines (499 loc) · 36.2 KB

MESHLAB_DOCUMENTATION.md

File metadata and controls

732 lines (499 loc) · 36.2 KB

MeshLab documentation

For more info on MeshLab, you can watch the youtube videos of Mister P. MeshLab Tutorials

Random tip: For massive pointclouds (ie. >2mil points), you can:

  1. make it invisible
  2. take a smaller sample of it (how to sample)
  3. select the original (massive) pointcloud layer
  4. do operations (eg. selecting points/faces) on the invisible original pointcloud, while using the smaller sample pointcloud to guide you

    or perhaps, view the normals of the sample pointcloud, to get a representative view of the normals of the original pointcloud (without the lag)




Table of Contents





WARNINGS

MeshLab does NOT:

  • have an undo function
  • prompt you to save when you close it
  • prompt you when deleting layers, points/faces, etc.
  • prompt you before performing an operation. Thus, before you perform an operation on a layer, ensure you selected the right layer




Saving / Exporting (back to Contents)

I highly recommend that you DON'T save using File > Save Project As... (Ctrl + S).

  • it's quite iffy
  • forces you to choose to save/not-save each and every one of the layers
  • if you change the directory of the project later, it might not be able to detect the mesh/pointcloud files when you open it

Instead, use File > Export Mesh As... (Ctrl + Shift + E), which saves the selected layer as a file type of your choice. (I usually save as .ply)

Then to open the mesh/pointcloud files, simply import them into MeshLab via File > Import Mesh... (Ctrl + I) or by clicking this icon at the top left:





Navigation / Manipulation (back to Contents)

Key What it does
LeftMouseButton(LMB) (hold + drag) rotate about trackball center
MouseWheel zoom in/out
MiddleMouseButton(MMB) (hold + drag) move trackball
double click (on a point/face) center trackball at the selected point/face



Useful shortcuts (back to Contents)

Key What it does
Ctrl + H reset camera settings
Shift + mouseWheel change Field of View (FOV)
Alt + Enter fullscreen mode
Ctrl + Shift + LMB (hold + drag) change direction of lighting
(effects are only visible if model has normals)
Ctrl + mouseWheel change near clipping range
(how close a point/face has to be to you, before it unrenders)
Ctrl + Shift + E export mesh/pointcloud



Point / Face display settings (at bottom right) (back to Contents)

For points:

For faces:


Tip: Hold shift and change these settings to apply the settings to all visible layers.


Shading (for points) (back to Contents)

Setting What it does
Vert square points, shading based on point's normal and direction of lighting
(adjustable via Ctrl + Shift + LMB (hold + drag))
Dot Decorator circular points, no shading
None square points, no shading

Setting What it does
Vert based on point's color
Mesh Usually either gray or purple color
User-Def defined your own color

Back-Face (for faces) (back to Contents)

Setting What it does
Single face's normal pointing at you -> brightest
pointing away from you -> darkest
Double face's normal is pointing at or away from you -> brightest
pointing perpendicular from you -> darkest
Fancy face's normal pointing < 90° from you -> slightly bluish
pointing > 90° from you -> slightly reddish
Cull face's normal pointing < 90° from you -> visible
pointing > 90° from you -> invisible




Layer control (back to Contents)

Inverting the layers selected (back to Contents)

Hold shift and toggle the visibility of any one layer. It will cause all visible layers to be invisible, and vice versa.




Duplicating layers (back to Contents)

Right-click the desired layer, and select Duplicate current layer




Moving / Copying selected points/faces to new layer (back to Contents)

  1. select the points/faces you want to move

  2. right-click the layer

  3. select Move select faces/vertices to another layer

    Image

  4. (Optional) If you want to copy to new layer instead of moving, uncheck Delete original selection

  5. Apply




Combining layers (back to Contents)

  1. make all the layers you want to combine visible

  2. right-click on any layer

  3. select Flatten visible layers

  4. check:

    • Merge only visible layers
    • Merge duplicate vertices (duplicate vertices are points that have exact same coordinates)
    • Keep unreferenced vertices (this is needed for pointclouds, else it will delete all points that doesn't have a face)
  5. (Optional) If you only want the resulting merged layer, and don't want the currently selected componenet layers, check Delete layers

  6. Apply




Deleting layers (back to Contents)

WARNING
MeshLab does NOT prompt for confirmation when deleting layers.

  • to delete 1 layer, right-click that layer, and select Delete Current Mesh
  • to delete multiple layers at once, make all the layers you want to keep visible, and all the layers you don't want invisible. Then right-click a layer and select Delete all non visible Mesh Layers.




Point / Face selection (back to Contents)

The selection mode (back to Contents)

To enter selection mode, click on one of these icons:
They are (from left to right):

  • Select vertexes
  • Select faces
  • Select connected components in a region

I've never used Select connected components in a region before so idk how to.

After clicking, most of the top-bar icons should be grayed out like this

To move/rotate the camera: click on the trackball icon or press Esc

Which will display the trackball

To go back to selecting: click on the Select vertexes/face/connected components icon again, or press Esc.

Which will hide the trackball

Note: the red-highlighting of selected points might not be visible (or barely visible) at small point sizes.

GIFAs show in the GIF, at small point sizes, the red-highlight is barely visible. So you might need to increase point size to see them.




To select points/faces, enter the selection mode (as described above), then hold and drag LMB.

When selecting, you can press and hold on these keys:

Key What it does
Ctrl(Hold) Additive/Union selection
Shift(Hold) Deselection



What it does Location Shortcut
Inverts the selection Filters > Selection > Invert Selection Ctrl + Shift + I
Select all Filters > Selection > Select All Ctrl + Shift + A
Deselect all Filters > Selection > Select None Ctrl + Shift + D

Some noteworthy advanced operations (back to Contents)

Note: The operations here are just the ones I often used. There's many more under Filters > Selection.

What it does Location
Select big faces (useful for cleaning up meshs) Filters > Selection > Select faces with edges longer than
Select specific faces/vertices using a user-defined function Filters > Selection > Conditional face/vertex selection



WARNING
MeshLab does not have an undo function, and does not prompt for confirmation when deleting. So ensure that you select the correct pointcloud/mesh layer, as it's possible to accidentally delete from a selected non-visible layer.

To delete selected points/faces, click on one of these icons:





Sampling / Subsampling / Down-sampling (back to Contents)

It's an operation to take a smaller pointcloud sample from a pointcloud. Useful for when the pointcloud is too large.

I only used screen poisson-disk sampling, so idk about the other algorithms.


Poisson-disk sampling (back to Contents)

  1. select Filters > Sampling > Poisson-disk Sampling

  2. set the Number of samples

    I often set to 2mil, which usually results in 400k-1mil points

    If you want a specific number of samples, check Exact number of samples which will result in a pointcloud with (Number of samples ± 0.5%) points but takes MUCH longer

  3. check Base Mesh Subsampling (this is needed if the model is a pointcloud with no faces)

  4. Apply





Computing normals for pointcloud (back to Contents)

Computing the normals for a pointcloud is quite easy:

  1. select Filters > Normals, Curvatures and Orientation > Compute normals for point sets
  2. set desired Neighbour num
    I usually go for the default 10, and it so far worked out; but I've seen some online articles state to set more neighbour (eg. 16)
  3. Apply (or Preview, if you want to preview the results instead)



HOWEVER, here's the problem (back to Contents)

Sometimes, computed normals points in the opposite direction of what you want.

Example images Here's an image of the pointcloud of a floor.
Notice how some of the normals are pointing downwards instead of up.



Here's a bird's-eye view of the same floor pointcloud.
The dark gray points have normals facing downwards instead of upwards.



Here's the cross section of a square column / pillar.
Notice how all the normals are pointing inwards instead of outwards.


This can cause problems during meshing, resulting in malformed meshes.

Example images Here's an image of the pointcloud of a floor, where the dark yellow points are pointing the wrong way.

Here's reconstructed mesh made from the above pointcloud.
Notice the rock-like malformation at the spot with alot of incorrectly pointed normals.


Also, it may cause problems when rendering pointcloud models. (this only cause problems when the normals are used in rendering, eg. for lighting, or back-face culling)

One such situation is when the rendering engine uses back-face culling, where if the points' normals are pointing away from you, it won't be rendered.



To fix the above problem (back to Contents)

  • For a simple model, that only has a single plane, like a wall or floor:

    1. look at the pointcloud/mesh in the direction opposing the normal vector direction that you want. (eg. for a floor mesh, look at it from a bird's-eye view, as you want the normals to point up)

      Example imageBird's-eye view of the pointcloud of a floor.

      Zoom out so that the pointcloud/mesh looks far away from you (reason)
      Example image

    2. select Filters > Normals, Curvatures and Orientation > Compute normals for point sets

    3. set desired Neighbour num

    4. under Viewpoint Pos., in the Get drop down list, select View Pos.

      Example image

    5. check the Flip normals w.r.t. viewpoint option

    6. Apply

    This will flip all the normals towards your view point in Step 1


  • For models that aren't just a single plane pointcloud:

    • you'll have to first compute the normals with the Flip normals w.r.t. viewpoint option unchecked

    • then by using multiple different view-points / view-directions, you'll need to flip the wrongly faced points using the method described in the Flipping normals for pointcloud section below

      Example imageHere's the cross-section of a column / pillar.
      Notice how some points' normals are facing inwards instead of outwards.


      To flip the inward-facing normals using the Flipping normals for pointcloud methods, at least 2 viewpoints are needed as shown.
      To understand why, read up about how this works here.




Viewing normals (back to Contents)

To get a rough visualisation of the normals

  1. change color of the points/faces to a either Mesh or User-defined
  2. change shading of the points/faces to Vert
    Example image

This will make the points/faces (with normals that are pointing towards you) darker.

This is much less laggy than Method 2.

Useful for finding outliers with normals that are facing the wrong way.


Image The lighter-colored gray points have normals pointing towards me. The almost-black darker ones are pointing away from me.

WARNING
This method can get quite laggy if there are alot of points/faces. (around >1mil, depending on your GPU)

To see normals vectors:

  1. select Render > Show normals

  2. if you don't see blue-purple lines like this:

    Image
    go to the bottom right panel and check Per Vertex/Face
    Image

  3. (Optional) If the normals are too long or short, go to the bottom right panel and increase/decrease Vector length

    Image


FYI: For very big pointclouds, you can do a Sampling operation to get a smaller pointcloud, and then viewing the normals of the sample instead.




Flipping normals for pointcloud (back to Contents)

Sometimes, computed normals points in the opposite direction of what you want.

Example image In the image below, there are some normals pointing downwards instead of up.

To correct this:

To select the points that are pointing the wrong direction:

  • If there are only a few points, just select them manually

  • If there are many:

    1. look at the pointcloud/mesh in the direction opposing the normal vector direction that you want. (eg. for a floor mesh, look at it from a bird's-eye view, as you want the normals to point up)

      Example imageThis is a bird's-eye view of a pointcloud of a floor.
      The dark gray points have normals facing downwards instead of upwards.

      Zoom out so that the pointcloud/mesh looks far away from you (reason)
      Example image

    2. select Filters > Normals, Curvatures and Orientation > Compute normals for point sets

    3. under Viewpoint Pos., in the Get drop down list, select View Pos.

      Example image

    4. using notepad (or any other text program), replace the cx, cy, cz in the code below, with the xyz coordinates from the Viewpoint Pos. in Step 3

      vsel && (acos((nx * (cx - x) + ny * (cy - y) + nz * (cz - z)) / (sqrt((cx - x) * (cx - x) + (cy - y) * (cy - y) + (cz - z) * (cz - z)))) > 3.14159265/2.0)
      Example image

    5. select the affected region. The operation will only pick points from the selected points

      Example imageYou can select only part of the pointcloud like this:

      Or the entire pointcloud like this:

    6. select Filters > Selection > Conditional Vertex Selection

    7. copy the modified code in Step 4 into the boolean function input, and apply.

      Example image

      This will select all the wrong-facing points from the points selected in Step 5
      Example image



    1. by holding the middle-mouse-button (MMB), position the trackball center far away in the direction of the normals you want (eg. if you want the normals to point up, put the trackball far above the points)

      Example imageThis is a pointcloud of a floor, with the purple normal vectors pointing upwards towards the trackball center.

      The trackball is place far above the pointcloud.

    2. select Filters > Normals, Curvatures and Orientation > Compute normals for point sets

    3. under Viewpoint Pos., in the Get drop down list, select Trackball Center

      Example image

    4. Follow the steps from Method 1 - by view position starting Step 4



    1. look in the direction opposing the normal vector direction that you want (eg. if you want the normals to point up, look downwards) (this doesn't depend on your position, only your view direction)

      Example imageThis is a pointcloud of a floor, with the purple normal vectors pointing upwards.

      So I'm looking downwards.

    2. select Filters > Normals, Curvatures and Orientation > Compute normals for point sets

    3. under Viewpoint Pos., in the Get drop down list, select something besides View Dir. first, then select View Dir.. (else it won't update the Viewpoint Pos. coords)

      Ensure the Viewpoint Pos. coord isn't 0, 0, 0

      Example image

    4. using notepad (or any other text program), replace the vdx, vdy, vdz in the code below, with the xyz coordinates from the Viewpoint Pos. in Step 3

      vsel && (acos((nx * vdx + ny * vdy + nz * vdz) / (sqrt(vdx * vdx + vdy * vdy + vdz * vdz))) > 3.14159265/2.0)
      Example image

    5. select the affected region. The operation will only pick points from the selected points

      Example imageYou can select only part of the pointcloud like this:

      Or the entire pointcloud like this:

    6. select Filters > Selection > Conditional Vertex Selection

    7. copy the modified code in Step 4 into the boolean function input, and apply.

      Example image

      This will select all the wrong-facing points from the points selected in Step 5
      Example image



Flipping the selected (back to Contents)

  1. select Normals, Curvatures, Orientation > Per Vertex Normal Function

  2. leave the functions as default, and check only on selection

    Image

  3. Apply




For illustration purposes, 2D vectors are used here

  • For Method 1 (by view position) and Method 2 (by trackball):

    • a point is taken as the viewpoint, either by view position or by the trackball center.

    • for each point in the pointcloud:

      • a vector is created, from that point to the viewpoint

      • then the angle between the new vector and the point's normal is computed by using this formula:

        θ = acos[(uv) / (|u||v|)]
        where θ is the angle,
        u and v are the 2 vectors,
        and |u| and |v| are their magnitudes.

      • if that angle is > 90° (ie. π/2), the point's normal is flipped

    • Here's a gif showing the above steps:


    • as to why the view point must be far away from the model,
      here's a gif showing a viewpoint thats very close the the model,
      and a point that's on a "bump" on a floor pointcloud.
      Notice how although the point's normal is facing the wrong way, it isn't flipped as the angle is < 90°.



  • For Method 3 (by view direction):

    • with reference to the above For Method 1 (by view position) and Method 2 (by trackball) section, the new vector used is the view direction.

      The view direction (obtained from Method 3 - Step 3) is a vector with a direction opposing the direction you are facing. (ie. a vector that points at you)




Meshing of a pointcloud (back to Contents)

Note: You'll need a pointcloud WITH NORMALS to do meshing. If the pointcloud doesn't have normals, go to the Normals – Computing normals for pointcloud section to see how to computing the normals.




I only used screen poisson surface reconstruction, so idk about the other algorithms.

Poisson surface reconstruction algorithm (back to Contents)

  1. select Filters > Remeshing, Simplification and Reconstruction > Screen Poisson Surface Reconstruction.
    Which will display this menu:

  2. Reconstruction Depth determines the resolution of the resulting mesh. It also depends on the size of the pointcloud (ie. if depth=10 produced a good mesh for one pointcloud, it might not for a bigger/smaller pointcloud)

    you'll have to experiment with this value yourself

  3. For all the other parameters, idk what they exactly do. Click on Help for more info on them

  4. Apply (the meshing might take awhile)




Cleaning the mesh (back to Contents)

Here's the mesh of a floor. The yellow region is the pointcloud used.

Notice how the mesh extents further than the pointcloud.

To remove this excess surface:

  • you can select and delete the excess faces manually

  • or you can select the based on the face size like this:

    1. select Filters > Selection > Select Faces with edges longer than....

      Image

    2. check the Preview option

    3. keep tweaking the Edge Threshold value until it selects as much of the excess faces , but none of the faces in the area that you want to keep

      Image

    4. Apply

    5. delete the selected faces and their vertices, by clicking this icon:

    • Then you'll need to remove all the isolated pieces of faces by:

      1. select Filters > Cleaning and Repairing > Remove Isolated pieces (wrt Face Num.)

      2. leave the Remove unreferenced vertices option checked

      3. set Enter minimum conn. comp size higher if there are bigger isolated pieces in your model

      4. Apply
        Result:





Closing holes in mesh (back to Contents)

If you mesh has holes like this:

you can fill / close them up by:

  1. select Filters > Remeshing, Simplification and Reconstruction > Close Holes

  2. (if you want close specific holes) select the faces around the hole, and check Close holes with selected faces

    Image

  3. set desired Max size to be close (you'll need to experiment with this to find the right value)

  4. Apply

    Result image





Moving, rotating, and scaling (back to Contents)

To do these, you need to click on the Manipulators Tool, which is this icon:

Which will display this on the top left:

While in Manipulator mode, if your trackball is displayed, press Esc which should hide your trackball

If you want to rotate the camera view, press Esc, which will display the trackball.
Press Esc again to return to the manipulating.

Note: During translation, rotation, and scaling, ensure that your trackball is hidden. They won't work if your trackball is shown, because you are moving the camera instead.

To exit the Manipulator mode, click on this icon again:




Moving / Translation (back to Contents)

  1. press T, which will display this on the top left:

  2. if you want to move only in 1 axis, press X, Y or Z, which will lock the movement to only the X, Y or Z axis respectively.
    Which displays this:

    Note: Idk what's the difference between global and local X/Y/Z.

  3. left-click, hold and drag to move the model. Hold shift if you want to snap to the nearest integer

  4. once you're done moving, press Enter to apply the translation.
    If you want to discard the changes, press Backspace

  5. (IMPORTANT) right-click the model's layer, select Matrix: Freeze Current Matrix, and Apply

    CAUTION: If you don't freeze the matrix, the translation, rotation and/or scaling will be reverted after you export the model.




  1. press R, which will display this on the top left:

  2. if you want to rotate about an axis, press X, Y or Z, which will lock the rotation to only the X, Y or Z axis respectively.

  3. if you want to rotated about the center of the model instead of the origin, press Spacebar, which will show Rotate around BBox center instead of Rotate around Mesh Origin

  4. left-click, hold and drag to rotate the model. Hold shift if you want to snap to the nearest integer

  5. once you're done rotating, press Enter to apply the rotation.
    If you want to discard the changes, press Backspace

  6. (IMPORTANT) right-click the model's layer, select Matrix: Freeze Current Matrix, and Apply

    CAUTION: If you don't freeze the matrix, the translation, rotation and/or scaling will be reverted after you export the model.




  1. press S, which will display this on the top left:

  2. if you want to scale in 1 axis only, press X, Y or Z, which will lock the scaling to only the X, Y or Z axis respectively.

  3. if you want the scaling to be centered at the center of the model instead of the origin, press Spacebar, which will show Scale around BBox center instead of Scale around Mesh Origin

  4. left-click, hold and drag to scale the model. Hold shift if you want to snap to the nearest integer

  5. once you're done rotating, press Enter to apply the scaling.
    If you want to discard the changes, press Backspace

  6. (IMPORTANT) right-click the model's layer, select Matrix: Freeze Current Matrix, and Apply

    CAUTION: If you don't freeze the matrix, the translation, rotation and/or scaling will be reverted after you export the model.