Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add obj mesh support to viewer #3670

Merged
merged 2 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/re_renderer/src/importer/obj.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::{
pub fn load_obj_from_buffer(
buffer: &[u8],
lifetime: ResourceLifeTime,
ctx: &mut RenderContext,
ctx: &RenderContext,
) -> anyhow::Result<Vec<MeshInstance>> {
re_tracing::profile_function!();

Expand Down
2 changes: 1 addition & 1 deletion crates/re_space_view_spatial/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ re_format.workspace = true
re_log_types.workspace = true
re_log.workspace = true
re_query.workspace = true
re_renderer = { workspace = true, features = ["import-gltf"] }
re_renderer = { workspace = true, features = ["import-gltf", "import-obj"] }
re_types = { workspace = true, features = ["ecolor", "glam", "image"] }
re_tracing.workspace = true
re_ui.workspace = true
Expand Down
17 changes: 10 additions & 7 deletions crates/re_space_view_spatial/src/mesh_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,20 @@ impl LoadedMesh {
) -> anyhow::Result<Self> {
re_tracing::profile_function!();

let mesh_instances = if media_type == &MediaType::gltf() || media_type == &MediaType::glb()
{
re_renderer::importer::gltf::load_gltf_from_buffer(
let mesh_instances = match media_type.as_str() {
MediaType::GLTF | MediaType::GLB => re_renderer::importer::gltf::load_gltf_from_buffer(
&name,
bytes,
ResourceLifeTime::LongLived,
render_ctx,
)
} else {
anyhow::bail!("{media_type} files are not supported")
}?;
)?,
MediaType::OBJ => re_renderer::importer::obj::load_obj_from_buffer(
bytes,
ResourceLifeTime::LongLived,
render_ctx,
)?,
_ => anyhow::bail!("{media_type} files are not supported"),
};

let bbox = re_renderer::importer::calculate_bounding_box(&mesh_instances);

Expand Down
4 changes: 2 additions & 2 deletions crates/re_types/definitions/rerun/archetypes/asset3d.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ table Asset3D (

/// The Media Type of the asset.
///
/// For instance:
/// Supported values:
/// * `model/gltf-binary`
/// * `model/obj`
/// * `model/obj` (.mtl material files are not supported yet, references are silently ignored)
///
/// 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.
Expand Down
4 changes: 2 additions & 2 deletions crates/re_types/src/archetypes/asset3d.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions rerun_cpp/src/rerun/archetypes/asset3d.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions rerun_py/rerun_sdk/rerun/archetypes/asset3d.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading