Add mjs_makeMesh to create a builtin mesh.
PiperOrigin-RevId: 788538127 Change-Id: I999733399a1a0da07b0f915f34d31364ab8b3b52
This commit is contained in:
committed by
Copybara-Service
parent
46dc67b7eb
commit
89f4789085
@@ -4074,6 +4074,15 @@ Add texture.
|
||||
|
||||
Add material.
|
||||
|
||||
.. _mjs_makeMesh:
|
||||
|
||||
`mjs_makeMesh <#mjs_makeMesh>`__
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. mujoco-include:: mjs_makeMesh
|
||||
|
||||
Sets the vertices and normals of a mesh.
|
||||
|
||||
.. _FindAndGetUtilities:
|
||||
|
||||
Find and get utilities
|
||||
|
||||
@@ -1323,6 +1323,60 @@ The full list of processing steps applied by the compiler to each mesh is as fol
|
||||
Reference orientation relative to which the 3D vertex coordinates and normals are defined. The conjugate of this
|
||||
quaternion is used to rotate the positions and normals. The model compiler normalizes the quaternion automatically.
|
||||
|
||||
.. _asset-mesh-builtin:
|
||||
|
||||
:at:`builtin`: :at-val:`string, optional`
|
||||
The mesh is generated by the compiler from a set of parameters specified in :ref:`params<asset-mesh-params>`.
|
||||
When saved to XML, meshes produced this way are converted to explicit vertices.
|
||||
The available built-in types, their parameters and semantics are:
|
||||
|
||||
:at-val:`sphere` (subdivision)
|
||||
Repeated subdivisions :math:`s` of a unit icosahedron. Has :math:`2 + 10 \cdot 4^s` vertices.
|
||||
|
||||
**subdivision**: integer in [0-4]: The number of subdivisions to apply to icosahedron faces.
|
||||
|
||||
:at-val:`hemisphere` (subdivision)
|
||||
Repeated subdivisions :math:`s` of a square-based pyramid. Has :math:`1 + 2(s+1)(s+2)` vertices.
|
||||
|
||||
**subdivision**: integer in [0-10]: The number of subdivisions to apply to the pyramid.
|
||||
|
||||
:at-val:`prism` (nvert)
|
||||
An extruded regular unit polygon.
|
||||
|
||||
**nvert**: integer >= 3: The number vertices in the polygon.
|
||||
|
||||
:at-val:`cone` (nvert)
|
||||
The convex hull of a regular unit polygon and the vertex (0, 0, 1).
|
||||
|
||||
**nvert**: integer >= 3: The number vertices in the polygon.
|
||||
|
||||
:at-val:`torus` (radius, resolution)
|
||||
A torus with major radius of 1 and given minor radius.
|
||||
|
||||
**radius**: real in (0, 1]: The minor radius of the torus.
|
||||
|br| **resolution** integer >= 4: The discretization of both major and minor radii.
|
||||
|
||||
:at-val:`wedge` (res_phi, res_theta, fov_phi, fov_theta, gamma)
|
||||
A slice of a unit spherical shell in spherical coordinates.
|
||||
|
||||
**res_phi**: integer >= 0: The vertical resolution of the slice.
|
||||
|br| **res_theta**: integer >= 0: The horizontal resolution of the slice.
|
||||
|br| **fov_phi**: real in (0, 180]: The horizontal field of view (longitude) in degrees.
|
||||
|br| **fov_phi**: real in (0, 90): The vertical field of view (latitude) in degrees.
|
||||
|br| **gamma**: real in [0, 1]: Foveal deformation of the discretization.
|
||||
|
||||
:at-val:`plate` (res_x, res_y)
|
||||
A rectangular plate with resolution in each dimension.
|
||||
|
||||
**res_x**: integer > 0: The horizontal resolution of the plate.
|
||||
|br| **res_y**: integer > 0: The vertical resolution of the plate.
|
||||
|
||||
.. _asset-mesh-params:
|
||||
|
||||
:at:`params`: :at-val:`real(nparam), optional`
|
||||
The parameters used to generate a builtin mesh. The number and type of parameters and their semantic depends on the
|
||||
mesh type. See :ref:`mesh/builtin<asset-mesh-builtin>` for details.
|
||||
|
||||
.. _mesh-plugin:
|
||||
|
||||
:el-prefix:`mesh/` |-| **plugin** (?)
|
||||
|
||||
+1
-1
@@ -103,7 +103,7 @@
|
||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||
| | | | :ref:`refpos<asset-mesh-refpos>` | :ref:`refquat<asset-mesh-refquat>` | :ref:`scale<asset-mesh-scale>` | :ref:`smoothnormal<asset-mesh-smoothnormal>` | |
|
||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||
| | | | :ref:`maxhullvert<asset-mesh-maxhullvert>` | :ref:`inertia<asset-mesh-inertia>` | | | |
|
||||
| | | | :ref:`maxhullvert<asset-mesh-maxhullvert>` | :ref:`inertia<asset-mesh-inertia>` | :ref:`builtin<asset-mesh-builtin>` | :ref:`params<asset-mesh-params>` | |
|
||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||
+------------------------------------+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| |_2| mesh |br| |_2| |L| | | .. table:: |
|
||||
|
||||
@@ -15,6 +15,7 @@ General
|
||||
- Removed the SdfLib plugin and the dependency on `SdfLib <https://github.com/UPC-ViRVIG/SdfLib>`__. SDFs are now
|
||||
supported natively in mjModel.
|
||||
- Removed ``oct_depth`` from :ref:`mjvOption` (unused).
|
||||
- Added the functionality to create a builtin meshes, see :ref:`mesh/builtin<asset-mesh-builtin>`.
|
||||
- Inertia computation in MuJoCo C is now performed by a new :ref:`pipeline<piStages>` function :ref:`mj_makeM`, which
|
||||
combines the Composite Rigid Body algorithm in :ref:`mj_crb` and additional terms related to
|
||||
:ref:`tendon armature<tendon-spatial-armature>`. Code that uses :ref:`mj_crb` to compute the inertia should now use
|
||||
|
||||
@@ -1781,6 +1781,16 @@ typedef enum mjtMeshInertia_ { // type of mesh inertia
|
||||
mjMESH_INERTIA_LEGACY, // legacy mesh inertia
|
||||
mjMESH_INERTIA_SHELL // shell mesh inertia
|
||||
} mjtMeshInertia;
|
||||
typedef enum mjtMeshBuiltin_ { // type of built-in procedural mesh
|
||||
mjMESH_BUILTIN_NONE = 0, // no built-in mesh
|
||||
mjMESH_BUILTIN_SPHERE, // sphere
|
||||
mjMESH_BUILTIN_HEMISPHERE, // hemisphere
|
||||
mjMESH_BUILTIN_PRISM, // prism
|
||||
mjMESH_BUILTIN_CONE, // cone
|
||||
mjMESH_BUILTIN_TORUS, // torus
|
||||
mjMESH_BUILTIN_WEDGE, // wedge
|
||||
mjMESH_BUILTIN_PLATE, // plate
|
||||
} mjtMeshBuiltin;
|
||||
typedef enum mjtBuiltin_ { // type of built-in procedural texture
|
||||
mjBUILTIN_NONE = 0, // no built-in texture
|
||||
mjBUILTIN_GRADIENT, // gradient: rgb1->rgb2
|
||||
@@ -3457,6 +3467,7 @@ mjsHField* mjs_addHField(mjSpec* s);
|
||||
mjsSkin* mjs_addSkin(mjSpec* s);
|
||||
mjsTexture* mjs_addTexture(mjSpec* s);
|
||||
mjsMaterial* mjs_addMaterial(mjSpec* s, const mjsDefault* def);
|
||||
int mjs_makeMesh(mjsMesh* mesh, mjtMeshBuiltin builtin, double* params, int nparams);
|
||||
mjSpec* mjs_getSpec(mjsElement* element);
|
||||
mjSpec* mjs_findSpec(mjSpec* spec, const char* name);
|
||||
mjsBody* mjs_findBody(mjSpec* s, const char* name);
|
||||
|
||||
@@ -70,6 +70,16 @@ typedef enum mjtMeshInertia_ { // type of mesh inertia
|
||||
mjMESH_INERTIA_SHELL // shell mesh inertia
|
||||
} mjtMeshInertia;
|
||||
|
||||
typedef enum mjtMeshBuiltin_ { // type of built-in procedural mesh
|
||||
mjMESH_BUILTIN_NONE = 0, // no built-in mesh
|
||||
mjMESH_BUILTIN_SPHERE, // sphere
|
||||
mjMESH_BUILTIN_HEMISPHERE, // hemisphere
|
||||
mjMESH_BUILTIN_PRISM, // prism
|
||||
mjMESH_BUILTIN_CONE, // cone
|
||||
mjMESH_BUILTIN_TORUS, // torus
|
||||
mjMESH_BUILTIN_WEDGE, // wedge
|
||||
mjMESH_BUILTIN_PLATE, // plate
|
||||
} mjtMeshBuiltin;
|
||||
|
||||
typedef enum mjtBuiltin_ { // type of built-in procedural texture
|
||||
mjBUILTIN_NONE = 0, // no built-in texture
|
||||
|
||||
@@ -1545,6 +1545,8 @@ MJAPI mjsTexture* mjs_addTexture(mjSpec* s);
|
||||
// Add material.
|
||||
MJAPI mjsMaterial* mjs_addMaterial(mjSpec* s, const mjsDefault* def);
|
||||
|
||||
// Sets the vertices and normals of a mesh.
|
||||
MJAPI int mjs_makeMesh(mjsMesh* mesh, mjtMeshBuiltin builtin, double* params, int nparams);
|
||||
|
||||
//---------------------------------- Find and get utilities ----------------------------------------
|
||||
|
||||
|
||||
@@ -791,6 +791,21 @@ ENUMS: Mapping[str, EnumDecl] = dict([
|
||||
('mjMESH_INERTIA_SHELL', 3),
|
||||
]),
|
||||
)),
|
||||
('mjtMeshBuiltin',
|
||||
EnumDecl(
|
||||
name='mjtMeshBuiltin',
|
||||
declname='enum mjtMeshBuiltin_',
|
||||
values=dict([
|
||||
('mjMESH_BUILTIN_NONE', 0),
|
||||
('mjMESH_BUILTIN_SPHERE', 1),
|
||||
('mjMESH_BUILTIN_HEMISPHERE', 2),
|
||||
('mjMESH_BUILTIN_PRISM', 3),
|
||||
('mjMESH_BUILTIN_CONE', 4),
|
||||
('mjMESH_BUILTIN_TORUS', 5),
|
||||
('mjMESH_BUILTIN_WEDGE', 6),
|
||||
('mjMESH_BUILTIN_PLATE', 7),
|
||||
]),
|
||||
)),
|
||||
('mjtBuiltin',
|
||||
EnumDecl(
|
||||
name='mjtBuiltin',
|
||||
|
||||
@@ -9869,6 +9869,34 @@ FUNCTIONS: Mapping[str, FunctionDecl] = dict([
|
||||
),
|
||||
doc='Add material.',
|
||||
)),
|
||||
('mjs_makeMesh',
|
||||
FunctionDecl(
|
||||
name='mjs_makeMesh',
|
||||
return_type=ValueType(name='int'),
|
||||
parameters=(
|
||||
FunctionParameterDecl(
|
||||
name='mesh',
|
||||
type=PointerType(
|
||||
inner_type=ValueType(name='mjsMesh'),
|
||||
),
|
||||
),
|
||||
FunctionParameterDecl(
|
||||
name='builtin',
|
||||
type=ValueType(name='mjtMeshBuiltin'),
|
||||
),
|
||||
FunctionParameterDecl(
|
||||
name='params',
|
||||
type=PointerType(
|
||||
inner_type=ValueType(name='double'),
|
||||
),
|
||||
),
|
||||
FunctionParameterDecl(
|
||||
name='nparams',
|
||||
type=ValueType(name='int'),
|
||||
),
|
||||
),
|
||||
doc='Sets the vertices and normals of a mesh.',
|
||||
)),
|
||||
('mjs_getSpec',
|
||||
FunctionDecl(
|
||||
name='mjs_getSpec',
|
||||
|
||||
@@ -1001,6 +1001,38 @@ PYBIND11_MODULE(_specs, m) {
|
||||
mjs_setDefault(self.element, &default_);
|
||||
},
|
||||
py::return_value_policy::reference_internal);
|
||||
mjsMesh.def(
|
||||
"make_wedge",
|
||||
[](raw::MjsMesh* self, std::array<int, 2>& resolution, double radius,
|
||||
std::array<double, 2>& fov, double gamma) {
|
||||
double params[5] = {static_cast<double>(resolution[0]),
|
||||
static_cast<double>(resolution[1]), fov[0], fov[1],
|
||||
gamma};
|
||||
if (mjs_makeMesh(self, mjMESH_BUILTIN_WEDGE, params, 5)) {
|
||||
throw pybind11::value_error(mjs_getError(mjs_getSpec(self->element)));
|
||||
}
|
||||
},
|
||||
py::arg("resolution") = std::array<int, 2>{0, 0}, py::arg("radius"),
|
||||
py::arg("fov") = std::array<double, 2>{0, 0}, py::arg("gamma") = 0);
|
||||
mjsMesh.def(
|
||||
"make_prism",
|
||||
[](raw::MjsMesh* self, int nedge) {
|
||||
double params[1] = {static_cast<double>(nedge)};
|
||||
if (mjs_makeMesh(self, mjMESH_BUILTIN_PRISM, params, 1)) {
|
||||
throw pybind11::value_error(mjs_getError(mjs_getSpec(self->element)));
|
||||
}
|
||||
},
|
||||
py::arg("nedge"));
|
||||
mjsMesh.def(
|
||||
"make_plate",
|
||||
[](raw::MjsMesh* self, std::array<int, 2>& resolution) {
|
||||
double params[2] = {static_cast<double>(resolution[0]),
|
||||
static_cast<double>(resolution[1])};
|
||||
if (mjs_makeMesh(self, mjMESH_BUILTIN_PLATE, params, 2)) {
|
||||
throw pybind11::value_error(mjs_getError(mjs_getSpec(self->element)));
|
||||
}
|
||||
},
|
||||
py::arg("resolution") = std::array<int, 2>{0, 0});
|
||||
|
||||
// ============================= MJSPAIR =====================================
|
||||
mjSpec.def("delete", [](MjSpec& self, raw::MjsPair& obj) {
|
||||
|
||||
@@ -484,6 +484,14 @@ class SpecsTest(absltest.TestCase):
|
||||
# Check that the state is the same.
|
||||
np.testing.assert_array_equal(state1, state2)
|
||||
|
||||
def test_make_mesh(self):
|
||||
spec = mujoco.MjSpec()
|
||||
mesh = spec.add_mesh(name='wedge')
|
||||
mesh.make_wedge(resolution=[25, 25], radius=1, fov=[90, 45], gamma=0)
|
||||
model = spec.compile()
|
||||
self.assertEqual(model.nmesh, 1)
|
||||
self.assertEqual(model.nmeshvert, 25 * 25)
|
||||
|
||||
def test_compile_errors_with_line_info(self):
|
||||
spec = mujoco.MjSpec()
|
||||
|
||||
|
||||
+63
-2
@@ -16,6 +16,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <functional>
|
||||
#include <iterator>
|
||||
#include <map>
|
||||
@@ -27,9 +28,9 @@
|
||||
|
||||
#include <mujoco/mujoco.h>
|
||||
#include "engine/engine_support.h"
|
||||
#include "user/user_cache.h"
|
||||
#include "user/user_model.h"
|
||||
#include "user/user_objects.h"
|
||||
#include "user/user_cache.h"
|
||||
#include "user/user_util.h"
|
||||
|
||||
namespace {
|
||||
@@ -500,7 +501,67 @@ mjsMaterial* mjs_addMaterial(mjSpec* s, const mjsDefault* defspec) {
|
||||
return &material->spec;
|
||||
}
|
||||
|
||||
|
||||
// Sets the vertices and normals of a mesh.
|
||||
int mjs_makeMesh(mjsMesh* mesh, mjtMeshBuiltin builtin, double* params, int nparams) {
|
||||
mjCMesh* meshC = static_cast<mjCMesh*>(mesh->element);
|
||||
mjCModel* m = meshC->model;
|
||||
if (builtin == mjMESH_BUILTIN_WEDGE) {
|
||||
if (nparams != 5) {
|
||||
m->SetError(mjCError(0, "Wedge builtin mesh types require 5 parameters"));
|
||||
return -1;
|
||||
}
|
||||
int resolution[2] = {static_cast<int>(params[0]),
|
||||
static_cast<int>(params[1])};
|
||||
double fov[2] = {params[2], params[3]};
|
||||
double gamma = params[4];
|
||||
if (fov[0] <= 0 || fov[0] > 180) {
|
||||
m->SetError(
|
||||
mjCError(0, "fov[0] must be a float between (0, 180] degrees"));
|
||||
return -1;
|
||||
}
|
||||
if (fov[1] <= 0 || fov[1] > 90) {
|
||||
m->SetError(
|
||||
mjCError(0, "`fov[1]` must be a float between (0, 90] degrees"));
|
||||
return -1;
|
||||
}
|
||||
if (resolution[0] <= 0 || resolution[1] <= 0) {
|
||||
m->SetError(
|
||||
mjCError(0, "Horizontal and vertical resolutions must be positive"));
|
||||
return -1;
|
||||
}
|
||||
if (gamma < 0 || gamma > 1) {
|
||||
m->SetError(
|
||||
mjCError(0, "`gamma` must be a nonnegative float between [0, 1]"));
|
||||
return -1;
|
||||
}
|
||||
meshC->MakeWedge(resolution, fov, gamma);
|
||||
return 0;
|
||||
} else if (builtin == mjMESH_BUILTIN_PLATE) {
|
||||
if (nparams != 2) {
|
||||
m->SetError(mjCError(0, "Plate builtin mesh type requires 2 parameters"));
|
||||
return -1;
|
||||
}
|
||||
int resolution[2] = {static_cast<int>(params[0]),
|
||||
static_cast<int>(params[1])};
|
||||
if (resolution[0] <= 0 || resolution[1] <= 0) {
|
||||
m->SetError(
|
||||
mjCError(0, "Horizontal and vertical resolutions must be positive"));
|
||||
return -1;
|
||||
}
|
||||
meshC->MakeRect(resolution);
|
||||
return 0;
|
||||
} else if (builtin == mjMESH_BUILTIN_PRISM) {
|
||||
if (nparams != 1) {
|
||||
m->SetError(mjCError(0, "Prism mesh type requires 1 parameter"));
|
||||
return -1;
|
||||
}
|
||||
int nedge = static_cast<int>(params[0]);
|
||||
meshC->MakePrism(nedge);
|
||||
return 0;
|
||||
}
|
||||
m->SetError(mjCError(0, "Unsupported mesh type"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
// add pair to model
|
||||
mjsPair* mjs_addPair(mjSpec* s, const mjsDefault* defspec) {
|
||||
|
||||
@@ -209,6 +209,8 @@ MJAPI mjsTexture* mjs_addTexture(mjSpec* s);
|
||||
// Add material.
|
||||
MJAPI mjsMaterial* mjs_addMaterial(mjSpec* s, const mjsDefault* def);
|
||||
|
||||
// Sets the vertices and normals of a mesh.
|
||||
MJAPI int mjs_makeMesh(mjsMesh* mesh, mjtMeshBuiltin builtin, double* params, int nparams);
|
||||
|
||||
//---------------------------------- Find/get utilities --------------------------------------------
|
||||
|
||||
|
||||
+151
-1
@@ -75,6 +75,70 @@ namespace {
|
||||
using mujoco::user::FilePath;
|
||||
using std::max;
|
||||
using std::min;
|
||||
|
||||
// Parametrized linear/quintic interpolated nonlinearity.
|
||||
double Fovea(double x, double gamma) {
|
||||
// Quick return.
|
||||
if (!gamma) return x;
|
||||
|
||||
// Foveal deformation.
|
||||
double g = mjMAX(0, mjMIN(1, gamma));
|
||||
return g * std::pow(x, 5) + (1 - g) * x;
|
||||
}
|
||||
|
||||
// Evenly spaced numbers over a specified interval.
|
||||
void LinSpace(double lower, double upper, int n, double array[]) {
|
||||
double increment = n > 1 ? (upper - lower) / (n - 1) : 0;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
*array = lower;
|
||||
++array;
|
||||
lower += increment;
|
||||
}
|
||||
}
|
||||
|
||||
// Make bin edges.
|
||||
void BinEdges(double* x_edges, double* y_edges, int size[2], double fov[2],
|
||||
double gamma) {
|
||||
// Make unit bin edges.
|
||||
LinSpace(-1, 1, size[0] + 1, x_edges);
|
||||
LinSpace(-1, 1, size[1] + 1, y_edges);
|
||||
|
||||
// Apply foveal deformation.
|
||||
for (int i = 0; i < size[0] + 1; i++) {
|
||||
x_edges[i] = Fovea(x_edges[i], gamma);
|
||||
}
|
||||
for (int i = 0; i < size[1] + 1; i++) {
|
||||
y_edges[i] = Fovea(y_edges[i], gamma);
|
||||
}
|
||||
|
||||
// Scale by field-of-view.
|
||||
mjuu_scalevec(x_edges, x_edges, fov[0] * mjPI / 180, size[0] + 1);
|
||||
mjuu_scalevec(y_edges, y_edges, fov[1] * mjPI / 180, size[1] + 1);
|
||||
}
|
||||
|
||||
// Transform spherical (azimuth, elevation, radius) to Cartesian (x,y,z).
|
||||
void SphericalToCartesian(const double aer[3], float xyz[3]) {
|
||||
double a = aer[0], e = aer[1], r = aer[2];
|
||||
xyz[0] = r * std::cos(e) * std::sin(a);
|
||||
xyz[1] = r * std::sin(e);
|
||||
xyz[2] = -r * std::cos(e) * std::cos(a);
|
||||
}
|
||||
|
||||
// Tangent frame in Cartesian coordinates.
|
||||
void TangentFrame(const double aer[3], float mat[9]) {
|
||||
double a = aer[0], e = aer[1], r = aer[2];
|
||||
double ta[3] = {r * std::cos(e) * std::cos(a), 0,
|
||||
r * std::cos(e) * std::sin(a)};
|
||||
double te[3] = {-r * std::sin(e) * std::sin(a), r * std::cos(e),
|
||||
r * std::sin(e) * std::cos(a)};
|
||||
double n[3];
|
||||
mjuu_normvec(ta, 3);
|
||||
mjuu_normvec(te, 3);
|
||||
mjuu_copyvec(mat + 3, ta, 3);
|
||||
mjuu_copyvec(mat + 6, te, 3);
|
||||
mjuu_crossvec(n, te, ta);
|
||||
mjuu_copyvec(mat, n, 3);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// compute triangle area, surface normal, center
|
||||
@@ -1488,7 +1552,11 @@ void mjCMesh::Process() {
|
||||
|
||||
// facenormal might not exist if usernormal was specified
|
||||
if (facenormal_.empty()) {
|
||||
facenormal_ = face_;
|
||||
int normal_per_vertex = normal_.size() / vert_.size();
|
||||
facenormal_.assign(face_.size(), 0);
|
||||
for (int i = 0; i < face_.size(); i++) {
|
||||
facenormal_[i] = normal_per_vertex * face_[i];
|
||||
}
|
||||
}
|
||||
|
||||
MakePolygons();
|
||||
@@ -1954,7 +2022,89 @@ void mjCMesh::CopyGraph() {
|
||||
}
|
||||
}
|
||||
|
||||
// make a mesh of a spherical wedge
|
||||
void mjCMesh::MakeWedge(int resolution[2], double fov[2], double gamma) {
|
||||
std::vector<double> x_edges(resolution[0] + 1, 0);
|
||||
std::vector<double> y_edges(resolution[1] + 1, 0);
|
||||
BinEdges(x_edges.data(), y_edges.data(), resolution, fov, gamma);
|
||||
std::vector<float> uservert(3 * resolution[0] * resolution[1], 0);
|
||||
std::vector<float> usernormal(9 * resolution[0] * resolution[1], 0);
|
||||
|
||||
for (int i = 0; i < resolution[0]; i++) {
|
||||
for (int j = 0; j < resolution[1]; j++) {
|
||||
double aer[3];
|
||||
aer[0] = 0.5 * (x_edges[i + 1] + x_edges[i]);
|
||||
aer[1] = 0.5 * (y_edges[j + 1] + y_edges[j]);
|
||||
aer[2] = 1;
|
||||
SphericalToCartesian(aer, uservert.data() + 3 * (i * resolution[1] + j));
|
||||
TangentFrame(aer, usernormal.data() + 9 * (i * resolution[1] + j));
|
||||
}
|
||||
}
|
||||
|
||||
mjs_setFloat(spec.uservert, uservert.data(),
|
||||
3 * resolution[0] * resolution[1]);
|
||||
mjs_setFloat(spec.usernormal, usernormal.data(),
|
||||
9 * resolution[0] * resolution[1]);
|
||||
}
|
||||
|
||||
// make a mesh of a rectangle
|
||||
void mjCMesh::MakeRect(int resolution[2]) {
|
||||
std::vector<double> x_edges(resolution[0] + 1, 0);
|
||||
std::vector<double> y_edges(resolution[1] + 1, 0);
|
||||
LinSpace(-1, 1, resolution[0] + 1, x_edges.data());
|
||||
LinSpace(-1, 1, resolution[1] + 1, y_edges.data());
|
||||
std::vector<float> uservert(3 * resolution[0] * resolution[1], 0);
|
||||
std::vector<float> usernormal(9 * resolution[0] * resolution[1], 0);
|
||||
std::vector<int> userface(6 * (resolution[0] - 1) * (resolution[1] - 1), 0);
|
||||
spec.inertia = mjMESH_INERTIA_SHELL;
|
||||
|
||||
for (int i = 0; i < resolution[0]; i++) {
|
||||
for (int j = 0; j < resolution[1]; j++) {
|
||||
int vert = i * resolution[1] + j;
|
||||
mjtNum dx = 2. / resolution[0];
|
||||
mjtNum dy = 2. / resolution[1];
|
||||
uservert[3 * vert + 0] = -1 + (i + 0.5) * dx;
|
||||
uservert[3 * vert + 1] = -1 + (j + 0.5) * dy;
|
||||
uservert[3 * vert + 2] = -1;
|
||||
usernormal[9 * vert + 0] = 1;
|
||||
usernormal[9 * vert + 4] = 1;
|
||||
usernormal[9 * vert + 8] = 1;
|
||||
if (i > 0 && j > 0) {
|
||||
int cell = (i - 1) * (resolution[1] - 1) + j - 1;
|
||||
userface[6 * cell + 0] = (i - 1) * resolution[1] + j - 1;
|
||||
userface[6 * cell + 1] = (i - 0) * resolution[1] + j - 1;
|
||||
userface[6 * cell + 2] = (i - 1) * resolution[1] + j - 0;
|
||||
userface[6 * cell + 3] = (i - 0) * resolution[1] + j - 0;
|
||||
userface[6 * cell + 4] = (i - 1) * resolution[1] + j - 0;
|
||||
userface[6 * cell + 5] = (i - 0) * resolution[1] + j - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mjs_setFloat(spec.uservert, uservert.data(),
|
||||
3 * resolution[0] * resolution[1]);
|
||||
mjs_setFloat(spec.usernormal, usernormal.data(),
|
||||
9 * resolution[0] * resolution[1]);
|
||||
mjs_setInt(spec.userface, userface.data(),
|
||||
6 * (resolution[0] - 1) * (resolution[1] - 1));
|
||||
}
|
||||
|
||||
// make a mesh of a prism
|
||||
void mjCMesh::MakePrism(int nedge) {
|
||||
int layer = 2;
|
||||
std::vector<float> uservert(3 * nedge * layer, 0);
|
||||
|
||||
for (int i = 0; i < nedge; i++) {
|
||||
for (int j = 0; j < layer; j++) {
|
||||
int v = i * layer + j;
|
||||
uservert[3 * v + 0] = std::cos(2 * i * mjPI / nedge);
|
||||
uservert[3 * v + 1] = std::sin(2 * i * mjPI / nedge);
|
||||
uservert[3 * v + 2] = -1 + 2 * j / (layer - 1);
|
||||
}
|
||||
}
|
||||
|
||||
mjs_setFloat(spec.uservert, uservert.data(), 3 * nedge * layer);
|
||||
}
|
||||
|
||||
// compute vertex normals
|
||||
void mjCMesh::MakeNormal() {
|
||||
|
||||
@@ -1050,6 +1050,11 @@ class mjCMesh: public mjCMesh_, private mjsMesh {
|
||||
void PointToLocal(void);
|
||||
void NameSpace(const mjCModel* m);
|
||||
|
||||
// make a mesh of a predefined shape
|
||||
void MakeWedge(int resolution[2], double fov[2], double gamma);
|
||||
void MakeRect(int resolution[2]);
|
||||
void MakePrism(int nedge);
|
||||
|
||||
// accessors
|
||||
const mjsPlugin& Plugin() const { return plugin; }
|
||||
const std::string& ContentType() const { return content_type_; }
|
||||
|
||||
@@ -192,6 +192,12 @@ float mjuu_normvec(float* vec, const int n) {
|
||||
return nrm;
|
||||
}
|
||||
|
||||
// scale vector by scalar
|
||||
void mjuu_scalevec(double* res, const double* vec, double s, int n) {
|
||||
for (int i = 0; i < n; i++) {
|
||||
res[i] = s * vec[i];
|
||||
}
|
||||
}
|
||||
|
||||
// convert quaternion to rotation matrix
|
||||
void mjuu_quat2mat(double* res, const double* quat) {
|
||||
|
||||
@@ -73,6 +73,9 @@ double mjuu_L1(const double* a, const double* b, int n);
|
||||
double mjuu_normvec(double* vec, int n);
|
||||
float mjuu_normvec(float* vec, int n);
|
||||
|
||||
// scale vector by scalar
|
||||
void mjuu_scalevec(double* res, const double* vec, double s, int n);
|
||||
|
||||
// convert quaternion to rotation matrix
|
||||
void mjuu_quat2mat(double* res, const double* quat);
|
||||
|
||||
|
||||
@@ -230,9 +230,9 @@ const char* MJCF[nMJCF][mjXATTRNUM] = {
|
||||
|
||||
{"asset", "*", "0"},
|
||||
{"<"},
|
||||
{"mesh", "*", "14", "name", "class", "content_type", "file", "vertex", "normal",
|
||||
{"mesh", "*", "16", "name", "class", "content_type", "file", "vertex", "normal",
|
||||
"texcoord", "face", "refpos", "refquat", "scale", "smoothnormal",
|
||||
"maxhullvert", "inertia"},
|
||||
"maxhullvert", "inertia", "builtin", "params"},
|
||||
{"<"},
|
||||
{"plugin", "*", "2", "plugin", "instance"},
|
||||
{"<"},
|
||||
@@ -825,6 +825,20 @@ const mjMap meshinertia_map[4] = {
|
||||
};
|
||||
|
||||
|
||||
// mesh builtin type
|
||||
const int meshbuiltin_sz = 8;
|
||||
const mjMap meshbuiltin_map[meshbuiltin_sz] = {
|
||||
{"none", mjMESH_BUILTIN_NONE},
|
||||
{"sphere", mjMESH_BUILTIN_SPHERE},
|
||||
{"hemisphere", mjMESH_BUILTIN_HEMISPHERE},
|
||||
{"prism", mjMESH_BUILTIN_PRISM},
|
||||
{"cone", mjMESH_BUILTIN_CONE},
|
||||
{"torus", mjMESH_BUILTIN_TORUS},
|
||||
{"wedge", mjMESH_BUILTIN_WEDGE},
|
||||
{"plate", mjMESH_BUILTIN_PLATE}
|
||||
};
|
||||
|
||||
|
||||
// flexcomp type
|
||||
const mjMap fcomp_map[mjNFCOMPTYPES] = {
|
||||
{"grid", mjFCOMPTYPE_GRID},
|
||||
@@ -1539,6 +1553,21 @@ void mjXReader::OneMesh(XMLElement* elem, mjsMesh* mesh, const mjVFS* vfs) {
|
||||
}
|
||||
}
|
||||
|
||||
// read builtin options
|
||||
if (MapValue(elem, "builtin", &n, meshbuiltin_map, meshbuiltin_sz)) {
|
||||
std::vector<double> params;
|
||||
int nparams = ReadVector(elem, "params", params, text, /*required*/ true);
|
||||
if (file) {
|
||||
throw mjXError(elem, "builtin cannot be used with a mesh file");
|
||||
}
|
||||
if (!mesh->uservert->empty()) {
|
||||
throw mjXError(elem, "builtin mesh cannot be used with user vertex data");
|
||||
}
|
||||
if (mjs_makeMesh(mesh, (mjtMeshBuiltin)n, params.data(), nparams)) {
|
||||
throw mjXError(elem, mjs_getError(spec));
|
||||
}
|
||||
}
|
||||
|
||||
// write error info
|
||||
mjs_setString(mesh->info, ("line " + std::to_string(elem->GetLineNum())).c_str());
|
||||
}
|
||||
|
||||
+1
-643
@@ -40,648 +40,6 @@
|
||||
</worldbody>
|
||||
|
||||
<asset>
|
||||
<mesh name="sphere" scale=".08 .08 .08"
|
||||
vertex="0.3996070 0.9129825 0.0823236
|
||||
0.3996070 0.9129825 -0.0823236
|
||||
0.2664047 0.9638612 0.0000000
|
||||
0.2628656 0.9510565 0.1624599
|
||||
0.5257311 0.8506508 0.0000000
|
||||
0.2628656 0.9510565 -0.1624599
|
||||
0.1330711 0.9876884 0.0822425
|
||||
0.1330711 0.9876884 -0.0822425
|
||||
0.0000000 1.0000000 0.0000000
|
||||
0.5192585 0.8401779 0.1564345
|
||||
0.3861874 0.8910066 0.2386769
|
||||
0.5000000 0.8090170 0.3090170
|
||||
0.3861874 0.8910066 -0.2386769
|
||||
0.5192585 0.8401779 -0.1564345
|
||||
0.5000000 0.8090170 -0.3090170
|
||||
0.1327925 0.9663926 -0.2201170
|
||||
0.2640827 0.9162441 -0.3012589
|
||||
0.1316554 0.9243046 -0.3582288
|
||||
0.0000000 0.9619384 -0.2732666
|
||||
0.2598919 0.8626685 -0.4338886
|
||||
0.0000000 0.9150434 -0.4033554
|
||||
0.1312004 0.8649293 -0.4844417
|
||||
0.0000000 0.8506508 -0.5257311
|
||||
0.0000000 0.9904389 -0.1379523
|
||||
0.3836137 0.8439115 -0.3750386
|
||||
0.2640827 0.9162441 0.3012589
|
||||
0.1327925 0.9663926 0.2201170
|
||||
0.1316554 0.9243046 0.3582288
|
||||
0.2598919 0.8626685 0.4338886
|
||||
0.0000000 0.9619384 0.2732666
|
||||
0.1312004 0.8649293 0.4844417
|
||||
0.0000000 0.9150434 0.4033554
|
||||
0.0000000 0.8506508 0.5257311
|
||||
0.3836137 0.8439115 0.3750386
|
||||
0.0000000 0.9904389 0.1379523
|
||||
0.6202396 0.7802044 -0.0811418
|
||||
0.6202396 0.7802044 0.0811418
|
||||
0.7112817 0.7029070 0.0000000
|
||||
0.7020465 0.6937805 -0.1606220
|
||||
0.7020465 0.6937805 0.1606220
|
||||
0.7838430 0.6156421 -0.0810863
|
||||
0.7838430 0.6156421 0.0810863
|
||||
0.8506508 0.5257311 0.0000000
|
||||
0.6068251 0.7586523 -0.2370863
|
||||
0.6068251 0.7586523 0.2370863
|
||||
-0.3996070 0.9129825 -0.0823236
|
||||
-0.3996070 0.9129825 0.0823236
|
||||
-0.2664047 0.9638612 0.0000000
|
||||
-0.2628656 0.9510565 -0.1624599
|
||||
-0.5257311 0.8506508 0.0000000
|
||||
-0.2628656 0.9510565 0.1624599
|
||||
-0.1330711 0.9876884 -0.0822425
|
||||
-0.1330711 0.9876884 0.0822425
|
||||
-0.5192585 0.8401779 -0.1564345
|
||||
-0.3861874 0.8910066 -0.2386769
|
||||
-0.5000000 0.8090170 -0.3090170
|
||||
-0.3861874 0.8910066 0.2386769
|
||||
-0.5192585 0.8401779 0.1564345
|
||||
-0.5000000 0.8090170 0.3090170
|
||||
-0.1327925 0.9663926 0.2201170
|
||||
-0.2640827 0.9162441 0.3012589
|
||||
-0.1316554 0.9243046 0.3582288
|
||||
-0.2598919 0.8626685 0.4338886
|
||||
-0.1312004 0.8649293 0.4844417
|
||||
-0.3836137 0.8439115 0.3750386
|
||||
-0.2640827 0.9162441 -0.3012589
|
||||
-0.1327925 0.9663926 -0.2201170
|
||||
-0.1316554 0.9243046 -0.3582288
|
||||
-0.2598919 0.8626685 -0.4338886
|
||||
-0.1312004 0.8649293 -0.4844417
|
||||
-0.3836137 0.8439115 -0.3750386
|
||||
-0.6202396 0.7802044 0.0811418
|
||||
-0.6202396 0.7802044 -0.0811418
|
||||
-0.7112817 0.7029070 0.0000000
|
||||
-0.7020465 0.6937805 0.1606220
|
||||
-0.7020465 0.6937805 -0.1606220
|
||||
-0.7838430 0.6156421 0.0810863
|
||||
-0.7838430 0.6156421 -0.0810863
|
||||
-0.8506508 0.5257311 0.0000000
|
||||
-0.6068251 0.7586523 0.2370863
|
||||
-0.6068251 0.7586523 -0.2370863
|
||||
0.3996070 -0.9129825 -0.0823236
|
||||
0.3996070 -0.9129825 0.0823236
|
||||
0.2664047 -0.9638612 0.0000000
|
||||
0.2628656 -0.9510565 -0.1624599
|
||||
0.5257311 -0.8506508 0.0000000
|
||||
0.2628656 -0.9510565 0.1624599
|
||||
0.1330711 -0.9876884 -0.0822425
|
||||
0.1330711 -0.9876884 0.0822425
|
||||
0.0000000 -1.0000000 0.0000000
|
||||
0.5192585 -0.8401779 -0.1564345
|
||||
0.3861874 -0.8910066 -0.2386769
|
||||
0.5000000 -0.8090170 -0.3090170
|
||||
0.3861874 -0.8910066 0.2386769
|
||||
0.5192585 -0.8401779 0.1564345
|
||||
0.5000000 -0.8090170 0.3090170
|
||||
0.1327925 -0.9663926 0.2201170
|
||||
0.2640827 -0.9162441 0.3012589
|
||||
0.1316554 -0.9243046 0.3582288
|
||||
0.0000000 -0.9619384 0.2732666
|
||||
0.2598919 -0.8626685 0.4338886
|
||||
0.0000000 -0.9150434 0.4033554
|
||||
0.1312004 -0.8649293 0.4844417
|
||||
0.0000000 -0.8506508 0.5257311
|
||||
0.0000000 -0.9904389 0.1379523
|
||||
0.3836137 -0.8439115 0.3750386
|
||||
0.2640827 -0.9162441 -0.3012589
|
||||
0.1327925 -0.9663926 -0.2201170
|
||||
0.1316554 -0.9243046 -0.3582288
|
||||
0.2598919 -0.8626685 -0.4338886
|
||||
0.0000000 -0.9619384 -0.2732666
|
||||
0.1312004 -0.8649293 -0.4844417
|
||||
0.0000000 -0.9150434 -0.4033554
|
||||
0.0000000 -0.8506508 -0.5257311
|
||||
0.3836137 -0.8439115 -0.3750386
|
||||
0.0000000 -0.9904389 -0.1379523
|
||||
0.6202396 -0.7802044 0.0811418
|
||||
0.6202396 -0.7802044 -0.0811418
|
||||
0.7112817 -0.7029070 0.0000000
|
||||
0.7020465 -0.6937805 0.1606220
|
||||
0.7020465 -0.6937805 -0.1606220
|
||||
0.7838430 -0.6156421 0.0810863
|
||||
0.7838430 -0.6156421 -0.0810863
|
||||
0.8506508 -0.5257311 0.0000000
|
||||
0.6068251 -0.7586523 0.2370863
|
||||
0.6068251 -0.7586523 -0.2370863
|
||||
-0.3996070 -0.9129825 0.0823236
|
||||
-0.3996070 -0.9129825 -0.0823236
|
||||
-0.2664047 -0.9638612 0.0000000
|
||||
-0.2628656 -0.9510565 0.1624599
|
||||
-0.5257311 -0.8506508 0.0000000
|
||||
-0.2628656 -0.9510565 -0.1624599
|
||||
-0.1330711 -0.9876884 0.0822425
|
||||
-0.1330711 -0.9876884 -0.0822425
|
||||
-0.5192585 -0.8401779 0.1564345
|
||||
-0.3861874 -0.8910066 0.2386769
|
||||
-0.5000000 -0.8090170 0.3090170
|
||||
-0.3861874 -0.8910066 -0.2386769
|
||||
-0.5192585 -0.8401779 -0.1564345
|
||||
-0.5000000 -0.8090170 -0.3090170
|
||||
-0.1327925 -0.9663926 -0.2201170
|
||||
-0.2640827 -0.9162441 -0.3012589
|
||||
-0.1316554 -0.9243046 -0.3582288
|
||||
-0.2598919 -0.8626685 -0.4338886
|
||||
-0.1312004 -0.8649293 -0.4844417
|
||||
-0.3836137 -0.8439115 -0.3750386
|
||||
-0.2640827 -0.9162441 0.3012589
|
||||
-0.1327925 -0.9663926 0.2201170
|
||||
-0.1316554 -0.9243046 0.3582288
|
||||
-0.2598919 -0.8626685 0.4338886
|
||||
-0.1312004 -0.8649293 0.4844417
|
||||
-0.3836137 -0.8439115 0.3750386
|
||||
-0.6202396 -0.7802044 -0.0811418
|
||||
-0.6202396 -0.7802044 0.0811418
|
||||
-0.7112817 -0.7029070 0.0000000
|
||||
-0.7020465 -0.6937805 -0.1606220
|
||||
-0.7020465 -0.6937805 0.1606220
|
||||
-0.7838430 -0.6156421 -0.0810863
|
||||
-0.7838430 -0.6156421 0.0810863
|
||||
-0.8506508 -0.5257311 0.0000000
|
||||
-0.6068251 -0.7586523 -0.2370863
|
||||
-0.6068251 -0.7586523 0.2370863
|
||||
0.9129825 -0.0823236 -0.3996070
|
||||
0.9129825 0.0823236 -0.3996070
|
||||
0.9638612 0.0000000 -0.2664047
|
||||
0.9510565 -0.1624599 -0.2628656
|
||||
0.8506508 0.0000000 -0.5257311
|
||||
0.9510565 0.1624599 -0.2628656
|
||||
0.9876884 -0.0822425 -0.1330711
|
||||
0.9876884 0.0822425 -0.1330711
|
||||
1.0000000 0.0000000 0.0000000
|
||||
0.8401779 -0.1564345 -0.5192585
|
||||
0.8910065 -0.2386769 -0.3861874
|
||||
0.8090170 -0.3090170 -0.5000000
|
||||
0.8910065 0.2386769 -0.3861874
|
||||
0.8401779 0.1564345 -0.5192585
|
||||
0.8090170 0.3090170 -0.5000000
|
||||
0.9663926 0.2201170 -0.1327925
|
||||
0.9162441 0.3012589 -0.2640827
|
||||
0.9243046 0.3582288 -0.1316554
|
||||
0.9619384 0.2732666 0.0000000
|
||||
0.8626685 0.4338886 -0.2598919
|
||||
0.9150434 0.4033554 0.0000000
|
||||
0.8649293 0.4844417 -0.1312004
|
||||
0.9904389 0.1379523 0.0000000
|
||||
0.8439115 0.3750386 -0.3836137
|
||||
0.9162441 -0.3012589 -0.2640827
|
||||
0.9663926 -0.2201170 -0.1327925
|
||||
0.9243046 -0.3582288 -0.1316554
|
||||
0.8626685 -0.4338886 -0.2598919
|
||||
0.9619384 -0.2732666 0.0000000
|
||||
0.8649293 -0.4844417 -0.1312004
|
||||
0.9150434 -0.4033554 0.0000000
|
||||
0.8439115 -0.3750386 -0.3836137
|
||||
0.9904389 -0.1379523 0.0000000
|
||||
0.7802044 0.0811418 -0.6202396
|
||||
0.7802044 -0.0811418 -0.6202396
|
||||
0.7029070 0.0000000 -0.7112817
|
||||
0.6937805 0.1606220 -0.7020465
|
||||
0.6937805 -0.1606220 -0.7020465
|
||||
0.6156421 0.0810863 -0.7838430
|
||||
0.6156421 -0.0810863 -0.7838430
|
||||
0.5257311 0.0000000 -0.8506508
|
||||
0.7586523 0.2370863 -0.6068251
|
||||
0.7586523 -0.2370863 -0.6068251
|
||||
0.9129825 0.0823236 0.3996070
|
||||
0.9129825 -0.0823236 0.3996070
|
||||
0.9638612 0.0000000 0.2664047
|
||||
0.9510565 0.1624599 0.2628656
|
||||
0.8506508 0.0000000 0.5257311
|
||||
0.9510565 -0.1624599 0.2628656
|
||||
0.9876884 0.0822425 0.1330711
|
||||
0.9876884 -0.0822425 0.1330711
|
||||
0.8401779 0.1564345 0.5192585
|
||||
0.8910065 0.2386769 0.3861874
|
||||
0.8090170 0.3090170 0.5000000
|
||||
0.8910065 -0.2386769 0.3861874
|
||||
0.8401779 -0.1564345 0.5192585
|
||||
0.8090170 -0.3090170 0.5000000
|
||||
0.9663926 -0.2201170 0.1327925
|
||||
0.9162441 -0.3012589 0.2640827
|
||||
0.9243046 -0.3582288 0.1316554
|
||||
0.8626685 -0.4338886 0.2598919
|
||||
0.8649293 -0.4844417 0.1312004
|
||||
0.8439115 -0.3750386 0.3836137
|
||||
0.9162441 0.3012589 0.2640827
|
||||
0.9663926 0.2201170 0.1327925
|
||||
0.9243046 0.3582288 0.1316554
|
||||
0.8626685 0.4338886 0.2598919
|
||||
0.8649293 0.4844417 0.1312004
|
||||
0.8439115 0.3750386 0.3836137
|
||||
0.7802044 -0.0811418 0.6202396
|
||||
0.7802044 0.0811418 0.6202396
|
||||
0.7029070 0.0000000 0.7112817
|
||||
0.6937805 -0.1606220 0.7020465
|
||||
0.6937805 0.1606220 0.7020465
|
||||
0.6156421 -0.0810863 0.7838430
|
||||
0.6156421 0.0810863 0.7838430
|
||||
0.5257311 0.0000000 0.8506508
|
||||
0.7586523 -0.2370863 0.6068251
|
||||
0.7586523 0.2370863 0.6068251
|
||||
-0.9129825 -0.0823236 0.3996070
|
||||
-0.9129825 0.0823236 0.3996070
|
||||
-0.9638612 0.0000000 0.2664047
|
||||
-0.9510565 -0.1624599 0.2628656
|
||||
-0.8506508 0.0000000 0.5257311
|
||||
-0.9510565 0.1624599 0.2628656
|
||||
-0.9876884 -0.0822425 0.1330711
|
||||
-0.9876884 0.0822425 0.1330711
|
||||
-1.0000000 0.0000000 0.0000000
|
||||
-0.8401779 -0.1564345 0.5192585
|
||||
-0.8910065 -0.2386769 0.3861874
|
||||
-0.8090170 -0.3090170 0.5000000
|
||||
-0.8910065 0.2386769 0.3861874
|
||||
-0.8401779 0.1564345 0.5192585
|
||||
-0.8090170 0.3090170 0.5000000
|
||||
-0.9663926 0.2201170 0.1327925
|
||||
-0.9162441 0.3012589 0.2640827
|
||||
-0.9243046 0.3582288 0.1316554
|
||||
-0.9619384 0.2732666 0.0000000
|
||||
-0.8626685 0.4338886 0.2598919
|
||||
-0.9150434 0.4033554 0.0000000
|
||||
-0.8649293 0.4844417 0.1312004
|
||||
-0.9904389 0.1379523 0.0000000
|
||||
-0.8439115 0.3750386 0.3836137
|
||||
-0.9162441 -0.3012589 0.2640827
|
||||
-0.9663926 -0.2201170 0.1327925
|
||||
-0.9243046 -0.3582288 0.1316554
|
||||
-0.8626685 -0.4338886 0.2598919
|
||||
-0.9619384 -0.2732666 0.0000000
|
||||
-0.8649293 -0.4844417 0.1312004
|
||||
-0.9150434 -0.4033554 0.0000000
|
||||
-0.8439115 -0.3750386 0.3836137
|
||||
-0.9904389 -0.1379523 0.0000000
|
||||
-0.7802044 0.0811418 0.6202396
|
||||
-0.7802044 -0.0811418 0.6202396
|
||||
-0.7029070 0.0000000 0.7112817
|
||||
-0.6937805 0.1606220 0.7020465
|
||||
-0.6937805 -0.1606220 0.7020465
|
||||
-0.6156421 0.0810863 0.7838430
|
||||
-0.6156421 -0.0810863 0.7838430
|
||||
-0.5257311 0.0000000 0.8506508
|
||||
-0.7586523 0.2370863 0.6068251
|
||||
-0.7586523 -0.2370863 0.6068251
|
||||
-0.9129825 0.0823236 -0.3996070
|
||||
-0.9129825 -0.0823236 -0.3996070
|
||||
-0.9638612 0.0000000 -0.2664047
|
||||
-0.9510565 0.1624599 -0.2628656
|
||||
-0.8506508 0.0000000 -0.5257311
|
||||
-0.9510565 -0.1624599 -0.2628656
|
||||
-0.9876884 0.0822425 -0.1330711
|
||||
-0.9876884 -0.0822425 -0.1330711
|
||||
-0.8401779 0.1564345 -0.5192585
|
||||
-0.8910065 0.2386769 -0.3861874
|
||||
-0.8090170 0.3090170 -0.5000000
|
||||
-0.8910065 -0.2386769 -0.3861874
|
||||
-0.8401779 -0.1564345 -0.5192585
|
||||
-0.8090170 -0.3090170 -0.5000000
|
||||
-0.9663926 -0.2201170 -0.1327925
|
||||
-0.9162441 -0.3012589 -0.2640827
|
||||
-0.9243046 -0.3582288 -0.1316554
|
||||
-0.8626685 -0.4338886 -0.2598919
|
||||
-0.8649293 -0.4844417 -0.1312004
|
||||
-0.8439115 -0.3750386 -0.3836137
|
||||
-0.9162441 0.3012589 -0.2640827
|
||||
-0.9663926 0.2201170 -0.1327925
|
||||
-0.9243046 0.3582288 -0.1316554
|
||||
-0.8626685 0.4338886 -0.2598919
|
||||
-0.8649293 0.4844417 -0.1312004
|
||||
-0.8439115 0.3750386 -0.3836137
|
||||
-0.7802044 -0.0811418 -0.6202396
|
||||
-0.7802044 0.0811418 -0.6202396
|
||||
-0.7029070 0.0000000 -0.7112817
|
||||
-0.6937805 -0.1606220 -0.7020465
|
||||
-0.6937805 0.1606220 -0.7020465
|
||||
-0.6156421 -0.0810863 -0.7838430
|
||||
-0.6156421 0.0810863 -0.7838430
|
||||
-0.5257311 0.0000000 -0.8506508
|
||||
-0.7586523 -0.2370863 -0.6068251
|
||||
-0.7586523 0.2370863 -0.6068251
|
||||
-0.0823236 -0.3996070 0.9129825
|
||||
0.0823236 -0.3996070 0.9129825
|
||||
0.0000000 -0.2664047 0.9638612
|
||||
-0.1624599 -0.2628656 0.9510565
|
||||
0.0000000 -0.5257311 0.8506508
|
||||
0.1624599 -0.2628656 0.9510565
|
||||
-0.0822425 -0.1330711 0.9876884
|
||||
0.0822425 -0.1330711 0.9876884
|
||||
0.0000000 0.0000000 1.0000000
|
||||
-0.1564345 -0.5192585 0.8401779
|
||||
-0.2386769 -0.3861874 0.8910065
|
||||
-0.3090170 -0.5000000 0.8090170
|
||||
0.2386769 -0.3861874 0.8910065
|
||||
0.1564345 -0.5192585 0.8401779
|
||||
0.3090170 -0.5000000 0.8090170
|
||||
0.2201170 -0.1327925 0.9663926
|
||||
0.3012589 -0.2640827 0.9162441
|
||||
0.3582288 -0.1316554 0.9243046
|
||||
0.2732666 0.0000000 0.9619384
|
||||
0.4338886 -0.2598919 0.8626685
|
||||
0.4033554 0.0000000 0.9150434
|
||||
0.4844417 -0.1312004 0.8649293
|
||||
0.1379523 0.0000000 0.9904389
|
||||
0.3750386 -0.3836137 0.8439115
|
||||
-0.3012589 -0.2640827 0.9162441
|
||||
-0.2201170 -0.1327925 0.9663926
|
||||
-0.3582288 -0.1316554 0.9243046
|
||||
-0.4338886 -0.2598919 0.8626685
|
||||
-0.2732666 0.0000000 0.9619384
|
||||
-0.4844417 -0.1312004 0.8649293
|
||||
-0.4033554 0.0000000 0.9150434
|
||||
-0.3750386 -0.3836137 0.8439115
|
||||
-0.1379523 0.0000000 0.9904389
|
||||
0.0811418 -0.6202396 0.7802044
|
||||
-0.0811418 -0.6202396 0.7802044
|
||||
0.0000000 -0.7112817 0.7029070
|
||||
0.1606220 -0.7020465 0.6937805
|
||||
-0.1606220 -0.7020465 0.6937805
|
||||
0.0810863 -0.7838430 0.6156421
|
||||
-0.0810863 -0.7838430 0.6156421
|
||||
0.2370863 -0.6068251 0.7586523
|
||||
-0.2370863 -0.6068251 0.7586523
|
||||
0.0823236 0.3996070 0.9129825
|
||||
-0.0823236 0.3996070 0.9129825
|
||||
0.0000000 0.2664047 0.9638612
|
||||
0.1624599 0.2628656 0.9510565
|
||||
0.0000000 0.5257311 0.8506508
|
||||
-0.1624599 0.2628656 0.9510565
|
||||
0.0822425 0.1330711 0.9876884
|
||||
-0.0822425 0.1330711 0.9876884
|
||||
0.1564345 0.5192585 0.8401779
|
||||
0.2386769 0.3861874 0.8910065
|
||||
0.3090170 0.5000000 0.8090170
|
||||
-0.2386769 0.3861874 0.8910065
|
||||
-0.1564345 0.5192585 0.8401779
|
||||
-0.3090170 0.5000000 0.8090170
|
||||
-0.2201170 0.1327925 0.9663926
|
||||
-0.3012589 0.2640827 0.9162441
|
||||
-0.3582288 0.1316554 0.9243046
|
||||
-0.4338886 0.2598919 0.8626685
|
||||
-0.4844417 0.1312004 0.8649293
|
||||
-0.3750386 0.3836137 0.8439115
|
||||
0.3012589 0.2640827 0.9162441
|
||||
0.2201170 0.1327925 0.9663926
|
||||
0.3582288 0.1316554 0.9243046
|
||||
0.4338886 0.2598919 0.8626685
|
||||
0.4844417 0.1312004 0.8649293
|
||||
0.3750386 0.3836137 0.8439115
|
||||
-0.0811418 0.6202396 0.7802044
|
||||
0.0811418 0.6202396 0.7802044
|
||||
0.0000000 0.7112817 0.7029070
|
||||
-0.1606220 0.7020465 0.6937805
|
||||
0.1606220 0.7020465 0.6937805
|
||||
-0.0810863 0.7838430 0.6156421
|
||||
0.0810863 0.7838430 0.6156421
|
||||
-0.2370863 0.6068251 0.7586523
|
||||
0.2370863 0.6068251 0.7586523
|
||||
-0.0823236 0.3996070 -0.9129825
|
||||
0.0823236 0.3996070 -0.9129825
|
||||
0.0000000 0.2664047 -0.9638612
|
||||
-0.1624599 0.2628656 -0.9510565
|
||||
0.0000000 0.5257311 -0.8506508
|
||||
0.1624599 0.2628656 -0.9510565
|
||||
-0.0822425 0.1330711 -0.9876884
|
||||
0.0822425 0.1330711 -0.9876884
|
||||
0.0000000 0.0000000 -1.0000000
|
||||
-0.1564345 0.5192585 -0.8401779
|
||||
-0.2386769 0.3861874 -0.8910065
|
||||
-0.3090170 0.5000000 -0.8090170
|
||||
0.2386769 0.3861874 -0.8910065
|
||||
0.1564345 0.5192585 -0.8401779
|
||||
0.3090170 0.5000000 -0.8090170
|
||||
0.2201170 0.1327925 -0.9663926
|
||||
0.3012589 0.2640827 -0.9162441
|
||||
0.3582288 0.1316554 -0.9243046
|
||||
0.2732666 0.0000000 -0.9619384
|
||||
0.4338886 0.2598919 -0.8626685
|
||||
0.4033554 0.0000000 -0.9150434
|
||||
0.4844417 0.1312004 -0.8649293
|
||||
0.1379523 0.0000000 -0.9904389
|
||||
0.3750386 0.3836137 -0.8439115
|
||||
-0.3012589 0.2640827 -0.9162441
|
||||
-0.2201170 0.1327925 -0.9663926
|
||||
-0.3582288 0.1316554 -0.9243046
|
||||
-0.4338886 0.2598919 -0.8626685
|
||||
-0.2732666 0.0000000 -0.9619384
|
||||
-0.4844417 0.1312004 -0.8649293
|
||||
-0.4033554 0.0000000 -0.9150434
|
||||
-0.3750386 0.3836137 -0.8439115
|
||||
-0.1379523 0.0000000 -0.9904389
|
||||
0.0811418 0.6202396 -0.7802044
|
||||
-0.0811418 0.6202396 -0.7802044
|
||||
0.0000000 0.7112817 -0.7029070
|
||||
0.1606220 0.7020465 -0.6937805
|
||||
-0.1606220 0.7020465 -0.6937805
|
||||
0.0810863 0.7838430 -0.6156421
|
||||
-0.0810863 0.7838430 -0.6156421
|
||||
0.2370863 0.6068251 -0.7586523
|
||||
-0.2370863 0.6068251 -0.7586523
|
||||
0.0823236 -0.3996070 -0.9129825
|
||||
-0.0823236 -0.3996070 -0.9129825
|
||||
0.0000000 -0.2664047 -0.9638612
|
||||
0.1624599 -0.2628656 -0.9510565
|
||||
0.0000000 -0.5257311 -0.8506508
|
||||
-0.1624599 -0.2628656 -0.9510565
|
||||
0.0822425 -0.1330711 -0.9876884
|
||||
-0.0822425 -0.1330711 -0.9876884
|
||||
0.1564345 -0.5192585 -0.8401779
|
||||
0.2386769 -0.3861874 -0.8910065
|
||||
0.3090170 -0.5000000 -0.8090170
|
||||
-0.2386769 -0.3861874 -0.8910065
|
||||
-0.1564345 -0.5192585 -0.8401779
|
||||
-0.3090170 -0.5000000 -0.8090170
|
||||
-0.2201170 -0.1327925 -0.9663926
|
||||
-0.3012589 -0.2640827 -0.9162441
|
||||
-0.3582288 -0.1316554 -0.9243046
|
||||
-0.4338886 -0.2598919 -0.8626685
|
||||
-0.4844417 -0.1312004 -0.8649293
|
||||
-0.3750386 -0.3836137 -0.8439115
|
||||
0.3012589 -0.2640827 -0.9162441
|
||||
0.2201170 -0.1327925 -0.9663926
|
||||
0.3582288 -0.1316554 -0.9243046
|
||||
0.4338886 -0.2598919 -0.8626685
|
||||
0.4844417 -0.1312004 -0.8649293
|
||||
0.3750386 -0.3836137 -0.8439115
|
||||
-0.0811418 -0.6202396 -0.7802044
|
||||
0.0811418 -0.6202396 -0.7802044
|
||||
0.0000000 -0.7112817 -0.7029070
|
||||
-0.1606220 -0.7020465 -0.6937805
|
||||
0.1606220 -0.7020465 -0.6937805
|
||||
-0.0810863 -0.7838430 -0.6156421
|
||||
0.0810863 -0.7838430 -0.6156421
|
||||
-0.2370863 -0.6068251 -0.7586523
|
||||
0.2370863 -0.6068251 -0.7586523
|
||||
0.6465778 0.5133755 0.5642542
|
||||
0.5642542 0.6465778 0.5133755
|
||||
0.5133755 0.5642542 0.6465778
|
||||
0.5877853 0.4253254 0.6881909
|
||||
0.6881909 0.5877853 0.4253254
|
||||
0.4253254 0.6881909 0.5877853
|
||||
0.4539905 0.4684299 0.7579354
|
||||
0.3717480 0.6015009 0.7071068
|
||||
0.7579354 0.4539905 0.4684299
|
||||
0.7071068 0.3717480 0.6015009
|
||||
0.4684299 0.7579354 0.4539905
|
||||
0.6015009 0.7071068 0.3717480
|
||||
0.2960046 0.7023098 0.6474119
|
||||
0.3461530 0.7834517 0.5161216
|
||||
0.2130228 0.7926492 0.5712517
|
||||
0.6474119 0.2960046 0.7023098
|
||||
0.5161216 0.3461530 0.7834517
|
||||
0.5712517 0.2130228 0.7926492
|
||||
0.7023098 0.6474119 0.2960046
|
||||
0.7834517 0.5161216 0.3461530
|
||||
0.7926493 0.5712517 0.2130229
|
||||
-0.6465778 0.5133755 0.5642542
|
||||
-0.5133755 0.5642542 0.6465778
|
||||
-0.5642542 0.6465778 0.5133755
|
||||
-0.6881909 0.5877853 0.4253254
|
||||
-0.5877853 0.4253254 0.6881909
|
||||
-0.4253254 0.6881909 0.5877853
|
||||
-0.6015009 0.7071068 0.3717480
|
||||
-0.4684299 0.7579354 0.4539905
|
||||
-0.7071068 0.3717480 0.6015009
|
||||
-0.7579354 0.4539905 0.4684299
|
||||
-0.3717480 0.6015009 0.7071068
|
||||
-0.4539905 0.4684299 0.7579354
|
||||
-0.3461530 0.7834517 0.5161216
|
||||
-0.2960046 0.7023098 0.6474119
|
||||
-0.2130228 0.7926492 0.5712517
|
||||
-0.7834517 0.5161216 0.3461530
|
||||
-0.7023098 0.6474119 0.2960046
|
||||
-0.7926493 0.5712517 0.2130229
|
||||
-0.5161216 0.3461530 0.7834517
|
||||
-0.6474119 0.2960046 0.7023098
|
||||
-0.5712517 0.2130228 0.7926492
|
||||
0.6465778 0.5133755 -0.5642542
|
||||
0.5133755 0.5642542 -0.6465778
|
||||
0.5642542 0.6465778 -0.5133755
|
||||
0.6881909 0.5877853 -0.4253254
|
||||
0.5877853 0.4253254 -0.6881909
|
||||
0.4253254 0.6881909 -0.5877853
|
||||
0.6015009 0.7071068 -0.3717480
|
||||
0.4684299 0.7579354 -0.4539905
|
||||
0.7071068 0.3717480 -0.6015009
|
||||
0.7579354 0.4539905 -0.4684299
|
||||
0.3717480 0.6015009 -0.7071068
|
||||
0.4539905 0.4684299 -0.7579354
|
||||
0.3461530 0.7834517 -0.5161216
|
||||
0.2960046 0.7023098 -0.6474119
|
||||
0.2130228 0.7926492 -0.5712517
|
||||
0.7834517 0.5161216 -0.3461530
|
||||
0.7023098 0.6474119 -0.2960046
|
||||
0.7926493 0.5712517 -0.2130229
|
||||
0.5161216 0.3461530 -0.7834517
|
||||
0.6474119 0.2960046 -0.7023098
|
||||
0.5712517 0.2130228 -0.7926492
|
||||
-0.6465778 0.5133755 -0.5642542
|
||||
-0.5642542 0.6465778 -0.5133755
|
||||
-0.5133755 0.5642542 -0.6465778
|
||||
-0.5877853 0.4253254 -0.6881909
|
||||
-0.6881909 0.5877853 -0.4253254
|
||||
-0.4253254 0.6881909 -0.5877853
|
||||
-0.4539905 0.4684299 -0.7579354
|
||||
-0.3717480 0.6015009 -0.7071068
|
||||
-0.7579354 0.4539905 -0.4684299
|
||||
-0.7071068 0.3717480 -0.6015009
|
||||
-0.4684299 0.7579354 -0.4539905
|
||||
-0.6015009 0.7071068 -0.3717480
|
||||
-0.2960046 0.7023098 -0.6474119
|
||||
-0.3461530 0.7834517 -0.5161216
|
||||
-0.2130228 0.7926492 -0.5712517
|
||||
-0.6474119 0.2960046 -0.7023098
|
||||
-0.5161216 0.3461530 -0.7834517
|
||||
-0.5712517 0.2130228 -0.7926492
|
||||
-0.7023098 0.6474119 -0.2960046
|
||||
-0.7834517 0.5161216 -0.3461530
|
||||
-0.7926493 0.5712517 -0.2130229
|
||||
0.6465778 -0.5133755 0.5642542
|
||||
0.5133755 -0.5642542 0.6465778
|
||||
0.5642542 -0.6465778 0.5133755
|
||||
0.6881909 -0.5877853 0.4253254
|
||||
0.5877853 -0.4253254 0.6881909
|
||||
0.4253254 -0.6881909 0.5877853
|
||||
0.6015009 -0.7071068 0.3717480
|
||||
0.4684299 -0.7579354 0.4539905
|
||||
0.7071068 -0.3717480 0.6015009
|
||||
0.7579354 -0.4539905 0.4684299
|
||||
0.3717480 -0.6015009 0.7071068
|
||||
0.4539905 -0.4684299 0.7579354
|
||||
0.3461530 -0.7834517 0.5161216
|
||||
0.2960046 -0.7023098 0.6474119
|
||||
0.2130228 -0.7926492 0.5712517
|
||||
0.7834517 -0.5161216 0.3461530
|
||||
0.7023098 -0.6474119 0.2960046
|
||||
0.7926493 -0.5712517 0.2130229
|
||||
0.5161216 -0.3461530 0.7834517
|
||||
0.6474119 -0.2960046 0.7023098
|
||||
0.5712517 -0.2130228 0.7926492
|
||||
-0.6465778 -0.5133755 0.5642542
|
||||
-0.5642542 -0.6465778 0.5133755
|
||||
-0.5133755 -0.5642542 0.6465778
|
||||
-0.5877853 -0.4253254 0.6881909
|
||||
-0.6881909 -0.5877853 0.4253254
|
||||
-0.4253254 -0.6881909 0.5877853
|
||||
-0.4539905 -0.4684299 0.7579354
|
||||
-0.3717480 -0.6015009 0.7071068
|
||||
-0.7579354 -0.4539905 0.4684299
|
||||
-0.7071068 -0.3717480 0.6015009
|
||||
-0.4684299 -0.7579354 0.4539905
|
||||
-0.6015009 -0.7071068 0.3717480
|
||||
-0.2960046 -0.7023098 0.6474119
|
||||
-0.3461530 -0.7834517 0.5161216
|
||||
-0.2130228 -0.7926492 0.5712517
|
||||
-0.6474119 -0.2960046 0.7023098
|
||||
-0.5161216 -0.3461530 0.7834517
|
||||
-0.5712517 -0.2130228 0.7926492
|
||||
-0.7023098 -0.6474119 0.2960046
|
||||
-0.7834517 -0.5161216 0.3461530
|
||||
-0.7926493 -0.5712517 0.2130229
|
||||
0.6465778 -0.5133755 -0.5642542
|
||||
0.5642542 -0.6465778 -0.5133755
|
||||
0.5133755 -0.5642542 -0.6465778
|
||||
0.5877853 -0.4253254 -0.6881909
|
||||
0.6881909 -0.5877853 -0.4253254
|
||||
0.4253254 -0.6881909 -0.5877853
|
||||
0.4539905 -0.4684299 -0.7579354
|
||||
0.3717480 -0.6015009 -0.7071068
|
||||
0.7579354 -0.4539905 -0.4684299
|
||||
0.7071068 -0.3717480 -0.6015009
|
||||
0.4684299 -0.7579354 -0.4539905
|
||||
0.6015009 -0.7071068 -0.3717480
|
||||
0.2960046 -0.7023098 -0.6474119
|
||||
0.3461530 -0.7834517 -0.5161216
|
||||
0.2130228 -0.7926492 -0.5712517
|
||||
0.6474119 -0.2960046 -0.7023098
|
||||
0.5161216 -0.3461530 -0.7834517
|
||||
0.5712517 -0.2130228 -0.7926492
|
||||
0.7023098 -0.6474119 -0.2960046
|
||||
0.7834517 -0.5161216 -0.3461530
|
||||
0.7926493 -0.5712517 -0.2130229
|
||||
-0.6465778 -0.5133755 -0.5642542
|
||||
-0.5133755 -0.5642542 -0.6465778
|
||||
-0.5642542 -0.6465778 -0.5133755
|
||||
-0.6881909 -0.5877853 -0.4253254
|
||||
-0.5877853 -0.4253254 -0.6881909
|
||||
-0.4253254 -0.6881909 -0.5877853
|
||||
-0.6015009 -0.7071068 -0.3717480
|
||||
-0.4684299 -0.7579354 -0.4539905
|
||||
-0.7071068 -0.3717480 -0.6015009
|
||||
-0.7579354 -0.4539905 -0.4684299
|
||||
-0.3717480 -0.6015009 -0.7071068
|
||||
-0.4539905 -0.4684299 -0.7579354
|
||||
-0.3461530 -0.7834517 -0.5161216
|
||||
-0.2960046 -0.7023098 -0.6474119
|
||||
-0.2130228 -0.7926492 -0.5712517
|
||||
-0.7834517 -0.5161216 -0.3461530
|
||||
-0.7023098 -0.6474119 -0.2960046
|
||||
-0.7926493 -0.5712517 -0.2130229
|
||||
-0.5161216 -0.3461530 -0.7834517
|
||||
-0.6474119 -0.2960046 -0.7023098
|
||||
-0.5712517 -0.2130228 -0.7926492"/>
|
||||
<mesh name="sphere" builtin="wedge" params="25 25 180 90 0" scale=".08 .08 .08"/>
|
||||
</asset>
|
||||
</mujoco>
|
||||
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
<mujoco model='makemesh'>
|
||||
<asset>
|
||||
<mesh name="wedge" builtin="wedge" params="25 25 180 90 0"/>
|
||||
<mesh name="plate" builtin="plate" params="37 37" scale="3 5 2"/>
|
||||
<mesh name="prism" builtin="prism" params="3"/>
|
||||
</asset>
|
||||
|
||||
<worldbody>
|
||||
<geom mesh="wedge" type="mesh"/>
|
||||
<geom mesh="plate" type="mesh" contype="0" conaffinity="0"/>
|
||||
<geom mesh="prism" type="mesh" pos="0 0 3"/>
|
||||
</worldbody>
|
||||
</mujoco>
|
||||
@@ -2021,6 +2021,118 @@ TEST_F(XMLReaderTest, ReadShellParameter) {
|
||||
mj_deleteModel(model);
|
||||
}
|
||||
|
||||
// ----------------------- test builtin mesh parsing ---------------------------
|
||||
|
||||
TEST_F(XMLReaderTest, ReadWedgeMesh) {
|
||||
static constexpr char xml[] = R"(
|
||||
<mujoco>
|
||||
<asset>
|
||||
<mesh name="wedge" builtin="wedge" params="25 25 180 90 0"/>
|
||||
</asset>
|
||||
<worldbody>
|
||||
<geom type="mesh" mesh="wedge"/>
|
||||
</worldbody>
|
||||
</mujoco>
|
||||
)";
|
||||
std::array<char, 1024> error;
|
||||
mjModel* model = LoadModelFromString(xml, error.data(), error.size());
|
||||
ASSERT_THAT(model, NotNull()) << error.data();
|
||||
mj_deleteModel(model);
|
||||
}
|
||||
|
||||
TEST_F(XMLReaderTest, UnsupportedMesh) {
|
||||
static constexpr char xml[] = R"(
|
||||
<mujoco>
|
||||
<asset>
|
||||
<mesh name="cone" builtin="cone" params="25 25 180 90 0"/>
|
||||
</asset>
|
||||
<worldbody>
|
||||
<geom type="mesh" mesh="cone"/>
|
||||
</worldbody>
|
||||
</mujoco>
|
||||
)";
|
||||
std::array<char, 1024> error;
|
||||
mjModel* model = LoadModelFromString(xml, error.data(), error.size());
|
||||
ASSERT_THAT(model, IsNull());
|
||||
EXPECT_THAT(error.data(), HasSubstr("Unsupported mesh type"));
|
||||
mj_deleteModel(model);
|
||||
}
|
||||
|
||||
TEST_F(XMLReaderTest, BuiltinAndFile) {
|
||||
static constexpr char xml[] = R"(
|
||||
<mujoco>
|
||||
<asset>
|
||||
<mesh name="wedge" builtin="wedge" vertex="0 0 0 1 0 0 0 1 0 0 1 0"
|
||||
params="25 25 180 90 0"/>
|
||||
</asset>
|
||||
<worldbody>
|
||||
<geom type="mesh" mesh="wedge"/>
|
||||
</worldbody>
|
||||
</mujoco>
|
||||
)";
|
||||
std::array<char, 1024> error;
|
||||
mjModel* model = LoadModelFromString(xml, error.data(), error.size());
|
||||
ASSERT_THAT(model, IsNull());
|
||||
EXPECT_THAT(error.data(),
|
||||
HasSubstr("builtin mesh cannot be used with user vertex data"));
|
||||
mj_deleteModel(model);
|
||||
}
|
||||
|
||||
TEST_F(XMLReaderTest, MakePlateNoParameters) {
|
||||
static constexpr char xml[] = R"(
|
||||
<mujoco>
|
||||
<asset>
|
||||
<mesh name="plate" builtin="plate"/>
|
||||
</asset>
|
||||
<worldbody>
|
||||
<geom type="mesh" mesh="plate" contype="0" conaffinity="0"/>
|
||||
</worldbody>
|
||||
</mujoco>)";
|
||||
std::array<char, 1024> error;
|
||||
mjModel* model = LoadModelFromString(xml, error.data(), error.size());
|
||||
ASSERT_THAT(model, IsNull());
|
||||
EXPECT_THAT(error.data(), HasSubstr("required attribute missing: 'params'"));
|
||||
mj_deleteModel(model);
|
||||
}
|
||||
|
||||
TEST_F(XMLReaderTest, MakePlateTooFewParameters) {
|
||||
static constexpr char xml[] = R"(
|
||||
<mujoco>
|
||||
<asset>
|
||||
<mesh name="plate" builtin="plate" params="1"/>
|
||||
</asset>
|
||||
<worldbody>
|
||||
<geom type="mesh" mesh="plate" contype="0" conaffinity="0"/>
|
||||
</worldbody>
|
||||
</mujoco>)";
|
||||
std::array<char, 1024> error;
|
||||
mjModel* model = LoadModelFromString(xml, error.data(), error.size());
|
||||
ASSERT_THAT(model, IsNull());
|
||||
EXPECT_THAT(
|
||||
error.data(),
|
||||
HasSubstr("Plate builtin mesh type requires 2 parameters"));
|
||||
mj_deleteModel(model);
|
||||
}
|
||||
|
||||
TEST_F(XMLReaderTest, MakePlateInvalidParameters) {
|
||||
static constexpr char xml[] = R"(
|
||||
<mujoco>
|
||||
<asset>
|
||||
<mesh name="plate" builtin="plate" params="-1 -1"/>
|
||||
</asset>
|
||||
<worldbody>
|
||||
<geom type="mesh" mesh="plate" contype="0" conaffinity="0"/>
|
||||
</worldbody>
|
||||
</mujoco>)";
|
||||
std::array<char, 1024> error;
|
||||
mjModel* model = LoadModelFromString(xml, error.data(), error.size());
|
||||
ASSERT_THAT(model, IsNull());
|
||||
EXPECT_THAT(error.data(), HasSubstr("resolutions must be positive"));
|
||||
mj_deleteModel(model);
|
||||
}
|
||||
|
||||
// ----------------------- test skin parsing --------------------------------
|
||||
|
||||
TEST_F(XMLReaderTest, ReadsSkinGroups) {
|
||||
static constexpr char xml[] = R"(
|
||||
<mujoco>
|
||||
|
||||
@@ -1386,6 +1386,7 @@ TEST_F(XMLWriterTest, WriteReadCompare) {
|
||||
absl::StrContains(p.path().string(), "shark_") ||
|
||||
absl::StrContains(p.path().string(), "spheremesh") ||
|
||||
// exclude files that fail the comparison test
|
||||
absl::StrContains(p.path().string(), "makemesh") ||
|
||||
absl::StrContains(p.path().string(), "usd") ||
|
||||
absl::StrContains(p.path().string(), "torus_maxhull") ||
|
||||
absl::StrContains(p.path().string(), "fitmesh_") ||
|
||||
|
||||
@@ -496,6 +496,16 @@ public enum mjtMeshInertia : int{
|
||||
mjMESH_INERTIA_LEGACY = 2,
|
||||
mjMESH_INERTIA_SHELL = 3,
|
||||
}
|
||||
public enum mjtMeshBuiltin : int{
|
||||
mjMESH_BUILTIN_NONE = 0,
|
||||
mjMESH_BUILTIN_SPHERE = 1,
|
||||
mjMESH_BUILTIN_HEMISPHERE = 2,
|
||||
mjMESH_BUILTIN_PRISM = 3,
|
||||
mjMESH_BUILTIN_CONE = 4,
|
||||
mjMESH_BUILTIN_TORUS = 5,
|
||||
mjMESH_BUILTIN_WEDGE = 6,
|
||||
mjMESH_BUILTIN_PLATE = 7,
|
||||
}
|
||||
public enum mjtBuiltin : int{
|
||||
mjBUILTIN_NONE = 0,
|
||||
mjBUILTIN_GRADIENT = 1,
|
||||
|
||||
Reference in New Issue
Block a user