Tango Constructorから出力したモデルをちょこっと綺麗にする

Preview:

Citation preview

Tango Constructorから出力したモデルをちょこっと綺麗にする

社内勉強会#30スタジオアルカナ

遠藤勝也

綺麗にするモデル

https://sketchfab.com/models/4461c2d0da1a44588b499691f38aece4

https://sketchfab.com/models/9b2c4d3eb4ee4d8d9166ee07f6e23dc9

やってみよう

できれば3DモデリングソフトとかのAPIを叩いたりしたい

自分で頂点のいじったら

テクスチャの頂点とかもずれそうで怖い

候補

Blender

Mesh Lab

3Dモデルの編集に特化しているMesh Labで実験

ノイズを消すならおそらく

平滑化とかだろう!

だけどどんな平滑化手法が

いいんだろう�

http://cg.xyamu.net/Blender/entry276.html

Laplacian Smooth微細なポリゴンで構成されたオブジェクト表面の

荒れを軽減したり、シンプルな形状のオブジェクトを元に新しい形状にしたりできます。

Mesh LabでLaplacian Smoothを

試してみる

綺麗になったけど床に穴が空いてる

しかもStepを増やすと大きくなる

壁にも規則正しく

面選択すると綺麗に選択できちゃう

面選択すると綺麗に選択できちゃう

おそらくTango ConstructorではSLAMの際にこんな感じで平面を分割している

原因

おそらくTangoから出力されたモデルは1つの平面を複数の平面に分割している

解決策

重複する頂点をマージしてから平滑化してみる

マージして……

平滑化!!

できた!

一通りの手順

Mesh Labを立ち上げた画面

.objを読み込み

.objを読み込み

.objを読み込み

右上のFindから"Remove Duplicate Vertices"を選択

見た目はわからないけどマージされた

次は"Laplacian Smooth"を選択

Smoothing stepsとか設定できるけどそのままPreviewにチェックをいれて確認

Smoothing stepsとか設定できるけどそのままPreviewにチェックをいれて確認

適応前

適応後

一応比較

MeshLabにはmeshlabserverというcliが用意されている

みたいなのでスクリプトにしておく

環境

MacOS X High Sierra

Mesh Lab v2016.12

まずはQtの依存関係を解決$ cd /Applications/meshlab.app/Contents/MacOS$ install_name_tool -add_rpath\> "@executable_path/../Frameworks" meshlabserver$ ./meshlabserver

Usage:meshlabserver [logargs] [args] where logargs can be: -d filename dump on a text file a list of all filtering functions -l filename log of the filters is ouput on a where args can be: -p filename meshlab project (.mlp) to be loaded -w filename [-x] output meshlab project (.mlp) to If -x flag is

平滑化までの一通りの処理を

スクリプトで保存

1. 一通りの処理を実行するマージ -> 平滑化

2. 終わったらFilters > Show current �lter script

3. 処理があっているか確認してSave Scriptで.mlxを書き出し

<!DOCTYPE FilterScript><FilterScript> <filter name="Remove Duplicate Vertices"/> <filter name="Laplacian Smooth"> <Param tooltip="The number of times that the whole algorithm (normal smoothing + vertex fitting) is iterated." <Param tooltip="If true the boundary edges are smoothed only by themselves (e.g. the polyline forming the boundary of the mesh is independently smoothed). Can reduce the shrinking on the border but can have strange effects on very small boundaries." <Param tooltip="If true the cotangente weighting scheme is computed for the averaging of the position. Otherwise (false) the simpler umbrella scheme (1 if the edge is present) is used." <Param tooltip="If checked the filter is performed only on the selected faces" </filter></FilterScript>

実行

$ /Applications/meshlab.app/Contents/MacOS/meshlabserver \-i 20170626154555/20170626154555.obj \-o 20170626154555/output.obj \-m wt \-s merge_smoothing.mlx

まとめ

ちょっとだけ綺麗にすることができた

平滑化はあくまでオリジナルの形を崩してしまう

ことを理解しておくことが必要

参考

http://cg.xyamu.net/Blender/entry276.html

https://jnphgs.blogspot.jp/2016/06/meshlab.html

ありがとうございました

Recommended