VisuTwin Canvas
C++ 3D Engine — Metal Backend
Loading...
Searching...
No Matches
stlParser.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2025-2026 Arnis Lektauers
3//
4// STL (Stereolithography) file parser for VisuTwin Canvas.
5//
6// Loads binary and ASCII STL geometry, producing a GlbContainerResource that
7// plugs into the existing asset pipeline (same instantiateRenderEntity() path
8// as the GLB and OBJ parsers).
9//
10// STL files have no materials, no UVs, no hierarchy, and only face normals.
11// The parser provides optional crease-angle smooth normal generation and
12// configurable default PBR material properties.
13//
14// Custom STL loader (not derived from upstream).
15// This is a VisuTwin-specific addition for robot/CAD visualization.
16//
17#pragma once
18
19#include <memory>
20#include <string>
21
23
24namespace visutwin::canvas
25{
26 class GraphicsDevice;
27
30 {
32 float uniformScale = 1.0f;
33
35 bool flipYZ = false;
36
38 bool flipWinding = false;
39
43
48 float creaseAngle = 40.0f;
49
51 bool generateTangents = true;
52
54 float diffuseR = 0.8f;
55 float diffuseG = 0.8f;
56 float diffuseB = 0.8f;
57
59 float metalness = 0.0f;
60
62 float roughness = 0.5f;
63 };
64
66 {
67 public:
70 static std::unique_ptr<GlbContainerResource> parse(
71 const std::string& path,
72 const std::shared_ptr<GraphicsDevice>& device,
73 const StlParserConfig& config = StlParserConfig{});
74 };
75}
Abstract GPU interface for resource creation, state management, and draw submission.
static std::unique_ptr< GlbContainerResource > parse(const std::string &path, const std::shared_ptr< GraphicsDevice > &device, const StlParserConfig &config=StlParserConfig{})
Configuration options for STL loading.
Definition stlParser.h:30
bool flipYZ
If true, swap Y and Z axes (Z-up CAD -> Y-up engine) and negate new Z.
Definition stlParser.h:35
bool generateTangents
Generate tangents from normals (Gram-Schmidt fallback since STL has no UVs).
Definition stlParser.h:51
bool flipWinding
If true, reverse face winding order.
Definition stlParser.h:38
float diffuseR
Default material diffuse color (STL has no material data).
Definition stlParser.h:54
float metalness
Default material metalness (0 = dielectric, 1 = metal).
Definition stlParser.h:59
float roughness
Default material roughness (0 = mirror, 1 = matte).
Definition stlParser.h:62
float uniformScale
Uniform scale applied to all vertex positions (e.g., 0.001 for mm -> m).
Definition stlParser.h:32