Rerun C++ SDK
Loading...
Searching...
No Matches
rerun::archetypes::Asset3D Struct Reference

Archetype: A prepacked 3D asset (.gltf, .glb, .obj, .stl, etc.). More...

#include <rerun/archetypes/asset3d.hpp>

Public Types

using IndicatorComponent = rerun::components::IndicatorComponent< IndicatorComponentName >
 Indicator component, used to identify the archetype when converting to a list of components.
 

Public Member Functions

 Asset3D (Asset3D &&other)=default
 
 Asset3D (const Asset3D &other)=default
 
Asset3Doperator= (const Asset3D &other)=default
 
Asset3Doperator= (Asset3D &&other)=default
 
 Asset3D (rerun::components::Blob _blob)
 
Asset3D with_blob (const rerun::components::Blob &_blob) &&
 The asset's bytes.
 
Asset3D with_many_blob (const Collection< rerun::components::Blob > &_blob) &&
 This method makes it possible to pack multiple blob in a single component batch.
 
Asset3D with_media_type (const rerun::components::MediaType &_media_type) &&
 The Media Type of the asset.
 
Asset3D with_many_media_type (const Collection< rerun::components::MediaType > &_media_type) &&
 This method makes it possible to pack multiple media_type in a single component batch.
 
Asset3D with_albedo_factor (const rerun::components::AlbedoFactor &_albedo_factor) &&
 A color multiplier applied to the whole asset.
 
Asset3D with_many_albedo_factor (const Collection< rerun::components::AlbedoFactor > &_albedo_factor) &&
 This method makes it possible to pack multiple albedo_factor in a single component batch.
 
Collection< ComponentColumncolumns (const Collection< uint32_t > &lengths_)
 Partitions the component data into multiple sub-batches.
 
Collection< ComponentColumncolumns ()
 Partitions the component data into unit-length sub-batches.
 

Static Public Member Functions

static Result< Asset3Dfrom_file (const std::filesystem::path &path)
 Creates a new Asset3D from the file contents at path.
 
static Asset3D from_bytes (rerun::Collection< uint8_t > bytes, std::optional< rerun::components::MediaType > media_type={})
 Creates a new Asset3D from the given bytes.
 
static Asset3D update_fields ()
 Update only some specific fields of a Asset3D.
 
static Asset3D clear_fields ()
 Clear all the fields of a Asset3D.
 

Public Attributes

std::optional< ComponentBatchblob
 The asset's bytes.
 
std::optional< ComponentBatchmedia_type
 The Media Type of the asset.
 
std::optional< ComponentBatchalbedo_factor
 A color multiplier applied to the whole asset.
 

Static Public Attributes

static constexpr const char IndicatorComponentName [] = "rerun.components.Asset3DIndicator"
 
static constexpr const char ArchetypeName [] = "rerun.archetypes.Asset3D"
 The name of the archetype as used in ComponentDescriptors.
 
static constexpr auto Descriptor_blob
 ComponentDescriptor for the blob field.
 
static constexpr auto Descriptor_media_type
 ComponentDescriptor for the media_type field.
 
static constexpr auto Descriptor_albedo_factor
 ComponentDescriptor for the albedo_factor field.
 

Detailed Description

Archetype: A prepacked 3D asset (.gltf, .glb, .obj, .stl, etc.).

See also archetypes::Mesh3D.

If there are multiple archetypes::InstancePoses3D instances logged to the same entity as a mesh, an instance of the mesh will be drawn for each transform.

Example

Simple 3D asset

image

#include <rerun.hpp>
#include <iostream>
int main(int argc, char* argv[]) {
if (argc <2) {
std::cerr <<"Usage: " <<argv[0] <<" <path_to_asset.[gltf|glb|obj|stl]>" <<std::endl;
return 1;
}
const auto path = argv[1];
const auto rec = rerun::RecordingStream("rerun_example_asset3d");
rec.spawn().exit_on_failure();
rec.log_static("world", rerun::ViewCoordinates::RIGHT_HAND_Z_UP); // Set an up-axis
rec.log("world/asset", rerun::Asset3D::from_file(path).value_or_throw());
}
A RecordingStream handles everything related to logging data into Rerun.
Definition recording_stream.hpp:60

Member Function Documentation

◆ from_file()

static Result< Asset3D > rerun::archetypes::Asset3D::from_file ( const std::filesystem::path &  path)
static

Creates a new Asset3D from the file contents at path.

The MediaType will be guessed from the file extension.

If no MediaType can be guessed at the moment, the Rerun Viewer will try to guess one from the data at render-time. If it can't, rendering will fail with an error.

◆ from_bytes()

static Asset3D rerun::archetypes::Asset3D::from_bytes ( rerun::Collection< uint8_t >  bytes,
std::optional< rerun::components::MediaType media_type = {} 
)
inlinestatic

Creates a new Asset3D from the given bytes.

If no MediaType is specified, the Rerun Viewer will try to guess one from the data at render-time. If it can't, rendering will fail with an error.

◆ with_many_blob()

Asset3D rerun::archetypes::Asset3D::with_many_blob ( const Collection< rerun::components::Blob > &  _blob) &&
inline

This method makes it possible to pack multiple blob in a single component batch.

This only makes sense when used in conjunction with columns. with_blob should be used when logging a single row's worth of data.

◆ with_media_type()

Asset3D rerun::archetypes::Asset3D::with_media_type ( const rerun::components::MediaType _media_type) &&
inline

The Media Type of the asset.

Supported values:

  • model/gltf-binary
  • model/gltf+json
  • model/obj (.mtl material files are not supported yet, references are silently ignored)
  • model/stl

If omitted, the viewer will try to guess from the data blob. If it cannot guess, it won't be able to render the asset.

◆ with_many_media_type()

Asset3D rerun::archetypes::Asset3D::with_many_media_type ( const Collection< rerun::components::MediaType > &  _media_type) &&
inline

This method makes it possible to pack multiple media_type in a single component batch.

This only makes sense when used in conjunction with columns. with_media_type should be used when logging a single row's worth of data.

◆ with_albedo_factor()

Asset3D rerun::archetypes::Asset3D::with_albedo_factor ( const rerun::components::AlbedoFactor _albedo_factor) &&
inline

A color multiplier applied to the whole asset.

For mesh who already have albedo_factor in materials, it will be overwritten by actual albedo_factor of archetypes::Asset3D (if specified).

◆ with_many_albedo_factor()

Asset3D rerun::archetypes::Asset3D::with_many_albedo_factor ( const Collection< rerun::components::AlbedoFactor > &  _albedo_factor) &&
inline

This method makes it possible to pack multiple albedo_factor in a single component batch.

This only makes sense when used in conjunction with columns. with_albedo_factor should be used when logging a single row's worth of data.

◆ columns() [1/2]

Collection< ComponentColumn > rerun::archetypes::Asset3D::columns ( const Collection< uint32_t > &  lengths_)

Partitions the component data into multiple sub-batches.

Specifically, this transforms the existing ComponentBatch data into ComponentColumns instead, via ComponentBatch::partitioned.

This makes it possible to use RecordingStream::send_columns to send columnar data directly into Rerun.

The specified lengths must sum to the total length of the component batch.

◆ columns() [2/2]

Collection< ComponentColumn > rerun::archetypes::Asset3D::columns ( )

Partitions the component data into unit-length sub-batches.

This is semantically similar to calling columns with std::vector<uint32_t>(n, 1), where n is automatically guessed.

Member Data Documentation

◆ media_type

std::optional<ComponentBatch> rerun::archetypes::Asset3D::media_type

The Media Type of the asset.

Supported values:

  • model/gltf-binary
  • model/gltf+json
  • model/obj (.mtl material files are not supported yet, references are silently ignored)
  • model/stl

If omitted, the viewer will try to guess from the data blob. If it cannot guess, it won't be able to render the asset.

◆ albedo_factor

std::optional<ComponentBatch> rerun::archetypes::Asset3D::albedo_factor

A color multiplier applied to the whole asset.

For mesh who already have albedo_factor in materials, it will be overwritten by actual albedo_factor of archetypes::Asset3D (if specified).

◆ Descriptor_blob

constexpr auto rerun::archetypes::Asset3D::Descriptor_blob
staticconstexpr
Initial value:
= ComponentDescriptor(
ArchetypeName, "blob", Loggable<rerun::components::Blob>::Descriptor.component_name
)
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition asset3d.hpp:82

ComponentDescriptor for the blob field.

◆ Descriptor_media_type

constexpr auto rerun::archetypes::Asset3D::Descriptor_media_type
staticconstexpr
Initial value:
= ComponentDescriptor(
ArchetypeName, "media_type",
Loggable<rerun::components::MediaType>::Descriptor.component_name
)

ComponentDescriptor for the media_type field.

◆ Descriptor_albedo_factor

constexpr auto rerun::archetypes::Asset3D::Descriptor_albedo_factor
staticconstexpr
Initial value:
= ComponentDescriptor(
ArchetypeName, "albedo_factor",
Loggable<rerun::components::AlbedoFactor>::Descriptor.component_name
)

ComponentDescriptor for the albedo_factor field.


The documentation for this struct was generated from the following file: