|
40 | 40 | #include <pxr/usd/usdGeom/cube.h> |
41 | 41 | #include <pxr/usd/usdGeom/cylinder.h> |
42 | 42 | #include <pxr/usd/usdGeom/mesh.h> |
| 43 | +#include <pxr/usd/usdGeom/plane.h> |
43 | 44 | #include <pxr/usd/usdGeom/primvar.h> |
44 | 45 | #include <pxr/usd/usdGeom/primvarsAPI.h> |
45 | 46 | #include <pxr/usd/usdGeom/sphere.h> |
@@ -389,6 +390,62 @@ TEST_F(MjcfSdfFileFormatPluginTest, TestKindAuthoring) { |
389 | 390 | EXPECT_PRIM_KIND(stage, "/test/root/tet", pxr::KindTokens->subcomponent); |
390 | 391 | } |
391 | 392 |
|
| 393 | +TEST_F(MjcfSdfFileFormatPluginTest, TestGeomsPrims) { |
| 394 | + static constexpr char kXml[] = R"( |
| 395 | + <mujoco model="test"> |
| 396 | + <worldbody> |
| 397 | + <geom type="plane" name="plane_geom" size="10 20 0.1"/> |
| 398 | + <geom type="box" name="box_geom" size="10 20 30"/> |
| 399 | + <geom type="sphere" name="sphere_geom" size="10 20 30"/> |
| 400 | + <geom type="capsule" name="capsule_geom" size="10 20 30"/> |
| 401 | + <geom type="cylinder" name="cylinder_geom" size="10 20 30"/> |
| 402 | + <geom type="ellipsoid" name="ellipsoid_geom" size="10 20 30"/> |
| 403 | + </worldbody> |
| 404 | + </mujoco> |
| 405 | + )"; |
| 406 | + |
| 407 | + pxr::SdfLayerRefPtr layer = LoadLayer(kXml); |
| 408 | + auto stage = pxr::UsdStage::Open(layer); |
| 409 | + |
| 410 | + // Note that all sizes are multiplied by 2 because Mujoco uses half sizes. |
| 411 | + |
| 412 | + // Plane |
| 413 | + EXPECT_PRIM_VALID(stage, "/test/plane_geom"); |
| 414 | + EXPECT_PRIM_IS_A(stage, "/test/plane_geom", pxr::UsdGeomPlane); |
| 415 | + ExpectAttributeEqual(stage, "/test/plane_geom.width", 2 * 10.0); |
| 416 | + ExpectAttributeEqual(stage, "/test/plane_geom.length", 2 * 20.0); |
| 417 | + // Box |
| 418 | + EXPECT_PRIM_VALID(stage, "/test/box_geom"); |
| 419 | + EXPECT_PRIM_IS_A(stage, "/test/box_geom", pxr::UsdGeomCube); |
| 420 | + // Box is a special case, it uses a UsdGeomCube and scales it with |
| 421 | + // xformOp:scale. The radius is always set to 2. |
| 422 | + ExpectAttributeEqual(stage, "/test/box_geom.size", 2.0); |
| 423 | + ExpectAttributeEqual(stage, "/test/box_geom.xformOp:scale", |
| 424 | + pxr::GfVec3f(10.0, 20.0, 30.0)); |
| 425 | + // Sphere |
| 426 | + EXPECT_PRIM_VALID(stage, "/test/sphere_geom"); |
| 427 | + EXPECT_PRIM_IS_A(stage, "/test/sphere_geom", pxr::UsdGeomSphere); |
| 428 | + ExpectAttributeEqual(stage, "/test/sphere_geom.radius", 2 * 10.0); |
| 429 | + // Capsule |
| 430 | + EXPECT_PRIM_VALID(stage, "/test/capsule_geom"); |
| 431 | + EXPECT_PRIM_IS_A(stage, "/test/capsule_geom", pxr::UsdGeomCapsule); |
| 432 | + ExpectAttributeEqual(stage, "/test/capsule_geom.radius", 2 * 10.0); |
| 433 | + ExpectAttributeEqual(stage, "/test/capsule_geom.height", 2 * 20.0); |
| 434 | + // Cylinder |
| 435 | + EXPECT_PRIM_VALID(stage, "/test/cylinder_geom"); |
| 436 | + EXPECT_PRIM_IS_A(stage, "/test/cylinder_geom", pxr::UsdGeomCylinder); |
| 437 | + ExpectAttributeEqual(stage, "/test/cylinder_geom.radius", 2 * 10.0); |
| 438 | + ExpectAttributeEqual(stage, "/test/cylinder_geom.height", 2 * 20.0); |
| 439 | + // Ellipsoid |
| 440 | + EXPECT_PRIM_VALID(stage, "/test/ellipsoid_geom"); |
| 441 | + // Ellipsoid is a special case, it uses a UsdGeomSphere and scales it with |
| 442 | + // xformOp:scale. The radius is always set to 1. |
| 443 | + EXPECT_PRIM_IS_A(stage, "/test/ellipsoid_geom", pxr::UsdGeomSphere); |
| 444 | + ExpectAttributeEqual(stage, "/test/ellipsoid_geom.radius", 1.0); |
| 445 | + ExpectAttributeEqual(stage, "/test/ellipsoid_geom.xformOp:scale", |
| 446 | + pxr::GfVec3f(2.0 * 10.0, 2.0 * 20.0, 2.0 * 30.0)); |
| 447 | +} |
| 448 | + |
392 | 449 | static constexpr char kSiteXml[] = R"( |
393 | 450 | <mujoco model="test"> |
394 | 451 | <worldbody> |
@@ -435,6 +492,7 @@ TEST_F(MjcfSdfFileFormatPluginTest, TestSitePrimsPurpose) { |
435 | 492 | EXPECT_PRIM_PURPOSE(stage, "/test/ball/ball/ellipsoid_site", |
436 | 493 | pxr::UsdGeomTokens->guide); |
437 | 494 | } |
| 495 | + |
438 | 496 | TEST_F(MjcfSdfFileFormatPluginTest, TestPhysicsToggleSdfFormatArg) { |
439 | 497 | std::string xml_path = GetTestDataFilePath(kMeshObjPath); |
440 | 498 |
|
|
0 commit comments