Files
ViewDesignEngine/docs/guides/01-quickstart.md
T
茂之钳 486a0fe011
CI / Build & Test (push) Failing after 35s
CI / Release Build (push) Failing after 33s
Build & Test / build-and-test (push) Has been cancelled
Build & Test / python-bindings (push) Has been cancelled
docs: reorganize documentation — developer-friendly structure
New structure:
- docs/index.md — main navigation
- docs/getting-started.md — 5-minute quick start
- docs/guides/module-manual.md — all 11 modules with file listing
- docs/guides/api-usage.md — API reference with code examples
- docs/guides/ — architecture, building, testing, contributing
- docs/reference/ — competitive analysis, gap analysis, versioning
- docs/api/ — Doxygen generated HTML
- docs/archive/ — historical development plans

Old development plans archived. Clean 4-directory layout.
2026-07-27 13:32:20 +08:00

2.1 KiB
Raw Blame History

快速开始

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

GLBglTF Binary)可直接在以下工具中打开:

  • 本项目自带的 viewer/index.html(拖放即可)
  • BlenderFile → Import → glTF 2.0
  • 在线工具:gltf-viewer.donmccurdy.com
  • Windows/macOS 自带 3D Viewer

下一步