Skip to main content

Python bindings for SlamDunk

Project description


SlamDunk is a powerful and user-friendly C++/Python library for making live 3D and 2D visualizations for prototyping, data exploration, and algorithm development.

It is very lightweight, built using OpenGL and ImGui.

The project is in very early development with many improvements coming in the near future.

Examples

Hello world

Here is a simple "hello world" program for a SlamDunk visualization.

#python
import slamd

if __name__ == "__main__":
    vis = slamd.Visualizer("Hello world")

    scene = slamd.Scene()

    scene.set_object("/origin", slamd.geom.Triad())

    vis.add_scene("scene", scene)

    vis.hang_forever()
// C++
#include <slamd/slamd.hpp>

int main() {
    auto vis = slamd::visualizer("hello_world");

    auto scene = slamd::scene();

    scene->set_object("/origin", slamd::geom::triad());

    vis->add_scene("scene", scene);

    vis->hang_forever();
}

This example highlights the main components of SlamDunk.

  1. The Visualizer object maintains the state of the visualization. It starts a TCP server, and spawns a viewer process that reads from it and displays the visualizations.
  2. A Scene object represents and contains a tree of 3D objects.
  3. Geometry objects can be added to Scenes with a path in the tree.
  4. To display a scene, we must add it to the visualizer - this creates a view of the scene.

Running this program results in the following interactive visualization:

Multiple scenes

We use ImGui to allow multiple sub-windows with floating and docking support inside the SlamDunk viewer. The following example illustrates creating two windows, each showing its own scene.

# python
import slamd
import numpy as np

if __name__ == "__main__":
    vis = slamd.Visualizer("two windows")

    scene1 = slamd.Scene()
    scene2 = slamd.Scene()

    vis.add_scene("scene 1", scene1)
    scene1.set_object("/box", slamd.geom.Box())

    vis.add_scene("scene 2", scene2)
    scene2.set_object("/origin", slamd.geom.Triad())

    scene2.set_object("/ball", slamd.geom.Sphere(2.0))

    sphere_transform = np.identity(4, dtype=np.float32)
    sphere_transform[:, 3] = np.array([5.0, 1.0, 2.0, 1.0])

    scene2.set_transform("/ball", sphere_transform)

    vis.hang_forever()
// C++
#include <glm/glm.hpp>
#include <slamd/slamd.hpp>

int main() {
    auto vis = slamd::visualizer("two windows");

    auto scene1 = slamd::scene();
    auto scene2 = slamd::scene();

    vis->add_scene("scene 1", scene1);
    scene1->set_object("/box", slamd::geom::box());

    vis->add_scene("scene 2", scene2);
    scene2->set_object("/origin", slamd::geom::triad());
    scene2->set_object("/ball", slamd::geom::sphere(2.0f));

    glm::mat4 sphere_transform(1.0);
    sphere_transform[3] += glm::vec4(5.0, 1.0, 2.0, 1.0);

    scene2->set_transform("/ball", sphere_transform);

    vis->hang_forever();
}

The resulting window looks like this:

The windows are fully controllable - you can drag then around, make tabs, use them in floating mode, dock them to the sides like you see in the screenshot. All of this is supported by ImGui.

Further reading

The examples in the /examples folder showcase some more features of SlamDunk, like

  • Canvases for 2D visualizations
  • Multiple views of the same scene
  • Moving objects around.
  • Taking control of the render loop to create fully-fletced GUIs around SlamDunk using the power of ImGui.

Installation

Python

The python binding wheels are available on PyPi, so you can simply

pip install slamd

C++

With FetchContent

You can use CMake's FetchContent. Add this to your CMakeLists.txt:

include(FetchContent)

FetchContent_Declare(
  slamd
  GIT_REPOSITORY https://github.com/Robertleoj/slam_dunk.git
  GIT_TAG main
  SOURCE_SUBDIR slamd
)

FetchContent_MakeAvailable(slamd)

Linking to it then looks like:

target_link_libraries(
    your_target PRIVATE

    slamd::slamd
)

With git submodules

If you add the repo as a submodule in your project, you can add it as a subdirectory with

