Home

Awesome

vviz

Latest version Documentation Continuous integration MIT Apache

Rapid prototyping GUI, and visual printf-style debugging for computer vision development.

Its core dependencies are egui and Miniquad. For a full list of dependencies, please inspect the Cargo.toml file.

Warning: Development halted

This project is currently parked - I do not plan to continue development in the short term. It is likely I will continue in a year or three - especially if Rust adoption continues in similar rapid fashin.

A few challenges I encountered with the current approach:

Getting started

Placing a 3d entity in the main panel.

    vviz::app::spawn(vviz::app::VVizMode::Local, |mut manager: vviz::manager::Manager| {
        let w3d = manager.add_widget3("w3d".to_string());
        w3d.place_entity_at(
            "cube".to_string(),
            vviz::entities::colored_cube(1.0),
            vviz::math::rot_x(0.7),
        );
        loop {
            manager.sync_with_gui();
        }
    });

simple example image

Interacting with ranged values (sliders) and enums (combo boxes).

    #[derive(
        Clone,
        Debug,
        PartialEq,
        strum_macros::Display,
        strum_macros::EnumString,
        strum_macros::EnumVariantNames,
    )]
    enum Manipulation {
        Position,
        Orientation,
    }

    vviz::app::spawn(vviz::app::VVizMode::Local, |mut manager: vviz::manager::Manager| {
        let w3d = manager.add_widget3("w3d".to_string());

        w3d.place_entity("cube".to_string(), vviz::entities::colored_cube(1.0));
        let mut scene_pose_entity = nalgebra::Isometry3::<f32>::identity();

        let mut ui_delta = manager.add_ranged_value("delta".to_string(), 0.0, (-1.0, 1.0));
        let mut ui_dim = manager.add_ranged_value("dimension".to_string(), 0, (0, 2));
        let mut ui_manipulation =
            manager.add_enum("manipulation".to_string(), Manipulation::Position);

        loop {
            if ui_delta.get_new_value().is_some()
                || ui_dim.get_new_value().is_some()
                || ui_manipulation.get_new_value().is_some()
            {
                let delta = ui_delta.get_value();
                let manipulation = ui_manipulation.get_value();
                match manipulation {
                    Manipulation::Position => {
                        scene_pose_entity.translation.vector[ui_dim.get_value()] = delta;
                    }
                    Manipulation::Orientation => {
                        let mut scaled_axis = nalgebra::Vector3::zeros();
                        scaled_axis[ui_dim.get_value()] = delta;
                        scene_pose_entity.rotation =
                            nalgebra::UnitQuaternion::<f32>::from_scaled_axis(scaled_axis);
                    }
                }
                w3d.update_scene_pose_entity("cube".to_string(), scene_pose_entity)
            }
            manager.sync_with_gui();
        }
    });

interaction example gif

Multiple widgets

    vviz::app::spawn(vviz::app::VVizMode::Local, |mut manager: vviz::manager::Manager| {
        let w3d = manager.add_widget3("w3d".to_string());
        w3d.place_entity_at(
            "cube".to_string(),
            vviz::entities::colored_cube(0.5),
            nalgebra::Isometry3::<f32>::translation(0.0, 0.75, 0.0),
        );
        w3d.place_entity_at(
            "cube2".to_string(),
            vviz::entities::colored_cube(0.5),
            nalgebra::Isometry3::<f32>::translation(0.0, -0.75, 0.0),
        );

        let w2 = manager.add_widget3("w2".to_string());
        let triangles = vec![vviz::entities::ColoredTriangle {
            face: [[2.0, -2.0, 0.0], [2.0, 1.0, 0.0], [0.0, 1.0, 0.0]],
            color: vviz::entities::Color {
                r: 1.0,
                g: 0.0,
                b: 0.0,
                alpha: 1.0,
            },
        }];
        w2.place_entity(
            "triangles".to_string(),
            vviz::entities::colored_triangles(triangles),
        );
        let _w3 = manager.add_widget3("empty".to_string());

        let mut ui_a_button = manager.add_button("a button".to_string());
        loop {
            if ui_a_button.was_pressed() {
                println!("a button pressed");
            }
            manager.sync_with_gui();
        }
    });

multi-widget example gif

2d widgets - to show an image

    vviz::app::spawn(vviz::app::VVizMode::Local, |mut manager: vviz::manager::Manager| {
        let image: image::DynamicImage = vviz::utilities::load_image_from_url(
            "https://rustacean.net/assets/rustacean-orig-noshadow.png",
        )
        .unwrap();
        manager.add_widget2("img".to_string(), image.into_rgba8());
        manager.sync_with_gui();
    });
    

widget2 gif

    vviz::app::spawn(vviz::app::VVizMode::Local, |mut manager: vviz::manager::Manager| {
        let w3d = manager.add_widget3("w3d".to_string());
        w3d.place_entity_at(
            "axis".to_string(),
            vviz::entities::Axis3::from_scale(1.0).into(),
            vviz::math::rot_x(0.7),
        );

        w3d.place_entity_at(
            "points".to_string(),
            vviz::entities::ColoredPoints3::from_arrays_and_color(
                vec![
                    [0.50, 0.50, 0.5],
                    [0.25, 0.50, 0.5],
                    [0.50, 0.25, 0.5],
                    [0.25, 0.25, 0.5],
                ],
                vviz::entities::Color {
                    r: 1.0,
                    g: 0.0,
                    b: 0.0,
                    alpha: 1.0,
                },
            )
            .into(),
            vviz::math::rot_x(0.7),
        );
        loop {
            manager.sync_with_gui();
        }
    });
    

Lines and points

lines and points gif

Goals

Non-goals

Roadmap

Acknowledgements

vviz is influenced by other open source projects, especially Pangolin.