Skip to content

Commit

Permalink
create world prim and add physics information
Browse files Browse the repository at this point in the history
Signed-off-by: Ashton Larkin <[email protected]>
  • Loading branch information
adlarkin committed Jan 10, 2022
1 parent fa4568b commit 18f3ac1
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion usd/src/World.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@
#include <string>

#include <pxr/base/gf/vec3f.h>
#include <pxr/usd/sdf/path.h>
#include <pxr/usd/usd/prim.h>
#include <pxr/usd/usd/stage.h>
#include <pxr/usd/usdGeom/tokens.h>
#include <pxr/usd/usdPhysics/scene.h>

#include "sdf/World.hh"

namespace usd
{
Expand All @@ -35,8 +40,20 @@ namespace usd
_stage->SetStartTimeCode(0);
_stage->SetTimeCodesPerSecond(24);

const pxr::SdfPath worldPrimPath(_path);
auto usdWorldPrim = _stage->DefinePrim(worldPrimPath);

auto usdPhysics = pxr::UsdPhysicsScene::Define(_stage,
pxr::SdfPath(_path + "/physics"));
const auto &sdfWorldGravity = _world.Gravity();
const auto normalizedGravity = sdfWorldGravity.Normalized();
usdPhysics.CreateGravityDirectionAttr().Set(pxr::GfVec3f(
normalizedGravity.X(), normalizedGravity.Y(), normalizedGravity.Z()));
usdPhysics.CreateGravityMagnitudeAttr().Set(
static_cast<float>(sdfWorldGravity.Length()));

// TODO(ahcorde) Add parser
std::cerr << "Parser is not yet implemented" << '\n';
std::cerr << "Parser for a sdf world is not yet implemented\n";

return true;
}
Expand Down

0 comments on commit 18f3ac1

Please sign in to comment.