Skip to content

Commit

Permalink
USD to SDF: Added visuals (#897)
Browse files Browse the repository at this point in the history
Signed-off-by: Alejandro Hernández <[email protected]>

Co-authored-by: Ashton Larkin <[email protected]>
  • Loading branch information
ahcorde and adlarkin authored Apr 11, 2022
1 parent 256fc6b commit a0b022d
Show file tree
Hide file tree
Showing 11 changed files with 788 additions and 32 deletions.
59 changes: 52 additions & 7 deletions test/usd/upAxisZ.usda
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,15 @@ def Xform "ground_plane"
double3 xformOp:translate = (0, 0, 0)
uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ"]

def Cube "geometry" (
def Cube "geometry"
{
float3[] extent = [(-0.5, -0.5, -0.5), (0.5, 0.5, 0.5)]
rel material:binding = </Looks/Material_0>
double size = 1
float3 xformOp:scale = (100, 100, 0.25)
uniform token[] xformOpOrder = ["xformOp:scale"]
}
def Cube "collision" (
prepend apiSchemas = ["PhysicsCollisionAPI"]
)
{
Expand Down Expand Up @@ -85,15 +93,24 @@ def Xform "box" (
float physics:mass = 1
float3 xformOp:rotateXYZ = (0, 0, 0)
double3 xformOp:translate = (0, 0, 0)
uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ"]
float3 xformOp:scale = (1, 0.1, 1)
uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"]

def Xform "box_visual"
{
float3 xformOp:rotateXYZ = (0, 0, 0)
double3 xformOp:translate = (0, 0, 0)
uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ"]

def Cube "geometry" (
def Cube "geometry"
{
float3[] extent = [(-0.5, -0.5, -0.5), (0.5, 0.5, 0.5)]
rel material:binding = </Looks/Material_1>
double size = 1
float3 xformOp:scale = (1, 0.1, 0.2)
uniform token[] xformOpOrder = ["xformOp:scale"]
}
def Cube "collision" (
prepend apiSchemas = ["PhysicsCollisionAPI"]
)
{
Expand Down Expand Up @@ -130,7 +147,14 @@ def Xform "cylinder"
double3 xformOp:translate = (0, 0, 0)
uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ"]

def Cylinder "geometry" (
def Cylinder "geometry"
{
float3[] extent = [(-0.5, -0.5, -0.5), (0.5, 0.5, 0.5)]
double height = 1
rel material:binding = </Looks/Material_2>
double radius = 0.5
}
def Cylinder "collision" (
prepend apiSchemas = ["PhysicsCollisionAPI"]
)
{
Expand Down Expand Up @@ -166,7 +190,13 @@ def Xform "sphere"
double3 xformOp:translate = (0, 0, 0)
uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ"]

def Sphere "geometry" (
def Sphere "geometry"
{
float3[] extent = [(-0.5, -0.5, -0.5), (0.5, 0.5, 0.5)]
rel material:binding = </Looks/Material_3>
double radius = 0.5
}
def Sphere "collision" (
prepend apiSchemas = ["PhysicsCollisionAPI"]
)
{
Expand Down Expand Up @@ -201,7 +231,14 @@ def Xform "capsule"
double3 xformOp:translate = (0, 0, 0)
uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateZYX"]

def Capsule "geometry" (
def Capsule "geometry"
{
float3[] extent = [(-0.2, -0.2, -0.5), (0.2, 0.2, 0.5)]
double height = 0.6
rel material:binding = </Looks/Material_4>
double radius = 0.2
}
def Capsule "collision" (
prepend apiSchemas = ["PhysicsCollisionAPI"]
)
{
Expand Down Expand Up @@ -237,7 +274,15 @@ def Xform "ellipsoid"
double3 xformOp:translate = (0, 0, 0)
uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ"]

def Sphere "geometry" (
def Sphere "geometry"
{
float3[] extent = [(-0.5, -0.5, -0.5), (0.5, 0.5, 0.5)]
rel material:binding = </Looks/Material_5>
double radius = 0.5
float3 xformOp:scale = (0.4, 0.6, 1)
uniform token[] xformOpOrder = ["xformOp:scale"]
}
def Sphere "collision" (
prepend apiSchemas = ["PhysicsCollisionAPI"]
)
{
Expand Down
3 changes: 3 additions & 0 deletions usd/include/sdf/usd/UsdError.hh
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ namespace sdf

/// \brief Parsing of USD object to a SDF object failed.
USD_TO_SDF_PARSING_ERROR,

/// \brief Parsing of USD polygin object to a SDF object failed.
USD_TO_SDF_POLYGON_PARSING_ERROR,
};

class IGNITION_SDFORMAT_USD_VISIBLE UsdError
Expand Down
5 changes: 4 additions & 1 deletion usd/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ set(sources
sdf_parser/Visual.cc
sdf_parser/World.cc
usd_parser/Parser.cc
usd_parser/polygon_helper.cc
usd_parser/USD2SDF.cc
usd_parser/USDData.cc
usd_parser/USDLights.cc
Expand Down Expand Up @@ -69,7 +70,9 @@ ign_build_tests(

if (TARGET UNIT_USDLinks_TEST)
target_sources(UNIT_USDLinks_TEST PRIVATE
usd_parser/USDLinks.cc)
usd_parser/USDLinks.cc
Conversions.cc
usd_parser/polygon_helper.cc)
endif()

if (TARGET UNIT_USDPhysics_TEST)
Expand Down
Loading

0 comments on commit a0b022d

Please sign in to comment.