rust ~ 3D描画ライブラリ ~


rustの3D描画ライブラリkiss3dのサンプルを動作させてみました。その結果をまとめたいと思います。

環境

ubuntu18.04

インストール

$ git clone https://github.com/sebcrozet/kiss3d.git

サンプルの実行

どのようなサンプルが用意されているか確認すると次のようになります。

$ cd ~/kiss3d
$ cargo run --example
error: "--example" takes one argument.
Available examples:
    add_remove
    camera
    cube
    custom_material
    custom_mesh
    custom_mesh_shared
    decomp
    event
    group
    lines
    mouse_events
    obj
    persistent_point_cloud
    planar_lines
    points
    post_processing
    primitives
    primitives2d
    primitives_scale
    procedural
    quad
    rectangle
    screenshot
    stereo
    text
    texturing
    ui
    window
    wireframe

次に各サンプルの動作を確認していきます。

サンプル1 add_remove

$ cargo run --example add_remove

このサンプルでは3Dのキューブ表示されます。写真ではわかりませんが、実際にはキューブがチカチカしていたため、描画したり消したりといった処理を行っていると考えられます。

サンプル2 camera

$ cargo run --example camera

このサンプルでは座標軸が画面内で回転している様子を確認することができます。

サンプル3 cube

$ cargo run --example cube

このサンプルでは3Dのキューブが表示されます。

サンプル4 custom_material

$ cargo run --example custom_material

このサンプルでは3Dグラフィック上で、きれいな色の球体が回転します。

サンプル5 custom_mesh

$ cargo run --example custom_mesh

このサンプルでは三角形のメッシュが回転します。

サンプル6 custom_mesh_shared

cargo run --example custom_mesh_shared

このサンプルでは赤、緑2枚の三角形メッシュが回転します。

サンプル7 decomp

$ cargo run --example decomp
Usage: target/debug/examples/decomp obj_file scale clusters concavity

Options:
    obj_file  - the obj file to decompose.
    scale     - the scale to apply to the displayed model.
    clusters  - minimum number of clusters.
    concavity - the maximum concavity accepted by the decomposition

こちらのサンプルは何らかのファイルを入力必要があるようです。今回は試せていません。

サンプル8 event

$ cargo run --example event

このサンプルは3Dグラフィック上のマウスカーソルの座標を出力します。

サンプル9 group

$ cargo run --example group

このサンプルでは写真のような3Dオブジェクトがそれぞれ回転します。

サンプル10 lines

$ cargo run --example lines

このサンプルでは2次元上に三角形のラインが描画されます。

サンプル11 mouse_events

$ cargo run --example mouse_events

このサンプルではグラフィック上のクリックした位置を出力します。

サンプル12 obj

$ cargo run --example obj
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/scene/scene_node.rs:865:16
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

このサンプルは何らかのエラーが発生して、今回は試すことができませんでした。

サンプル13 persistent_point_cloud

$ cargo run --example persistent_point_cloud
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0277`.
error: could not compile `kiss3d`

To learn more, run the command again with --verbose.

このサンプルでも何らかのエラーが発生して、今回は試すことができませんでした。

サンプル14 planar_lines

$ cargo run --example planar_lines

こちらのサンプルでは2Dグラフィック上に三角形のラインが描画されました。

サンプル15 points

$ cargo run --example points

写真では見えにくいですが赤、緑、青の3つの点が表示されます。

サンプル16 post_processing

$ cargo run --example post_processing

このサンプルでは下の写真の物体が変形したり、縁の色を変化させたりといった様子が表示されます。

サンプル17 primitives

$ cargo run --example primitives

こちらのサンプルでは、上のサンプルと形状が似た物体が生成されますが、上のように変化はありません。

サンプル18 primitives2d

$ cargo run --example primitives2d

このサンプルでは丸や四角形の図形が表示されます。

サンプル19 primitives_scale

$ cargo run --example primitives_scale

このサンプルでは、次のようにとてもたくさんの物体が表示され回転している様子を確認できます。

サンプル20 procedural

$ cargo run --example procedural
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0277`.
error: could not compile `kiss3d`

To learn more, run the command again with --verbose.

このサンプルはエラーにより動作しませんでした。

サンプル21 quad

$ cargo run --example quad

このサンプルでは、3次元空間上に平面が波打っている様子が確認できます。

サンプル22 rectangle

$ cargo run --example rectangle

このサンプルでは2D空間上に四角形が回転している様子が確認できます

サンプル23 screenshot

$ cargo run --example screenshot

このサンプルを実行すると3Dグラフィック上のスクリーンショットが生成されます。

サンプル24 stereo

$ cargo run --example stereo

下の写真のように四角形が2つ表示されます。マウスでグリグリするとどちらも同じように動くので、物体がコピーされて表示されているようです。

サンプル25 text

$ cargo run --example text

サンプル26 texturing

$ cargo run --example texturing

このサンプルでは、キューブにテキスチャーを貼っている様子が表示されます。

サンプル27 ui

$ cargo run --example ui
thread 'main' panicked at 'The 'conrod' feature must be enabled for this example to work.', examples/ui.rs:21:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

このサンプルでは、上記のメッセージが表示されるのみでした。

サンプル28 window

$ cargo run --example window

このサンプルでは、青い色のwindowが表示されます。

サンプル29 wireframe

$ cargo run --example wireframe

このサンプルでは3次元の物体をフレームで表示している様子が表示されます。