add chinese
build / setup (compute matrix) (push) Has been cancelled
build / ${{ matrix.label }} (push) Has been cancelled
build / macos-15-arm64-studio (push) Has been cancelled
build / ubuntu-24.04-clang-18-studio (push) Has been cancelled
build / ubuntu-24.04-gcc-14-studio (push) Has been cancelled
build / windows-2025-ninja-studio (push) Has been cancelled
build / ubuntu-24.04-clang-18-wasm (push) Has been cancelled
build / ubuntu-24.04-clang-18-mjx (push) Has been cancelled
build / setup (compute matrix) (push) Has been cancelled
build / ${{ matrix.label }} (push) Has been cancelled
build / macos-15-arm64-studio (push) Has been cancelled
build / ubuntu-24.04-clang-18-studio (push) Has been cancelled
build / ubuntu-24.04-gcc-14-studio (push) Has been cancelled
build / windows-2025-ninja-studio (push) Has been cancelled
build / ubuntu-24.04-clang-18-wasm (push) Has been cancelled
build / ubuntu-24.04-clang-18-mjx (push) Has been cancelled
This commit is contained in:
+42
-51
@@ -2,106 +2,97 @@
|
||||
<a href="#"><img alt="MuJoCo" src="../../banner.png" width="100%"/></a>
|
||||
</h1>
|
||||
|
||||
## Signed distance function (SDF) plugins
|
||||
## 符号距离函数(SDF)插件
|
||||
|
||||
These are first-party plugins that implement implicit geometries using SDFs. They can be applied to **geoms** and
|
||||
**meshes** (in the **asset** section). Sample models can be found in [this folder](../../model/plugin/sdf/).
|
||||
这些是第一方插件,使用符号距离函数(Signed Distance Functions, SDF)实现隐式几何体。它们可以应用于 **geoms**(几何体)和 **meshes**(网格,在 **asset** 资产部分)。示例模型可在[此文件夹](../../model/plugin/sdf/)中找到。
|
||||
|
||||
### Bolt
|
||||
### 螺栓(Bolt)
|
||||
|
||||
Implemented in [bolt.cc](bolt.cc). Example usage in [nutbolt.xml](../../model/plugin/sdf/nutbolt.xml).
|
||||
在 [bolt.cc](bolt.cc) 中实现。使用示例见 [nutbolt.xml](../../model/plugin/sdf/nutbolt.xml)。
|
||||
|
||||
This plugin implements a bolt with a hexagonal head, similar to https://www.shadertoy.com/view/XtffzX.
|
||||
该插件实现了一个带有六角头的螺栓,类似于 https://www.shadertoy.com/view/XtffzX。
|
||||
|
||||
Parameters:
|
||||
参数:
|
||||
|
||||
- `radius` [m]: bolt radius (default `0.26`).
|
||||
- `radius` [m]:螺栓半径(默认 `0.26`)。
|
||||
|
||||
### Bowl
|
||||
### 碗(Bowl)
|
||||
|
||||
Implemented in [bowl.cc](bowl.cc). Example usage in [bowl.xml](../../model/plugin/sdf/bowl.xml).
|
||||
在 [bowl.cc](bowl.cc) 中实现。使用示例见 [bowl.xml](../../model/plugin/sdf/bowl.xml)。
|
||||
|
||||
The plugin implements a cut hollow sphere from https://www.shadertoy.com/view/7tVXRt.
|
||||
该插件实现了来自 https://www.shadertoy.com/view/7tVXRt 的被切割中空球体。
|
||||
|
||||
Parameters:
|
||||
参数:
|
||||
|
||||
- `height` [m]: location of the cut plane (default `0.4`).
|
||||
- `radius` [m]: radius of the sphere (default `1`).
|
||||
- `thickness` [m]: thickness of the bowl (default `0.02`).
|
||||
- `height` [m]:切割平面的位置(默认 `0.4`)。
|
||||
- `radius` [m]:球体半径(默认 `1`)。
|
||||
- `thickness` [m]:碗的壁厚(默认 `0.02`)。
|
||||
|
||||
### Gear
|
||||
### 齿轮(Gear)
|
||||
|
||||
Implemented in [gear.cc](gear.cc). Example usage in [gear.xml](../../model/plugin/sdf/gear.xml).
|
||||
在 [gear.cc](gear.cc) 中实现。使用示例见 [gear.xml](../../model/plugin/sdf/gear.xml)。
|
||||
|
||||
The plugin implements a 3D extrusion of the 2D gear geometry from https://www.shadertoy.com/view/3lG3WR.
|
||||
该插件实现了来自 https://www.shadertoy.com/view/3lG3WR 的 2D 齿轮几何体的 3D 拉伸挤出。
|
||||
|
||||
Parameters:
|
||||
参数:
|
||||
|
||||
- `alpha` [m]: initial angle of rotation of the gear (default `0`).
|
||||
- `diameter` [m]: gear diameter (default `2.8`).
|
||||
- `teeth` []: number of teeth (default `25`).
|
||||
- `alpha` [m]:齿轮的初始旋转角度(默认 `0`)。
|
||||
- `diameter` [m]:齿轮直径(默认 `2.8`)。
|
||||
- `teeth` []:齿数(默认 `25`)。
|
||||
|
||||
### Nut
|
||||
### 螺母(Nut)
|
||||
|
||||
Implemented in [nut.cc](nut.cc). Example usage in [nutbolt.xml](../../model/plugin/sdf/nutbolt.xml).
|
||||
在 [nut.cc](nut.cc) 中实现。使用示例见 [nutbolt.xml](../../model/plugin/sdf/nutbolt.xml)。
|
||||
|
||||
This plugin implements a hexagonal nut identical to the bolt head from https://www.shadertoy.com/view/XtffzX.
|
||||
该插件实现了一个六角螺母,与来自 https://www.shadertoy.com/view/XtffzX 的螺栓头部相同。
|
||||
|
||||
Parameters:
|
||||
参数:
|
||||
|
||||
- `radius` [m]: nut radius (default `0.26`).
|
||||
- `radius` [m]:螺母半径(默认 `0.26`)。
|
||||
|
||||
### Torus
|
||||
### 圆环体(Torus)
|
||||
|
||||
Implemented in [torus.cc](torus.cc). Example usage in [torus.xml](../../model/plugin/sdf/torus.xml).
|
||||
在 [torus.cc](torus.cc) 中实现。使用示例见 [torus.xml](../../model/plugin/sdf/torus.xml)。
|
||||
|
||||
This plugin implements a torus.
|
||||
该插件实现了一个圆环体。
|
||||
|
||||
Parameters:
|
||||
参数:
|
||||
|
||||
- `radius1` [m]: major radius (default `0.35`).
|
||||
- `radius1` [m]: minor radius (default `0.15`).
|
||||
- `radius1` [m]:主半径/大半径(默认 `0.35`)。
|
||||
- `radius1` [m]:次半径/小半径(默认 `0.15`)。
|
||||
|
||||
### How to make your own SDF
|
||||
### 如何创建自定义 SDF
|
||||
|
||||
Create your `MySDF.h` and `MySDF.cc` files in the SDF folder, where this README is located. Implement your SDF using the
|
||||
following interface:
|
||||
在当前 README 所在的 SDF 文件夹中创建您的 `MySDF.h` 和 `MySDF.cc` 文件。使用以下接口实现您的 SDF:
|
||||
|
||||
```
|
||||
```cpp
|
||||
struct MySDFAttribute {
|
||||
static constexpr int nattribute =
|
||||
/* insert the number of attributes */;
|
||||
/* 填入属性数量 */;
|
||||
static constexpr char const* names[nattribute] =
|
||||
/* an array of attributes with the same order as the attribute array in your SDF class */;
|
||||
/* 与 SDF 类中属性数组顺序相同的属性名称数组 */;
|
||||
static constexpr mjtNum defaults[nattribute] =
|
||||
/* an array of default values for your attributes */;
|
||||
/* 属性的默认值数组 */;
|
||||
};
|
||||
|
||||
class MySDF {
|
||||
public:
|
||||
// creates a new MySDF instance or returns null on failure.
|
||||
// 创建新的 MySDF 实例,失败时返回 null。
|
||||
static std::optional<MySDF> Create(const mjModel* m, mjData* d, int instance);
|
||||
MySDF(MySDF&&) = default;
|
||||
~MySDF() = default;
|
||||
|
||||
// functions that return the SDF and its gradient at a query point
|
||||
// 在查询点返回 SDF 距离及其梯度的函数
|
||||
mjtNum Distance(const mjtNum point[3]) const;
|
||||
void Gradient(mjtNum grad[3], const mjtNum point[3]) const;
|
||||
|
||||
// a call to this needs to be added to register.cc
|
||||
// 需要在 register.cc 中添加对此函数的调用
|
||||
static void RegisterPlugin();
|
||||
|
||||
// an array of attributes with the same order as in the struct above
|
||||
// 与上述结构体中顺序相同的属性数组
|
||||
mjtNum attribute[MySDFAttribute::nattribute];
|
||||
|
||||
private:
|
||||
MySDF(const mjModel* m, mjData* d, int instance);
|
||||
};
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user