-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
101 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
cmake_minimum_required(VERSION 3.16...3.27) | ||
|
||
# If you use the example outside of the Rerun SDK you need to specify | ||
# where the rerun_c build is to be found by setting the `RERUN_CPP_URL` variable. | ||
# This can be done by passing `-DRERUN_CPP_URL=<path to rerun_sdk_cpp zip>` to cmake. | ||
if(DEFINED RERUN_REPOSITORY) | ||
add_executable(example_incremental main.cpp) | ||
rerun_strict_warning_settings(example_incremental) | ||
else() | ||
project(example_incremental LANGUAGES CXX) | ||
|
||
add_executable(example_incremental main.cpp) | ||
|
||
# Set the path to the rerun_c build. | ||
set(RERUN_CPP_URL "https://github.com/rerun-io/rerun/releases/latest/download/rerun_cpp_sdk.zip" CACHE STRING "URL to the rerun_cpp zip.") | ||
|
||
# Download the rerun_sdk | ||
include(FetchContent) | ||
FetchContent_Declare(rerun_sdk URL ${RERUN_CPP_URL}) | ||
FetchContent_MakeAvailable(rerun_sdk) | ||
|
||
# Rerun requires at least C++17, but it should be compatible with newer versions. | ||
set_property(TARGET example_incremental PROPERTY CXX_STANDARD 17) | ||
endif() | ||
|
||
# Link against rerun_sdk. | ||
target_link_libraries(example_incremental PRIVATE rerun_sdk) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!--[metadata] | ||
title = "Helix" | ||
tags = ["3d", "api-example"] | ||
description = "Simple example of logging point and line primitives to draw a 3D helix." | ||
thumbnail = "https://static.rerun.io/helix/f4c375546fa9d24f7cd3a1a715ebf75b2978817a/480w.png" | ||
thumbnail_dimensions = [480, 285] | ||
channel = "main" | ||
--> | ||
|
||
|
||
<picture> | ||
<source media="(max-width: 480px)" srcset="https://static.rerun.io/helix/f4c375546fa9d24f7cd3a1a715ebf75b2978817a/480w.png"> | ||
<source media="(max-width: 768px)" srcset="https://static.rerun.io/helix/f4c375546fa9d24f7cd3a1a715ebf75b2978817a/768w.png"> | ||
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/helix/f4c375546fa9d24f7cd3a1a715ebf75b2978817a/1024w.png"> | ||
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/helix/f4c375546fa9d24f7cd3a1a715ebf75b2978817a/1200w.png"> | ||
<img src="https://static.rerun.io/helix/f4c375546fa9d24f7cd3a1a715ebf75b2978817a/full.png" alt=""> | ||
</picture> | ||
|
||
Simple example of logging point and line primitives to draw a 3D helix. | ||
|
||
|
||
To build it from a checkout of the repository (requires a Rust toolchain): | ||
```bash | ||
cmake . | ||
cmake --build . --target example_incremental | ||
./examples/cpp/incremental/example_incremental | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include <rerun.hpp> | ||
|
||
#include <algorithm> | ||
#include <random> | ||
|
||
int main() { | ||
const auto rec = rerun::RecordingStream("rerun_example_incremental"); | ||
rec.spawn().exit_on_failure(); | ||
|
||
// TODO(#5264): just log one once clamp-to-edge semantics land. | ||
std::vector<rerun::Color> colors(10, rerun::Color(255, 0, 0)); | ||
std::vector<rerun::Radius> radii(10, rerun::Radius(0.1)); | ||
|
||
// Only log colors and radii once. | ||
rec.set_time_sequence("frame_nr", 0); | ||
rec.log("points", colors, radii); | ||
// Logging timelessly with `RecordingStream::log_timeless` would also work. | ||
// rec.log_timeless("points", colors, radii); | ||
|
||
std::default_random_engine gen; | ||
std::uniform_real_distribution<float> dist_pos(-5.0f, 5.0f); | ||
|
||
// Then log only the points themselves each frame. | ||
// | ||
// They will automatically re-use the colors and radii logged at the beginning. | ||
for (int i = 0; i < 10; ++i) { | ||
rec.set_time_sequence("frame_nr", i); | ||
|
||
std::vector<rerun::Position3D> points(10); | ||
std::generate(points.begin(), points.end(), [&] { | ||
return rerun::Position3D(dist_pos(gen), dist_pos(gen), dist_pos(gen)); | ||
}); | ||
rec.log("points", rerun::Points3D(points)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters