Page:
01 quickstart
Pages
01 quickstart
02 sdf modeling
03 brep modeling
27 竞品分析
30 严谨差距分析
API REFERENCE
API使用手册
Home
README
VERSIONING
api overview
api reference brep
api reference capi
api reference core
api reference curves
api reference foundation
api reference mesh
api reference spatial
api usage
architecture
benchmark report
building
changelog
contributing
format support
module manual
testing
严谨差距分析
几何引擎全景调研
向ACIS学习
向Parasolid学习
布尔算法调研
快速入门
改进路线图
更新日志
构建指南
架构概览
模块说明书
测试指南
版本管理规范
竞品分析
贡献指南
项目概述
Clone
Table of Contents
This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
快速开始
5 分钟从零到第一个 GLB 模型。
安装
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:
#include <vde/sdf/sdf_primitives.h>
#include <vde/sdf/sdf_operations.h>
#include <vde/sdf/sdf_to_mesh.h>
#include <vde/mesh/marching_cubes.h>
#include <vde/mesh/halfedge_mesh.h>
#include <vde/foundation/io_gltf.h>
#include <iostream>
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;
}
编译运行:
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 隐式建模教程 —— 学习更多图元与操作
- B-Rep 工业建模教程 —— 精确边界表示建模
- API 参考 —— 完整 API 文档