# 快速开始 5 分钟从零到第一个 GLB 模型。 --- ## 安装 ```bash git clone https://github.com/your-org/ViewDesignEngine.git cd ViewDesignEngine mkdir build && cd build cmake .. -DBUILD_EXAMPLES=ON cmake --build . -j$(nproc) ``` ## 第一个 SDF 形状 创建文件 `hello_vde.cpp`: ```cpp #include #include #include #include #include #include #include using namespace vde::core; using namespace vde::sdf; using namespace vde::mesh; using namespace vde::foundation; int main() { // 1. 定义 SDF 函数 auto shape = [](double x, double y, double z) -> double { Point3D p(x, y, z); double d_sphere = sphere(p, 1.2); double d_box = box(p, Point3D(1.5, 1.5, 0.5)); // 平滑并集 (k=0.3 控制融合程度) return op_smooth_union(d_sphere, d_box, 0.3); }; // 2. Marching Cubes → 三角形网格 Point3D bmin(-2.5, -2.5, -2.5); Point3D bmax( 2.5, 2.5, 2.5); auto mc = marching_cubes(shape, 0.0, bmin, bmax, 64); // 3. 构建半边网格 HalfedgeMesh mesh; mesh.build_from_triangles(mc.vertices, mc.triangles); // 4. 导出 GLB GltfOptions opts; opts.binary = true; opts.include_normals = true; write_gltf("hello_vde.glb", mesh, opts); std::cout << "Done! Open hello_vde.glb in viewer/index.html\n"; return 0; } ``` 编译运行: ```bash g++ -std=c++17 -I../include hello_vde.cpp -L. -lvde -o hello_vde ./hello_vde ``` ## 导出 GLB GLB(glTF Binary)可直接在以下工具中打开: - 本项目自带的 `viewer/index.html`(拖放即可) - Blender(File → Import → glTF 2.0) - 在线工具:gltf-viewer.donmccurdy.com - Windows/macOS 自带 3D Viewer ## 下一步 - [SDF 隐式建模教程](02-sdf-modeling.md) —— 学习更多图元与操作 - [B-Rep 工业建模教程](03-brep-modeling.md) —— 精确边界表示建模 - [API 参考](../API-REFERENCE.md) —— 完整 API 文档