add_subdirectory(path/to/slam_dunk/slamd)

Just make sure to

git submodule update --init --recursive

inside the submodule, as all necessary dependencies are vendored.

You can then link it to your executable or library with

target_link_libraries(
    your_target PRIVATE

    slamd::slamd
)

Contributions

All contributions are welcome! SlamDunk is in very early development, so there is enough work to do, and multiple things to improve.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

slamd-2.1.3-cp313-cp313-manylinux_2_28_x86_64.whl (67.9 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

slamd-2.1.3-cp313-cp313-macosx_11_0_arm64.whl (8.0 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

slamd-2.1.3-cp312-cp312-manylinux_2_28_x86_64.whl (67.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

slamd-2.1.3-cp312-cp312-macosx_11_0_arm64.whl (8.0 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

slamd-2.1.3-cp311-cp311-manylinux_2_28_x86_64.whl (67.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

slamd-2.1.3-cp311-cp311-macosx_11_0_arm64.whl (8.0 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

Details for the file slamd-2.1.3-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for slamd-2.1.3-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c9ed94cf9f35d3bfd2c0ce0ac8c4a1305b7a851caf72575203f4aeb3f98abf1d
MD5 486ae97e9e96f02c69583a2d657e790f
BLAKE2b-256 76028bfe2fe11d162228c13b121bf4a182de65a8c1b0ae3787f26d9cbe2cd7e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for slamd-2.1.3-cp313-cp313-manylinux_2_28_x86_64.whl:

Publisher: pip_publish.yml on Robertleoj/slam_dunk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file slamd-2.1.3-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for slamd-2.1.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 783ab3645f7c4d001cb066245fa1a943c47417741b24c4fa6029aa5e9da01f99
MD5 9ca591a2e214dbb334ee255118fcbaf8
BLAKE2b-256 5eb9da3156146acd9b24c648e9a17c2d97efe8b754f7262cfb802bcaa38185a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for slamd-2.1.3-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: pip_publish.yml on Robertleoj/slam_dunk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file slamd-2.1.3-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for slamd-2.1.3-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 31dbf25ada1abd51a3673910df0248d6167a514959f6f52e0534056bc91ad568
MD5 d9e61a7a3555e08aa88c3b1e4a71ad48
BLAKE2b-256 165d110ab78ed51f485026132c90ae94ee46c1d7c9adbff1092ffa5bd4bf6ebc

See more details on using hashes here.

Provenance

The following attestation bundles were made for slamd-2.1.3-cp312-cp312-manylinux_2_28_x86_64.whl:

Publisher: pip_publish.yml on Robertleoj/slam_dunk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file slamd-2.1.3-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for slamd-2.1.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7342a7e235f0ca6834d6e32c68f47010dc459622a3873e48c4247c23fa5bbf36
MD5 80e8cb87f86438f38d259af12aebeec5
BLAKE2b-256 7b8086fd68076956374e70efad461d5ec272a9e48cc40b35d793c42a295438af

See more details on using hashes here.

Provenance

The following attestation bundles were made for slamd-2.1.3-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: pip_publish.yml on Robertleoj/slam_dunk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file slamd-2.1.3-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for slamd-2.1.3-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fd2d45ab58284b8fb9c3a3adbd2777c221935d86ad501b80a981d75b477a2476
MD5 e697067f9e80b3e974053fafc09e24b2
BLAKE2b-256 1634b9c44d3a21cc3ac0cde46c8cbaaef797f70ea505f46f771978cd11d838bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for slamd-2.1.3-cp311-cp311-manylinux_2_28_x86_64.whl:

Publisher: pip_publish.yml on Robertleoj/slam_dunk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file slamd-2.1.3-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for slamd-2.1.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 526d15a3f6151f99e4c98228455c9aecf9d95ded84a9c5af78d94b480918c413
MD5 1e78e189f3afed33852bbe9758e87aef
BLAKE2b-256 5af196142bf0689e701ca60092d2489335e1a3856b37cc1f22fbe306acb72ed9

See more details on using hashes here.

Provenance

The following attestation bundles were made for slamd-2.1.3-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: pip_publish.yml on Robertleoj/slam_dunk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page