├── .gitattributes
├── .gitignore
├── Animation
├── GetCurrentTimeCode.py
├── GetTimeCode.py
├── SkeletonSkin.md
├── SkeletonSkin.py
├── SkeletonSkinBlendShape.py
├── SkeletonSkinPose.md
├── SkeletonSkinPose.py
├── TransformAnimation.py
├── UsdTimeCode.md
├── images
│ ├── skelAnimation_01.png
│ ├── skelAnimation_02.jpg
│ ├── skelAnimation_03.png
│ ├── skeleton_skin_01.png
│ ├── skeleton_structure.jpg
│ └── skeleton_structure_02.jpg
└── readme.md
├── AssetConverter
├── importObjToUSD.py
├── readme.md
└── simple_obj
│ ├── simple_obj.mtl
│ ├── simple_obj.obj
│ └── textures
│ ├── txt_001_diff.png
│ └── txt_002_diff.png
├── Audio
├── PlaySound.py
├── audio
│ └── HitWall.ogg
└── readme.md
├── Camera
├── CalcPanoramaCameraVector.py
├── CreateCamera.py
├── GetCurrentCamera.py
└── readme.md
├── Event
├── UpdateInterval.py
└── readme.md
├── Extensions
├── ft_lab.sample.callDLL
│ ├── bin
│ │ └── win
│ │ │ └── x64
│ │ │ └── OmniverseSimpleDLL.dll
│ ├── build
│ │ └── OmniverseSimpleDLL
│ │ │ ├── OmniverseSimpleDLL.sln
│ │ │ └── OmniverseSimpleDLL
│ │ │ ├── OmniverseSimpleDLL.vcxproj
│ │ │ ├── OmniverseSimpleDLL.vcxproj.filters
│ │ │ └── sources
│ │ │ └── dllmain.cpp
│ ├── config
│ │ └── extension.toml
│ ├── data
│ │ ├── icon.png
│ │ └── preview.png
│ ├── docs
│ │ ├── CHANGELOG.md
│ │ ├── README.md
│ │ └── index.rst
│ ├── ft_lab
│ │ └── sample
│ │ │ └── callDLL
│ │ │ ├── __init__.py
│ │ │ └── callDLL.py
│ └── readme.md
├── ft_lab.sample.hello
│ ├── config
│ │ └── extension.toml
│ ├── data
│ │ ├── icon.png
│ │ └── preview.png
│ ├── docs
│ │ ├── CHANGELOG.md
│ │ ├── README.md
│ │ └── index.rst
│ ├── ft_lab
│ │ └── sample
│ │ │ └── hello
│ │ │ ├── __init__.py
│ │ │ └── hello.py
│ └── readme.md
├── ft_lab.sample.loadStage
│ ├── config
│ │ └── extension.toml
│ ├── data
│ │ ├── icon.png
│ │ └── preview.png
│ ├── docs
│ │ ├── CHANGELOG.md
│ │ ├── README.md
│ │ └── index.rst
│ ├── ft_lab
│ │ └── sample
│ │ │ └── loadStage
│ │ │ ├── __init__.py
│ │ │ ├── main.py
│ │ │ └── usd
│ │ │ └── test.usd
│ └── readme.md
├── ft_lab.sample.menu
│ ├── config
│ │ └── extension.toml
│ ├── data
│ │ ├── icon.png
│ │ └── preview.png
│ ├── docs
│ │ ├── CHANGELOG.md
│ │ ├── README.md
│ │ └── index.rst
│ ├── ft_lab
│ │ └── sample
│ │ │ └── menu
│ │ │ ├── __init__.py
│ │ │ └── main.py
│ └── readme.md
├── ft_lab.sample.uiScene
│ ├── config
│ │ └── extension.toml
│ ├── data
│ │ ├── icon.png
│ │ └── preview.png
│ ├── docs
│ │ ├── CHANGELOG.md
│ │ ├── README.md
│ │ └── index.rst
│ └── ft_lab
│ │ └── sample
│ │ └── uiScene
│ │ ├── __init__.py
│ │ └── extension.py
├── ft_lab.sample.uiSceneDraw
│ ├── config
│ │ └── extension.toml
│ ├── data
│ │ ├── icon.png
│ │ └── preview.png
│ ├── docs
│ │ ├── CHANGELOG.md
│ │ ├── README.md
│ │ └── index.rst
│ └── ft_lab
│ │ └── sample
│ │ └── uiSceneDraw
│ │ ├── __init__.py
│ │ └── main.py
├── ft_lab.sample.uiSceneShowPrimName
│ ├── config
│ │ └── extension.toml
│ ├── data
│ │ ├── icon.png
│ │ └── preview.png
│ ├── docs
│ │ ├── CHANGELOG.md
│ │ ├── README.md
│ │ └── index.rst
│ └── ft_lab
│ │ └── sample
│ │ └── uiSceneShowPrimName
│ │ ├── __init__.py
│ │ └── extension.py
├── ft_lab.sample.uiSceneViewportOverlay
│ ├── config
│ │ └── extension.toml
│ ├── data
│ │ ├── icon.png
│ │ └── preview.png
│ ├── docs
│ │ ├── CHANGELOG.md
│ │ ├── README.md
│ │ └── index.rst
│ └── ft_lab
│ │ └── sample
│ │ └── uiSceneViewportOverlay
│ │ ├── __init__.py
│ │ └── extension.py
├── ft_lab.sample.widgets
│ ├── config
│ │ └── extension.toml
│ ├── data
│ │ ├── icon.png
│ │ └── preview.png
│ ├── docs
│ │ ├── CHANGELOG.md
│ │ ├── README.md
│ │ └── index.rst
│ └── ft_lab
│ │ └── sample
│ │ └── widgets
│ │ ├── __init__.py
│ │ ├── extension.py
│ │ └── images
│ │ ├── radio_off.svg
│ │ ├── radio_on.svg
│ │ └── radio_on_off.afdesign
├── ft_lab.sample.widgets_progressBar
│ ├── config
│ │ └── extension.toml
│ ├── data
│ │ ├── icon.png
│ │ └── preview.png
│ ├── docs
│ │ ├── CHANGELOG.md
│ │ ├── README.md
│ │ └── index.rst
│ └── ft_lab
│ │ └── sample
│ │ └── widgets_progressBar
│ │ ├── __init__.py
│ │ ├── extension.py
│ │ └── images
│ │ ├── radio_off.svg
│ │ ├── radio_on.svg
│ │ └── radio_on_off.afdesign
├── images
│ ├── extension_cap_01.jpg
│ ├── extension_cap_02.jpg
│ ├── extension_menu_00.png
│ ├── extension_menu_01.png
│ ├── extension_widgets_01.png
│ ├── extension_widgets_progressBar.png
│ ├── omniverse_code_extension_uiScene.png
│ ├── omniverse_code_extension_uiSceneDraw.png
│ ├── omniverse_code_extension_uiSceneShowPrimName.jpg
│ └── omniverse_code_extension_uiSceneViewportOverlay.jpg
├── knowledge
│ └── config_info.md
└── readme.md
├── Geometry
├── CreateCube
│ ├── CreateCube.py
│ ├── images
│ │ └── createCube.jpg
│ └── readme.md
├── CreateMesh
│ ├── CreateGear.py
│ ├── CreateMeshInterpolation.py
│ ├── CreateSimpleMesh.py
│ ├── CreateSimpleMeshWithSubset.py
│ ├── GetMeshInfo.py
│ ├── images
│ │ ├── createGear.jpg
│ │ └── createMesh.jpg
│ └── readme.md
├── CreateSphere
│ ├── CReateSphereWithRefinement.py
│ ├── CreateSphere.py
│ ├── GetSphereInfo.py
│ ├── images
│ │ ├── createSphere2_img.jpg
│ │ └── createSphere_img.jpg
│ └── readme.md
├── GetMeshPrimvars.py
├── SetMeshPrimvars.py
└── readme.md
├── Light
├── CheckLightPrim.py
├── CreateLight.py
├── CreateSphereLight.py
└── readme.md
├── Material
├── GetMaterial
│ ├── GetMaterial.py
│ ├── GetMaterialInputs.py
│ ├── GetMaterialTexturePath.py
│ ├── GetMaterialType.py
│ └── readme.md
├── OmniPBR
│ ├── CreateMaterial.py
│ ├── CreateMaterialWithCommand.py
│ ├── CreateMaterialWithDiffuseNormalTexture.py
│ ├── CreateMaterialWithDiffuseTexture.py
│ ├── images
│ │ ├── CreateMaterial.jpg
│ │ ├── CreateMaterialWithDiffuseNormalTexture.jpg
│ │ └── CreateMaterialWithDiffuseTexture.jpg
│ └── readme.md
├── UnbindMaterial.py
├── UsdPreviewSurface
│ ├── CreateMaterial.py
│ ├── CreateMaterialWithDiffuseNormalTexture.py
│ ├── CreateMaterialWithDiffuseTexture.py
│ ├── images
│ │ ├── CreateMaterial.jpg
│ │ ├── CreateMaterialWithDiffuseNormalTexture.jpg
│ │ └── CreateMaterialWithDiffuseTexture.jpg
│ └── readme.md
├── readme.md
└── textures
│ ├── stone_01_diffuse.png
│ ├── stone_01_normal.png
│ └── tile_image.png
├── Math
├── CalcDotCrossProduct.py
├── CalcMatrix.py
├── CalcVector3.py
├── ConvRGB2SRGB.py
├── DecomposeTransform.py
├── DecomposeTransform2.py
├── GetVector3Length.py
├── NormalizeVector3.py
├── QuatToRotation.py
├── TransRotationFrom2Vec.py
├── VectorToRotationAngle.py
└── readme.md
├── Nucleus
├── FileCopy.py
├── ReadImageFile.py
├── createFolder.py
├── deleteFile.py
├── existPath.py
├── listFiles.py
└── readme.md
├── Operation
├── CommandsExecute
│ ├── CopyPrim.py
│ ├── DeletePrims.py
│ ├── GetCommandsList.py
│ ├── MovePrim.py
│ ├── RenamePrim.py
│ ├── SelectNone.py
│ └── readme.md
├── FocusPrim.py
├── GamePad
│ ├── GamePad.py
│ ├── GamePad_moveSelectPrim.py
│ ├── images
│ │ └── gamepad_image_01.jpg
│ └── readme.md
├── Keyboard
│ ├── InputKeyboard.py
│ ├── InputKeyboard_ShowViewport.py
│ └── readme.md
├── Selection
│ ├── EventSelection.py
│ ├── EventSelection_showFacesCount.py
│ ├── GetSelection.py
│ ├── IsSelected.py
│ ├── Select.py
│ ├── images
│ │ └── EventSelection_showFacesCount.jpg
│ └── readme.md
├── UNDO
│ ├── CreateSphereUndo.py
│ ├── readme.md
│ └── simpleClassUndo.py
└── readme.md
├── PLATEAU
├── calcDistance.py
├── calcDistanceWithLatLong.py
├── calcLatLongToOmniverse.py
├── divide_GeoTiff_images.py
├── images
│ ├── plateau_01_01.jpg
│ ├── plateau_01_02.jpg
│ ├── plateau_02_01.jpg
│ ├── plateau_02_02.jpg
│ ├── plateau_03_00.jpg
│ ├── plateau_03_01.jpg
│ ├── plateau_03_02.jpg
│ ├── plateau_04_01.jpg
│ ├── plateau_calc_dist_01.jpg
│ ├── plateau_calc_lat_longi_01.jpg
│ ├── plateau_calc_lat_longi_02.jpg
│ ├── plateau_collectAsset_01.png
│ └── plateau_collectAsset_02.png
├── import_PLATEAU_tokyo23ku_obj.py
└── readme.md
├── Physics
├── Gear
│ └── gear_01.py
├── Joint
│ ├── simpleJoint01.py
│ └── simpleJoint02.py
├── RayCast.py
├── RigidBody
│ ├── rigidBody_01.py
│ └── rigidbody_benchmark.py
├── images
│ ├── physics_gears_01.jpg
│ ├── physics_joint_01.jpg
│ ├── physics_joint_02.jpg
│ ├── physics_raycast_01.jpg
│ ├── physics_rigidbody_00.jpg
│ ├── physics_rigidbody_01.jpg
│ └── physics_settings.jpg
└── readme.md
├── PostProcessing
├── ChangePostProcessing.py
├── images
│ └── postprocessing_01.png
└── readme.md
├── Prim
├── CalcWorldBoundingBox.py
├── CreateScope.py
├── CreateXform.py
├── GetChildren.py
├── GetDefaultPrim.py
├── GetDoubleSided.py
├── GetParent.py
├── GetPrimNamePath.py
├── GetSingleSided.py
├── IsValid.py
├── Kind
│ ├── GetKind.py
│ ├── SetComponent.py
│ └── readme.md
├── PointInstancer
│ ├── PointInstancer_01.py
│ ├── images
│ │ └── usd_pointinstancer_01.jpg
│ ├── readme.md
│ └── usd
│ │ └── simpleTree.usda
├── Reference
│ ├── GetReferencePayload.py
│ ├── HasPayload.py
│ ├── HasReference.py
│ ├── InternalReferenceTest.py
│ ├── PayloadTest.py
│ ├── ReferenceTest.py
│ ├── ReferenceTest2.py
│ ├── images
│ │ ├── usd_prim_reference_00.jpg
│ │ ├── usd_prim_reference_01.jpg
│ │ ├── usd_prim_reference_02.jpg
│ │ └── usd_reference_payload.png
│ ├── readme.md
│ └── usd
│ │ ├── cyawan
│ │ ├── cyawan.usdc
│ │ ├── cyawan_mat_albedo.png
│ │ ├── cyawan_mat_normal.png
│ │ ├── cyawan_mat_occlusion.png
│ │ └── cyawan_mat_roughness.png
│ │ ├── simple_chair.usda
│ │ └── sphere.usda
├── RemovePrim.py
├── RenamePrim.py
├── SetDefaultPrim.py
├── Skeleton
│ ├── GetJoints.py
│ ├── GetSkeletonTransforms.py
│ └── readme.md
├── Transform
│ ├── DeletePivot.py
│ ├── GetLocalMatrix.py
│ ├── GetTransform.py
│ ├── GetTransformOrder.py
│ ├── GetTransformVectors.py
│ ├── GetWorldTransform.py
│ ├── SetPivot.py
│ ├── SetRotate.py
│ ├── SetRotateWithQuat.py
│ ├── SetScale.py
│ ├── SetTransform.py
│ ├── SetTranslate.py
│ ├── images
│ │ └── SetTransform.jpg
│ └── readme.md
├── TypeName
│ ├── GetTypeName.py
│ └── readme.md
├── Variant
│ ├── Variant_01.py
│ ├── images
│ │ └── prim_variant_01.jpg
│ └── readme.md
├── Visibility
│ ├── GetShowHidePrim.py
│ ├── ShowHidePrim.py
│ └── readme.md
└── readme.md
├── Python
├── Class
│ ├── SimpleClass.py
│ └── readme.md
├── Web
│ ├── WebOpen.py
│ └── readme.md
├── readme.md
└── string
│ ├── NumToStr.py
│ ├── StringTest.py
│ └── readme.md
├── Rendering
├── Capture
│ ├── CaptureCameraRenderingColorToBuffer.py
│ ├── CaptureRenderingColorToBuffer.py
│ ├── CaptureRenderingColorToFile.py
│ ├── CaptureRenderingDepth.py
│ ├── images
│ │ └── capture_SyntheticDataSensor_1.jpg
│ └── readme.md
└── readme.md
├── Samples
├── CreateSimpleCurve
│ ├── CreateSimpleCurve.py
│ ├── images
│ │ ├── createSimpleCurve_01.jpg
│ │ ├── createSimpleCurve_02.png
│ │ ├── createSimpleCurve_03.png
│ │ └── createSimpleCurve_04.png
│ └── readme.md
├── FlipMeshNormals
│ └── FlipMeshNormals.py
├── UnitsToCentimeters
│ ├── UnitsToCentimeters.py
│ └── readme.md
└── readme.md
├── Scene
├── CloseStage.py
├── CreateHierarchy.py
├── GetAllFacesCount.py
├── GetMetersPerUnit.py
├── GetResolvedPath.py
├── Layers
│ ├── GetRealPath.py
│ └── GetSublayers.py
├── NewStage.py
├── OpenUSDFile.py
├── StageUpAxis.py
├── TraverseHierarchy.py
├── Traverse_mesh.py
├── images
│ └── createHierarchy_img.jpg
└── readme.md
├── Settings
├── GetKitPath.py
├── GetKitVersion.py
├── GetRenderMode.py
├── GetRenderingSize.py
└── readme.md
├── System
├── GetPythonVersion.py
├── GetSysPath.py
├── GetUSDVersion.py
└── readme.md
├── UI
├── DebugDraw
│ ├── UseDebugDraw.py
│ ├── images
│ │ └── debugDraw_line_01.png
│ └── readme.md
├── DragAndDrop
│ ├── dropTest.py
│ ├── images
│ │ └── dropTest.png
│ └── readme.md
├── DrawImage
│ ├── drawImage.py
│ ├── drawImageWithPIL.py
│ ├── images
│ │ ├── ui_draw_image_00.png
│ │ └── ui_draw_image_01.png
│ └── readme.md
├── Viewport
│ ├── DrawRandomRect.py
│ ├── DrawText.py
│ ├── DrawText2.py
│ ├── GetActiveViewportInfo.py
│ ├── GetViewportRect.py
│ ├── UpdateDrawImage.py
│ ├── UpdateText.py
│ ├── UpdateText2.py
│ ├── WorldToScreen.py
│ ├── images
│ │ ├── DisplayText.png
│ │ ├── DisplayText2.png
│ │ ├── DrawPrimName.png
│ │ ├── DrawRandomRect.png
│ │ ├── UpdateText.png
│ │ ├── UpdateText2.png
│ │ ├── viewport_104_01.jpg
│ │ ├── viewport_104_02.jpg
│ │ └── viewport_104_03.jpg
│ └── readme.md
├── Window
│ ├── CreateNewWindow.py
│ ├── FileDialog.py
│ ├── ImageWindow.py
│ ├── InputField.py
│ ├── images
│ │ ├── CreateNewWindow.png
│ │ ├── ImageWindow.png
│ │ └── InputField.png
│ └── readme.md
└── readme.md
├── images
└── omniverse_script_editor_01.png
├── knowledge
├── dev_info.md
├── dev_method.md
├── dev_usd.md
└── images
│ ├── knowledge_dev_info_01.png
│ ├── knowledge_dev_info_02.png
│ ├── knowledge_dev_info_03.jpg
│ ├── knowledge_dev_info_04.png
│ ├── knowledge_dev_method_01.png
│ └── knowledge_dev_usd_01.png
├── pip_archive
├── PIL
│ ├── DrawImage.py
│ ├── LoadImage.py
│ └── readme.md
├── numpy
│ ├── CalcMultiplyMatrix.py
│ ├── CalcMultiplyMatrixVector.py
│ ├── CalcVector.py
│ ├── CalcVectorDotCross.py
│ ├── CalcVectorLength.py
│ ├── CreateMatrix.py
│ └── readme.md
└── readme.md
└── readme.md
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Mac OS X
3 | *.DS_Store
4 |
5 | # VSCode
6 | .vscode
7 |
8 | # Affinity Photo
9 | *.afphoto
10 |
11 | # Others
12 | InternalExtensions/*
13 |
--------------------------------------------------------------------------------
/Animation/GetCurrentTimeCode.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 | import omni.usd
3 | import omni.timeline
4 |
5 | # Get stage.
6 | stage = omni.usd.get_context().get_stage()
7 |
8 | # Get current timeCode.
9 | time_code = omni.timeline.get_timeline_interface().get_current_time() * stage.GetTimeCodesPerSecond()
10 |
11 | print(f"Current timeCode : {time_code}")
12 |
--------------------------------------------------------------------------------
/Animation/GetTimeCode.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get TimeCode.
7 | print(f"Start TimeCode : {stage.GetStartTimeCode()}")
8 | print(f"End TimeCode : {stage.GetEndTimeCode()}")
9 |
10 | # Get frame rate.
11 | print(f"TimeCodesPerSecond : {stage.GetTimeCodesPerSecond()}")
12 |
13 |
--------------------------------------------------------------------------------
/Animation/UsdTimeCode.md:
--------------------------------------------------------------------------------
1 | # Usd.TimeCode(value)とUsd.TimeCode.Default()の違い
2 |
3 | キーフレームを割り当てる場合は以下のように指定します。
4 |
5 | ```python
6 | primPath = "/World/sphere"
7 | prim = createSphere(primPath, 20.0)
8 |
9 | # Set Keyframe.
10 | xformAPI = UsdGeom.XformCommonAPI(prim)
11 | xformAPI.SetTranslate(Gf.Vec3d(0, 0, 0), Usd.TimeCode(0))
12 | xformAPI.SetTranslate(Gf.Vec3d(0, 100, 0), Usd.TimeCode(50))
13 | ```
14 | SetTranslateの第二引数がキーフレーム位置となります。
15 |
16 | この場合、usdaファイルでは以下のようになっています。
17 | ```
18 | double3[] xformOp:translate.timeSamples = {
19 | 0: [(0, 0, 0)],
20 | 50: [(0, 100, 0)],
21 | }
22 | ```
23 | "xformOp:translate.timeSamples"となっています。
24 |
25 | 一方、このUsd.TimeCode(v)を省略した場合は **Usd.TimeCode.Default()** が指定されたことになります。
26 |
27 | ```python
28 | xformAPI.SetTranslate(Gf.Vec3d(0, 0, 0))
29 | ```
30 | もしくは、
31 | ```python
32 | xformAPI.SetTranslate(Gf.Vec3d(0, 0, 0), Usd.TimeCode.Default())
33 | ```
34 |
35 | この場合、usdaファイルでは以下のようになっています。
36 | ```
37 | double3 xformOp:translate = (0, 0, 0)
38 | ```
39 | "xformOp:translate"となっています。
40 | この"TimeCode.Default()"を使用した場合は対象primそのものが持つtransform要素の指定になります(アニメーションをPlayしないときの姿勢)。
41 |
42 |
43 |
--------------------------------------------------------------------------------
/Animation/images/skelAnimation_01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Animation/images/skelAnimation_01.png
--------------------------------------------------------------------------------
/Animation/images/skelAnimation_02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Animation/images/skelAnimation_02.jpg
--------------------------------------------------------------------------------
/Animation/images/skelAnimation_03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Animation/images/skelAnimation_03.png
--------------------------------------------------------------------------------
/Animation/images/skeleton_skin_01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Animation/images/skeleton_skin_01.png
--------------------------------------------------------------------------------
/Animation/images/skeleton_structure.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Animation/images/skeleton_structure.jpg
--------------------------------------------------------------------------------
/Animation/images/skeleton_structure_02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Animation/images/skeleton_structure_02.jpg
--------------------------------------------------------------------------------
/Animation/readme.md:
--------------------------------------------------------------------------------
1 | # Animation
2 |
3 | アニメーション関連の処理を行います。
4 |
5 | USDのアニメーションは、それぞれの要素にキーフレームを登録することでタイムラインに沿った動きを与えます。
6 | アニメーションを割り当てることができる要素は以下のようなものがあります。
7 |
8 | * Transform : Primごとの変換のTralslate, Rotate, Scale
9 | * Skeleton
10 | * ボーン (USDではJoint)ごとのTralslate, Rotate, Scale
11 | * BlendShape
12 |
13 | Skeletonを使う場合は、Meshに対してスキンを割り当てます。スキンはJointとMeshの頂点をつなぐ役割をします。
14 | BlendShapeはMeshの頂点をグループ化し複数の移動量を持つShape Keyを与えます。
15 | このキーをモーション時にスムーズに変形させることにより動きを表現します。
16 | BlendShapeは人の顔の表情のような、ボーンでの変形が難しい動きに向いています。
17 |
18 | |ファイル|説明|
19 | |---|---|
20 | |[GetTimeCode.py](./GetTimeCode.py)|現在のStageの開始/終了TimeCode、TimeCodesPerSecond(フレームレート)を取得。|
21 | |[GetCurrentTimeCode.py](./GetCurrentTimeCode.py)|現在のタイムコード(フレーム位置)を取得。|
22 | |[TransformAnimation.py](./TransformAnimation.py)|Translate, Rotate, Scaleのキーフレーム指定|
23 | |[SkeletonSkin.py](./SkeletonSkin.py)|MeshへのSkeleton、Skinの割り当て|
24 | |[SkeletonSkinBlendShape.py](./SkeletonSkinBlendShape.py)|MeshへのBlendShapeの割り当て|
25 | |[SkeletonSkinPose.py](./SkeletonSkinPose.py)|SkelAnimation : Skeletonのポーズを指定|
26 |
27 |
28 | ## Tips
29 |
30 | * [Usd.TimeCode(value)とUsd.TimeCode.Default()の違い](./UsdTimeCode.md)
31 | * [スケルトンの構造とスキン](./SkeletonSkin.md)
32 | * [SkelAnimationでポーズを与える](./SkeletonSkinPose.md)
33 |
34 |
35 |
--------------------------------------------------------------------------------
/AssetConverter/readme.md:
--------------------------------------------------------------------------------
1 | # Asset Converter
2 |
3 | obj/fbx/glTFなどのファイルをUSDにコンバートします。
4 |
5 | |ファイル|説明|
6 | |---|---|
7 | |[importObjToUSD.py](./importObjToUSD.py)|指定のobjファイルをUSDファイルにコンバートします。
「[simple_obj.obj](./simple_obj/simple_obj.obj)」を入力のobjファイルの参考にしてくださいませ。|
8 |
9 |
--------------------------------------------------------------------------------
/AssetConverter/simple_obj/simple_obj.mtl:
--------------------------------------------------------------------------------
1 | # Shade3D - Wavefront OBJ Exporter
2 |
3 | newmtl mtl_default
4 | Kd 1.000000 1.000000 1.000000
5 | Ka 0.200000 0.200000 0.200000
6 | Ks 1.000000 1.000000 1.000000
7 | Ns 20.000000
8 | d 1.000000
9 | Ni 0.000000
10 | illum 2
11 |
12 | newmtl mat1
13 | Kd 1.000000 1.000000 1.000000
14 | Ka 1.000000 1.000000 1.000000
15 | Ks 1.000000 1.000000 1.000000
16 | Ns 20.000000
17 | d 1.000000
18 | Ni 1.000000
19 | illum 2
20 | map_Kd ./textures/txt_001_diff.png
21 |
22 | newmtl mat2
23 | Kd 1.000000 1.000000 1.000000
24 | Ka 1.000000 1.000000 1.000000
25 | Ks 1.000000 1.000000 1.000000
26 | Ns 20.000000
27 | d 1.000000
28 | Ni 1.000000
29 | illum 2
30 | map_Kd ./textures/txt_002_diff.png
31 |
32 |
--------------------------------------------------------------------------------
/AssetConverter/simple_obj/textures/txt_001_diff.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/AssetConverter/simple_obj/textures/txt_001_diff.png
--------------------------------------------------------------------------------
/AssetConverter/simple_obj/textures/txt_002_diff.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/AssetConverter/simple_obj/textures/txt_002_diff.png
--------------------------------------------------------------------------------
/Audio/audio/HitWall.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Audio/audio/HitWall.ogg
--------------------------------------------------------------------------------
/Audio/readme.md:
--------------------------------------------------------------------------------
1 | # Audio
2 |
3 | Audioファイルを読み込んで再生します。
4 | Audio自身はUSDでPrimとして指定することができます。
5 |
6 | UsdAudio Proposal
7 | https://graphics.pixar.com/usd/release/wp_usdaudio.html
8 |
9 |
10 | また、OmniverseでもUIとしてAudioのStageへのインポートができます。
11 |
12 | https://docs.omniverse.nvidia.com/app_create/prod_extensions/ext_audio.html
13 |
14 | Audioファイルフォーマットは、wav/ogg/mp3が再生できるのを確認しています。
15 |
16 | USDファイルにAudioを指定でき、この場合はTimelineの指定の位置での再生が可能です。
17 | Pythonスクリプトから任意のタイミングでの再生するにはExtensionの「omni.audioplayer」を使用します。
18 |
19 | Audioファイルは [HitWall.ogg](./audio/HitWall.ogg) をサンプルとしてアップしているため、
20 | スクリプトから検索できる位置に配置してご利用くださいませ。
21 |
22 | |ファイル|説明|
23 | |---|---|
24 | |[PlaySound.py](./PlaySound.py)|Audioファイルを読み込んで再生
"omni.audioplayer" ExtensionをOnにする必要があります。|
25 |
26 |
--------------------------------------------------------------------------------
/Camera/CreateCamera.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Create camera.
7 | pathName = '/World/camera'
8 | cameraGeom = UsdGeom.Camera.Define(stage, pathName)
9 |
10 | cameraGeom.CreateFocalLengthAttr(24.0)
11 | cameraGeom.CreateFocusDistanceAttr(400.0)
12 | cameraGeom.CreateFStopAttr(0.0)
13 | cameraGeom.CreateProjectionAttr('perspective')
14 |
15 | # Set position.
16 | UsdGeom.XformCommonAPI(cameraGeom).SetTranslate((0.0, 20.0, 40.0))
17 |
18 | # Set rotation.
19 | UsdGeom.XformCommonAPI(cameraGeom).SetRotate((-20, 15.0, 0.0), UsdGeom.XformCommonAPI.RotationOrderXYZ)
20 |
21 | # Set scale.
22 | UsdGeom.XformCommonAPI(cameraGeom).SetScale((1, 1, 1))
23 |
24 | # Change active camera.
25 | # Kit103 : changed from omni.kit.viewport to omni.kit.viewport_legacy
26 | #viewport = omni.kit.viewport_legacy.get_viewport_interface()
27 | #viewport.get_viewport_window().set_active_camera(pathName)
28 |
29 | # Kit104 : changed from omni.kit.viewport_legacy to omni.kit.viewport.utility.get_active_viewport_window
30 | import omni.kit.viewport.utility
31 |
32 | # Get active viewport window.
33 | active_vp_window = omni.kit.viewport.utility.get_active_viewport_window()
34 | viewport_api = active_vp_window.viewport_api
35 |
36 | viewport_api.set_active_camera(pathName)
37 |
38 |
39 |
--------------------------------------------------------------------------------
/Camera/readme.md:
--------------------------------------------------------------------------------
1 | # Camera
2 |
3 | カメラ操作を行います。
4 | カメラはUsdGeom.Camera ( https://graphics.pixar.com/usd/release/api/class_usd_geom_camera.html ) を使用します。
5 |
6 | Omniverse Kit.102では「omni.kit.viewport」を使っていましたが、kit.103では「omni.kit.viewport_legacy」となりました(とりあえずの変更)。
7 |
8 | kit.104では「omni.kit.viewport_legacy」は廃止になっています。
9 | ```python
10 | import omni.kit.viewport.utility
11 |
12 | # Get active viewport window.
13 | active_vp_window = omni.kit.viewport.utility.get_active_viewport_window()
14 | viewport_api = active_vp_window.viewport_api
15 |
16 | # Get camera path ("/OmniverseKit_Persp" etc).
17 | cameraPath = viewport_api.camera_path.pathString
18 | ```
19 | としてviewport_apiからカメラのPrimパスを取得します。
20 | kit.104は"Viewport 2.0"となっており、複数のViewportを持つことができます。
21 | そのため、アクティブなビューポートを"omni.kit.viewport.utility.get_active_viewport_window()"から取得してきています。
22 |
23 |
24 | ## サンプル
25 |
26 | Kit104以上で動作。
27 |
28 | |ファイル|説明|
29 | |---|---|
30 | |[CreateCamera.py](./CreateCamera.py)|カメラを作成|
31 | |[GetCurrentCamera.py](./GetCurrentCamera.py)|カレントのカメラを情報を取得|
32 | |[CalcPanoramaCameraVector.py](./CalcPanoramaCameraVector.py)|立体視用の2つのカメラを作成|
33 |
--------------------------------------------------------------------------------
/Event/readme.md:
--------------------------------------------------------------------------------
1 | # Event
2 |
3 | イベント処理を行います。
4 |
5 | ## 更新イベント
6 |
7 | 以下のように更新イベントを登録すると、コールバックとして更新処理が呼ばれます。
8 |
9 | ```python
10 | import omni.kit.app
11 | import carb.events
12 |
13 | def on_update(e: carb.events.IEvent):
14 | pass
15 |
16 | subs = omni.kit.app.get_app().get_update_event_stream().create_subscription_to_pop(on_update)
17 | ```
18 |
19 | ## サンプル
20 |
21 | |ファイル|説明|
22 | |---|---|
23 | |[UpdateInterval.py](./UpdateInterval.py)|update_event_streamの更新間隔をビューポートに表示|
24 |
25 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.callDLL/bin/win/x64/OmniverseSimpleDLL.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/ft_lab.sample.callDLL/bin/win/x64/OmniverseSimpleDLL.dll
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.callDLL/build/OmniverseSimpleDLL/OmniverseSimpleDLL.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.28307.1321
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OmniverseSimpleDLL", "OmniverseSimpleDLL\OmniverseSimpleDLL.vcxproj", "{188D7B27-333B-4F18-8482-A4858B2070BC}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {188D7B27-333B-4F18-8482-A4858B2070BC}.Debug|x64.ActiveCfg = Debug|x64
17 | {188D7B27-333B-4F18-8482-A4858B2070BC}.Debug|x64.Build.0 = Debug|x64
18 | {188D7B27-333B-4F18-8482-A4858B2070BC}.Debug|x86.ActiveCfg = Debug|Win32
19 | {188D7B27-333B-4F18-8482-A4858B2070BC}.Debug|x86.Build.0 = Debug|Win32
20 | {188D7B27-333B-4F18-8482-A4858B2070BC}.Release|x64.ActiveCfg = Release|x64
21 | {188D7B27-333B-4F18-8482-A4858B2070BC}.Release|x64.Build.0 = Release|x64
22 | {188D7B27-333B-4F18-8482-A4858B2070BC}.Release|x86.ActiveCfg = Release|Win32
23 | {188D7B27-333B-4F18-8482-A4858B2070BC}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {E0BAA2A5-1328-474C-831F-AA22D6B6CABC}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.callDLL/build/OmniverseSimpleDLL/OmniverseSimpleDLL/OmniverseSimpleDLL.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | ソース ファイル
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.callDLL/build/OmniverseSimpleDLL/OmniverseSimpleDLL/sources/dllmain.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include
3 | #include
4 |
5 | #define DLL_API extern "C" __declspec(dllexport)
6 |
7 | // ----------------------------------------------------------------.
8 | // DLLMain.
9 | // ----------------------------------------------------------------.
10 | BOOL APIENTRY DllMain( HMODULE hModule,
11 | DWORD ul_reason_for_call,
12 | LPVOID lpReserved
13 | )
14 | {
15 | switch (ul_reason_for_call)
16 | {
17 | case DLL_PROCESS_ATTACH:
18 | case DLL_THREAD_ATTACH:
19 | case DLL_THREAD_DETACH:
20 | case DLL_PROCESS_DETACH:
21 | break;
22 | }
23 | return TRUE;
24 | }
25 |
26 | // ----------------------------------------------------------------.
27 | // External functions.
28 | // ----------------------------------------------------------------.
29 | DLL_API int ext_add (int a, int b) {
30 | return a + b;
31 | }
32 |
33 | DLL_API int ext_sub (int a, int b) {
34 | return a - b;
35 | }
36 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.callDLL/data/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/ft_lab.sample.callDLL/data/icon.png
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.callDLL/data/preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/ft_lab.sample.callDLL/data/preview.png
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.callDLL/docs/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # CHANGELOG
2 |
3 | This document records all notable changes to ``ft_lab.sample.callDLL`` extension.
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.callDLL/docs/README.md:
--------------------------------------------------------------------------------
1 | # Calling function from dll [ft_lab.sample.callDLL]
2 |
3 | This is sample of calling function from dll using Python's LoadLibrary.
4 |
5 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.callDLL/docs/index.rst:
--------------------------------------------------------------------------------
1 | ft_lab.sample.callDLL
2 | ###########################
3 |
4 | .. toctree::
5 | :maxdepth: 1
6 |
7 | README
8 | CHANGELOG
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.callDLL/ft_lab/sample/callDLL/__init__.py:
--------------------------------------------------------------------------------
1 | from .callDLL import *
2 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.callDLL/ft_lab/sample/callDLL/callDLL.py:
--------------------------------------------------------------------------------
1 | import omni.ext
2 |
3 | from ctypes import *
4 |
5 | # Load library.
6 | # Add the search path for [[native.library]] to "config/extension.toml".
7 | dll = cdll.LoadLibrary(r"OmniverseSimpleDLL.dll")
8 |
9 | # ----------------------------------------------------.
10 | # Call external function.
11 | # ----------------------------------------------------.
12 | def callExtFunc():
13 | if dll == None:
14 | return
15 |
16 | v = dll.ext_add(3, 8)
17 | print("dll.ext_add(3, 8) : " + str(v))
18 |
19 | v2 = dll.ext_sub(3, 8)
20 | print("dll.ext_sub(3, 8) : " + str(v2))
21 |
22 | # ----------------------------------------------------.
23 | class CallDLLExtension(omni.ext.IExt):
24 | def on_startup(self, ext_id):
25 | print("[ft_lab.sample.callDLL] HelloExtension startup")
26 | callExtFunc()
27 |
28 | def on_shutdown(self):
29 | print("[ft_lab.sample.callDLL] HelloExtension shutdown")
30 |
31 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.hello/config/extension.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | # Semantic Versionning is used: https://semver.org/
3 | version = "0.0.1"
4 |
5 | # Lists people or organizations that are considered the "authors" of the package.
6 | authors = ["ft-lab"]
7 |
8 | # The title and description fields are primarily for displaying extension info in UI
9 | title = "Python Extension Example"
10 | description="Very simple extension."
11 |
12 | # Path (relative to the root) or content of readme markdown file for UI.
13 | readme = "docs/README.md"
14 |
15 | # URL of the extension source repository.
16 | repository = ""
17 |
18 | # One of categories for UI.
19 | category = "Example"
20 |
21 | # Keywords for the extension
22 | keywords = ["kit", "example"]
23 |
24 | # Location of change log file in target (final) folder of extension, relative to the root. Can also be just a content
25 | # of it instead of file path. More info on writing changelog: https://keepachangelog.com/en/1.0.0/
26 | changelog="docs/CHANGELOG.md"
27 |
28 | # Preview image and icon. Folder named "data" automatically goes in git lfs (see .gitattributes file).
29 | # Preview image is shown in "Overview" of Extensions window. Screenshot of an extension might be a good preview image.
30 | preview_image = "data/preview.png"
31 |
32 | # Icon is shown in Extensions window, it is recommended to be square, of size 256x256.
33 | icon = "data/icon.png"
34 |
35 | # We only depend on testing framework currently:
36 | [dependencies]
37 |
38 | # Main python module this extension provides.
39 | [[python.module]]
40 | name = "ft_lab.sample.hello"
41 |
42 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.hello/data/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/ft_lab.sample.hello/data/icon.png
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.hello/data/preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/ft_lab.sample.hello/data/preview.png
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.hello/docs/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # CHANGELOG
2 |
3 | This document records all notable changes to ``ft_lab.sample.hello`` extension.
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.hello/docs/README.md:
--------------------------------------------------------------------------------
1 | # Python Extension Example [ft_lab.sample.hello]
2 |
3 | sample extension.
4 |
5 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.hello/docs/index.rst:
--------------------------------------------------------------------------------
1 | ft_lab.sample.hello
2 | ###########################
3 |
4 | .. toctree::
5 | :maxdepth: 1
6 |
7 | README
8 | CHANGELOG
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.hello/ft_lab/sample/hello/__init__.py:
--------------------------------------------------------------------------------
1 | from .hello import *
2 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.hello/ft_lab/sample/hello/hello.py:
--------------------------------------------------------------------------------
1 | import omni.ext
2 |
3 |
4 | # Any class derived from `omni.ext.IExt` in top level module (defined in `python.modules` of `extension.toml`) will be
5 | # instantiated when extension gets enabled and `on_startup(ext_id)` will be called. Later when extension gets disabled
6 | # on_shutdown() is called.
7 | class HelloExtension(omni.ext.IExt):
8 | # ext_id is current extension id. It can be used with extension manager to query additional information, like where
9 | # this extension is located on filesystem.
10 | def on_startup(self, ext_id):
11 | print("[ft_lab.sample.hello] HelloExtension startup")
12 |
13 | def on_shutdown(self):
14 | print("[ft_lab.sample.hello] HelloExtension shutdown")
15 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.loadStage/config/extension.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | # Semantic Versionning is used: https://semver.org/
3 | version = "0.0.1"
4 |
5 | # Lists people or organizations that are considered the "authors" of the package.
6 | authors = ["ft-lab"]
7 |
8 | # The title and description fields are primarily for displaying extension info in UI
9 | title = "Load Stage"
10 | description="Sample of opening usd."
11 |
12 | # Path (relative to the root) or content of readme markdown file for UI.
13 | readme = "docs/README.md"
14 |
15 | # URL of the extension source repository.
16 | repository = ""
17 |
18 | # One of categories for UI.
19 | category = "Example"
20 |
21 | # Keywords for the extension
22 | keywords = ["kit", "example"]
23 |
24 | # Location of change log file in target (final) folder of extension, relative to the root. Can also be just a content
25 | # of it instead of file path. More info on writing changelog: https://keepachangelog.com/en/1.0.0/
26 | changelog="docs/CHANGELOG.md"
27 |
28 | # Preview image and icon. Folder named "data" automatically goes in git lfs (see .gitattributes file).
29 | # Preview image is shown in "Overview" of Extensions window. Screenshot of an extension might be a good preview image.
30 | preview_image = "data/preview.png"
31 |
32 | # Icon is shown in Extensions window, it is recommended to be square, of size 256x256.
33 | icon = "data/icon.png"
34 |
35 | # We only depend on testing framework currently:
36 | [dependencies]
37 |
38 | # Main python module this extension provides.
39 | [[python.module]]
40 | name = "ft_lab.sample.loadStage"
41 |
42 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.loadStage/data/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/ft_lab.sample.loadStage/data/icon.png
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.loadStage/data/preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/ft_lab.sample.loadStage/data/preview.png
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.loadStage/docs/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # CHANGELOG
2 |
3 | This document records all notable changes to ``ft_lab.sample.loadStage`` extension.
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.loadStage/docs/README.md:
--------------------------------------------------------------------------------
1 | # Python Extension Example [ft_lab.sample.loadStage]
2 |
3 | sample extension.
4 |
5 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.loadStage/docs/index.rst:
--------------------------------------------------------------------------------
1 | ft_lab.sample.loadStage
2 | ###########################
3 |
4 | .. toctree::
5 | :maxdepth: 1
6 |
7 | README
8 | CHANGELOG
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.loadStage/ft_lab/sample/loadStage/__init__.py:
--------------------------------------------------------------------------------
1 | from .main import *
2 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.loadStage/ft_lab/sample/loadStage/main.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdShade, Sdf, Gf, Tf
2 | import omni.ext
3 | from pathlib import Path
4 |
5 | class LoadStageExtension(omni.ext.IExt):
6 | def on_startup(self, ext_id):
7 | print("[ft_lab.sample.loadStage] LoadStageExtension startup")
8 |
9 | # Get USD file.
10 | usdPath = Path(__file__).parent.joinpath("usd")
11 | usdFile = f"{usdPath}/test.usd"
12 |
13 | # Load stage.
14 | omni.usd.get_context().open_stage(usdFile)
15 |
16 | def on_shutdown(self):
17 | print("[ft_lab.sample.loadStage] LoadStageExtension shutdown")
18 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.loadStage/ft_lab/sample/loadStage/usd/test.usd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/ft_lab.sample.loadStage/ft_lab/sample/loadStage/usd/test.usd
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.menu/config/extension.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | # Semantic Versionning is used: https://semver.org/
3 | version = "0.0.1"
4 |
5 | # Lists people or organizations that are considered the "authors" of the package.
6 | authors = ["ft-lab"]
7 |
8 | # The title and description fields are primarily for displaying extension info in UI
9 | title = "Menu Test"
10 | description="Sample of adding a Menu."
11 |
12 | # Path (relative to the root) or content of readme markdown file for UI.
13 | readme = "docs/README.md"
14 |
15 | # URL of the extension source repository.
16 | repository = ""
17 |
18 | # One of categories for UI.
19 | category = "Example"
20 |
21 | # Keywords for the extension
22 | keywords = ["kit", "example"]
23 |
24 | # Location of change log file in target (final) folder of extension, relative to the root. Can also be just a content
25 | # of it instead of file path. More info on writing changelog: https://keepachangelog.com/en/1.0.0/
26 | changelog="docs/CHANGELOG.md"
27 |
28 | # Preview image and icon. Folder named "data" automatically goes in git lfs (see .gitattributes file).
29 | # Preview image is shown in "Overview" of Extensions window. Screenshot of an extension might be a good preview image.
30 | preview_image = "data/preview.png"
31 |
32 | # Icon is shown in Extensions window, it is recommended to be square, of size 256x256.
33 | icon = "data/icon.png"
34 |
35 | # We only depend on testing framework currently:
36 | [dependencies]
37 |
38 | # Main python module this extension provides.
39 | [[python.module]]
40 | name = "ft_lab.sample.menu"
41 |
42 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.menu/data/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/ft_lab.sample.menu/data/icon.png
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.menu/data/preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/ft_lab.sample.menu/data/preview.png
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.menu/docs/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # CHANGELOG
2 |
3 | This document records all notable changes to ``ft_lab.sample.menu`` extension.
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.menu/docs/README.md:
--------------------------------------------------------------------------------
1 | # Python Extension Example [ft_lab.sample.menu]
2 |
3 | menu sample extension.
4 |
5 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.menu/docs/index.rst:
--------------------------------------------------------------------------------
1 | ft_lab.sample.menu
2 | ###########################
3 |
4 | .. toctree::
5 | :maxdepth: 1
6 |
7 | README
8 | CHANGELOG
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.menu/ft_lab/sample/menu/__init__.py:
--------------------------------------------------------------------------------
1 | from .main import *
2 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.uiScene/config/extension.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | # Semantic Versionning is used: https://semver.org/
3 | version = "0.0.1"
4 |
5 | # Lists people or organizations that are considered the "authors" of the package.
6 | authors = ["ft-lab"]
7 |
8 | # The title and description fields are primarily for displaying extension info in UI
9 | title = "UI Scene example"
10 | description="omni.ui scene example"
11 |
12 | # Path (relative to the root) or content of readme markdown file for UI.
13 | readme = "docs/README.md"
14 |
15 | # URL of the extension source repository.
16 | repository = ""
17 |
18 | # One of categories for UI.
19 | category = "Example"
20 |
21 | # Keywords for the extension
22 | keywords = ["kit", "example"]
23 |
24 | # Location of change log file in target (final) folder of extension, relative to the root. Can also be just a content
25 | # of it instead of file path. More info on writing changelog: https://keepachangelog.com/en/1.0.0/
26 | changelog="docs/CHANGELOG.md"
27 |
28 | # Preview image and icon. Folder named "data" automatically goes in git lfs (see .gitattributes file).
29 | # Preview image is shown in "Overview" of Extensions window. Screenshot of an extension might be a good preview image.
30 | preview_image = "data/preview.png"
31 |
32 | # Icon is shown in Extensions window, it is recommended to be square, of size 256x256.
33 | icon = "data/icon.png"
34 |
35 | # We only depend on testing framework currently:
36 | [dependencies]
37 |
38 | # Main python module this extension provides.
39 | [[python.module]]
40 | name = "ft_lab.sample.uiScene"
41 |
42 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.uiScene/data/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/ft_lab.sample.uiScene/data/icon.png
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.uiScene/data/preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/ft_lab.sample.uiScene/data/preview.png
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.uiScene/docs/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # CHANGELOG
2 |
3 | This document records all notable changes to ``ft_lab.sample.uiScene`` extension.
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.uiScene/docs/README.md:
--------------------------------------------------------------------------------
1 | # Python Extension Example [ft_lab.sample.uiScene]
2 |
3 | sample extension.
4 |
5 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.uiScene/docs/index.rst:
--------------------------------------------------------------------------------
1 | ft_lab.sample.uiScene
2 | ###########################
3 |
4 | .. toctree::
5 | :maxdepth: 1
6 |
7 | README
8 | CHANGELOG
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.uiScene/ft_lab/sample/uiScene/__init__.py:
--------------------------------------------------------------------------------
1 | from .extension import *
2 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.uiSceneDraw/config/extension.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | # Semantic Versionning is used: https://semver.org/
3 | version = "0.0.1"
4 |
5 | # Lists people or organizations that are considered the "authors" of the package.
6 | authors = ["ft-lab"]
7 |
8 | # The title and description fields are primarily for displaying extension info in UI
9 | title = "UI Scene draw example"
10 | description="omni.ui scene draw example"
11 |
12 | # Path (relative to the root) or content of readme markdown file for UI.
13 | readme = "docs/README.md"
14 |
15 | # URL of the extension source repository.
16 | repository = ""
17 |
18 | # One of categories for UI.
19 | category = "Example"
20 |
21 | # Keywords for the extension
22 | keywords = ["kit", "example"]
23 |
24 | # Location of change log file in target (final) folder of extension, relative to the root. Can also be just a content
25 | # of it instead of file path. More info on writing changelog: https://keepachangelog.com/en/1.0.0/
26 | changelog="docs/CHANGELOG.md"
27 |
28 | # Preview image and icon. Folder named "data" automatically goes in git lfs (see .gitattributes file).
29 | # Preview image is shown in "Overview" of Extensions window. Screenshot of an extension might be a good preview image.
30 | preview_image = "data/preview.png"
31 |
32 | # Icon is shown in Extensions window, it is recommended to be square, of size 256x256.
33 | icon = "data/icon.png"
34 |
35 | # We only depend on testing framework currently:
36 | [dependencies]
37 |
38 | # Main python module this extension provides.
39 | [[python.module]]
40 | name = "ft_lab.sample.uiSceneDraw"
41 |
42 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.uiSceneDraw/data/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/ft_lab.sample.uiSceneDraw/data/icon.png
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.uiSceneDraw/data/preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/ft_lab.sample.uiSceneDraw/data/preview.png
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.uiSceneDraw/docs/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # CHANGELOG
2 |
3 | This document records all notable changes to ``ft_lab.sample.uiSceneDraw`` extension.
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.uiSceneDraw/docs/README.md:
--------------------------------------------------------------------------------
1 | # Python Extension Example [ft_lab.sample.uiSceneDraw]
2 |
3 | sample extension.
4 |
5 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.uiSceneDraw/docs/index.rst:
--------------------------------------------------------------------------------
1 | ft_lab.sample.uiSceneDraw
2 | ###########################
3 |
4 | .. toctree::
5 | :maxdepth: 1
6 |
7 | README
8 | CHANGELOG
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.uiSceneDraw/ft_lab/sample/uiSceneDraw/__init__.py:
--------------------------------------------------------------------------------
1 | from .main import *
2 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.uiSceneShowPrimName/config/extension.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | # Semantic Versionning is used: https://semver.org/
3 | version = "0.0.1"
4 |
5 | # Lists people or organizations that are considered the "authors" of the package.
6 | authors = ["ft-lab"]
7 |
8 | # The title and description fields are primarily for displaying extension info in UI
9 | title = "UI Scene draw viewport overlay example"
10 | description="omni.ui scene draw viewport overlay example"
11 |
12 | # Path (relative to the root) or content of readme markdown file for UI.
13 | readme = "docs/README.md"
14 |
15 | # URL of the extension source repository.
16 | repository = ""
17 |
18 | # One of categories for UI.
19 | category = "Example"
20 |
21 | # Keywords for the extension
22 | keywords = ["kit", "example"]
23 |
24 | # Location of change log file in target (final) folder of extension, relative to the root. Can also be just a content
25 | # of it instead of file path. More info on writing changelog: https://keepachangelog.com/en/1.0.0/
26 | changelog="docs/CHANGELOG.md"
27 |
28 | # Preview image and icon. Folder named "data" automatically goes in git lfs (see .gitattributes file).
29 | # Preview image is shown in "Overview" of Extensions window. Screenshot of an extension might be a good preview image.
30 | preview_image = "data/preview.png"
31 |
32 | # Icon is shown in Extensions window, it is recommended to be square, of size 256x256.
33 | icon = "data/icon.png"
34 |
35 | # We only depend on testing framework currently:
36 | [dependencies]
37 | "omni.ui.scene" = {}
38 | "omni.kit.viewport.utility" = {}
39 |
40 | # Main python module this extension provides.
41 | [[python.module]]
42 | name = "ft_lab.sample.uiSceneShowPrimName"
43 |
44 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.uiSceneShowPrimName/data/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/ft_lab.sample.uiSceneShowPrimName/data/icon.png
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.uiSceneShowPrimName/data/preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/ft_lab.sample.uiSceneShowPrimName/data/preview.png
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.uiSceneShowPrimName/docs/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # CHANGELOG
2 |
3 | This document records all notable changes to ``ft_lab.sample.uiSceneShowPrimName`` extension.
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.uiSceneShowPrimName/docs/README.md:
--------------------------------------------------------------------------------
1 | # Python Extension Example [ft_lab.sample.uiSceneShowPrimName]
2 |
3 | sample extension.
4 |
5 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.uiSceneShowPrimName/docs/index.rst:
--------------------------------------------------------------------------------
1 | ft_lab.sample.uiSceneShowPrimName
2 | ###########################
3 |
4 | .. toctree::
5 | :maxdepth: 1
6 |
7 | README
8 | CHANGELOG
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.uiSceneShowPrimName/ft_lab/sample/uiSceneShowPrimName/__init__.py:
--------------------------------------------------------------------------------
1 | from .extension import *
2 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.uiSceneViewportOverlay/data/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/ft_lab.sample.uiSceneViewportOverlay/data/icon.png
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.uiSceneViewportOverlay/data/preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/ft_lab.sample.uiSceneViewportOverlay/data/preview.png
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.uiSceneViewportOverlay/docs/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # CHANGELOG
2 |
3 | This document records all notable changes to ``ft_lab.sample.uiSceneViewportOverlay`` extension.
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.uiSceneViewportOverlay/docs/README.md:
--------------------------------------------------------------------------------
1 | # Python Extension Example [ft_lab.sample.uiSceneViewportOverlay]
2 |
3 | sample extension.
4 |
5 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.uiSceneViewportOverlay/docs/index.rst:
--------------------------------------------------------------------------------
1 | ft_lab.sample.uiSceneViewportOverlay
2 | ###########################
3 |
4 | .. toctree::
5 | :maxdepth: 1
6 |
7 | README
8 | CHANGELOG
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.uiSceneViewportOverlay/ft_lab/sample/uiSceneViewportOverlay/__init__.py:
--------------------------------------------------------------------------------
1 | from .extension import *
2 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.widgets/config/extension.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | # Semantic Versionning is used: https://semver.org/
3 | version = "0.0.1"
4 |
5 | # Lists people or organizations that are considered the "authors" of the package.
6 | authors = ["ft-lab"]
7 |
8 | # The title and description fields are primarily for displaying extension info in UI
9 | title = "Widgets example"
10 | description="omni.ui widgets example"
11 |
12 | # Path (relative to the root) or content of readme markdown file for UI.
13 | readme = "docs/README.md"
14 |
15 | # URL of the extension source repository.
16 | repository = ""
17 |
18 | # One of categories for UI.
19 | category = "Example"
20 |
21 | # Keywords for the extension
22 | keywords = ["kit", "example"]
23 |
24 | # Location of change log file in target (final) folder of extension, relative to the root. Can also be just a content
25 | # of it instead of file path. More info on writing changelog: https://keepachangelog.com/en/1.0.0/
26 | changelog="docs/CHANGELOG.md"
27 |
28 | # Preview image and icon. Folder named "data" automatically goes in git lfs (see .gitattributes file).
29 | # Preview image is shown in "Overview" of Extensions window. Screenshot of an extension might be a good preview image.
30 | preview_image = "data/preview.png"
31 |
32 | # Icon is shown in Extensions window, it is recommended to be square, of size 256x256.
33 | icon = "data/icon.png"
34 |
35 | # We only depend on testing framework currently:
36 | [dependencies]
37 |
38 | # Main python module this extension provides.
39 | [[python.module]]
40 | name = "ft_lab.sample.widgets"
41 |
42 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.widgets/data/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/ft_lab.sample.widgets/data/icon.png
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.widgets/data/preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/ft_lab.sample.widgets/data/preview.png
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.widgets/docs/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # CHANGELOG
2 |
3 | This document records all notable changes to ``ft_lab.sample.widgets`` extension.
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.widgets/docs/README.md:
--------------------------------------------------------------------------------
1 | # Python Extension Example [ft_lab.sample.widgets]
2 |
3 | sample extension.
4 |
5 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.widgets/docs/index.rst:
--------------------------------------------------------------------------------
1 | ft_lab.sample.widgets
2 | ###########################
3 |
4 | .. toctree::
5 | :maxdepth: 1
6 |
7 | README
8 | CHANGELOG
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.widgets/ft_lab/sample/widgets/__init__.py:
--------------------------------------------------------------------------------
1 | from .extension import *
2 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.widgets/ft_lab/sample/widgets/images/radio_off.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.widgets/ft_lab/sample/widgets/images/radio_on.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
11 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.widgets/ft_lab/sample/widgets/images/radio_on_off.afdesign:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/ft_lab.sample.widgets/ft_lab/sample/widgets/images/radio_on_off.afdesign
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.widgets_progressBar/config/extension.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | # Semantic Versionning is used: https://semver.org/
3 | version = "0.0.1"
4 |
5 | # Lists people or organizations that are considered the "authors" of the package.
6 | authors = ["ft-lab"]
7 |
8 | # The title and description fields are primarily for displaying extension info in UI
9 | title = "Widgets ProgressBar example"
10 | description="omni.ui widgets ProgressBar example"
11 |
12 | # Path (relative to the root) or content of readme markdown file for UI.
13 | readme = "docs/README.md"
14 |
15 | # URL of the extension source repository.
16 | repository = ""
17 |
18 | # One of categories for UI.
19 | category = "Example"
20 |
21 | # Keywords for the extension
22 | keywords = ["kit", "example"]
23 |
24 | # Location of change log file in target (final) folder of extension, relative to the root. Can also be just a content
25 | # of it instead of file path. More info on writing changelog: https://keepachangelog.com/en/1.0.0/
26 | changelog="docs/CHANGELOG.md"
27 |
28 | # Preview image and icon. Folder named "data" automatically goes in git lfs (see .gitattributes file).
29 | # Preview image is shown in "Overview" of Extensions window. Screenshot of an extension might be a good preview image.
30 | preview_image = "data/preview.png"
31 |
32 | # Icon is shown in Extensions window, it is recommended to be square, of size 256x256.
33 | icon = "data/icon.png"
34 |
35 | # We only depend on testing framework currently:
36 | [dependencies]
37 |
38 | # Main python module this extension provides.
39 | [[python.module]]
40 | name = "ft_lab.sample.widgets_progressBar"
41 |
42 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.widgets_progressBar/data/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/ft_lab.sample.widgets_progressBar/data/icon.png
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.widgets_progressBar/data/preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/ft_lab.sample.widgets_progressBar/data/preview.png
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.widgets_progressBar/docs/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # CHANGELOG
2 |
3 | This document records all notable changes to ``ft_lab.sample.widgets_progressBar`` extension.
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.widgets_progressBar/docs/README.md:
--------------------------------------------------------------------------------
1 | # Python Extension Example [ft_lab.sample.widgets_progressBar]
2 |
3 | sample extension.
4 |
5 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.widgets_progressBar/docs/index.rst:
--------------------------------------------------------------------------------
1 | ft_lab.sample.widgets_progressBar
2 | ###########################
3 |
4 | .. toctree::
5 | :maxdepth: 1
6 |
7 | README
8 | CHANGELOG
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.widgets_progressBar/ft_lab/sample/widgets_progressBar/__init__.py:
--------------------------------------------------------------------------------
1 | from .extension import *
2 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.widgets_progressBar/ft_lab/sample/widgets_progressBar/images/radio_off.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.widgets_progressBar/ft_lab/sample/widgets_progressBar/images/radio_on.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
11 |
--------------------------------------------------------------------------------
/Extensions/ft_lab.sample.widgets_progressBar/ft_lab/sample/widgets_progressBar/images/radio_on_off.afdesign:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/ft_lab.sample.widgets_progressBar/ft_lab/sample/widgets_progressBar/images/radio_on_off.afdesign
--------------------------------------------------------------------------------
/Extensions/images/extension_cap_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/images/extension_cap_01.jpg
--------------------------------------------------------------------------------
/Extensions/images/extension_cap_02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/images/extension_cap_02.jpg
--------------------------------------------------------------------------------
/Extensions/images/extension_menu_00.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/images/extension_menu_00.png
--------------------------------------------------------------------------------
/Extensions/images/extension_menu_01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/images/extension_menu_01.png
--------------------------------------------------------------------------------
/Extensions/images/extension_widgets_01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/images/extension_widgets_01.png
--------------------------------------------------------------------------------
/Extensions/images/extension_widgets_progressBar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/images/extension_widgets_progressBar.png
--------------------------------------------------------------------------------
/Extensions/images/omniverse_code_extension_uiScene.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/images/omniverse_code_extension_uiScene.png
--------------------------------------------------------------------------------
/Extensions/images/omniverse_code_extension_uiSceneDraw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/images/omniverse_code_extension_uiSceneDraw.png
--------------------------------------------------------------------------------
/Extensions/images/omniverse_code_extension_uiSceneShowPrimName.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/images/omniverse_code_extension_uiSceneShowPrimName.jpg
--------------------------------------------------------------------------------
/Extensions/images/omniverse_code_extension_uiSceneViewportOverlay.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Extensions/images/omniverse_code_extension_uiSceneViewportOverlay.jpg
--------------------------------------------------------------------------------
/Extensions/knowledge/config_info.md:
--------------------------------------------------------------------------------
1 | # extension.tomlでの記述内容
2 |
3 | "extension.toml"に記載する内容の覚書です。
4 |
5 | ## 他のExtensionを使用し、機能を呼び出したい
6 |
7 | 他のExtensionの機能を使用したい場合、[dependencies]にExtension名を追加します。
8 |
9 | ```
10 | [dependencies]
11 | "omni.audioplayer" = {}
12 | ```
13 | この場合は「omni.audioplayer」を有効にします。
14 | こうすることで、Pythonで「import omni.audioplayer」が使用できるようになります。
15 |
16 | なお、参照で記載するExtension名は [[python.module]] に記載しているものと同じになります。
17 | 以下は「omni.audioplayer」内の"extension.toml"の記載です。
18 | ```
19 | [[python.module]]
20 | name = "omni.audioplayer"
21 | ```
22 | ここで記載しているExtensionがOnになっていない場合は、対象のExtensionを起動した時に自動的にOnになります。
23 |
24 | ## 外部のC/C++モジュールを呼び出す
25 |
26 | Windows環境の場合、dllの形で外部関数を作成します。
27 | これをExtensionから呼び出すことができます。
28 |
29 | ```
30 | [[native.library]]
31 | path = "bin/win/x64/OmniverseSimpleDLL.dll"
32 | ```
33 |
34 | DLL呼び出しのサンプルExtensionは「[ft_lab.sample.callDLL](../ft_lab.sample.callDLL)」をご参照くださいませ。
35 |
--------------------------------------------------------------------------------
/Geometry/CreateCube/CreateCube.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Create cube.
7 | pathName = '/World/cube'
8 | cubeGeom = UsdGeom.Cube.Define(stage, pathName)
9 |
10 | # Set cube size.
11 | cubeGeom.CreateSizeAttr(10.0)
12 |
13 | # Set color.
14 | cubeGeom.CreateDisplayColorAttr([(0.0, 1.0, 0.0)])
15 |
16 | # Set position.
17 | UsdGeom.XformCommonAPI(cubeGeom).SetTranslate((0.0, 5.0, 0.0))
18 |
19 | # Set scale.
20 | UsdGeom.XformCommonAPI(cubeGeom).SetScale((2.0, 1.0, 2.0))
21 |
--------------------------------------------------------------------------------
/Geometry/CreateCube/images/createCube.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Geometry/CreateCube/images/createCube.jpg
--------------------------------------------------------------------------------
/Geometry/CreateCube/readme.md:
--------------------------------------------------------------------------------
1 | # CreateCube
2 |
3 | |ファイル|説明|
4 | |---|---|
5 | |[CreateCube.py](./CreateCube.py)|直方体を作成
|
6 |
7 |
--------------------------------------------------------------------------------
/Geometry/CreateMesh/images/createGear.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Geometry/CreateMesh/images/createGear.jpg
--------------------------------------------------------------------------------
/Geometry/CreateMesh/images/createMesh.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Geometry/CreateMesh/images/createMesh.jpg
--------------------------------------------------------------------------------
/Geometry/CreateMesh/readme.md:
--------------------------------------------------------------------------------
1 | # CreateMesh
2 |
3 | Meshを生成/Mesh情報を取得します。
4 |
5 | |ファイル|説明|
6 | |---|---|
7 | |[CreateSimpleMesh.py](./CreateSimpleMesh.py)|簡単な1枚板のMeshを作成
|
8 | |[CreateMeshInterpolation.py](./CreateMeshInterpolation.py)|2つの四角形で構成されるMeshを作成。
「頂点ごと(vertex)」「面の頂点ごと(faceVarying)」の法線/UVの指定。|
9 | |[CreateSimpleMeshWithSubset.py](./CreateSimpleMeshWithSubset.py)|2つの面を持つMeshにて、面のマテリアルを別々に指定。|
10 | |[CreateGear.py](./CreateGear.py)|歯車のMeshを作成
|
11 | |[GetMeshInfo.py](./GetMeshInfo.py)|選択形状がMeshの場合のMesh情報を取得|
12 |
13 |
--------------------------------------------------------------------------------
/Geometry/CreateSphere/CReateSphereWithRefinement.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Create sphere.
7 | pathName = '/World/sphere'
8 | sphereGeom = UsdGeom.Sphere.Define(stage, pathName)
9 |
10 | # Set radius.
11 | sphereGeom.CreateRadiusAttr(5.0)
12 |
13 | # Set color.
14 | sphereGeom.CreateDisplayColorAttr([(1.0, 0.0, 0.0)])
15 |
16 | # Set position.
17 | UsdGeom.XformCommonAPI(sphereGeom).SetTranslate((0.0, 5.0, 0.0))
18 |
19 | # Set refinement.
20 | objPrim = stage.GetPrimAtPath(pathName)
21 | objPrim.CreateAttribute('refinementEnableOverride', Sdf.ValueTypeNames.Bool).Set(True)
22 | objPrim.CreateAttribute('refinementLevel', Sdf.ValueTypeNames.Int).Set(2)
23 |
--------------------------------------------------------------------------------
/Geometry/CreateSphere/CreateSphere.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Create sphere.
7 | pathName = '/World/sphere'
8 | sphereGeom = UsdGeom.Sphere.Define(stage, pathName)
9 |
10 | # Set radius.
11 | sphereGeom.CreateRadiusAttr(5.0)
12 |
13 | # Set color.
14 | sphereGeom.CreateDisplayColorAttr([(1.0, 0.0, 0.0)])
15 |
16 | # Set position.
17 | UsdGeom.XformCommonAPI(sphereGeom).SetTranslate((0.0, 5.0, 0.0))
18 |
--------------------------------------------------------------------------------
/Geometry/CreateSphere/images/createSphere2_img.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Geometry/CreateSphere/images/createSphere2_img.jpg
--------------------------------------------------------------------------------
/Geometry/CreateSphere/images/createSphere_img.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Geometry/CreateSphere/images/createSphere_img.jpg
--------------------------------------------------------------------------------
/Geometry/CreateSphere/readme.md:
--------------------------------------------------------------------------------
1 | # CreateSphere
2 |
3 |
4 | 球を作成します。
5 |
6 | |ファイル|説明|
7 | |---|---|
8 | |[CreateSphere.py](./CreateSphere.py)|簡単な球を作成
|
9 | |[CreateSphereWithRefinement.py](./CReateSphereWithRefinement.py)|作成する球の分割数を増やす。
属性"Refinement"を指定。
|
10 | |[GetSphereInfo.py](./GetSphereInfo.py)|球の情報を取得|
11 |
12 |
--------------------------------------------------------------------------------
/Geometry/GetMeshPrimvars.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get selection.
7 | selection = omni.usd.get_context().get_selection()
8 | paths = selection.get_selected_prim_paths()
9 |
10 | for path in paths:
11 | # Get prim.
12 | prim = stage.GetPrimAtPath(path)
13 | if prim.GetTypeName() != "Mesh":
14 | continue
15 |
16 | # USD 22.11 : The specification has been changed to use UsdGeom.PrimvarsAPI.
17 | primvarsAPI = UsdGeom.PrimvarsAPI(prim)
18 |
19 | primvars = primvarsAPI.GetPrimvars()
20 | if len(primvars) > 0:
21 | print("[" + prim.GetPath().pathString + "]")
22 | for primvar in primvars:
23 | primName = primvar.GetPrimvarName()
24 | typeName = primvar.GetTypeName()
25 | val = primvar.Get()
26 |
27 | print(" " + primName + " (" + str(typeName) + ") : " + str(val))
28 |
29 |
--------------------------------------------------------------------------------
/Geometry/SetMeshPrimvars.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get selection.
7 | selection = omni.usd.get_context().get_selection()
8 | paths = selection.get_selected_prim_paths()
9 |
10 | for path in paths:
11 | # Get prim.
12 | prim = stage.GetPrimAtPath(path)
13 | if prim.GetTypeName() != "Mesh":
14 | continue
15 |
16 | m = UsdGeom.Mesh(prim)
17 |
18 | # USD 22.11 : The specification has been changed to use UsdGeom.PrimvarsAPI.
19 |
20 | # Set primvar(float).
21 | primvarV = UsdGeom.PrimvarsAPI(prim).CreatePrimvar("dat1", Sdf.ValueTypeNames.Float)
22 | attr = primvarV.GetAttr()
23 | attr.Set((2.2))
24 |
25 | if UsdGeom.primvarV(prim).HasPrimvar("dat1"): # Check primvar.
26 | # Remove primvar.
27 | UsdGeom.primvarV(prim).RemovePrimvar("dat1")
28 |
29 | # Set primvar (float2).
30 | # If there is already a primvar with the same name but a different type,
31 | # it must be removed using RemoveProperty.
32 | primvarV = UsdGeom.PrimvarsAPI(prim).CreatePrimvar("dat1", Sdf.ValueTypeNames.Float2)
33 | attr = primvarV.GetAttr()
34 | attr.Set((1.0, 2.0))
35 |
36 | # Set primvar (color).
37 | primvarV = UsdGeom.PrimvarsAPI(prim).CreatePrimvar("dat2", Sdf.ValueTypeNames.Color3f)
38 | attr = primvarV.GetAttr()
39 | attr.Set((1.0, 0.5, 0.2))
40 |
41 | # Set primvar (float3 array)
42 | primvarV = UsdGeom.PrimvarsAPI(prim).CreatePrimvar("dat3", Sdf.ValueTypeNames.Float3Array)
43 | attr = primvarV.GetAttr()
44 | attr.Set([(0.1, 0.2, 0.5), (0.4, 0.05, 0.0), (0.1, 0.4, 0.05)])
45 |
46 |
--------------------------------------------------------------------------------
/Geometry/readme.md:
--------------------------------------------------------------------------------
1 | # Geometry
2 |
3 | ジオメトリを作成するためのサンプルです。
4 |
5 | ## primvarの仕様変更
6 |
7 | USD 20.08からUSD 22.11にかけて、primvarの仕様が変更されました。
8 | 「[UsdGeom.PrimvarsAPI](https://openusd.org/release/api/class_usd_geom_primvars_a_p_i.html)」を使用してprimvarを操作する必要があります。
9 |
10 | ## Samples
11 |
12 | |サンプル|説明|
13 | |---|---|
14 | |[CreateSphere](./CreateSphere)|球を作成
UsdGeom.Sphere ( https://graphics.pixar.com/usd/release/api/class_usd_geom_sphere.html )を使用。|
15 | |[CreateCube](./CreateCube)|直方体を作成
UsdGeom.Cube ( https://graphics.pixar.com/usd/release/api/class_usd_geom_cube.html )を使用。|
16 | |[CreateMesh](./CreateMesh)|Meshを作成/Mesh情報を取得
UsdGeom.Mesh ( https://graphics.pixar.com/usd/release/api/class_usd_geom_mesh.html )を使用。|
17 |
18 | |ファイル|説明|
19 | |---|---|
20 | |[GetMeshPrimvars.py](./GetMeshPrimvars.py)|選択Meshの「primvars:xxx」の情報を取得。|
21 | |[SetMeshPrimvars.py](./SetMeshPrimvars.py)|選択Meshにprimvarを追加/削除。|
22 |
23 |
24 |
--------------------------------------------------------------------------------
/Light/CheckLightPrim.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdLux, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get selection.
7 | selection = omni.usd.get_context().get_selection()
8 | paths = selection.get_selected_prim_paths()
9 |
10 | # Check if prim is Light.
11 | def checkLight (prim : Usd.Prim):
12 | typeName = prim.GetTypeName()
13 |
14 | if typeName == "DistantLight" or typeName == "CylinderLight" or \
15 | typeName == "DiskLight" or typeName == "DomeLight" or \
16 | typeName == "RectLight" or typeName == "SphereLight":
17 | return True
18 |
19 | return False
20 |
21 | for path in paths:
22 | # Get prim.
23 | prim = stage.GetPrimAtPath(path)
24 |
25 | if checkLight(prim):
26 | print(f"[ {prim.GetPath().pathString} ] : {prim.GetTypeName()}")
27 |
28 |
--------------------------------------------------------------------------------
/Light/CreateLight.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdLux, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Create distant light.
7 | pathName = "/World/distantLight"
8 | light = UsdLux.DistantLight.Define(stage, pathName)
9 |
10 | # Set intensity.
11 | light.CreateIntensityAttr(100.0)
12 |
13 | # Set color.
14 | light.CreateColorAttr(Gf.Vec3f(1.0, 0.5, 0.2))
15 |
16 | # Set Exposure.
17 | light.CreateExposureAttr(0.0)
18 |
19 | # Compute extent.
20 | boundable = UsdGeom.Boundable(light.GetPrim())
21 | extent = boundable.ComputeExtent(Usd.TimeCode(0))
22 |
23 | # Set Extent.
24 | light.CreateExtentAttr(extent)
25 |
--------------------------------------------------------------------------------
/Light/CreateSphereLight.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdLux, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Create sphere light.
7 | pathName = "/World/sphereLight"
8 | light = UsdLux.SphereLight.Define(stage, pathName)
9 |
10 | # Set Radius.
11 | light.CreateRadiusAttr(2.0)
12 |
13 | # Set intensity.
14 | light.CreateIntensityAttr(10000.0)
15 |
16 | # Set color.
17 | light.CreateColorAttr(Gf.Vec3f(1.0, 0.9, 0.8))
18 |
19 | # Set Exposure.
20 | light.CreateExposureAttr(0.0)
21 |
22 | # cone angle.
23 | shapingAPI = UsdLux.ShapingAPI(light)
24 | shapingAPI.CreateShapingConeAngleAttr(180.0)
25 | shapingAPI.Apply(light.GetPrim()) # Register ShapingAPI as a schema in prim.
26 |
27 | # Compute extent.
28 | boundable = UsdGeom.Boundable(light.GetPrim())
29 | extent = boundable.ComputeExtent(Usd.TimeCode(0))
30 |
31 | # Set Extent.
32 | light.CreateExtentAttr(extent)
33 |
--------------------------------------------------------------------------------
/Light/readme.md:
--------------------------------------------------------------------------------
1 | # Light
2 |
3 | 光源を作成/取得するためのサンプルです。
4 |
5 | ## Samples
6 |
7 | |ファイル|説明|
8 | |---|---|
9 | |[CreateLight.py](./CreateLight.py)|DistantLightを作成してパラメータを指定。|
10 | |[CreateSphereLight.py](./CreateSphereLight.py)|SphereLightを作成してパラメータを指定。|
11 | |[CheckLightPrim.py](./CheckLightPrim.py)|選択PrimがLightかどうか判断。|
12 |
13 |
--------------------------------------------------------------------------------
/Material/GetMaterial/GetMaterial.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | selection = omni.usd.get_context().get_selection()
7 | paths = selection.get_selected_prim_paths()
8 |
9 | for path in paths:
10 | prim = stage.GetPrimAtPath(path)
11 |
12 | # Get Material.
13 | rel = UsdShade.MaterialBindingAPI(prim).GetDirectBindingRel()
14 | pathList = rel.GetTargets()
15 |
16 | print('[ ' + prim.GetName() + ' ]')
17 | for mTargetPath in pathList:
18 | print(' material : ' + mTargetPath.pathString)
19 |
20 | material = UsdShade.Material(stage.GetPrimAtPath(mTargetPath))
21 | print(material)
22 |
23 |
--------------------------------------------------------------------------------
/Material/GetMaterial/GetMaterialInputs.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | selection = omni.usd.get_context().get_selection()
7 | paths = selection.get_selected_prim_paths()
8 |
9 | for path in paths:
10 | prim = stage.GetPrimAtPath(path)
11 | if prim.GetTypeName() != "Material":
12 | continue
13 |
14 | print("[" + prim.GetPath().pathString + "]")
15 |
16 | # Get Shader of Material and input parameters.
17 | pChildren = prim.GetChildren()
18 | for cPrim in pChildren:
19 | if cPrim.GetTypeName() == "Shader":
20 | shaderPrim = UsdShade.Shader(cPrim)
21 |
22 | mInputs = shaderPrim.GetInputs()
23 | for inputV in mInputs:
24 | baseName = inputV.GetBaseName()
25 | typeName = inputV.GetTypeName()
26 | print(" [" + baseName + "] (" + str(typeName) + ")")
27 |
28 | v = inputV.Get()
29 | print(" " + str(type(v)) + " ==> " + str(v))
30 |
31 |
32 |
--------------------------------------------------------------------------------
/Material/GetMaterial/GetMaterialTexturePath.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | selection = omni.usd.get_context().get_selection()
7 | paths = selection.get_selected_prim_paths()
8 |
9 | for path in paths:
10 | prim = stage.GetPrimAtPath(path)
11 | if prim.GetTypeName() != "Material":
12 | continue
13 |
14 | # List textures referenced by Material.
15 | pChildren = prim.GetChildren()
16 | for cPrim in pChildren:
17 | if cPrim.GetTypeName() == "Shader":
18 | shaderPrim = UsdShade.Shader(cPrim)
19 |
20 | print(f"[{shaderPrim.GetPath().pathString}]")
21 |
22 | mInputs = shaderPrim.GetInputs()
23 | for inputV in mInputs:
24 | baseName = inputV.GetBaseName()
25 | typeName = inputV.GetTypeName()
26 | if typeName == "asset":
27 | v = inputV.Get() # Sdf.AssetPath
28 | if v.path != "":
29 | # v.path ... display path.
30 | # v.resolvedPath ... absolute path.
31 | print(f" {baseName}")
32 | print(f" path [ {v.path} ]")
33 | print(f" resolvedPath [ {v.resolvedPath} ]")
34 |
35 |
--------------------------------------------------------------------------------
/Material/GetMaterial/readme.md:
--------------------------------------------------------------------------------
1 | # GetMaterial
2 |
3 | マテリアル情報を取得。
4 |
5 | 以下は、形状からマテリアルを取得するサンプルです。
6 |
7 | |ファイル|説明|
8 | |---|---|
9 | |[GetMaterial.py](./GetMaterial.py)|選択形状のマテリアル情報を取得|
10 |
11 | 以下は、マテリアルから情報を取得するサンプルです。
12 |
13 | |ファイル|説明|
14 | |---|---|
15 | |[GetMaterialType.py](./GetMaterialType.py)|選択マテリアルの種類を取得(UsdPreviewSurface or MDL)|
16 | |[GetMaterialInputs.py](./GetMaterialInputs.py)|選択マテリアルの入力パラメータを取得|
17 | |[GetMaterialTexturePath.py](./GetMaterialTexturePath.py)|選択マテリアルの入力パラメータからテクスチャ情報のみを取得。
Sdf.AssetPathのpathは入力そのまま。resolvedPathはフルパスが入っている。|
18 |
--------------------------------------------------------------------------------
/Material/OmniPBR/CreateMaterialWithCommand.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 | import omni.kit.commands
3 |
4 | # Get stage.
5 | stage = omni.usd.get_context().get_stage()
6 |
7 | # Create new material.
8 | omni.kit.commands.execute('CreateAndBindMdlMaterialFromLibrary', mdl_name='OmniPBR.mdl',
9 | mtl_name='OmniPBR', mtl_created_list=['/World/Looks/OmniPBR'])
10 |
11 | # Get selection.
12 | selection = omni.usd.get_context().get_selection()
13 | selectedPaths = selection.get_selected_prim_paths()
14 |
15 | # Path of the added material.
16 | selectPrimPath = ""
17 | for path in selectedPaths:
18 | selectPrimPath = path
19 | break
20 |
21 | print(selectPrimPath)
--------------------------------------------------------------------------------
/Material/OmniPBR/images/CreateMaterial.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Material/OmniPBR/images/CreateMaterial.jpg
--------------------------------------------------------------------------------
/Material/OmniPBR/images/CreateMaterialWithDiffuseNormalTexture.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Material/OmniPBR/images/CreateMaterialWithDiffuseNormalTexture.jpg
--------------------------------------------------------------------------------
/Material/OmniPBR/images/CreateMaterialWithDiffuseTexture.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Material/OmniPBR/images/CreateMaterialWithDiffuseTexture.jpg
--------------------------------------------------------------------------------
/Material/OmniPBR/readme.md:
--------------------------------------------------------------------------------
1 | # OmniPBR
2 |
3 | OmniPBRのマテリアルを割り当て。
4 |
5 | |ファイル|説明|
6 | |---|---|
7 | |[CreateMaterial.py](./CreateMaterial.py)|球にシンプルなマテリアルを割り当て。
|
8 | |[CreateMaterialWithCommand.py](./CreateMaterialWithCommand.py)|omni.kit.commandsを使ってOmniPBRの新しいマテリアルを作成|
9 | |[CreateMaterialWithDiffuseTexture.py](./CreateMaterialWithDiffuseTexture.py)|MeshにdiffuseColorテクスチャを割り当てる。
|
10 | |[CreateMaterialWithDiffuseNormalTexture.py](./CreateMaterialWithDiffuseNormalTexture.py)|MeshにdiffuseColorテクスチャ/法線マップテクスチャを割り当てる。
|
11 |
12 |
--------------------------------------------------------------------------------
/Material/UnbindMaterial.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get selection.
7 | selection = omni.usd.get_context().get_selection()
8 | paths = selection.get_selected_prim_paths()
9 |
10 | for path in paths:
11 | prim = stage.GetPrimAtPath(path)
12 | if prim.IsValid():
13 | # Unbind Material.
14 | UsdShade.MaterialBindingAPI(prim).UnbindAllBindings()
15 |
--------------------------------------------------------------------------------
/Material/UsdPreviewSurface/CreateMaterial.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Create sphere.
7 | spherePath = '/World/sphere'
8 | sphereGeom = UsdGeom.Sphere.Define(stage, spherePath)
9 | sphereGeom.CreateRadiusAttr(20.0)
10 | spherePrim = stage.GetPrimAtPath(spherePath)
11 | spherePrim.CreateAttribute('refinementEnableOverride', Sdf.ValueTypeNames.Bool).Set(True)
12 | spherePrim.CreateAttribute('refinementLevel', Sdf.ValueTypeNames.Int).Set(2)
13 |
14 | # Create material scope.
15 | materialScopePath = '/World/Materials'
16 | scopePrim = stage.GetPrimAtPath(materialScopePath)
17 | if scopePrim.IsValid() == False:
18 | UsdGeom.Scope.Define(stage, materialScopePath)
19 |
20 | # Create material (UsdPreviewSurface).
21 | materialPath = '/World/Materials/mat1'
22 | material = UsdShade.Material.Define(stage, materialPath)
23 | pbrShader = UsdShade.Shader.Define(stage, materialPath + '/PBRShader')
24 | pbrShader.CreateIdAttr("UsdPreviewSurface")
25 | pbrShader.CreateInput("diffuseColor", Sdf.ValueTypeNames.Color3f).Set((1.0, 0.2, 0.0))
26 | pbrShader.CreateInput("roughness", Sdf.ValueTypeNames.Float).Set(0.4)
27 | pbrShader.CreateInput("metallic", Sdf.ValueTypeNames.Float).Set(0.0)
28 |
29 | # Connect PBRShader to Material.
30 | material.CreateSurfaceOutput().ConnectToSource(pbrShader.ConnectableAPI(), "surface")
31 |
32 | # Bind material.
33 | UsdShade.MaterialBindingAPI(spherePrim).Bind(material)
34 |
--------------------------------------------------------------------------------
/Material/UsdPreviewSurface/images/CreateMaterial.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Material/UsdPreviewSurface/images/CreateMaterial.jpg
--------------------------------------------------------------------------------
/Material/UsdPreviewSurface/images/CreateMaterialWithDiffuseNormalTexture.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Material/UsdPreviewSurface/images/CreateMaterialWithDiffuseNormalTexture.jpg
--------------------------------------------------------------------------------
/Material/UsdPreviewSurface/images/CreateMaterialWithDiffuseTexture.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Material/UsdPreviewSurface/images/CreateMaterialWithDiffuseTexture.jpg
--------------------------------------------------------------------------------
/Material/UsdPreviewSurface/readme.md:
--------------------------------------------------------------------------------
1 | # UsdPreviewSurface
2 |
3 | UsdPreviewSurfaceのマテリアルを割り当て。
4 |
5 | |ファイル|説明|
6 | |---|---|
7 | |[CreateMaterial.py](./CreateMaterial.py)|球にシンプルなマテリアルを割り当て。
|
8 | |[CreateMaterialWithDiffuseTexture.py](./CreateMaterialWithDiffuseTexture.py) |MeshにdiffuseColorテクスチャを割り当てる。
|
9 | |[CreateMaterialWithDiffuseNormalTexture.py](./CreateMaterialWithDiffuseNormalTexture.py)|MeshにdiffuseColorテクスチャ/法線マップテクスチャを割り当てる。
|
10 |
11 |
--------------------------------------------------------------------------------
/Material/readme.md:
--------------------------------------------------------------------------------
1 | # Material
2 |
3 | マテリアルの割り当て/取得。
4 | なお、テクスチャファイルについては「[textures](./textures)」をローカルの相対パスの位置に配置してご使用くださいませ。
5 |
6 | マテリアルは UsdShade.Material ( https://graphics.pixar.com/usd/release/api/class_usd_shade_material.html )で定義されます。
7 |
8 | Primに対して以下のようにバインドすることで、対象形状にマテリアルが反映されます。
9 | ```python
10 | UsdShade.MaterialBindingAPI(prim).Bind(material)
11 | ```
12 | また、マテリアルはShaderを割り当てる必要があります。
13 | UsdShade.Shader ( https://graphics.pixar.com/usd/release/api/class_usd_shade_shader.html )。
14 | このShaderは、USD標準のUsdPreviewSurfaceを使用するほか、独自のShaderを割り当てることができます。
15 | Omniverseの場合は、MDL ( https://www.nvidia.com/ja-jp/design-visualization/technologies/material-definition-language/ )としてマテリアルを表現します。
16 |
17 | |ファイル|説明|
18 | |---|---|
19 | |[UnbindMaterial.py](./UnbindMaterial.py)|選択Primに割り当てられているマテリアルのバインドをクリア|
20 |
21 | |サンプル|説明|
22 | |---|---|
23 | |[GetMaterial](./GetMaterial)|マテリアル情報を取得|
24 | |[UsdPreviewSurface](./UsdPreviewSurface)|マテリアルの割り当て (UsdPreviewSurface)|
25 | |[OmniPBR](./OmniPBR)|マテリアルの割り当て (OmniPBR)|
26 |
--------------------------------------------------------------------------------
/Material/textures/stone_01_diffuse.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Material/textures/stone_01_diffuse.png
--------------------------------------------------------------------------------
/Material/textures/stone_01_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Material/textures/stone_01_normal.png
--------------------------------------------------------------------------------
/Material/textures/tile_image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Material/textures/tile_image.png
--------------------------------------------------------------------------------
/Math/CalcDotCrossProduct.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | v1 = Gf.Vec3f(1.0, 2.0, -5.0)
4 | v2 = Gf.Vec3f(2.5, 14.0, 12.0)
5 |
6 | # Dot : Inner product.
7 | print(f"{v1} x {v2} = {v1 * v2}")
8 | print(f"{v1} x {v2} = {Gf.Dot(v1, v2)}")
9 |
10 | # Cross : Outer product.
11 | vx = v1[1] * v2[2] - v1[2] * v2[1]
12 | vy = v1[2] * v2[0] - v1[0] * v2[2]
13 | vz = v1[0] * v2[1] - v1[1] * v2[0]
14 | print(f"Cross product : ( {vx}, {vy}, {vz} )")
15 |
16 | v1_2 = Gf.Vec4f(v1[0], v1[1], v1[2],1.0)
17 | v2_2 = Gf.Vec4f(v2[0], v2[1], v2[2],1.0)
18 | v3_2 = Gf.HomogeneousCross(v1_2, v2_2)
19 | print(f"Cross product : {v3_2}")
20 |
--------------------------------------------------------------------------------
/Math/CalcMatrix.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Identity matrix.
4 | m = Gf.Matrix4f()
5 | print(m)
6 |
7 | # Initialize with rotation and translate.
8 | rotV = Gf.Rotation(Gf.Vec3d(1, 0, 0), 90.0)
9 | transV = Gf.Vec3f(10, 5, 2.3)
10 | m1 = Gf.Matrix4f(rotV, transV)
11 | print(m1)
12 |
13 | # Get data.
14 | for i in range(4):
15 | print(f"{m1[i,0]} , {m1[i,1]} , {m1[i,2]} , {m1[i,3]}")
16 |
17 | # Set identity.
18 | m1.SetIdentity()
19 | print(m1)
20 |
21 | # Matrix multiplication.
22 | rot1 = Gf.Rotation(Gf.Vec3d(1, 0, 0), 90.0)
23 | m2 = Gf.Matrix4f(rot1, Gf.Vec3f())
24 |
25 | rot2 = Gf.Rotation(Gf.Vec3d(0, 1, 0), 30.0)
26 | m3 = Gf.Matrix4f(rot2, Gf.Vec3f())
27 | m4 = m2 * m3 # Gf.Matrix4f * Gf.Matrix4f
28 | print(m4)
29 |
30 | rot3 = rot1 * rot2 # Gf.Rotation * Gf.Rotation
31 | print(Gf.Matrix4f(rot3, Gf.Vec3f()))
32 |
33 | # Inverse matrix.
34 | m4Inv = m4.GetInverse()
35 | print(m4Inv)
36 |
37 | # vector3 * matrix4.
38 | rotV = Gf.Rotation(Gf.Vec3d(1, 0, 0), 90.0)
39 | transV = Gf.Vec3f(10, 5, 2.3)
40 | m5 = Gf.Matrix4f(rotV, transV)
41 |
42 | v1 = Gf.Vec3f(1.2, 1.0, 2.5)
43 | v2 = m5.Transform(v1)
44 | print(f"{v2}")
45 |
46 | # vector3 * matrix4 (Ignore position).
47 | v1 = Gf.Vec3f(1.2, 1.0, 2.5)
48 | v2 = m5.TransformDir(v1)
49 | print(f"{v2}")
50 |
--------------------------------------------------------------------------------
/Math/CalcVector3.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # float vector.
4 | print("\nfloat vector ----\n")
5 | v1 = Gf.Vec3f(1.0, 2.0, -5.0)
6 | v2 = Gf.Vec3f(2.5, 14.0, 12.0)
7 |
8 | v = v1 + v2
9 | print(f"{v1} + {v2} = {v}")
10 |
11 | v = v1 / 2
12 | print(f"{v1} / 2 = {v}")
13 |
14 | print(f"v.x = {v[0]} type = {type(v[0])}")
15 | print(f"v.y = {v[1]} type = {type(v[1])}")
16 | print(f"v.z = {v[2]} type = {type(v[2])}")
17 |
18 | # double vector.
19 | # It seems to be internally converted to Gf.Vec3f.
20 | print("\ndouble vector ----\n")
21 | v1d = Gf.Vec3d(1.0, 2.0, -5.0)
22 | v2d = Gf.Vec3d(2.5, 14.0, 12.0)
23 |
24 | v = v1d + v2d
25 | print("v.x = " + str(v1d[0]) + " type = " + str(type(v1d[0])))
26 |
27 | v = v1d / 2
28 | print(f"{v1d} / 2 = {v}")
29 |
30 | print(f"v.x = {v[0]} type = {type(v[0])}")
31 | print(f"v.y = {v[1]} type = {type(v[1])}")
32 | print(f"v.z = {v[2]} type = {type(v[2])}")
33 |
--------------------------------------------------------------------------------
/Math/DecomposeTransform.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdSkel, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | translate = Gf.Vec3f(10.5, 2.8, 6.0)
4 | rotation = Gf.Quatf(0.7071, 0.7071, 0, 0) # Gf.Rotation(Gf.Vec3d(1, 0, 0), 90)
5 | scale = Gf.Vec3f(2.0, 0.5, 1.0)
6 |
7 | print(f"translate : {translate}")
8 | print(f"rotation : {rotation}")
9 | print(f"scale : {scale}")
10 |
11 | # Make transform.
12 | transM = UsdSkel.MakeTransform(translate, rotation, Gf.Vec3h(scale))
13 | print(f"transform : {transM}")
14 |
15 | # Decompose transform.
16 | translate2, rotation2, scale2 = UsdSkel.DecomposeTransform(transM)
17 | print(f"==> translate : {translate2}")
18 | print(f"==> rotation : {rotation2}")
19 | print(f"==> scale : {scale2}")
20 |
--------------------------------------------------------------------------------
/Math/DecomposeTransform2.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdSkel, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Dump matrix.
4 | def DumpMatrix(m : Gf.Matrix4d):
5 | print("---------------------")
6 | for i in range(4):
7 | print(f"{mm[i,0]} {mm[i,1]} {mm[i,2]} {mm[i,3]}")
8 | print("")
9 |
10 | # Create Matrix4.
11 | translate = Gf.Vec3d(10.5, 2.8, 6.0)
12 | rotation = Gf.Rotation(Gf.Vec3d(0, 1, 0), 20) * Gf.Rotation(Gf.Vec3d(0, 0, 1), 45)
13 | scale = Gf.Vec3d(2.0, 0.5, 1.0)
14 |
15 | mm = Gf.Matrix4d().SetScale(scale) * Gf.Matrix4d(rotation, Gf.Vec3d(0)) * Gf.Matrix4d().SetTranslate(translate)
16 | DumpMatrix(mm)
17 |
18 | # Decompose matrix.
19 | mm2 = mm.RemoveScaleShear()
20 | rTrans = mm2.ExtractTranslation()
21 | rRot = mm2.ExtractRotation()
22 | mm3 = mm * mm2.GetInverse()
23 | rScale = Gf.Vec3d(mm3[0][0], mm3[1][1], mm3[2][2])
24 |
25 | rAxisX = Gf.Vec3d(1, 0, 0)
26 | rAxisY = Gf.Vec3d(0, 1, 0)
27 | rAxisZ = Gf.Vec3d(0, 0, 1)
28 | rRotE = rRot.Decompose(rAxisZ, rAxisY, rAxisX)
29 | rRotE = Gf.Vec3d(rRotE[2], rRotE[1], rRotE[0])
30 |
31 | print(f"Trans : {rTrans}")
32 | print(f"Rot : {rRotE}")
33 | print(f"Scale : {rScale}")
34 |
35 |
--------------------------------------------------------------------------------
/Math/GetVector3Length.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | v1 = Gf.Vec3f(1.0, 2.0, -5.0)
4 | v2 = Gf.Vec3f(2.5, 14.0, 12.0)
5 | print(f"{v1} : Length = {v1.GetLength()}")
6 | print(f"{v2} : Length = {v2.GetLength()}")
7 |
--------------------------------------------------------------------------------
/Math/NormalizeVector3.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | v1 = Gf.Vec3f(1.0, 2.0, -5.0)
4 | v1N = v1.GetNormalized()
5 | print(f"{v1} ==> {v1N}")
6 |
--------------------------------------------------------------------------------
/Math/QuatToRotation.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdSkel, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | rotation = Gf.Quatf(0.7071, 0.7071, 0, 0)
4 | print(f"quat : {rotation}")
5 |
6 | # Convert from quaternion to Euler's rotation angles(degree).
7 | # Rotate XYZ.
8 | rot = Gf.Rotation(rotation)
9 | rV = rot.Decompose(Gf.Vec3d(0, 0, 1), Gf.Vec3d(0, 1, 0), Gf.Vec3d(1, 0, 0))
10 | rV = Gf.Vec3d(rV[2], rV[1], rV[0])
11 | print(f"Euler's rotation angles : {rV}")
12 |
13 | # RotationXYZ to quaternion.
14 | rotX = Gf.Rotation(Gf.Vec3d(1, 0, 0), 90.0)
15 | rotY = Gf.Rotation(Gf.Vec3d(0, 1, 0), 30.0)
16 | rotZ = Gf.Rotation(Gf.Vec3d(0, 0, 1), -10.0)
17 | rotXYZ = rotX * rotY * rotZ
18 | q = rotXYZ.GetQuat()
19 | print("quaternion : " + str(q))
20 |
21 | # Quaternion to RotateXYZ.
22 | rV = Gf.Rotation(q).Decompose(Gf.Vec3d(0, 0, 1), Gf.Vec3d(0, 1, 0), Gf.Vec3d(1, 0, 0))
23 | rV = Gf.Vec3d(rV[2], rV[1], rV[0])
24 | print(" Euler's rotation angles : " + str(rV))
25 |
--------------------------------------------------------------------------------
/Math/TransRotationFrom2Vec.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdShade, Sdf, Gf, Tf
2 |
3 | # No need to normalize.
4 | dirA = Gf.Vec3f(1.0, 0.0, 0.0).GetNormalized()
5 | dirB = Gf.Vec3f(-0.2, 12.0, 15.0).GetNormalized()
6 |
7 | print(f"dirA : {dirA}")
8 | print(f"dirB : {dirB}")
9 |
10 | # Calculate the rotation to transform dirA to dirB.
11 | rot = Gf.Rotation().SetRotateInto(Gf.Vec3d(dirA), Gf.Vec3d(dirB))
12 |
13 | # Check that rot is correct.
14 | # v will have the same result as dirB.
15 | m = Gf.Matrix4f(rot, Gf.Vec3f(0, 0, 0))
16 | v = m.Transform(dirA)
17 | print(f"dirA * m = {v}")
18 |
--------------------------------------------------------------------------------
/Math/VectorToRotationAngle.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdShade, Sdf, Gf, Tf
2 |
3 | dirV = Gf.Vec3f(20.0, 5.0, -25.0)
4 |
5 | yUp = Gf.Vec3f(0, 1, 0)
6 | m = Gf.Matrix4f().SetLookAt(Gf.Vec3f(0, 0, 0), dirV.GetNormalized(), yUp)
7 |
8 | # Rotate XYZ.
9 | rV = m.ExtractRotation().Decompose(Gf.Vec3d(0, 0, 1), Gf.Vec3d(0, 1, 0), Gf.Vec3d(1, 0, 0))
10 | rV = Gf.Vec3d(rV[2], rV[1], rV[0])
11 |
12 | print(f"rotateXYZ(Euler) : {rV}")
13 |
14 |
--------------------------------------------------------------------------------
/Math/readme.md:
--------------------------------------------------------------------------------
1 | # Math
2 |
3 | ベクトルや行列計算関連。
4 | USDのベクトル/行列計算は、"Gf"にまとまっているためそれを使用します。
5 | numpyを経由しなくても計算できます。
6 |
7 | ベクトルはfloat型のGf.Vec3f ( https://graphics.pixar.com/usd/release/api/class_gf_vec3f.html )、
8 | double型のGf.Vec3d ( https://graphics.pixar.com/usd/release/api/class_gf_vec3d.html )が使用されます。
9 |
10 | 行列はfloat型のGf.Matrix4f ( https://graphics.pixar.com/usd/release/api/class_gf_matrix4f.html )、
11 | double型のGf.Matrix4d ( https://graphics.pixar.com/usd/release/api/class_gf_matrix4d.html )が使用されます。
12 |
13 |
14 | |ファイル|説明|
15 | |---|---|
16 | |[CalcDotCrossProduct.py](./CalcDotCrossProduct.py)|ベクトルの内積/外積計算|
17 | |[CalcMatrix.py](./CalcMatrix.py)|4x4行列の計算。行列とベクトルの乗算|
18 | |[CalcVector3.py](./CalcVector3.py)|Vector3の計算.|
19 | |[DecomposeTransform.py](./DecomposeTransform.py)|行列を移動(translate), 回転(rotation), スケール(scale)に変換。UsdSkelを使用。|
20 | |[DecomposeTransform2.py](./DecomposeTransform2.py)|行列を移動(translate), 回転(rotation), スケール(scale)に変換|
21 | |[GetVector3Length.py](./GetVector3Length.py)|Vector3の長さを計算|
22 | |[VectorToRotationAngle.py](./VectorToRotationAngle.py)|指定のベクトルをXYZ軸回転の角度(度数)に変換|
23 | |[NormalizeVector3.py](./NormalizeVector3.py)|Vector3の正規化|
24 | |[QuatToRotation.py](./QuatToRotation.py)|クォータニオンと回転角度(度数)の変換|
25 | |[TransRotationFrom2Vec.py](./TransRotationFrom2Vec.py)|ベクトルAをベクトルBに変換する回転を計算。|
26 | |[ConvRGB2SRGB.py](./ConvRGB2SRGB.py)|色のsRGBとRGBの相互変換。|
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/Nucleus/FileCopy.py:
--------------------------------------------------------------------------------
1 | # See : https://docs.omniverse.nvidia.com/py/kit/source/extensions/omni.client/docs/index.html
2 |
3 | import asyncio
4 | import omni.client
5 |
6 | # The following should be rewritten for your environment.
7 | srcURL = "K:\\NVIDIA_omniverse\\images\\tile_image.png"
8 | dstURL = "omniverse://localhost/test/tile_image.png"
9 |
10 | # Copy a file or folder.
11 | # When copying is complete, proceed.
12 | result = omni.client.copy(srcURL, dstURL)
13 | if result == omni.client.Result.OK:
14 | print("success !")
15 | else:
16 | print("failed ...")
17 |
18 |
--------------------------------------------------------------------------------
/Nucleus/ReadImageFile.py:
--------------------------------------------------------------------------------
1 | # See : https://docs.omniverse.nvidia.com/py/kit/source/extensions/omni.client/docs/index.html
2 |
3 | import io
4 | import omni.client
5 | from PIL import Image
6 |
7 | result, vers, content = omni.client.read_file("omniverse://localhost/Users/test/xxx.png")
8 | if result != omni.client.Result.ERROR_NOT_FOUND:
9 | image_data = memoryview(content).tobytes()
10 | image = Image.open(io.BytesIO(image_data))
11 |
12 | # Show Image.
13 | image.show()
14 |
15 | # Save Image.
16 | #image.save("C:\\temp\\xxx.png")
17 |
18 |
--------------------------------------------------------------------------------
/Nucleus/createFolder.py:
--------------------------------------------------------------------------------
1 | # See : https://docs.omniverse.nvidia.com/py/kit/source/extensions/omni.client/docs/index.html
2 |
3 | import asyncio
4 | import omni.client
5 |
6 | # The following should be rewritten for your environment.
7 | url = "omniverse://localhost/test/new_folder"
8 |
9 | result = omni.client.create_folder(url)
10 | if result == omni.client.Result.OK:
11 | print("success !")
12 | else:
13 | print("failed ...")
14 |
15 |
--------------------------------------------------------------------------------
/Nucleus/deleteFile.py:
--------------------------------------------------------------------------------
1 | # See : https://docs.omniverse.nvidia.com/py/kit/source/extensions/omni.client/docs/index.html
2 |
3 | import asyncio
4 | import omni.client
5 |
6 | # The following should be rewritten for your environment.
7 | url = "omniverse://localhost/test/new_folder"
8 |
9 | # Delete file or folder.
10 | result = omni.client.delete(url)
11 | if result == omni.client.Result.OK:
12 | print("success !")
13 | else:
14 | print("failed ...")
15 |
16 |
--------------------------------------------------------------------------------
/Nucleus/existPath.py:
--------------------------------------------------------------------------------
1 | # See : https://docs.omniverse.nvidia.com/py/kit/source/extensions/omni.client/docs/index.html
2 |
3 | import asyncio
4 | import omni.client
5 |
6 | # Check for the existence of the specified path.
7 | async def existPath (path : str):
8 | (result, entry) = await omni.client.stat_async(path)
9 | if result == omni.client.Result.ERROR_NOT_FOUND:
10 | print("Does not exist : " + path)
11 | return
12 |
13 | print("Exist : " + path)
14 |
15 | # Awaiting results.
16 | async def _ocl_existPath (path : str):
17 | (result, entry) = await omni.client.stat_async(path)
18 | if result == omni.client.Result.ERROR_NOT_FOUND:
19 | return False
20 | return True
21 |
22 | def ocl_existPath (path : str):
23 | loop = asyncio.get_event_loop()
24 | return loop.run_until_complete(_ocl_existPath(path))
25 |
26 | # ------------------------------------------.
27 | path1 = "omniverse://localhost/Users/test"
28 | asyncio.ensure_future(existPath(path1))
29 |
30 | path2 = "omniverse://localhost/Users/test/xxx.usd"
31 | asyncio.ensure_future(existPath(path2))
32 |
33 |
34 | if ocl_existPath(path1):
35 | print("Exist : " + path1)
36 | else:
37 | print("Does not exist : " + path1)
38 |
--------------------------------------------------------------------------------
/Nucleus/readme.md:
--------------------------------------------------------------------------------
1 | # Nucleus
2 |
3 | OmniverseではUSDからの保存はNucleusの指定のパス(omniverse://localhost/xxx/yyy.usd)に出力できます。
4 | 別途、Nucleus上でファイル操作を行う「omni.client」が用意されています。
5 |
6 |
7 | ## 参考
8 |
9 | https://docs.omniverse.nvidia.com/py/kit/source/extensions/omni.client/docs/index.html
10 |
11 | ## サンプル
12 |
13 | |ファイル|説明|
14 | |---|---|
15 | |[existPath.py](./existPath.py)|Nucleus上のファイルまたはフォルダが存在するかチェック。|
16 | |[listFiles.py](./listFiles.py)|Nucleus上の指定のフォルダ内のファイルを一覧。|
17 | |[FileCopy.py](./FileCopy.py)|ローカルからNucleus上にファイルを転送。|
18 | |[createFolder.py](./createFolder.py)|Nucleus上にフォルダを作成。|
19 | |[deleteFile.py](./deleteFile.py)|Nucleus上のファイルやフォルダを削除。|
20 | |[ReadImageFile.py](./ReadImageFile.py)|Nucleus上の画像ファイルをPIL.Imageに読み込み。|
21 |
22 |
--------------------------------------------------------------------------------
/Operation/CommandsExecute/CopyPrim.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 | import omni.kit
3 |
4 | # Get stage.
5 | stage = omni.usd.get_context().get_stage()
6 |
7 | # Get selection.
8 | selection = omni.usd.get_context().get_selection()
9 | selectedPaths = selection.get_selected_prim_paths()
10 |
11 | newPrimPathList = []
12 | for path in selectedPaths:
13 | # Duplicate Prim from specified path.
14 | omni.kit.commands.execute("CopyPrim", path_from=path)
15 |
16 | # Stores the path of the newly duplicated Prim.
17 | selection = omni.usd.get_context().get_selection()
18 | paths = selection.get_selected_prim_paths()
19 | if len(paths) >= 1:
20 | newPrimPathList.append(paths[0])
21 |
22 | # Show the path of the newly duplicated Prim.
23 | print(newPrimPathList)
24 |
--------------------------------------------------------------------------------
/Operation/CommandsExecute/DeletePrims.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 | import omni.kit
3 |
4 | # Get stage.
5 | stage = omni.usd.get_context().get_stage()
6 |
7 | # Get selection.
8 | selection = omni.usd.get_context().get_selection()
9 | selectedPaths = selection.get_selected_prim_paths()
10 |
11 | # Delete prims.
12 | omni.kit.commands.execute("DeletePrims", paths=selectedPaths)
13 |
--------------------------------------------------------------------------------
/Operation/CommandsExecute/GetCommandsList.py:
--------------------------------------------------------------------------------
1 | import omni.kit
2 |
3 | # Get commands list (dict).
4 | listA = omni.kit.commands.get_commands()
5 | keys = listA.keys()
6 |
7 | print(str(keys))
8 |
--------------------------------------------------------------------------------
/Operation/CommandsExecute/MovePrim.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 | import omni.kit
3 |
4 | # Get stage.
5 | stage = omni.usd.get_context().get_stage()
6 |
7 | # Get default prim.
8 | defaultPrim = stage.GetDefaultPrim()
9 |
10 | # Create empty node(Xform).
11 | defaultPrimPath = defaultPrim.GetPath().pathString
12 | xformPath = defaultPrimPath + '/Xform'
13 | UsdGeom.Xform.Define(stage, xformPath)
14 |
15 | # Get selection.
16 | selection = omni.usd.get_context().get_selection()
17 | selectedPaths = selection.get_selected_prim_paths()
18 |
19 | for path in selectedPaths:
20 | # Get prim.
21 | prim = stage.GetPrimAtPath(path)
22 | if prim.IsValid() == False:
23 | continue
24 |
25 | pathTo = xformPath + "/" + str(prim.GetName())
26 |
27 | # Change Prim's path.
28 | # path_from : Path of the original Prim.
29 | # path_to : Path to move to.
30 | omni.kit.commands.execute("MovePrim", path_from=path, path_to=pathTo)
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Operation/CommandsExecute/RenamePrim.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 | import omni.kit
3 |
4 | # Get stage.
5 | stage = omni.usd.get_context().get_stage()
6 |
7 | # Get selection.
8 | selection = omni.usd.get_context().get_selection()
9 | selectedPaths = selection.get_selected_prim_paths()
10 |
11 | for path in selectedPaths:
12 | # Get prim.
13 | prim = stage.GetPrimAtPath(path)
14 | if prim.IsValid() == False:
15 | continue
16 |
17 | newPathName = path + "_rename"
18 |
19 | # Rename Prim name.
20 | omni.kit.commands.execute("MovePrim", path_from=path, path_to=newPathName)
21 | break
22 |
--------------------------------------------------------------------------------
/Operation/CommandsExecute/SelectNone.py:
--------------------------------------------------------------------------------
1 | import omni.kit
2 |
3 | omni.kit.commands.execute("SelectNone")
4 |
--------------------------------------------------------------------------------
/Operation/CommandsExecute/readme.md:
--------------------------------------------------------------------------------
1 | # Execute
2 |
3 | omni.kit.commandsを使用して、Omniverseのコマンドを実行します。
4 |
5 | ## サンプル
6 |
7 | |ファイル|説明|
8 | |---|---|
9 | |[GetCommandsList.py](./GetCommandsList.py)|コマンドのリストを一覧。|
10 | |[SelectNone.py](./SelectNone.py)|Stageウィンドウでの選択を解除|
11 | |[CopyPrim.py](./CopyPrim.py)|選択されたPrimの複製を作成|
12 | |[DeletePrims.py](./DeletePrims.py)|選択されたPrimを削除|
13 | |[MovePrim.py](./MovePrim.py)|選択されたPrimのパスを変更。
/World/Xform 内に選択されたPrimを移動する。|
14 | |[RenamePrim.py](./RenamePrim.py)|選択されたPrimの名前を変更。
"MovePrim"でPrimの名前変更できる。|
15 |
--------------------------------------------------------------------------------
/Operation/FocusPrim.py:
--------------------------------------------------------------------------------
1 | # "omni.kit.viewport_legacy" is no longer available in kit104.
2 | #import omni.kit.viewport_legacy
3 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
4 | import omni.kit.commands
5 |
6 | # Kit104 : changed from omni.kit.viewport_legacy to omni.kit.viewport.utility.get_active_viewport_window
7 | import omni.kit.viewport.utility
8 |
9 | # Get active viewport window.
10 | active_vp_window = omni.kit.viewport.utility.get_active_viewport_window()
11 | viewport_api = active_vp_window.viewport_api
12 |
13 | # Get camera path ("/OmniverseKit_Persp" etc).
14 | cameraPath = viewport_api.camera_path.pathString
15 |
16 | # Get stage.
17 | stage = omni.usd.get_context().get_stage()
18 |
19 | #time_code = omni.timeline.get_timeline_interface().get_current_time() * stage.GetTimeCodesPerSecond()
20 | time_code = Usd.TimeCode()
21 |
22 | # Get active camera.
23 | cameraPrim = stage.GetPrimAtPath(cameraPath)
24 | if cameraPrim.IsValid():
25 | camera = UsdGeom.Camera(cameraPrim) # UsdGeom.Camera
26 | cameraV = camera.GetCamera(time_code) # Gf.Camera
27 |
28 | # Aspect ratio.
29 | aspect = cameraV.aspectRatio
30 |
31 | # Taret prim path.
32 | targetPrimPath = "/World/Sphere"
33 |
34 | prim = stage.GetPrimAtPath(targetPrimPath)
35 | if prim.IsValid():
36 | # Set focus.
37 | omni.kit.commands.execute('FramePrimsCommand',
38 | prim_to_move=Sdf.Path(cameraPath),
39 | prims_to_frame=[targetPrimPath],
40 | time_code=time_code,
41 | usd_context_name='',
42 | aspect_ratio=aspect)
43 |
44 |
45 |
--------------------------------------------------------------------------------
/Operation/GamePad/images/gamepad_image_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Operation/GamePad/images/gamepad_image_01.jpg
--------------------------------------------------------------------------------
/Operation/GamePad/readme.md:
--------------------------------------------------------------------------------
1 | # GamePad
2 |
3 | GamePadでの操作を取得します。
4 | XBOX Controllerの場合は以下のような入力になります。
5 | 
6 |
7 | |入力|値|
8 | |---|---|
9 | |carb.input.GamepadInput.LEFT_SHOULDER|0 or 1|
10 | |carb.input.GamepadInput.RIGHT_SHOULDER|0 or 1|
11 | |carb.input.GamepadInput.LEFT_TRIGGER|0 - 1|
12 | |carb.input.GamepadInput.RIGHT_TRIGGER|0 - 1|
13 | |carb.input.GamepadInput.DPAD_DOWN
carb.input.GamepadInput.DPAD_UP
carb.input.GamepadInput.DPAD_LEFT
carb.input.GamepadInput.DPAD_RIGHT|0 or 1|
14 | |carb.input.GamepadInput.X|0 or 1|
15 | |carb.input.GamepadInput.Y|0 or 1|
16 | |carb.input.GamepadInput.A|0 or 1|
17 | |carb.input.GamepadInput.B|0 or 1|
18 | |carb.input.GamepadInput.MENU1|0 or 1|
19 | |carb.input.GamepadInput.MENU2|0 or 1|
20 | |carb.input.GamepadInput.LEFT_STICK_DOWN
carb.input.GamepadInput.LEFT_STICK_UP
carb.input.GamepadInput.LEFT_STICK_LEFT
carb.input.GamepadInput.LEFT_STICK_RIGHT|0 - 1|
21 | |carb.input.GamepadInput.RIGHT_STICK_DOWN
carb.input.GamepadInput.RIGHT_STICK_UP
carb.input.GamepadInput.RIGHT_STICK_LEFT
carb.input.GamepadInput.RIGHT_STICK_RIGHT|0 - 1|
22 | |carb.input.GamepadInput.LEFT_STICK |0 or 1|
23 | |carb.input.GamepadInput.RIGHT_STICK |0 or 1|
24 |
25 | ## サンプル
26 |
27 | |ファイル|説明|
28 | |---|---|
29 | |[GamePad.py](./GamePad.py)|GamePad情報を取得(特定のボタンのみ)|
30 | |[GamePad_moveSelectPrim.py](./GamePad_moveSelectPrim.py)|GamePadのLeftStick操作で選択形状を移動|
31 |
--------------------------------------------------------------------------------
/Operation/Keyboard/InputKeyboard.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdSkel, UsdShade, Sdf, Gf, Tf
2 |
3 | import carb
4 | import carb.input
5 | import omni.kit.app
6 | import omni.ext
7 |
8 | # ------------------------------------------.
9 | # Input with Keyboard.
10 | # ------------------------------------------.
11 | class InputKeyboard:
12 | _keyboard = None
13 | _input = None
14 | _keyboard_subs = None
15 |
16 | def __init__(self):
17 | pass
18 |
19 | # Keyboard event.
20 | def _keyboard_event (self, event : carb.input.KeyboardEvent):
21 | if event.type == carb.input.KeyboardEventType.KEY_PRESS:
22 | print("KEY_PRESS : " + str(event.input))
23 | if event.type == carb.input.KeyboardEventType.KEY_RELEASE:
24 | print("KEY_RELEASE : " + str(event.input))
25 | return True
26 |
27 | def startup (self):
28 | # Assign keyboard event.
29 | appwindow = omni.appwindow.get_default_app_window()
30 | self._keyboard = appwindow.get_keyboard()
31 | self._input = carb.input.acquire_input_interface()
32 | self._keyboard_subs = self._input.subscribe_to_keyboard_events(self._keyboard, self._keyboard_event)
33 |
34 | def shutdown (self):
35 | # Release keyboard event.
36 | if self._input != None:
37 | self._input.unsubscribe_to_keyboard_events(self._keyboard, self._keyboard_subs)
38 |
39 | self._keyboard_subs = None
40 | self._keyboard = None
41 | self._input = None
42 |
43 | # -----------------------------------------.
44 | keyboardV = InputKeyboard()
45 | keyboardV.startup()
46 |
47 | # stop.
48 | #keyboardV.shutdown()
49 |
50 |
--------------------------------------------------------------------------------
/Operation/Keyboard/readme.md:
--------------------------------------------------------------------------------
1 | # Keyboard
2 |
3 | キーボードの入力を取得します。
4 |
5 | ## サンプル
6 |
7 | |ファイル|説明|
8 | |---|---|
9 | |[InputKeyboard.py](./InputKeyboard.py)|キーボードの入力を取得。|
10 | |[InputKeyboard_ShowViewport.py](./InputKeyboard_ShowViewport.py)|キーボードの入力を取得し、キー入力をViewportの左上に表示。|
11 |
12 |
--------------------------------------------------------------------------------
/Operation/Selection/EventSelection.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get context.
4 | context = omni.usd.get_context()
5 |
6 | # Get stage.
7 | stage = context.get_stage()
8 |
9 | # ---------------------------------------------.
10 | # Selected event.
11 | # ---------------------------------------------.
12 | def onStageEvent(evt):
13 | if evt.type == int(omni.usd.StageEventType.SELECTION_CHANGED):
14 | # Get selection paths.
15 | selection = omni.usd.get_context().get_selection()
16 | paths = selection.get_selected_prim_paths()
17 |
18 | for path in paths:
19 | prim = stage.GetPrimAtPath(path)
20 | if prim.IsValid() == True:
21 | print('Selected [ ' + prim.GetName() + ' ]')
22 |
23 | # ------------------------------------------------.
24 | # Register for stage events.
25 | # Specify "subs=None" to end the event.
26 | subs = context.get_stage_event_stream().create_subscription_to_pop(onStageEvent, name="sampleStageEvent")
27 |
--------------------------------------------------------------------------------
/Operation/Selection/GetSelection.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get selection.
4 | selection = omni.usd.get_context().get_selection()
5 | paths = selection.get_selected_prim_paths()
6 |
7 | for path in paths:
8 | print(path)
9 |
10 |
--------------------------------------------------------------------------------
/Operation/Selection/IsSelected.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get selection.
4 | selection = omni.usd.get_context().get_selection()
5 |
6 | pathStr = '/World'
7 | selectedF = selection.is_prim_path_selected(pathStr)
8 | if selectedF:
9 | print('[' + pathStr + ' ] Selected')
10 | else:
11 | print('[' + pathStr + ' ] Not selected')
12 |
13 |
--------------------------------------------------------------------------------
/Operation/Selection/Select.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get selection.
4 | selection = omni.usd.get_context().get_selection()
5 |
6 | # Select one.
7 | selection.set_selected_prim_paths(['/World'], True)
8 |
9 | # Multiple selection.
10 | selection.set_selected_prim_paths(['/World', '/World/defaultLight'], True)
11 |
12 | # Deselection.
13 | selection.clear_selected_prim_paths()
14 |
--------------------------------------------------------------------------------
/Operation/Selection/images/EventSelection_showFacesCount.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Operation/Selection/images/EventSelection_showFacesCount.jpg
--------------------------------------------------------------------------------
/Operation/Selection/readme.md:
--------------------------------------------------------------------------------
1 | # Selection
2 |
3 | StageウィンドウでのPrimの選択を取得。
4 |
5 | |ファイル|説明|
6 | |---|---|
7 | |[GetSelection.py](./GetSelection.py)|Primの選択を取得|
8 | |[IsSelected.py](./IsSelected.py)|指定されたパスのPrimが選択されているかどうか|
9 | |[Select.py](./Select.py)|指定されたパスのPrimを選択|
10 | |[EventSelection.py](./EventSelection.py)|選択変更イベントを取得し、選択されたPrim名を表示|
11 | |[EventSelection_showFacesCount.py](./EventSelection_showFacesCount.py)|選択されたPrim名、子要素も含めたMeshの面数をビューポートに表示

12 |
13 |
--------------------------------------------------------------------------------
/Operation/UNDO/CreateSphereUndo.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 | import omni.kit.commands
3 | import omni.kit.undo
4 |
5 | # Get stage.
6 | stage = omni.usd.get_context().get_stage()
7 |
8 | # Process to create a sphere.
9 | class MyCreateSphere (omni.kit.commands.Command):
10 | _path = ""
11 |
12 | def __init__ (self, path : str):
13 | self._path = path
14 |
15 | def do (self):
16 | sphereGeom = UsdGeom.Sphere.Define(stage, self._path)
17 |
18 | # Set radius.
19 | sphereGeom.CreateRadiusAttr(5.0)
20 |
21 | # Set color.
22 | sphereGeom.CreateDisplayColorAttr([(1.0, 0.0, 0.0)])
23 |
24 | # Set position.
25 | UsdGeom.XformCommonAPI(sphereGeom).SetTranslate((0.0, 5.0, 0.0))
26 |
27 | def undo (self):
28 | stage.RemovePrim(self._path)
29 |
30 | # Create sphere.
31 | pathName = '/World/sphere'
32 |
33 | # Register a Class and run it.
34 | omni.kit.commands.register(MyCreateSphere)
35 | omni.kit.commands.execute("MyCreateSphere", path=pathName)
36 |
37 | # UNDO.
38 | omni.kit.undo.undo()
39 |
40 | # REDO.
41 | omni.kit.undo.redo()
42 |
--------------------------------------------------------------------------------
/Operation/UNDO/readme.md:
--------------------------------------------------------------------------------
1 | # UNDO
2 |
3 | UNDO処理。
4 | 特にSkeleton情報を変更する場合、UNDOに対応しないと正常に動作しないケースがありました。
5 | Omniverse Kitのドキュメントの"Bundled Extensions/omni.kit.commands"が参考になります。
6 |
7 | |ファイル|説明|
8 | |---|---|
9 | |[simpleClassUNDO.py](./simpleClassUNDO.py)|classを使用してUNDO対応。|
10 | |[CreateSphereUndo.py](./CreateSphereUndo.py)|球を生成する処理でUNDO対応して位置|
11 |
12 |
13 |
--------------------------------------------------------------------------------
/Operation/UNDO/simpleClassUndo.py:
--------------------------------------------------------------------------------
1 | # From "Bundled Extensions/omni.kit.commands" in Omniverse Kit documentation.
2 | import omni.kit.commands
3 | import omni.kit.undo
4 |
5 | # Class for UNDO processing.
6 | class MyOrange (omni.kit.commands.Command):
7 | def __init__ (self, bar: list):
8 | self._bar = bar
9 |
10 | def do (self):
11 | self._bar.append('orange')
12 |
13 | def undo (self):
14 | del self._bar[-1]
15 |
16 | # Register a Class and run it.
17 | omni.kit.commands.register(MyOrange)
18 | my_list = []
19 | omni.kit.commands.execute("MyOrange", bar=my_list)
20 | print(my_list)
21 |
22 | # UNDO.
23 | omni.kit.undo.undo()
24 | print(my_list)
25 |
26 | # REDO.
27 | omni.kit.undo.redo()
28 | print(my_list)
29 |
30 |
31 |
--------------------------------------------------------------------------------
/Operation/readme.md:
--------------------------------------------------------------------------------
1 | # Operation
2 |
3 | Ominverseの操作/イベント処理を行います。
4 |
5 | |ファイル|説明|
6 | |---|---|
7 | |[FocusPrim.py](./FocusPrim.py)|Kit104以上で動作。
指定のPrim(ここでは"/World/Sphere")にフォーカスを合わせる
(キーボードの[F]をプッシュした時と同じ動作)|
8 |
9 | |サンプル|説明|
10 | |---|---|
11 | |[Selection](./Selection)|Stageウィンドウでの選択を取得|
12 | |[GamePad](./GamePad)|GamePadの入力イベント取得|
13 | |[Keyboard](./Keyboard)|Keyboardの入力イベント取得|
14 | |[UNDO](./UNDO)|UNDO処理|
15 | |[CommandsExecute](./CommandsExecute)|omni.kit.commandsを使用したコマンド実行|
16 |
17 |
--------------------------------------------------------------------------------
/PLATEAU/calcDistance.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 | import omni.usd
3 |
4 | # Get stage.
5 | stage = omni.usd.get_context().get_stage()
6 |
7 | # -------------------------------------------------.
8 | # Calculate bounding box in world coordinates.
9 | # -------------------------------------------------.
10 | def _calcWorldBoundingBox (prim : Usd.Prim):
11 | # Calc world boundingBox.
12 | bboxCache = UsdGeom.BBoxCache(Usd.TimeCode.Default(), ["default"])
13 | bboxD = bboxCache.ComputeWorldBound(prim).ComputeAlignedRange()
14 | bb_min = Gf.Vec3f(bboxD.GetMin())
15 | bb_max = Gf.Vec3f(bboxD.GetMax())
16 | return bb_min, bb_max
17 |
18 | # -------------------------------------------------.
19 | # Calculate the distance between two selected shapes.
20 | # -------------------------------------------------.
21 | # Get selection.
22 | selection = omni.usd.get_context().get_selection()
23 | paths = selection.get_selected_prim_paths()
24 |
25 | wPosList = []
26 | for path in paths:
27 | # Get prim.
28 | prim = stage.GetPrimAtPath(path)
29 | if prim.IsValid():
30 | bbMin, bbMax = _calcWorldBoundingBox(prim)
31 | wCenter = Gf.Vec3f((bbMax[0] + bbMin[0]) * 0.5, (bbMax[1] + bbMin[1]) * 0.5, (bbMax[2] + bbMin[2]) * 0.5)
32 | wPosList.append(wCenter)
33 | continue
34 |
35 | if len(wPosList) == 2:
36 | distV = (wPosList[1] - wPosList[0]).GetLength()
37 | print("Distance : " + str(distV) + " cm ( " + str(distV * 0.01) + " m)")
38 |
39 |
--------------------------------------------------------------------------------
/PLATEAU/images/plateau_01_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/PLATEAU/images/plateau_01_01.jpg
--------------------------------------------------------------------------------
/PLATEAU/images/plateau_01_02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/PLATEAU/images/plateau_01_02.jpg
--------------------------------------------------------------------------------
/PLATEAU/images/plateau_02_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/PLATEAU/images/plateau_02_01.jpg
--------------------------------------------------------------------------------
/PLATEAU/images/plateau_02_02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/PLATEAU/images/plateau_02_02.jpg
--------------------------------------------------------------------------------
/PLATEAU/images/plateau_03_00.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/PLATEAU/images/plateau_03_00.jpg
--------------------------------------------------------------------------------
/PLATEAU/images/plateau_03_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/PLATEAU/images/plateau_03_01.jpg
--------------------------------------------------------------------------------
/PLATEAU/images/plateau_03_02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/PLATEAU/images/plateau_03_02.jpg
--------------------------------------------------------------------------------
/PLATEAU/images/plateau_04_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/PLATEAU/images/plateau_04_01.jpg
--------------------------------------------------------------------------------
/PLATEAU/images/plateau_calc_dist_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/PLATEAU/images/plateau_calc_dist_01.jpg
--------------------------------------------------------------------------------
/PLATEAU/images/plateau_calc_lat_longi_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/PLATEAU/images/plateau_calc_lat_longi_01.jpg
--------------------------------------------------------------------------------
/PLATEAU/images/plateau_calc_lat_longi_02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/PLATEAU/images/plateau_calc_lat_longi_02.jpg
--------------------------------------------------------------------------------
/PLATEAU/images/plateau_collectAsset_01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/PLATEAU/images/plateau_collectAsset_01.png
--------------------------------------------------------------------------------
/PLATEAU/images/plateau_collectAsset_02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/PLATEAU/images/plateau_collectAsset_02.png
--------------------------------------------------------------------------------
/Physics/images/physics_gears_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Physics/images/physics_gears_01.jpg
--------------------------------------------------------------------------------
/Physics/images/physics_joint_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Physics/images/physics_joint_01.jpg
--------------------------------------------------------------------------------
/Physics/images/physics_joint_02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Physics/images/physics_joint_02.jpg
--------------------------------------------------------------------------------
/Physics/images/physics_raycast_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Physics/images/physics_raycast_01.jpg
--------------------------------------------------------------------------------
/Physics/images/physics_rigidbody_00.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Physics/images/physics_rigidbody_00.jpg
--------------------------------------------------------------------------------
/Physics/images/physics_rigidbody_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Physics/images/physics_rigidbody_01.jpg
--------------------------------------------------------------------------------
/Physics/images/physics_settings.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Physics/images/physics_settings.jpg
--------------------------------------------------------------------------------
/PostProcessing/ChangePostProcessing.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdShade, Sdf, Gf, Tf
2 | import omni.kit
3 |
4 | # Change Post Processing parameter.
5 | omni.kit.commands.execute("ChangeSetting", path="rtx/post/lensFlares/enabled", value=True)
6 | omni.kit.commands.execute("ChangeSetting", path="rtx/post/lensFlares/flareScale", value=0.2)
7 |
--------------------------------------------------------------------------------
/PostProcessing/images/postprocessing_01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/PostProcessing/images/postprocessing_01.png
--------------------------------------------------------------------------------
/PostProcessing/readme.md:
--------------------------------------------------------------------------------
1 | # Post Processing
2 |
3 | Post Processingの変更を行います。
4 |
5 | Post ProcessingはOmniverse Createの「Post Processings」ウィンドウでパラメータにマウスを合わせたときのツールチップにパスが表示されています。
6 |
7 | 下記の場合は"rtx/post/lensFlares/flareScale"。
8 | 
9 |
10 | もしくはPost Processingの値を変更してusda形式でエクスポートすると、
11 | customLayerDataで以下のように"rtx:post: ... " というパスを確認できます。
12 | ```
13 | dictionary renderSettings = {
14 | bool "rtx:post:lensFlares:enabled" = 1
15 | double "rtx:post:lensFlares:flareScale" = 0.2
16 | double "rtx:post:tonemap:fNumber" = 4.669999895617366
17 | token "rtx:rendermode" = "PathTracing"
18 | }
19 | ```
20 |
21 | Pythonで以下のようにするとその値を変更できます。
22 |
23 | ```python
24 | import omni.kit
25 |
26 | omni.kit.commands.execute("ChangeSetting", path="rtx/post/lensFlares/enabled", value=True)
27 | omni.kit.commands.execute("ChangeSetting", path="rtx/post/lensFlares/flareScale", value=0.2)
28 | ```
29 | 「enabled」がPost Processingのその項目自身を有効/無効にする設定です。
30 |
31 | ## サンプル
32 |
33 | |ファイル|説明|
34 | |---|---|
35 | |[ChangePostProcessing.py](./ChangePostProcessing.py)|Post Processingの"FTT Bloom"のパラメータを変更します。|
--------------------------------------------------------------------------------
/Prim/CalcWorldBoundingBox.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 | import omni.usd
3 |
4 | # Get stage.
5 | stage = omni.usd.get_context().get_stage()
6 |
7 | # Get selection.
8 | selection = omni.usd.get_context().get_selection()
9 | paths = selection.get_selected_prim_paths()
10 |
11 | # -------------------------------------------------.
12 | # Calculate bounding box in world coordinates.
13 | # -------------------------------------------------.
14 | def _calcWorldBoundingBox (prim : Usd.Prim):
15 | # Calc world boundingBox.
16 | bboxCache = UsdGeom.BBoxCache(Usd.TimeCode.Default(), ["default"])
17 | bboxD = bboxCache.ComputeWorldBound(prim).ComputeAlignedRange()
18 | bb_min = Gf.Vec3f(bboxD.GetMin())
19 | bb_max = Gf.Vec3f(bboxD.GetMax())
20 |
21 | return bb_min, bb_max
22 |
23 | # -------------------------------------------------.
24 | for path in paths:
25 | # Get prim.
26 | prim = stage.GetPrimAtPath(path)
27 | if prim.IsValid() == False:
28 | continue
29 |
30 | print("[ " + str(prim.GetName()) + "] ")
31 | bbMin, bbMax = _calcWorldBoundingBox(prim)
32 | print(" BoundingBox : " + str(bbMin) + " - " + str(bbMax))
33 |
34 | sx = bbMax[0] - bbMin[0]
35 | sy = bbMax[1] - bbMin[1]
36 | sz = bbMax[2] - bbMin[2]
37 | print(" BoundingBoxSize : " + str(sx) + " x " + str(sy) + " x " + str(sz))
38 |
--------------------------------------------------------------------------------
/Prim/CreateScope.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get default prim.
7 | defaultPrim = stage.GetDefaultPrim()
8 |
9 | defaultPrimPath = defaultPrim.GetPath().pathString
10 | path = defaultPrimPath + '/scope'
11 |
12 | # Create scope.
13 | UsdGeom.Scope.Define(stage, path)
14 |
15 |
--------------------------------------------------------------------------------
/Prim/CreateXform.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get default prim.
7 | defaultPrim = stage.GetDefaultPrim()
8 |
9 | defaultPrimPath = defaultPrim.GetPath().pathString
10 | path = defaultPrimPath + '/xform'
11 |
12 | # Create empty node(Xform).
13 | UsdGeom.Xform.Define(stage, path)
14 |
15 |
--------------------------------------------------------------------------------
/Prim/GetChildren.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get selection.
7 | selection = omni.usd.get_context().get_selection()
8 | paths = selection.get_selected_prim_paths()
9 |
10 | for path in paths:
11 | # Get prim.
12 | prim = stage.GetPrimAtPath(path)
13 | if prim.IsValid() == False:
14 | continue
15 |
16 | # Get children.
17 | pChildren = prim.GetChildren()
18 | if len(pChildren) >= 1:
19 | print("[ " + prim.GetPath().pathString + " ]")
20 | for cPrim in pChildren:
21 | print(" " + cPrim.GetPath().pathString)
22 |
23 |
--------------------------------------------------------------------------------
/Prim/GetDefaultPrim.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get default prim.
7 | defaultPrim = stage.GetDefaultPrim()
8 |
9 | # Default prim path.
10 | defaultPrimPath = defaultPrim.GetPath().pathString
11 |
12 | print("DefaultPrim : " + defaultPrimPath)
--------------------------------------------------------------------------------
/Prim/GetDoubleSided.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get selection.
7 | selection = omni.usd.get_context().get_selection()
8 | paths = selection.get_selected_prim_paths()
9 |
10 | for path in paths:
11 | # Get prim.
12 | prim = stage.GetPrimAtPath(path)
13 | if prim.IsValid() == False:
14 | continue
15 |
16 | try:
17 | gprim = UsdGeom.Gprim(prim)
18 | doubleSidedAttr = gprim.GetDoubleSidedAttr()
19 | if doubleSidedAttr != None and doubleSidedAttr.IsValid():
20 | # Get doubleSided (True/False).
21 | # The Omniverse Viewport does not reflect "doubleSided", but "singleSided".
22 | if doubleSidedAttr.Get() != None:
23 | print("[" + prim.GetName() + "] doubleSided : " + str(doubleSidedAttr.Get()))
24 |
25 | # Set DoubleSided.
26 | #doubleSidedAttr.Set(True)
27 |
28 | except Exception as e:
29 | print(e)
30 |
--------------------------------------------------------------------------------
/Prim/GetParent.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get selection.
7 | selection = omni.usd.get_context().get_selection()
8 | paths = selection.get_selected_prim_paths()
9 |
10 | for path in paths:
11 | # Get prim.
12 | prim = stage.GetPrimAtPath(path)
13 | if prim.IsValid() == False:
14 | continue
15 |
16 | # Get parent prim.
17 | parentPrim = prim.GetParent()
18 | if parentPrim.IsValid():
19 | print("[ " + prim.GetPath().pathString + " ]")
20 | print(" Parent : " + parentPrim.GetPath().pathString)
21 |
--------------------------------------------------------------------------------
/Prim/GetPrimNamePath.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get prim.
7 | orgPath = "/World/defaultLight"
8 | prim = stage.GetPrimAtPath(orgPath)
9 |
10 | if prim.IsValid():
11 | # Get Prim name.
12 | name = prim.GetName()
13 | print("Name : " + str(name))
14 |
15 | # Get Prim path.
16 | path = prim.GetPath()
17 | print("Path : " + str(path))
18 |
--------------------------------------------------------------------------------
/Prim/GetSingleSided.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get selection.
7 | selection = omni.usd.get_context().get_selection()
8 | paths = selection.get_selected_prim_paths()
9 |
10 | for path in paths:
11 | # Get prim.
12 | prim = stage.GetPrimAtPath(path)
13 | if prim.IsValid() == False:
14 | continue
15 |
16 | try:
17 | singleSidedAttr = prim.GetAttribute("singleSided")
18 | if singleSidedAttr != None and singleSidedAttr.IsValid():
19 | # Get singleSided (True/False).
20 | if singleSidedAttr.Get() != None:
21 | print("[" + prim.GetName() + "] singleSided : " + str(singleSidedAttr.Get()))
22 |
23 | # Set singleSided.
24 | #if prim.GetTypeName() == 'Mesh':
25 | # singleSidedAttr = prim.CreateAttribute("singleSided", Sdf.ValueTypeNames.Bool)
26 | # singleSidedAttr.Set(True)
27 |
28 | except Exception as e:
29 | print(e)
30 |
--------------------------------------------------------------------------------
/Prim/IsValid.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | path = "/World"
7 |
8 | # Get prim.
9 | prim = stage.GetPrimAtPath(path)
10 |
11 | # Use IsValid to check if the specified Prim exists.
12 | print(path + " : " + str(prim.IsValid()))
13 |
--------------------------------------------------------------------------------
/Prim/Kind/GetKind.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get selection.
7 | selection = omni.usd.get_context().get_selection()
8 | paths = selection.get_selected_prim_paths()
9 |
10 | for path in paths:
11 | # Get prim.
12 | prim = stage.GetPrimAtPath(path)
13 | if prim.IsValid() == False:
14 | continue
15 |
16 | v = Usd.ModelAPI(prim).GetKind()
17 | print('[ ' + prim.GetName() + ' ] Kind = ' + v)
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Prim/Kind/SetComponent.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get selection.
7 | selection = omni.usd.get_context().get_selection()
8 | paths = selection.get_selected_prim_paths()
9 |
10 | for path in paths:
11 | # Get prim.
12 | prim = stage.GetPrimAtPath(path)
13 | if prim.IsValid() == False:
14 | continue
15 |
16 | # Change the value of Kind in Prim to Component.
17 | Usd.ModelAPI(prim).SetKind(Kind.Tokens.component)
18 |
--------------------------------------------------------------------------------
/Prim/Kind/readme.md:
--------------------------------------------------------------------------------
1 | # Kind
2 |
3 | PrimのKindを取得/設定。
4 |
5 | |ファイル|説明|
6 | |---|---|
7 | |[SetComponent.py](./SetComponent.py)|選択PrimのKindをComponentに変更|
8 | |[GetKind.py](./GetKind.py)|選択PrimのKindを取得|
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Prim/PointInstancer/images/usd_pointinstancer_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Prim/PointInstancer/images/usd_pointinstancer_01.jpg
--------------------------------------------------------------------------------
/Prim/PointInstancer/readme.md:
--------------------------------------------------------------------------------
1 | # PointInstancer
2 |
3 | 指定のアセット(USDファイルで指定)をPointInstancerを使って、位置/回転/スケールを指定して複製。
4 | UsdGeom.PointInstancer ( https://graphics.pixar.com/usd/release/api/class_usd_geom_point_instancer.html ) を使用します。
5 |
6 | |ファイル|説明|
7 | |---|---|
8 | |[PointInstancer_01.py](./PointInstancer_01.py)|木の"simpleTree.usda"をアセットとして、ランダムな位置/スケールで複製。
木のusdは[simpleTree.usda](./usd/simpleTree.usda)を使用しています。
|
9 |
10 |
--------------------------------------------------------------------------------
/Prim/Reference/GetReferencePayload.py:
--------------------------------------------------------------------------------
1 | # "Pcp" added below.
2 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf, Pcp
3 |
4 | # Get stage.
5 | stage = omni.usd.get_context().get_stage()
6 |
7 | # Get selection.
8 | selection = omni.usd.get_context().get_selection()
9 | paths = selection.get_selected_prim_paths()
10 |
11 | for path in paths:
12 | prim = stage.GetPrimAtPath(path)
13 | if prim.IsValid():
14 | # If Prim has Reference or Payload.
15 | if prim.HasAuthoredReferences() or prim.HasPayload():
16 | query = Usd.PrimCompositionQuery.GetDirectRootLayerArcs(prim)
17 | qList = query.GetCompositionArcs()
18 |
19 | if qList != None:
20 | for arc in qList:
21 | arcType = arc.GetArcType()
22 | if arcType != Pcp.ArcTypeReference and arcType != Pcp.ArcTypePayload:
23 | continue
24 |
25 | # Get AssetPath.
26 | editorProxy, reference = arc.GetIntroducingListEditor()
27 | assetPath = reference.assetPath
28 |
29 | if arcType == Pcp.ArcTypeReference:
30 | print("[" + prim.GetName() + "] has reference > " + assetPath)
31 | if arcType == Pcp.ArcTypePayload:
32 | print("[" + prim.GetName() + "] has payload. > " + assetPath)
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/Prim/Reference/HasPayload.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get selection.
7 | selection = omni.usd.get_context().get_selection()
8 | paths = selection.get_selected_prim_paths()
9 |
10 | for path in paths:
11 | prim = stage.GetPrimAtPath(path)
12 | if prim.IsValid():
13 | if prim.HasPayload():
14 | print("[ " + prim.GetName() + " ] has payload.")
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Prim/Reference/HasReference.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get selection.
7 | selection = omni.usd.get_context().get_selection()
8 | paths = selection.get_selected_prim_paths()
9 |
10 | for path in paths:
11 | prim = stage.GetPrimAtPath(path)
12 | if prim.IsValid():
13 | if prim.HasAuthoredReferences():
14 | print("[ " + prim.GetName() + " ] has references.")
15 |
16 |
17 |
--------------------------------------------------------------------------------
/Prim/Reference/InternalReferenceTest.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get default prim.
7 | defaultPrim = stage.GetDefaultPrim()
8 | defaultPrimPath = defaultPrim.GetPath().pathString
9 |
10 | # Create sphere.
11 | orgPath = defaultPrimPath + '/org'
12 | UsdGeom.Xform.Define(stage, orgPath)
13 | spherePath = orgPath + '/sphere'
14 | sphereGeom = UsdGeom.Sphere.Define(stage, spherePath)
15 |
16 | # Set radius.
17 | sphereGeom.CreateRadiusAttr(2.0)
18 |
19 | # Set color.
20 | sphereGeom.CreateDisplayColorAttr([(1.0, 0.0, 0.0)])
21 |
22 | # Create empty node(Xform).
23 | path = defaultPrimPath + '/refShape'
24 | UsdGeom.Xform.Define(stage, path)
25 | prim = stage.GetPrimAtPath(path)
26 |
27 | # Set position.
28 | UsdGeom.XformCommonAPI(prim).SetTranslate((5.0, 0.0, 0.0))
29 |
30 | # Remove references.
31 | prim.GetReferences().ClearReferences()
32 |
33 | # Add a internal reference.
34 | # The Path to be added must be an Xform.
35 | prim.GetReferences().AddInternalReference(orgPath)
36 |
--------------------------------------------------------------------------------
/Prim/Reference/PayloadTest.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get default prim.
7 | defaultPrim = stage.GetDefaultPrim()
8 | defaultPrimPath = defaultPrim.GetPath().pathString
9 |
10 | # Create empty node(Xform).
11 | path = defaultPrimPath + '/refShape'
12 | UsdGeom.Xform.Define(stage, path)
13 | prim = stage.GetPrimAtPath(path)
14 |
15 | # Clear payload.
16 | prim.ClearPayload()
17 |
18 | # Set payload.
19 | #usdPath = "./sphere.usda"
20 | usdPath = "https://ft-lab.github.io/usd/omniverse/usd/sphere.usda"
21 | prim.SetPayload(Sdf.Payload(usdPath))
22 |
--------------------------------------------------------------------------------
/Prim/Reference/ReferenceTest.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get default prim.
7 | defaultPrim = stage.GetDefaultPrim()
8 | defaultPrimPath = defaultPrim.GetPath().pathString
9 |
10 | # Create empty node(Xform).
11 | path = defaultPrimPath + '/refShape'
12 | UsdGeom.Xform.Define(stage, path)
13 | prim = stage.GetPrimAtPath(path)
14 |
15 | # Remove references.
16 | prim.GetReferences().ClearReferences()
17 |
18 | # Add a reference.
19 | #usdPath = "./sphere.usda"
20 | usdPath = "https://ft-lab.github.io/usd/omniverse/usd/sphere.usda"
21 | prim.GetReferences().AddReference(usdPath)
22 |
--------------------------------------------------------------------------------
/Prim/Reference/ReferenceTest2.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get default prim.
7 | defaultPrim = stage.GetDefaultPrim()
8 | defaultPrimPath = defaultPrim.GetPath().pathString
9 |
10 | # Create empty node(Xform).
11 | path = defaultPrimPath + '/refShape'
12 | UsdGeom.Xform.Define(stage, path)
13 | prim = stage.GetPrimAtPath(path)
14 |
15 | # Remove references.
16 | prim.GetReferences().ClearReferences()
17 |
18 | # Add a reference.
19 | #usdPath = "./cyawan/cyawan.usdc"
20 | usdPath = "https://ft-lab.github.io/usd/omniverse/usd/cyawan/cyawan.usdc"
21 | prim.GetReferences().AddReference(usdPath)
22 |
--------------------------------------------------------------------------------
/Prim/Reference/images/usd_prim_reference_00.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Prim/Reference/images/usd_prim_reference_00.jpg
--------------------------------------------------------------------------------
/Prim/Reference/images/usd_prim_reference_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Prim/Reference/images/usd_prim_reference_01.jpg
--------------------------------------------------------------------------------
/Prim/Reference/images/usd_prim_reference_02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Prim/Reference/images/usd_prim_reference_02.jpg
--------------------------------------------------------------------------------
/Prim/Reference/images/usd_reference_payload.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Prim/Reference/images/usd_reference_payload.png
--------------------------------------------------------------------------------
/Prim/Reference/usd/cyawan/cyawan.usdc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Prim/Reference/usd/cyawan/cyawan.usdc
--------------------------------------------------------------------------------
/Prim/Reference/usd/cyawan/cyawan_mat_albedo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Prim/Reference/usd/cyawan/cyawan_mat_albedo.png
--------------------------------------------------------------------------------
/Prim/Reference/usd/cyawan/cyawan_mat_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Prim/Reference/usd/cyawan/cyawan_mat_normal.png
--------------------------------------------------------------------------------
/Prim/Reference/usd/cyawan/cyawan_mat_occlusion.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Prim/Reference/usd/cyawan/cyawan_mat_occlusion.png
--------------------------------------------------------------------------------
/Prim/Reference/usd/cyawan/cyawan_mat_roughness.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Prim/Reference/usd/cyawan/cyawan_mat_roughness.png
--------------------------------------------------------------------------------
/Prim/Reference/usd/sphere.usda:
--------------------------------------------------------------------------------
1 | #usda 1.0
2 | (
3 | defaultPrim = "World"
4 | upAxis = "Y"
5 | )
6 |
7 | def Xform "World"
8 | {
9 | def Sphere "sphere"
10 | {
11 | color3f[] primvars:displayColor = [(0, 0, 1)]
12 | double radius = 1.0
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Prim/RemovePrim.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get prim.
7 | path = "/World/Sphere"
8 | prim = stage.GetPrimAtPath(path)
9 |
10 | if prim.IsValid():
11 | # Remove prim.
12 | # See here : https://graphics.pixar.com/usd/release/api/class_usd_stage.html#ac605faad8fc2673263775b1eecad2955
13 | # For example, if Prim is used in a layer, RemovePrim will not remove it completely.
14 | #stage.RemovePrim(path)
15 |
16 | # Prepare specified paths as candidates for deletion.
17 | edit = Sdf.NamespaceEdit.Remove(path)
18 | batchE = Sdf.BatchNamespaceEdit()
19 | batchE.Add(edit)
20 |
21 | # Execute Deletion.
22 | stage.GetEditTarget().GetLayer().Apply(batchE)
23 |
24 |
--------------------------------------------------------------------------------
/Prim/RenamePrim.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get prim.
7 | path = "/World/Sphere"
8 | prim = stage.GetPrimAtPath(path)
9 |
10 | if prim.IsValid():
11 | # Rename prim.
12 |
13 | # Prepare specified paths as candidates for rename.
14 | # "/World/Sphere" to "/World/Sphere2"
15 | edit = Sdf.NamespaceEdit.Rename(path, "Sphere2")
16 | batchE = Sdf.BatchNamespaceEdit()
17 | batchE.Add(edit)
18 |
19 | # Execute rename.
20 | stage.GetEditTarget().GetLayer().Apply(batchE)
21 |
22 |
--------------------------------------------------------------------------------
/Prim/SetDefaultPrim.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Create empty node(Xform).
7 | path = "/NewWorld"
8 | UsdGeom.Xform.Define(stage, path)
9 | prim = stage.GetPrimAtPath(path)
10 |
11 | # Set default prim.
12 | stage.SetDefaultPrim(prim)
13 |
14 |
--------------------------------------------------------------------------------
/Prim/Skeleton/GetSkeletonTransforms.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, UsdSkel, Sdf, Gf, Tf
2 | import omni.kit
3 |
4 | # Get stage.
5 | stage = omni.usd.get_context().get_stage()
6 |
7 | # Get selection.
8 | selection = omni.usd.get_context().get_selection()
9 | paths = selection.get_selected_prim_paths()
10 |
11 | skel_cache = UsdSkel.Cache()
12 | #time_code = omni.timeline.get_timeline_interface().get_current_time() * stage.GetTimeCodesPerSecond()
13 | time_code = Usd.TimeCode.Default()
14 |
15 | for path in paths:
16 | # Get prim.
17 | prim = stage.GetPrimAtPath(path)
18 | if prim.IsValid() and prim.GetTypeName() == 'Skeleton':
19 | # Get transform from cache.
20 | skel_query = skel_cache.GetSkelQuery(UsdSkel.Skeleton(prim))
21 | transforms = skel_query.ComputeJointLocalTransforms(time_code)
22 |
23 | # joints name.
24 | jointNames = skel_query.GetJointOrder()
25 |
26 | # joints matrix to translate, rotations, scales.
27 | translates, rotations, scales = UsdSkel.DecomposeTransforms(transforms)
28 |
29 | print(jointNames)
30 | print(" Translates : " + str(translates))
31 | print(" Rotations : " + str(rotations))
32 | print(" Scales : " + str(scales))
33 |
34 |
35 |
--------------------------------------------------------------------------------
/Prim/Skeleton/readme.md:
--------------------------------------------------------------------------------
1 | # Skeleton
2 |
3 | Skeletonでの情報を取得。
4 |
5 | |ファイル|説明|
6 | |---|---|
7 | |[GetJoints.py](./GetJoints.py)|選択Primの中に"Skeleton"がある場合に、ジョイント名/バインドの行列/リセットの行列を表示|
8 | |[GetSkeletonTransforms.py](./GetSkeletonTransforms.py)|選択Primが"Skeleton"の場合に、ジョイント名と移動/回転/スケールのリストを取得|
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Prim/Transform/DeletePivot.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 | import omni.usd
3 | import omni.kit.commands
4 |
5 | # Get stage.
6 | stage = omni.usd.get_context().get_stage()
7 |
8 | # Get selection.
9 | selection = omni.usd.get_context().get_selection()
10 | paths = selection.get_selected_prim_paths()
11 |
12 | # --------------------------------------------------.
13 | # Delete pivot.
14 | # --------------------------------------------------.
15 | def _deletePivot (prim : Usd.Prim):
16 | if prim == None:
17 | return
18 |
19 | path = prim.GetPath().pathString + ".xformOp:translate:pivot"
20 | omni.kit.commands.execute('RemoveProperty', prop_path=path)
21 |
22 | transformOrder = prim.GetAttribute("xformOpOrder").Get()
23 | if transformOrder != None:
24 | orderList = []
25 | for sV in transformOrder:
26 | if sV == "xformOp:translate:pivot" or sV == "!invert!xformOp:translate:pivot":
27 | continue
28 | orderList.append(sV)
29 |
30 | prim.GetAttribute("xformOpOrder").Set(orderList)
31 |
32 | # --------------------------------------------------.
33 | for path in paths:
34 | prim = stage.GetPrimAtPath(path)
35 | if prim.IsValid() == True:
36 | # Print prim name.
37 | print('[ ' + prim.GetName() + ' ]')
38 |
39 | # Delete pivot.
40 | _deletePivot(prim)
41 |
42 |
--------------------------------------------------------------------------------
/Prim/Transform/GetLocalMatrix.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get selection.
7 | selection = omni.usd.get_context().get_selection()
8 | paths = selection.get_selected_prim_paths()
9 |
10 | xformCache = UsdGeom.XformCache(0)
11 |
12 | for path in paths:
13 | prim = stage.GetPrimAtPath(path)
14 | if prim.IsValid() == True:
15 | # Print prim name.
16 | print(f"[ {prim.GetName()} ]")
17 |
18 | # Calc local matrix.
19 | matrix = xformCache.GetLocalTransformation(prim)[0]
20 | print(matrix)
21 |
22 | # Decompose matrix.
23 | # If the result is False, then reduce the value of eps and call Factor again.
24 | eps = 1e-10
25 | result = matrix.Factor(eps)
26 | if result[0]:
27 | scale = result[2]
28 | rotate = result[3].ExtractRotation()
29 | translation = result[4]
30 |
31 | # Convert Rotate to Euler.
32 | # Rotate XYZ.
33 | rotateE = rotate.Decompose(Gf.Vec3d(0, 0, 1), Gf.Vec3d(0, 1, 0), Gf.Vec3d(1, 0, 0))
34 | rotateE = Gf.Vec3d(rotateE[2], rotateE[1], rotateE[0])
35 |
36 | print(f"Translation : {translation}")
37 | print(f"rotate : {rotateE}")
38 | print(f"scale : {scale}")
39 |
40 |
41 |
--------------------------------------------------------------------------------
/Prim/Transform/GetTransform.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get selection.
7 | selection = omni.usd.get_context().get_selection()
8 | paths = selection.get_selected_prim_paths()
9 |
10 | for path in paths:
11 | prim = stage.GetPrimAtPath(path)
12 | if prim.IsValid() == True:
13 | # Print prim name.
14 | print('[ ' + prim.GetName() + ' ]')
15 |
16 | # Order of Transform elements.
17 | transformOrder = prim.GetAttribute('xformOpOrder')
18 |
19 | if transformOrder.IsValid() and transformOrder.Get() != None:
20 | print(f" TransformOrder : {transformOrder.Get()}")
21 |
22 | for transV in transformOrder.Get():
23 | # 'xformOp:scale', 'xformOp:rotateXYZ', 'xformOp:translate', etc.
24 | tV = prim.GetAttribute(transV)
25 |
26 | if tV.IsValid():
27 | print(f" {transV} ( {tV.GetTypeName()} ) : {tV.Get()}")
28 |
29 |
--------------------------------------------------------------------------------
/Prim/Transform/GetTransformOrder.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get selection.
7 | selection = omni.usd.get_context().get_selection()
8 | paths = selection.get_selected_prim_paths()
9 |
10 | for path in paths:
11 | prim = stage.GetPrimAtPath(path)
12 | if prim.IsValid() == True:
13 | # Print prim name.
14 | print(f"[ {prim.GetName()} ]")
15 |
16 | # Order of Transform elements.
17 | transformOrder = prim.GetAttribute('xformOpOrder').Get()
18 | for sV in transformOrder:
19 | print(f" {sV}")
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Prim/Transform/GetWorldTransform.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, UsdSkel, Sdf, Gf, Tf
2 | import omni.kit
3 |
4 | # Get stage.
5 | stage = omni.usd.get_context().get_stage()
6 |
7 | # Get selection.
8 | selection = omni.usd.get_context().get_selection()
9 | paths = selection.get_selected_prim_paths()
10 |
11 | xformCache = UsdGeom.XformCache(0)
12 |
13 | for path in paths:
14 | prim = stage.GetPrimAtPath(path)
15 | if prim.IsValid():
16 | # Get world Transform.
17 | globalPose = xformCache.GetLocalToWorldTransform(prim)
18 | print(globalPose)
19 |
20 | # Decompose transform.
21 | translate, rotation, scale = UsdSkel.DecomposeTransform(globalPose)
22 |
23 | # Conv Quat to eular angles.
24 | # Rotate XYZ.
25 | rV = Gf.Rotation(rotation).Decompose(Gf.Vec3d(0, 0, 1), Gf.Vec3d(0, 1, 0), Gf.Vec3d(1, 0, 0))
26 | rV = Gf.Vec3d(rV[2], rV[1], rV[0])
27 |
28 | print(f"==> translate : {translate}")
29 | print(f"==> rotation : {rV}")
30 | print(f"==> scale : {scale}")
31 |
32 |
--------------------------------------------------------------------------------
/Prim/Transform/SetScale.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 | import omni.usd
3 | import omni.timeline
4 |
5 | # Get stage.
6 | stage = omni.usd.get_context().get_stage()
7 |
8 | # Get selection.
9 | selection = omni.usd.get_context().get_selection()
10 | paths = selection.get_selected_prim_paths()
11 |
12 | # --------------------------------------------------.
13 | # Set scale.
14 | # --------------------------------------------------.
15 | def _setScale (prim : Usd.Prim, sV : Gf.Vec3f):
16 | if prim == None:
17 | return
18 |
19 | scale = prim.GetAttribute("xformOp:scale").Get()
20 | if scale != None:
21 | # Specify a value for each type.
22 | if type(scale) == Gf.Vec3f:
23 | prim.GetAttribute("xformOp:scale").Set(Gf.Vec3f(sV))
24 | elif type(scale) == Gf.Vec3d:
25 | prim.GetAttribute("xformOp:scale").Set(Gf.Vec3d(sV))
26 | else:
27 | # xformOpOrder is also updated.
28 | xformAPI = UsdGeom.XformCommonAPI(prim)
29 | xformAPI.SetScale(Gf.Vec3f(sV))
30 |
31 | # --------------------------------------------------.
32 | for path in paths:
33 | prim = stage.GetPrimAtPath(path)
34 | if prim.IsValid() == True:
35 | # Print prim name.
36 | print(f"[ {prim.GetName()} ]")
37 |
38 | sV = Gf.Vec3f(1.1, 1.2, 1.3)
39 | _setScale(prim, sV)
40 |
41 |
--------------------------------------------------------------------------------
/Prim/Transform/SetTransform.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Create cube.
7 | pathName = '/World/cube'
8 | cubeGeom = UsdGeom.Cube.Define(stage, pathName)
9 |
10 | # Set cube size.
11 | cubeGeom.CreateSizeAttr(10.0)
12 |
13 | # Set color.
14 | cubeGeom.CreateDisplayColorAttr([(0.0, 1.0, 0.0)])
15 |
16 | # Set transform.
17 | prim = stage.GetPrimAtPath(pathName)
18 | prim.CreateAttribute("xformOp:translate", Sdf.ValueTypeNames.Float3, False).Set(Gf.Vec3f(0, 10, 0))
19 | prim.CreateAttribute("xformOp:scale", Sdf.ValueTypeNames.Float3, False).Set(Gf.Vec3f(1, 2, 1))
20 | prim.CreateAttribute("xformOp:rotateXYZ", Sdf.ValueTypeNames.Float3, False).Set(Gf.Vec3f(120, 45, 0))
21 |
22 | transformOrder = prim.CreateAttribute("xformOpOrder", Sdf.ValueTypeNames.String, False)
23 | transformOrder.Set(["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"])
24 |
--------------------------------------------------------------------------------
/Prim/Transform/SetTranslate.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 | import omni.usd
3 | import omni.timeline
4 |
5 | # Get stage.
6 | stage = omni.usd.get_context().get_stage()
7 |
8 | # Get selection.
9 | selection = omni.usd.get_context().get_selection()
10 | paths = selection.get_selected_prim_paths()
11 |
12 | # --------------------------------------------------.
13 | # Set translate.
14 | # --------------------------------------------------.
15 | def _setTranslate (prim : Usd.Prim, tV : Gf.Vec3f):
16 | if prim == None:
17 | return
18 |
19 | trans = prim.GetAttribute("xformOp:translate").Get()
20 | if trans != None:
21 | # Specify a value for each type.
22 | if type(trans) == Gf.Vec3f:
23 | prim.GetAttribute("xformOp:translate").Set(Gf.Vec3f(tV))
24 | elif type(trans) == Gf.Vec3d:
25 | prim.GetAttribute("xformOp:translate").Set(Gf.Vec3d(tV))
26 | else:
27 | # xformOpOrder is also updated.
28 | xformAPI = UsdGeom.XformCommonAPI(prim)
29 | xformAPI.SetTranslate(Gf.Vec3d(tV))
30 |
31 | # -------------------------------------------------.
32 | for path in paths:
33 | prim = stage.GetPrimAtPath(path)
34 | if prim.IsValid() == True:
35 | # Print prim name.
36 | print('[ ' + prim.GetName() + ' ]')
37 |
38 | tV = Gf.Vec3f(10, 20, 30)
39 | _setTranslate(prim, tV)
40 |
--------------------------------------------------------------------------------
/Prim/Transform/images/SetTransform.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Prim/Transform/images/SetTransform.jpg
--------------------------------------------------------------------------------
/Prim/Transform/readme.md:
--------------------------------------------------------------------------------
1 | # Transform
2 |
3 | Transform(scale/rotate/translate)情報の取得/設定。
4 |
5 | |ファイル|説明|
6 | |---|---|
7 | |[GetTransform.py](./GetTransform.py)|選択された形状のTransform要素を取得|
8 | |[GetTransformOrder.py](./GetTransformOrder.py)|選択された形状のxformOpOrder(Transformの変換順)を取得|
9 | |[SetTransform.py](./SetTransform.py)|Cubeを作成し、Transformを指定|
10 | |[GetWorldTransform.py](./GetWorldTransform.py)|選択形状のTransformをワールド変換して表示|
11 | |[GetLocalMatrix.py](./GetLocalMatrix.py)|選択形状のローカル座標での4x4変換行列を取得|
12 | |[GetTransformVectors.py](./GetTransformVectors.py)|UsdGeom.XformCommonAPIを使用して、選択形状の移動/回転/スケール/Pivot/回転を取得|
13 | |[SetTranslate.py](./SetTranslate.py)|選択形状の移動を指定。存在しなければxformOpOrderも考慮して追加|
14 | |[SetScale.py](./SetScale.py)|選択形状のスケールを指定。存在しなければxformOpOrderも考慮して追加|
15 | |[SetRotate.py](./SetRotate.py)|選択形状の回転を指定。存在しなければxformOpOrderも考慮して追加|
16 | |[SetRotateWithQuat.py](./SetRotateWithQuat.py)|選択形状の回転をQuatで指定|
17 | |[SetPivot.py](./SetPivot.py)|選択形状のPivotを指定。存在しなければxformOpOrderも考慮して追加|
18 | |[DeletePivot.py](./DeletePivot.py)|選択形状のPivotを削除。一部 omni.kit.commands.execute('RemoveProperty') を使用|
19 |
--------------------------------------------------------------------------------
/Prim/TypeName/GetTypeName.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get selection.
7 | selection = omni.usd.get_context().get_selection()
8 | paths = selection.get_selected_prim_paths()
9 |
10 | for path in paths:
11 | # Get prim.
12 | prim = stage.GetPrimAtPath(path)
13 | if prim.IsValid() == False:
14 | continue
15 |
16 | print('[ ' + prim.GetName() + ' ] TypeName = ' + prim.GetTypeName())
17 |
18 |
--------------------------------------------------------------------------------
/Prim/TypeName/readme.md:
--------------------------------------------------------------------------------
1 | # TypeName
2 |
3 | PrimのTypeName(Xform/Mesh/DistantLightなど)を取得。
4 |
5 | |ファイル|説明|
6 | |---|---|
7 | |[GetTypeName.py](./GetTypeName.py)|PrimのTypeNameを取得|
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Prim/Variant/images/prim_variant_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Prim/Variant/images/prim_variant_01.jpg
--------------------------------------------------------------------------------
/Prim/Variant/readme.md:
--------------------------------------------------------------------------------
1 | # Variant
2 |
3 | PrimのGetVariant( https://graphics.pixar.com/usd/release/api/class_usd_prim.html#a607da249e11bc4f5f3b4bf0db99861ab )を使用して、1つのPrim内で複数のPrimを「VariantSet」として登録します。
4 |
5 | この例の場合は椅子のusdファイル([simple_chair.usda](../Reference/usd/simple_chair.usda))を参照し、色を変えて3つの形状としています。
6 | 
7 | 表示されるのはVariantで指定された1つの形状のみです。
8 |
9 | |ファイル|説明|
10 | |---|---|
11 | |[Variant_01.py](./Variant_01.py)|Variantを使ったPrimの切り替えのテスト|
12 |
13 |
14 |
--------------------------------------------------------------------------------
/Prim/Visibility/GetShowHidePrim.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get selection.
7 | selection = omni.usd.get_context().get_selection()
8 | paths = selection.get_selected_prim_paths()
9 |
10 | for path in paths:
11 | # Get prim.
12 | prim = stage.GetPrimAtPath(path)
13 | if prim.IsValid() == False:
14 | continue
15 |
16 | # Get visibility.
17 | primImageable = UsdGeom.Imageable(prim)
18 | showF = (primImageable.ComputeVisibility() != 'invisible')
19 |
20 | if primImageable.GetVisibilityAttr().Get() == 'inherited':
21 | print('[ ' + prim.GetName() + ' ] inherited visible = ' + str(showF))
22 | else:
23 | print('[ ' + prim.GetName() + ' ] invisible visible = ' + str(showF))
24 |
25 |
--------------------------------------------------------------------------------
/Prim/Visibility/ShowHidePrim.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get selection.
7 | selection = omni.usd.get_context().get_selection()
8 | paths = selection.get_selected_prim_paths()
9 |
10 | # Toggle show/hide.
11 | for path in paths:
12 | # Get prim.
13 | prim = stage.GetPrimAtPath(path)
14 | if prim.IsValid() == False:
15 | continue
16 |
17 | # Get visibility.
18 | primImageable = UsdGeom.Imageable(prim)
19 | if primImageable.GetVisibilityAttr().Get() == 'inherited':
20 | # Set hide.
21 | primImageable.GetVisibilityAttr().Set('invisible')
22 | else:
23 | # Set show (inherited).
24 | primImageable.GetVisibilityAttr().Set('inherited')
25 |
--------------------------------------------------------------------------------
/Prim/Visibility/readme.md:
--------------------------------------------------------------------------------
1 | # Visibility
2 |
3 | Primの表示/非表示。
4 |
5 | |ファイル|説明|
6 | |---|---|
7 | |[GetShowHidePrim.py](./GetShowHidePrim.py)|選択Primの表示/非表示を取得|
8 | |[ShowHidePrim.py](./ShowHidePrim.py)|選択Primの表示/非表示を切り替え|
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Python/Class/SimpleClass.py:
--------------------------------------------------------------------------------
1 | # -----------------------------------------------.
2 | # Simple class.
3 | # -----------------------------------------------.
4 | class ClassFoo:
5 | _name = ""
6 |
7 | # Constructor
8 | def __init__(self, name : str):
9 | self.name = name
10 | print("Constructor")
11 |
12 | # Destructor
13 | def __del__(self):
14 | print("Destructor")
15 |
16 | def printName (self):
17 | print("name = " + self.name)
18 |
19 | def add (self, a : float, b : float):
20 | return (a + b)
21 |
22 | # -----------------------------------------------.
23 |
24 | # Create new class.
25 | foo = ClassFoo("test")
26 |
27 | foo.printName()
28 | print(foo.add(12.5, 8.2))
29 |
30 | # Destroying a class.
31 | foo = None
32 |
--------------------------------------------------------------------------------
/Python/Class/readme.md:
--------------------------------------------------------------------------------
1 | # Class
2 |
3 | Classのサンプル。
4 |
5 | ## サンプル
6 |
7 | |ファイル|説明|
8 | |---|---|
9 | |[SimpleClass.py](./SimpleClass.py)|簡単なクラス。
コンストラクタとデストラクタ。|
10 |
11 |
--------------------------------------------------------------------------------
/Python/Web/WebOpen.py:
--------------------------------------------------------------------------------
1 | import webbrowser
2 |
3 | url = "https://docs.omniverse.nvidia.com/"
4 | webbrowser.open(url)
5 |
--------------------------------------------------------------------------------
/Python/Web/readme.md:
--------------------------------------------------------------------------------
1 | # Web
2 |
3 | Webブラウザへのアクセス。
4 |
5 | |サンプル|説明|
6 | |---|---|
7 | |[WebOpen](./WebOpen.py)|指定のURLをWebブラウザで開く。|
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Python/readme.md:
--------------------------------------------------------------------------------
1 | # Python
2 |
3 | Pythonの標準的な機能の覚書きです。
4 |
5 | ## サンプル
6 |
7 | |ファイル|説明|
8 | |---|---|
9 | |[string](./string)|文字列処理|
10 | |[Class](./Class)|クラスの使用|
11 | |[Web](./Web)|Webブラウザへのアクセス|
12 |
13 |
--------------------------------------------------------------------------------
/Python/string/NumToStr.py:
--------------------------------------------------------------------------------
1 | v = 0.25364
2 |
3 | # number to string.
4 | # ==> "0.25364"
5 | print("Value = " + str(v))
6 |
7 | # Digit number specification.
8 | # ==> "0000.25364"
9 | print("Value : {:#010}".format(v))
10 | print("Value : " + format(v, '#010'))
11 |
12 | # Specify the number of decimal places.
13 | # ==> "0.254"
14 | print("Value : {:.3f}".format(v))
15 | print("Value : " + format(v, '.3f'))
16 |
17 | # Replaced by hexadecimal.
18 | # ==> "0x7fff"
19 | v2 = 32767
20 | print(hex(v2))
21 |
22 | # Replaced by a binary number.
23 | # ==> "0b101"
24 | v2 = 5
25 | print(bin(v2))
26 |
27 |
--------------------------------------------------------------------------------
/Python/string/StringTest.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | v = 25.3674
4 |
5 | print("Value = " + str(v))
6 | print(f"Value = {v}")
7 | print(f"Type = {type(v)}")
8 |
9 | # Specify the number of decimal places.
10 | # ==> "25.367"
11 | print(f"Value = {'{:.3f}'.format(v)}")
12 |
13 | vec3 = Gf.Vec3f(1.2, 5.6, 90)
14 | print(f"vec3 = {vec3}")
15 |
16 | array = [1.2, "test", True]
17 | print(f"array = {array}")
18 |
--------------------------------------------------------------------------------
/Python/string/readme.md:
--------------------------------------------------------------------------------
1 | # string
2 |
3 | 文字列処理。
4 |
5 | ## サンプル
6 |
7 | |ファイル|説明|
8 | |---|---|
9 | |[NumToStr.py](./NumToStr.py)|数値を文字列に変換|
10 | |[StringTest.py](./StringTest.py)|文字列指定時に変数を埋め込む|
11 |
12 |
--------------------------------------------------------------------------------
/Rendering/Capture/images/capture_SyntheticDataSensor_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Rendering/Capture/images/capture_SyntheticDataSensor_1.jpg
--------------------------------------------------------------------------------
/Rendering/Capture/readme.md:
--------------------------------------------------------------------------------
1 | # Capture
2 |
3 | レンダリング画像を取得。
4 | Kit.104で動作するように確認。
5 |
6 | "omni.kit.viewport.utility"を使用したキャプチャ。
7 |
8 | |サンプル|説明|
9 | |---|---|
10 | |[CaptureRenderingColorToFile.py](./CaptureRenderingColorToFile.py) |レンダリング画像をファイルに保存。|
11 | |[CaptureRenderingColorToBuffer.py](./CaptureRenderingColorToBuffer.py) |レンダリング画像をバッファ(RGBA)で取得し、PILのImageで表示。|
12 | |[CaptureCameraRenderingColorToBuffer.py](./CaptureCameraRenderingColorToBuffer.py) |指定のカメラからのレンダリングを行い、PILのImageで表示。
レンダリングのViewportは非表示にして、オフラインレンダリングを行う。|
13 |
14 | ## 古い実装
15 |
16 | キャプチャを行うには、Extensionの"omni.syntheticdata"をOnにして使用する必要があります。
17 |
18 | |サンプル|説明|
19 | |---|---|
20 | |[CaptureRenderingDepth.py](./CaptureRenderingDepth.py)|Synthetic Data Sensorを使用して、レンダリングのDepthをファイル保存。
また、Viewportで"Synthetic Data Sensor"の"Depth"をOnにしておく必要があります。
|
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/Rendering/readme.md:
--------------------------------------------------------------------------------
1 | # Rendering
2 |
3 | レンダリング画像を取得します。
4 |
5 |
6 | |サンプル|説明|
7 | |---|---|
8 | |[Capture](./Capture)|レンダリング画像を取得|
9 |
--------------------------------------------------------------------------------
/Samples/CreateSimpleCurve/images/createSimpleCurve_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Samples/CreateSimpleCurve/images/createSimpleCurve_01.jpg
--------------------------------------------------------------------------------
/Samples/CreateSimpleCurve/images/createSimpleCurve_02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Samples/CreateSimpleCurve/images/createSimpleCurve_02.png
--------------------------------------------------------------------------------
/Samples/CreateSimpleCurve/images/createSimpleCurve_03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Samples/CreateSimpleCurve/images/createSimpleCurve_03.png
--------------------------------------------------------------------------------
/Samples/CreateSimpleCurve/images/createSimpleCurve_04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Samples/CreateSimpleCurve/images/createSimpleCurve_04.png
--------------------------------------------------------------------------------
/Samples/CreateSimpleCurve/readme.md:
--------------------------------------------------------------------------------
1 | # CreateSimpleCurve
2 |
3 | Xform内の複数のSphereを使用し、Spbereをスプライン補間したチューブ形状を作成します。
4 |
5 | ## 使い方
6 |
7 | 複数のSphereを配置します。
8 | このSphereをつなぐようにスプラインでチューブ形状がMeshとして作成されることになります。
9 |
10 | 
11 |
12 | また、Xformに対してマテリアルを割り当てておきます。
13 |
14 | Xformを選択した状態でScript Editorで「[CreateSimpleCurve.py](./CreateSimpleCurve.py)」を実行します。
15 |
16 | Create Curveウィンドウが表示されました。
17 | 
18 |
19 | "Number of divisions"で分割数を指定して"Create"ボタンを押します。
20 | Sphereを曲線上でつないだチューブ形状がMeshとして生成されます。
21 | 
22 | 
23 |
24 |
--------------------------------------------------------------------------------
/Samples/FlipMeshNormals/FlipMeshNormals.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, UsdSkel, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # ------------------------------------------------------------.
7 | # Flip mesh normals.
8 | # ------------------------------------------------------------.
9 | def FlipMeshNormals (prim):
10 | if prim.GetTypeName() == 'Mesh':
11 | m = UsdGeom.Mesh(prim)
12 |
13 | # If it is displayed.
14 | if m.ComputeVisibility() == 'inherited':
15 | # Get prim path.
16 | path = prim.GetPath().pathString
17 |
18 |
19 |
20 | print(prim.GetName())
21 |
22 | pChildren = prim.GetChildren()
23 | for cPrim in pChildren:
24 | FlipMeshNormals(cPrim)
25 |
26 | # ------------------------------------------------------------.
27 |
28 | # Get selection.
29 | selection = omni.usd.get_context().get_selection()
30 | paths = selection.get_selected_prim_paths()
31 |
32 | for path in paths:
33 | prim = stage.GetPrimAtPath(path)
34 | if prim.IsValid():
35 | FlipMeshNormals(prim)
36 |
37 |
38 |
--------------------------------------------------------------------------------
/Samples/UnitsToCentimeters/readme.md:
--------------------------------------------------------------------------------
1 | # UnitsToCentimeters
2 |
3 | Stageの単位をセンチメートルに統一します。
4 | [UnitsToCentimeters.py](./UnitsToCentimeters.py) は、
5 | metersPerUnitを0.01に変換するスクリプトです。
6 |
7 | ## 使い方
8 |
9 | このスクリプトは、StageのmetersPerUnitが0.01(センチメートル)でない場合に
10 | DefaultPrimのscaleを調整し、metersPerUnitを0.01に置き換えます。
11 | ルートPrimがXformで「DefaultPrim」の指定がされているのが必要条件になります。
12 |
13 | なお、Nucleus上のusdファイルの場合はmetersPerUnitの変更が許可されないことがありました。
14 | そのため、このスクリプトはローカルのusdに対して行うようにしてください。
15 |
16 | なお、このスクリプトはファイル保存は行いません。
17 | 必要であれば、処理後にusdファイルを保存してご使用くださいませ。
18 |
19 |
--------------------------------------------------------------------------------
/Samples/readme.md:
--------------------------------------------------------------------------------
1 | # Samples
2 |
3 | 実用的に使えそうなスクリプトのサンプルです。
4 |
5 | |サンプル|説明|
6 | |---|---|
7 | |[CreateSimpleCurve](./CreateSimpleCurve)|複数のSphereをつなぐチューブ形状を生成|
8 | |[UnitsToCentimeters](./UnitsToCentimeters)|Stageの単位をセンチメートルに統一(MetersPerUnitを0.01にする)|
9 |
--------------------------------------------------------------------------------
/Scene/CloseStage.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdShade, Sdf, Gf, Tf
2 |
3 | omni.usd.get_context().close_stage()
4 |
--------------------------------------------------------------------------------
/Scene/CreateHierarchy.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get default prim.
7 | defaultPrim = stage.GetDefaultPrim()
8 |
9 | # Get root path.
10 | rootPath = ''
11 | if defaultPrim.IsValid():
12 | rootPath = defaultPrim.GetPath().pathString
13 |
14 | # Create empty node(Xform).
15 | UsdGeom.Xform.Define(stage, rootPath + '/node1')
16 |
17 | # Create empty node(Xform).
18 | UsdGeom.Xform.Define(stage, rootPath + '/node1/node1_2')
19 |
20 | # Create sphere.
21 | pathName = rootPath + '/node1/sphere'
22 | sphereGeom = UsdGeom.Sphere.Define(stage, pathName)
23 |
24 | # Set radius.
25 | sphereGeom.CreateRadiusAttr(1.0)
26 |
27 | # Set position.
28 | UsdGeom.XformCommonAPI(sphereGeom).SetTranslate((-3, 0, 0))
29 |
30 | # Create cube.
31 | pathName = rootPath + '/node1/cube'
32 | cubeGeom = UsdGeom.Cube.Define(stage, pathName)
33 |
34 | # Set position.
35 | UsdGeom.XformCommonAPI(cubeGeom).SetTranslate((0, 0, 0))
36 |
--------------------------------------------------------------------------------
/Scene/GetMetersPerUnit.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get metersPerUnit (default : 0.01).
7 | metersPerUnit = UsdGeom.GetStageMetersPerUnit(stage)
8 | print("MetersPerUnit : " + str(metersPerUnit))
9 |
10 | # Set metersPerUnit.
11 | try:
12 | UsdGeom.SetStageMetersPerUnit(stage, 0.01)
13 | except Exception as e:
14 | print(e)
15 |
--------------------------------------------------------------------------------
/Scene/GetResolvedPath.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | try:
4 | # Open USD File.
5 | usdPath = "https://ft-lab.github.io/usd/omniverse/usd/cyawan/cyawan.usdc"
6 | ret = omni.usd.get_context().open_stage(usdPath)
7 |
8 | if ret == True:
9 | # Get stage.
10 | stage = omni.usd.get_context().get_stage()
11 |
12 | # Convert relative paths to absolute paths from Stage.
13 | # It is necessary to specify the relative path where the texture name, Reference, etc. exists on the Stage.
14 | absPath = stage.ResolveIdentifierToEditTarget("./cyawan_mat_albedo.png")
15 |
16 | # "https://ft-lab.github.io/usd/omniverse/usd/cyawan/cyawan_mat_albedo.png"
17 | print(absPath)
18 |
19 | except Exception as e:
20 | print(e)
21 |
--------------------------------------------------------------------------------
/Scene/Layers/GetRealPath.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get root layer.
7 | rootLayer = stage.GetRootLayer()
8 |
9 | # Get real path.
10 | realPath = rootLayer.realPath
11 |
12 | print("realPath : " + realPath)
13 |
--------------------------------------------------------------------------------
/Scene/Layers/GetSublayers.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get root layer.
7 | rootLayer = stage.GetRootLayer()
8 |
9 | # Get subLayer paths.
10 | sublayerPaths = rootLayer.subLayerPaths
11 |
12 | for path in sublayerPaths:
13 | print(" " + path)
14 |
--------------------------------------------------------------------------------
/Scene/NewStage.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdShade, Sdf, Gf, Tf
2 |
3 | omni.usd.get_context().new_stage()
4 | print("New Stage !")
5 |
--------------------------------------------------------------------------------
/Scene/OpenUSDFile.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdShade, Sdf, Gf, Tf
2 |
3 | try:
4 | # Open USD File.
5 | ret = omni.usd.get_context().open_stage("xxx.usd")
6 | print("open_stage : " + str(ret))
7 |
8 | except Exception as e:
9 | print(e)
10 |
--------------------------------------------------------------------------------
/Scene/StageUpAxis.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | # Get UpAxis.
7 | upAxis = UsdGeom.GetStageUpAxis(stage)
8 |
9 | if upAxis == UsdGeom.Tokens.x:
10 | print("UpAxis : X")
11 | elif upAxis == UsdGeom.Tokens.y:
12 | print("UpAxis : Y")
13 | elif upAxis == UsdGeom.Tokens.z:
14 | print("UpAxis : Z")
15 |
16 | # Set UpAxis (Y-Up).
17 | try:
18 | UsdGeom.SetStageUpAxis(stage, UsdGeom.Tokens.y)
19 | except Exception as e:
20 | print(e)
21 |
22 |
--------------------------------------------------------------------------------
/Scene/Traverse_mesh.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 |
3 | # Get stage.
4 | stage = omni.usd.get_context().get_stage()
5 |
6 | defaultPrim = stage.GetDefaultPrim()
7 | if defaultPrim.IsValid():
8 | prims = []
9 | for prim in Usd.PrimRange(defaultPrim):
10 | if prim.IsA(UsdGeom.Mesh): # For Mesh.
11 | prims.append(prim)
12 |
13 | for prim in prims:
14 | print(prim.GetName() + " (" + prim.GetPath().pathString + ")")
15 |
16 |
--------------------------------------------------------------------------------
/Scene/images/createHierarchy_img.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/Scene/images/createHierarchy_img.jpg
--------------------------------------------------------------------------------
/Scene/readme.md:
--------------------------------------------------------------------------------
1 | # Scene
2 |
3 | シーン(Stage)の情報を取得/操作します。
4 |
5 | |ファイル|説明|
6 | |---|---|
7 | |[StageUpAxis.py](./StageUpAxis.py)|Stageのアップベクトルの取得/設定|
8 | |[CreateHierarchy.py](./CreateHierarchy.py)|Xformを使って階層構造を作って形状を配置
|
9 | |[GetAllFacesCount.py](./GetAllFacesCount.py)|シーン内のすべてのMeshの面数を合計して表示。
対象はMesh/PointInstancer。|
10 | |[TraverseHierarchy.py](./TraverseHierarchy.py)|シーンの階層構造をたどってPrim名を表示。
Meshの場合はMeshの面数も表示。|
11 | |[Traverse_mesh.py](./Traverse_mesh.py)|Usd.PrimRangeを使ってPrimを取得し、Meshのみを格納|
12 | |[GetMetersPerUnit.py](./GetMetersPerUnit.py)|metersPerUnitの取得/設定|
13 | |[NewStage.py](./NewStage.py)|何も配置されていない新しいStageを作成します。
なお、直前のStageの変更は保存されません。|
14 | |[CloseStage.py](./CloseStage.py)|現在のStageを閉じます。
なお、直前のStageの変更は保存されません。|
15 | |[OpenUSDFile.py](./OpenUSDFile.py)|指定のUSDファイルを開きます。
なお、直前のStageの変更は保存されません。|
16 | |[GetResolvedPath.py](./GetResolvedPath.py)|カレントStageで指定されている相対パス(テクスチャやReferenceとして参照しているusdファイルなど)を絶対パスに変換。
存在しないパスを指定した場合は空文字が返る。|
17 |
18 | ## レイヤ関連
19 |
20 | |ファイル|説明|
21 | |---|---|
22 | |[GetRealPath.py](./Layers/GetRealPath.py)|読み込んだStageのパスを取得|
23 | |[GetSublayers.py](./Layers/GetSublayers.py)|SubLayerのパスを取得|
--------------------------------------------------------------------------------
/Settings/GetKitPath.py:
--------------------------------------------------------------------------------
1 | import os.path
2 | import carb.tokens
3 |
4 | kitPath = os.path.abspath(carb.tokens.get_tokens_interface().resolve("${kit}"))
5 | print(kitPath)
6 |
--------------------------------------------------------------------------------
/Settings/GetKitVersion.py:
--------------------------------------------------------------------------------
1 | import omni.kit
2 |
3 | # Get Omniverse Kit version.
4 | kitVersion = omni.kit.app.get_app_interface().get_build_version()
5 |
6 | # 102.1.2+release.xxxx
7 | print("Kit Version : " + str(kitVersion))
8 |
9 | # 102.1.2
10 | print(str(" ") + kitVersion.split("+")[0])
11 |
12 |
--------------------------------------------------------------------------------
/Settings/GetRenderMode.py:
--------------------------------------------------------------------------------
1 | import omni.kit
2 | import carb.settings
3 | import asyncio
4 |
5 | # Get Render Mode.
6 | settings = carb.settings.get_settings()
7 | renderMode = settings.get('/rtx/rendermode')
8 |
9 | # rtx, iray
10 | activeRender = settings.get('/renderer/active')
11 |
12 | if activeRender == 'iray':
13 | print("Render Mode : Iray")
14 | else:
15 | if renderMode == 'RaytracedLighting':
16 | print("Render Mode : RTX Real-time")
17 | else:
18 | if renderMode == 'PathTracing':
19 | print("Render Mode : RTX Path-traced")
20 | else:
21 | print("Render Mode : " + renderMode)
22 |
23 | # Set Render mode.
24 | # It is safe to wait for one frame in the coroutine to change the RenderMode.
25 | async def SetRenderMode (modeName : str):
26 | await omni.kit.app.get_app().next_update_async()
27 | settings.set('/rtx/rendermode', modeName)
28 |
29 | # Set "RTX Real-time"
30 | asyncio.ensure_future(SetRenderMode('RaytracedLighting'))
31 |
32 | # Set "RTX Path-traced"
33 | asyncio.ensure_future(SetRenderMode('PathTracing'))
34 |
35 |
--------------------------------------------------------------------------------
/Settings/GetRenderingSize.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 | import carb.settings
3 |
4 | # Get rendering size.
5 | # If Render Resolution is "Viewport", -1 will be set.
6 | settings = carb.settings.get_settings()
7 | width = settings.get('/app/renderer/resolution/width')
8 | height = settings.get('/app/renderer/resolution/height')
9 |
10 | print("Rendering size : " + str(width) + " x " + str(height))
11 |
12 | # Set rendering size.
13 | #settings.set('/app/renderer/resolution/width', 1280)
14 | #settings.set('/app/renderer/resolution/height', 720)
15 |
--------------------------------------------------------------------------------
/Settings/readme.md:
--------------------------------------------------------------------------------
1 | # Settings
2 |
3 | carb.settingsより、設定を取得します。
4 | これは"/kit/config/kit-core.json"の情報を読み取ります。
5 |
6 |
7 | |ファイル|説明|
8 | |---|---|
9 | |[GetKitVersion.py](./GetKitVersion.py)|Omniverse Kitのバージョンを取得|
10 | |[GetKitPath.py](./GetKitPath.py)|Omniverse Kitの絶対パスを取得|
11 | |[GetRenderingSize.py](./GetRenderingSize.py)|レンダリングサイズを取得|
12 | |[GetRenderMode.py](./GetRenderMode.py)|Render Mode(RTX Real-time/RTX Path-traced)を取得、設定
Render Modeは、コルーチン内で「await omni.kit.app.get_app().next_update_async()」で1フレーム待ってから変更したほうが安全。|
13 |
14 |
--------------------------------------------------------------------------------
/System/GetPythonVersion.py:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | print(sys.version)
4 |
--------------------------------------------------------------------------------
/System/GetSysPath.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import os
3 |
4 | # Append path.
5 | def appendSysPath (newPath):
6 | existF = False
7 | for path in sys.path:
8 | if path == newPath:
9 | existF = True
10 | break
11 |
12 | if existF:
13 | return
14 |
15 | sys.path.append(newPath)
16 |
17 | for path in sys.path:
18 | print(path)
19 |
20 |
21 |
--------------------------------------------------------------------------------
/System/GetUSDVersion.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 | print(Usd.GetVersion())
3 |
4 |
--------------------------------------------------------------------------------
/System/readme.md:
--------------------------------------------------------------------------------
1 | # System
2 |
3 | システムの情報を取得します。
4 |
5 | |ファイル|説明|
6 | |---|---|
7 | |[GetPythonVersion.py](./GetPythonVersion.py)|Pythonのバージョンを取得|
8 | |[GetSysPath.py](./GetSysPath.py)|Pythonの検索パスの取得と追加|
9 | |[GetUSDVersion.py](./GetUSDVersion.py)|USDのバージョンを取得|
10 |
11 |
--------------------------------------------------------------------------------
/UI/DebugDraw/images/debugDraw_line_01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/UI/DebugDraw/images/debugDraw_line_01.png
--------------------------------------------------------------------------------
/UI/DebugDraw/readme.md:
--------------------------------------------------------------------------------
1 | # DebugDraw
2 |
3 | 3Dの座標指定で、Depthによる遮蔽を考慮したラインを描画(omni.debugdrawを使用)。
4 |
5 |
6 | |ファイル|説明|
7 | |---|---|
8 | |[UseDebugDraw.py](./UseDebugDraw.py)|ラインを描画
|
9 |
10 |
11 |
--------------------------------------------------------------------------------
/UI/DragAndDrop/dropTest.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
2 | import omni.ui
3 |
4 | # Create new window.
5 | my_window = omni.ui.Window("Drop test window", width=300, height=200)
6 |
7 | # ------------------------------------------.
8 | with my_window.frame:
9 | sField = None
10 |
11 | # Enable Drop.
12 | def drop_accept(url):
13 | return True
14 |
15 | # Called at Drop event.
16 | def drop (uiField, event):
17 | # prim path.
18 | vPath = event.mime_data
19 |
20 | # Get stage.
21 | stage = omni.usd.get_context().get_stage()
22 |
23 | # Get prim.
24 | if Sdf.Path(vPath):
25 | prim = stage.GetPrimAtPath(vPath)
26 | if prim.IsValid():
27 | # Set string.
28 | uiField.model.set_value(vPath)
29 |
30 | # Create window UI.
31 | with omni.ui.VStack(height=0):
32 | with omni.ui.Placer(offset_x=8, offset_y=8):
33 | omni.ui.Label("Please drop Prim below.")
34 |
35 | with omni.ui.Placer(offset_x=8, offset_y=0):
36 | omni.ui.Spacer(height=4)
37 |
38 | with omni.ui.Placer(offset_x=8, offset_y=0):
39 | sField = omni.ui.StringField(width=240, height=14, style={"color": 0xffffffff})
40 | sField.set_accept_drop_fn(drop_accept)
41 | sField.set_drop_fn(lambda a, w=sField: drop(w, a))
42 |
43 |
--------------------------------------------------------------------------------
/UI/DragAndDrop/images/dropTest.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/UI/DragAndDrop/images/dropTest.png
--------------------------------------------------------------------------------
/UI/DragAndDrop/readme.md:
--------------------------------------------------------------------------------
1 | # DragAndDrop
2 |
3 | UI間のドラッグ&ドロップ。
4 |
5 | |ファイル|説明|
6 | |---|---|
7 | |[dropTest.py](./dropTest.py)|Primをウィンドウ内のテキスト領域にドラッグすると、パスが表示される。
|
8 |
9 |
10 |
--------------------------------------------------------------------------------
/UI/DrawImage/images/ui_draw_image_00.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/UI/DrawImage/images/ui_draw_image_00.png
--------------------------------------------------------------------------------
/UI/DrawImage/images/ui_draw_image_01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/UI/DrawImage/images/ui_draw_image_01.png
--------------------------------------------------------------------------------
/UI/DrawImage/readme.md:
--------------------------------------------------------------------------------
1 | # DrawImage
2 |
3 | ビューポートに画像をオーバレイ表示します。
4 | なお、Omniverse Code(Omniverse Kit 103を使用)では、Omniverse自身のビューポートの実装が大きく進化しているようでした (2022/01/21 確認)。
5 | そのため、おそらく以下に列挙した描画実装は将来的には不要になると思われます。
6 |
7 |
8 | |ファイル|説明|
9 | |---|---|
10 | |[drawImage.py](./drawImage.py)|omni.ui.ByteImageProviderを使用して、RGBAバッファに描画したイメージをビューポートにオーバレイ
|
11 | |[drawImageWithPIL.py](./drawImageWithPIL.py)|omni.ui.ByteImageProviderを使用して、Pillow(PIL)での描画をRGBAバッファに送りビューポートにオーバレイ
|
12 |
13 |
14 |
--------------------------------------------------------------------------------
/UI/Viewport/DrawRandomRect.py:
--------------------------------------------------------------------------------
1 | import omni.ui
2 | import random
3 |
4 | # Get main window viewport.
5 | window = omni.ui.Window('Viewport')
6 |
7 | rectSize = 5.0
8 |
9 | with window.frame:
10 | # Use ZStack for multiple displays.
11 | with omni.ui.ZStack():
12 | for i in range(50):
13 | px = random.random() * 500.0
14 | py = random.random() * 500.0
15 | with omni.ui.VStack(height=0):
16 | with omni.ui.Placer(offset_x=px, offset_y=py):
17 | # Set rectangle.
18 | rect = omni.ui.Rectangle(width=rectSize, height=rectSize)
19 |
20 | # Color : 0xAABBGGRR.
21 | rect.set_style({"background_color":0xff0000ff})
22 |
--------------------------------------------------------------------------------
/UI/Viewport/DrawText.py:
--------------------------------------------------------------------------------
1 | import omni.ui
2 |
3 | # Get main window viewport.
4 | window = omni.ui.Window('Viewport')
5 |
6 | with window.frame:
7 | with omni.ui.VStack():
8 | # Display position from top left.
9 | with omni.ui.Placer(offset_x=20, offset_y=50):
10 | # Set label.
11 | f = omni.ui.Label("Hello Omniverse!", alignment=omni.ui.Alignment.LEFT_TOP)
12 | f.visible = True
13 |
14 | # Color : 0xAABBGGRR.
15 | f.set_style({"color": 0xff00ffff, "font_size": 32})
16 |
17 |
--------------------------------------------------------------------------------
/UI/Viewport/DrawText2.py:
--------------------------------------------------------------------------------
1 | import omni.ui
2 |
3 | # Get main window viewport.
4 | window = omni.ui.Window('Viewport')
5 |
6 | with window.frame:
7 | with omni.ui.VStack(height=0):
8 | with omni.ui.Placer(offset_x=20, offset_y=50):
9 | # Set label.
10 | f = omni.ui.Label("Hello Omniverse!")
11 | f.visible = True
12 | f.set_style({"color": 0xff00ffff, "font_size": 32})
13 |
14 | with omni.ui.Placer(offset_x=20, offset_y=0):
15 | f2 = omni.ui.Label("Line2!")
16 | f2.visible = True
17 | f2.set_style({"color": 0xff00ff00, "font_size": 32})
18 |
19 | with omni.ui.Placer(offset_x=20, offset_y=0):
20 | f3 = omni.ui.Label("Line3!")
21 | f3.visible = True
22 | f3.set_style({"color": 0xff0000ff, "font_size": 32})
23 |
24 |
--------------------------------------------------------------------------------
/UI/Viewport/GetActiveViewportInfo.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, CameraUtil, UsdShade, Sdf, Gf, Tf
2 | import omni.ext
3 | import omni.ui
4 | from omni.ui import color as cl
5 | from omni.ui import scene as sc
6 | import omni.kit
7 |
8 | # Kit104 : Get active viewport window.
9 | active_vp_window = omni.kit.viewport.utility.get_active_viewport_window()
10 | viewport_api = active_vp_window.viewport_api
11 |
12 | # Get Viewport window title.
13 | print("Viewport window : " + active_vp_window.name)
14 |
15 | # Get camera path ("/OmniverseKit_Persp" etc).
16 | cameraPath = viewport_api.camera_path.pathString
17 | print("cameraPath : " + cameraPath)
18 |
19 | # Resolution.
20 | resolution = viewport_api.resolution
21 | print("Resolution : " + str(resolution[0]) + " x " + str(resolution[1]))
22 |
23 | # Stage (Usd.Stage).
24 | print(viewport_api.stage)
25 |
26 | # Projection matrix (Gf.Matrix4d).
27 | print(viewport_api.projection)
28 |
29 | # Transform matrix (Gf.Matrix4d).
30 | print(viewport_api.transform)
31 |
32 | # View matrix (Gf.Matrix4d).
33 | print(viewport_api.view)
34 |
35 |
36 |
--------------------------------------------------------------------------------
/UI/Viewport/GetViewportRect.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, UsdPhysics, UsdSkel, UsdShade, Sdf, Gf, Tf
2 | import omni.ui
3 |
4 | # Get main window viewport.
5 | viewportI = omni.kit.viewport_legacy.acquire_viewport_interface()
6 | vWindow = viewportI.get_viewport_window(None)
7 |
8 | # Get viewport rect.
9 | viewportRect = vWindow.get_viewport_rect()
10 | viewportSize = (viewportRect[2] - viewportRect[0], viewportRect[3] - viewportRect[1])
11 | print(viewportRect)
12 | print(viewportSize)
13 |
14 | # Get Viewport window rect.
15 | uiViewportWindow = omni.ui.Workspace.get_window("Viewport")
16 | wid = uiViewportWindow.width
17 | hei = uiViewportWindow.height
18 | posX = uiViewportWindow.position_x
19 | posY = uiViewportWindow.position_y
20 | print("wid = " + str(wid))
21 | print("hei = " + str(hei))
22 | print("posX = " + str(posX))
23 | print("posY = " + str(posY))
24 |
25 |
--------------------------------------------------------------------------------
/UI/Viewport/UpdateText.py:
--------------------------------------------------------------------------------
1 | import omni.ui
2 | import asyncio
3 | import omni.kit.app
4 |
5 | # Get main window viewport.
6 | window = omni.ui.Window('Viewport')
7 |
8 | # ------------------------------------------.
9 | async def my_task():
10 | countV = 0
11 |
12 | print('Start task.')
13 |
14 | f = None
15 | for i in range(10):
16 | with window.frame:
17 | with omni.ui.VStack():
18 | with omni.ui.Placer(offset_x=20, offset_y=50):
19 | # Set label.
20 | f = omni.ui.Label("counter = " + str(countV), alignment=omni.ui.Alignment.LEFT_TOP)
21 | f.visible = True
22 | f.set_style({"color": 0xff00ffff, "font_size": 32})
23 | countV += 1
24 | await asyncio.sleep(1) # Sleep 1sec.
25 |
26 | print('End task.')
27 |
28 | if f != None:
29 | f.visible = False
30 | f = None
31 | # ------------------------------------------.
32 | # Start task.
33 | asyncio.ensure_future(my_task())
34 |
35 |
--------------------------------------------------------------------------------
/UI/Viewport/UpdateText2.py:
--------------------------------------------------------------------------------
1 | import omni.ui
2 | import omni.kit.app
3 | import carb.events
4 | import asyncio
5 | import time
6 |
7 | # Get main window viewport.
8 | window = omni.ui.Window('Viewport')
9 |
10 | countV = 0
11 | timeV = time.time()
12 |
13 | # ------------------------------------------.
14 | # Update event.
15 | # ------------------------------------------.
16 | def on_update(e: carb.events.IEvent):
17 | global countV
18 | global timeV
19 |
20 | # Process every second.
21 | curTimeV = time.time()
22 | if curTimeV - timeV > 1:
23 | timeV = curTimeV
24 |
25 | with window.frame:
26 | with omni.ui.VStack(height=0):
27 | with omni.ui.Placer(offset_x=20, offset_y=50):
28 | # Set label.
29 | f = omni.ui.Label("counter = " + str(countV))
30 | f.visible = True
31 | f.set_style({"color": 0xff00ffff, "font_size": 32})
32 | countV += 1
33 |
34 | # ------------------------------------------.
35 | # Register for update events.
36 | # To clear the event, specify "subs=None".
37 | subs = omni.kit.app.get_app().get_update_event_stream().create_subscription_to_pop(on_update, name="Test update")
38 |
39 |
40 |
--------------------------------------------------------------------------------
/UI/Viewport/WorldToScreen.py:
--------------------------------------------------------------------------------
1 | from pxr import Usd, UsdGeom, CameraUtil, UsdShade, Sdf, Gf, Tf
2 | import omni.ext
3 | import omni.ui
4 | from omni.ui import color as cl
5 | from omni.ui import scene as sc
6 | import omni.kit
7 |
8 | # Kit104 : Get active viewport window.
9 | active_vp_window = omni.kit.viewport.utility.get_active_viewport_window()
10 | viewport_api = active_vp_window.viewport_api
11 |
12 | # World to NDC space (X : -1.0 to +1.0, Y : -1.0 to +1.0).
13 | p = (0, 0, 0)
14 | p_screen = viewport_api.world_to_ndc.Transform(p)
15 |
16 | # NDC to Pixel space.
17 | sPos, in_viewport = viewport_api.map_ndc_to_texture_pixel(p_screen)
18 | if in_viewport:
19 | print(sPos)
20 |
21 |
--------------------------------------------------------------------------------
/UI/Viewport/images/DisplayText.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/UI/Viewport/images/DisplayText.png
--------------------------------------------------------------------------------
/UI/Viewport/images/DisplayText2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/UI/Viewport/images/DisplayText2.png
--------------------------------------------------------------------------------
/UI/Viewport/images/DrawPrimName.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/UI/Viewport/images/DrawPrimName.png
--------------------------------------------------------------------------------
/UI/Viewport/images/DrawRandomRect.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/UI/Viewport/images/DrawRandomRect.png
--------------------------------------------------------------------------------
/UI/Viewport/images/UpdateText.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/UI/Viewport/images/UpdateText.png
--------------------------------------------------------------------------------
/UI/Viewport/images/UpdateText2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/UI/Viewport/images/UpdateText2.png
--------------------------------------------------------------------------------
/UI/Viewport/images/viewport_104_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/UI/Viewport/images/viewport_104_01.jpg
--------------------------------------------------------------------------------
/UI/Viewport/images/viewport_104_02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/UI/Viewport/images/viewport_104_02.jpg
--------------------------------------------------------------------------------
/UI/Viewport/images/viewport_104_03.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/UI/Viewport/images/viewport_104_03.jpg
--------------------------------------------------------------------------------
/UI/Window/CreateNewWindow.py:
--------------------------------------------------------------------------------
1 | import omni.ui
2 |
3 | # Create new window.
4 | my_window = omni.ui.Window("New Window", width=300, height=200)
5 |
6 | # ------------------------------------------.
7 | # Clicked button event.
8 | # ------------------------------------------.
9 | def onButtonClick(floatField):
10 | print("Button pushed.")
11 |
12 | # get/set FloatField.
13 | fCounter = floatField.model.get_value_as_float()
14 | fCounter += 1.0
15 | floatField.model.set_value(fCounter)
16 |
17 | # ------------------------------------------.
18 | with my_window.frame:
19 | with omni.ui.VStack(height=0):
20 | floatField = None
21 |
22 | with omni.ui.Placer(offset_x=8, offset_y=8):
23 | # Set label.
24 | f = omni.ui.Label("Hello Omniverse!")
25 | f.set_style({"color": 0xff00ffff, "font_size": 20})
26 |
27 | with omni.ui.Placer(offset_x=8, offset_y=0):
28 | f2 = omni.ui.Label("Line2!")
29 | f2.set_style({"color": 0xff00ff00, "font_size": 20})
30 |
31 | with omni.ui.Placer(offset_x=8, offset_y=0):
32 | with omni.ui.HStack(width=300):
33 | omni.ui.Label("Edit : ", width=50)
34 | floatField = omni.ui.FloatField(width=200, height=0)
35 |
36 | with omni.ui.Placer(offset_x=8, offset_y=0):
37 | # Set button.
38 | btn = omni.ui.Button("Push", width=200, height=0)
39 | btn.set_clicked_fn(lambda f = floatField: onButtonClick(f))
40 |
--------------------------------------------------------------------------------
/UI/Window/FileDialog.py:
--------------------------------------------------------------------------------
1 | import omni.ui
2 |
3 | # ref : omni.kit.window.file
4 |
--------------------------------------------------------------------------------
/UI/Window/ImageWindow.py:
--------------------------------------------------------------------------------
1 | import omni.ui
2 |
3 | # Create new window.
4 | my_window = omni.ui.Window("New Window", width=300, height=200)
5 |
6 | # ------------------------------------------.
7 | with my_window.frame:
8 | with omni.ui.VStack(height=0):
9 | with omni.ui.Placer(offset_x=8, offset_y=8):
10 | f = omni.ui.Label("Hello Omniverse!")
11 | f.set_style({"color": 0xff00ffff, "font_size": 20})
12 | with omni.ui.Placer(offset_x=8, offset_y=0):
13 | # image search path :
14 | # "kit" or
15 | # absolute path
16 | omni.ui.Image("resources/desktop-icons/omniverse_64.png", width=64, height=64, fill_policy=omni.ui.FillPolicy.PRESERVE_ASPECT_FIT, alignment=omni.ui.Alignment.LEFT_CENTER)
17 |
18 |
--------------------------------------------------------------------------------
/UI/Window/InputField.py:
--------------------------------------------------------------------------------
1 | import omni.ui
2 |
3 | # Create new window.
4 | my_window = omni.ui.Window("Input test window", width=300, height=200)
5 |
6 | # ------------------------------------------.
7 | with my_window.frame:
8 | sField = None
9 | sLabel = None
10 |
11 | # Reset StringField, Label.
12 | def onReset (uiField, uiLabel):
13 | if not uiField or not uiLabel:
14 | return
15 |
16 | uiField.model.set_value("")
17 | uiLabel.text = ""
18 |
19 | # Called when a value is changed in a StringField.
20 | def onValueChanged (uiFieldModel, uiLabel):
21 | if not uiFieldModel or not uiLabel:
22 | return
23 |
24 | v = uiFieldModel.get_value_as_string()
25 | uiLabel.text = v
26 |
27 | # Create window UI.
28 | with omni.ui.VStack(height=0):
29 | with omni.ui.Placer(offset_x=8, offset_y=8):
30 | with omni.ui.HStack(width=0):
31 | omni.ui.Label("Input ")
32 | sField = omni.ui.StringField(width=120, height=14, style={"color": 0xffffffff})
33 |
34 | omni.ui.Spacer(height=4)
35 | sLabel = omni.ui.Label("text")
36 | omni.ui.Spacer(height=4)
37 |
38 | btn = omni.ui.Button(" Reset ")
39 |
40 | # Specify the callback to be called when the Button is pressed.
41 | btn.set_clicked_fn(lambda f = sField, l = sLabel: onReset(f, l))
42 |
43 | # Specify a callback when a value is changed in a StringField.
44 | sField.model.add_value_changed_fn(lambda f, l = sLabel: onValueChanged(f, l))
45 |
46 |
47 |
--------------------------------------------------------------------------------
/UI/Window/images/CreateNewWindow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/UI/Window/images/CreateNewWindow.png
--------------------------------------------------------------------------------
/UI/Window/images/ImageWindow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/UI/Window/images/ImageWindow.png
--------------------------------------------------------------------------------
/UI/Window/images/InputField.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/UI/Window/images/InputField.png
--------------------------------------------------------------------------------
/UI/Window/readme.md:
--------------------------------------------------------------------------------
1 | # Window
2 |
3 | ウィンドウを作成。
4 |
5 | |ファイル|説明|
6 | |---|---|
7 | |[CreateNewWindow.py](./CreateNewWindow.py)|新しいウィンドウを作成。
|
8 | |[ImageWindow.py](./ImageWindow.py)|イメージをウィンドウ内に表示。
|
9 |
10 | イメージは「kit」をカレントパスとして指定します。
11 | Extensionで絶対パスを指定する場合は、以下のように指定します。
12 |
13 | ```python
14 | from pathlib import Path
15 |
16 | IMAGE_PATH = Path(__file__).parent.parent.joinpath("images")
17 |
18 | imagePath = f"{IMAGE_PATH}/xxxx.png"
19 |
20 | omni.ui.Image(imagePath, width=64, height=64, fill_policy=omni.ui.FillPolicy.PRESERVE_ASPECT_FIT, alignment=omni.ui.Alignment.LEFT_CENTER)
21 | ```
22 |
23 | |ファイル|説明|
24 | |---|---|
25 | |[InputField.py](./InputField.py)|omni.ui.StringFieldを使った入力フィールド。
|
26 |
27 |
--------------------------------------------------------------------------------
/UI/readme.md:
--------------------------------------------------------------------------------
1 | # UI
2 |
3 | UI関連の処理を行います。
4 | UIは「omni.ui」からアクセスすることでさまざまなウィジットを表現できます。
5 | UIについては生成と破棄はセットになるためExtensionで実装するほうがよいですが、Script Editorからの実行でUI表示を行うこともできます(ただし、手動で破棄処理を呼ぶ必要あり)。
6 |
7 | |サンプル|説明|
8 | |---|---|
9 | |[DebugDraw](./DebugDraw)|3Dの座標指定で、Depthによる遮蔽を考慮したラインを描画 (omni.debugdrawを使用)|
10 | |[DragAndDrop](./DragAndDrop)|UIでのドラッグ&ドロップ|
11 | |[DrawImage](./DrawImage)|スクリーンにイメージをオーバーレイして描画|
12 | |[Viewport](./Viewport)|ビューポートにオーバレイして表示|
13 | |[Window](./Window)|新しいウィンドウを表示|
14 |
--------------------------------------------------------------------------------
/images/omniverse_script_editor_01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/images/omniverse_script_editor_01.png
--------------------------------------------------------------------------------
/knowledge/dev_method.md:
--------------------------------------------------------------------------------
1 | # Omniverseでの開発手段
2 |
3 | OmniverseはここでサンプルとしてアップしているPythonスクリプト以外に、
4 | スクリプトを機能ごとにまとめてモジュール化した「Extension」、
5 | 外部ツールから3DモデルをUSDを経由して連携する「Connector」、
6 | アプリケーション自身の「Omniverse App」があります。
7 | 
8 |
9 | Pythonスクリプトを機能別にまとめてモジュール化したものがExtensionになります。
10 | 複数のExtensionを組み合わせて目的別にアプリケーション化したものがOmniverse CreateやOmniverse Viewなどのアプリになります。
11 | サードパーティでもOmniverseアプリは開発できます。
12 |
13 | また、C/C++言語を使用して「Connector」を実装することにより、
14 | 外部の3DCGツールとUSDを介して連携できます。
15 | USD SDKでは、Pythonのモジュール/メソッドと、C/C++言語のクラスや関数は1対1で対応しています。
16 | そのため、PythonスクリプトでUSDを操作できるようになればConnectorを実装する際にはそのままその知識は活かせるようになるかと思います。
17 |
18 | Omniverse上でのマテリアル表現は、USD標準のUsdPreviewSurface、OmniPBR、OmniSurfaceが使用されます。
19 | これらでもかなりのマテリアル表現ができますが、
20 | MDL(Material Definition Language : マテリアル定義言語)を使うことで、よりマテリアルを自由にカスタマイズすることができるようになります。
21 | OmniPBR、OmniSurfaceも固定(プリセット)のMDLで実装されている構成になります。
22 | MDLは他の3DCGエンジンで言う「Shader」に近い存在です。
23 |
24 | MDLについては、「NVIDIA MDL SDK - Get Started」に詳しい情報があります。
25 |
26 | https://developer.nvidia.com/mdl-sdk
27 |
28 | このような感じで、Omniverseはあらゆる個所をカスタマイズしていくことができるようになっています。
29 | それぞれは範囲が膨大になるため、まずはOmniverse CreateのScript Editor上でスクリプトを使ってシーンを制御できるようになる、というのが入口としてちょうどよいかもしれません。
30 |
31 |
--------------------------------------------------------------------------------
/knowledge/images/knowledge_dev_info_01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/knowledge/images/knowledge_dev_info_01.png
--------------------------------------------------------------------------------
/knowledge/images/knowledge_dev_info_02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/knowledge/images/knowledge_dev_info_02.png
--------------------------------------------------------------------------------
/knowledge/images/knowledge_dev_info_03.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/knowledge/images/knowledge_dev_info_03.jpg
--------------------------------------------------------------------------------
/knowledge/images/knowledge_dev_info_04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/knowledge/images/knowledge_dev_info_04.png
--------------------------------------------------------------------------------
/knowledge/images/knowledge_dev_method_01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/knowledge/images/knowledge_dev_method_01.png
--------------------------------------------------------------------------------
/knowledge/images/knowledge_dev_usd_01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ft-lab/omniverse_sample_scripts/a60924991193ebd23e396010307e057efd8411ac/knowledge/images/knowledge_dev_usd_01.png
--------------------------------------------------------------------------------
/pip_archive/PIL/DrawImage.py:
--------------------------------------------------------------------------------
1 | # PIL exists in "kit/extscore/omni.kit.pip_archive/pip_prebundle".
2 | from PIL import Image, ImageDraw, ImageFont
3 |
4 | # Create new image.
5 | im = Image.new("RGBA", (512, 512), (0, 0, 0, 0))
6 |
7 | draw = ImageDraw.Draw(im)
8 |
9 | # Draw rectangle (fill).
10 | draw.rectangle((100, 100, 200, 200), fill=(255, 0, 0))
11 |
12 | # Draw rectangle.
13 | draw.rectangle((100, 220, 200, 320), outline=(0, 0, 255), width=1)
14 |
15 | # Draw line.
16 | draw.line((0, 0, im.width, im.height), fill=(0, 255, 0), width=2)
17 |
18 | # Draw circle.
19 | draw.ellipse((100, 400, 150, 450), outline=(0, 0, 255), width=2)
20 |
21 | # Draw circle (fill).
22 | draw.ellipse((280, 300, 380, 400), fill=(0, 0, 255))
23 |
24 | # Polygon.
25 | vers = ((40, 20), (140, 120), (180, 60))
26 | draw.polygon(vers, outline=(128, 0, 0))
27 |
28 | # Polygon (fill).
29 | vers = ((240, 20), (340, 120), (380, 60))
30 | draw.polygon(vers, fill=(128, 128, 0))
31 |
32 | # Font.
33 | font = None
34 | try:
35 | # The ttf font path should be replaced according to your environment.
36 | basePath = "K:/fonts"
37 | fontPath = basePath + "/SourceHanSansJP-Bold.otf"
38 | font = ImageFont.truetype(fontPath, 48)
39 | except Exception as e:
40 | print(e)
41 |
42 | # Draw text.
43 | if font != None:
44 | draw.multiline_text((16, 40), 'Draw Text!', fill=(0, 128, 0))
45 |
46 | # Save image.
47 | # Rewrite it to any file path and uncomment the following.
48 | #im.save("K:/NVIDIA_omniverse/images/out.png", quality=95)
49 |
--------------------------------------------------------------------------------
/pip_archive/PIL/LoadImage.py:
--------------------------------------------------------------------------------
1 | # PIL exists in "kit/extscore/omni.kit.pip_archive/pip_prebundle".
2 | from PIL import Image
3 |
4 | # Load image from file.
5 | path = "K:/NVIDIA_omniverse/images/omniverse_64.png"
6 | im = None
7 | try:
8 | im = Image.open(path)
9 |
10 | # Get image size.
11 | wid = im.size[0]
12 | hei = im.size[1]
13 | print("Image size : " + str(wid) + " x " + str(hei))
14 |
15 | # Get format (PNG, JPEG, etc).
16 | print("Format : " + str(im.format))
17 |
18 | # Get mode (RGB, RGBA, etc.).
19 | print("Mode : " + str(im.mode))
20 |
21 | except Exception as e:
22 | print(e)
23 |
24 |
--------------------------------------------------------------------------------
/pip_archive/PIL/readme.md:
--------------------------------------------------------------------------------
1 | # Pillow(PIL)
2 |
3 | Pillow(PIL)を使用して、2D画像の操作を行います。
4 |
5 | |ファイル|説明|
6 | |---|---|
7 | |[LoadImage.py](./LoadImage.py) |画像の読み込み|
8 | |[DrawImage.py](./DrawImage.py) |画像の描画と出力|
9 |
10 |
--------------------------------------------------------------------------------
/pip_archive/numpy/CalcMultiplyMatrix.py:
--------------------------------------------------------------------------------
1 | import numpy
2 |
3 | # Create 4x4 matrix (identity matrix).
4 | m1 = numpy.matrix(numpy.identity(4))
5 | m2 = numpy.matrix(numpy.identity(4))
6 |
7 | m1[3] = [22.3, 15.5, 3.0, 1.0]
8 | m2[3] = [50.0, 100.0, -20.0, 1.0]
9 |
10 | # Multiply matrix.
11 | # (Same result for mA and mB)
12 | mA = m1 * m2
13 | mB = numpy.dot(m1, m2)
14 | print(mA)
15 | print(mB)
16 |
17 |
--------------------------------------------------------------------------------
/pip_archive/numpy/CalcMultiplyMatrixVector.py:
--------------------------------------------------------------------------------
1 | import numpy
2 |
3 | # Create Vector3.
4 | v1 = numpy.array([0.0, 1.0, 2.0])
5 |
6 | # Create 4x4 matrix.
7 | m1 = numpy.matrix(numpy.identity(4))
8 | m1[3] = [22.3, 15.5, 3.0, 1.0]
9 |
10 | # Make sure that the vector to be multiplied has four elements.
11 | vec4 = numpy.array(v1)
12 | if v1.size == 3:
13 | vec4 = numpy.array([v1[0], v1[1], v1[2], 1.0])
14 |
15 | # Vector and matrix multiplication.
16 | retM = numpy.dot(vec4, m1)
17 | print(retM)
18 |
19 | # Replace the result with Vector3.
20 | retV = numpy.array([retM[0,0], retM[0,1], retM[0,2]])
21 | print(retV)
22 |
--------------------------------------------------------------------------------
/pip_archive/numpy/CalcVector.py:
--------------------------------------------------------------------------------
1 | import numpy
2 |
3 | v1 = numpy.array([0.0, 1.0, 2.0])
4 | v2 = numpy.array([1.2, 1.5, 2.3])
5 |
6 | v3 = v1 + v2
7 | print(v3)
8 |
9 | v3 = v1 * v2
10 | print(v3)
11 |
12 | v2[0] += 0.5
13 | print(v2[0])
14 | print(v2[1])
15 | print(v2[2])
16 |
17 |
--------------------------------------------------------------------------------
/pip_archive/numpy/CalcVectorDotCross.py:
--------------------------------------------------------------------------------
1 | import numpy
2 |
3 | v1 = numpy.array([0.0, 1.0, 2.0])
4 | v2 = numpy.array([1.2, 1.5, 2.3])
5 |
6 | # Calculating the Inner Product.
7 | v = numpy.dot(v1, v2)
8 | print("Inner product : " + str(v))
9 |
10 | # Calculating the Outer Product.
11 | v = numpy.cross(v1, v2)
12 | print("Outer product : " + str(v))
13 |
--------------------------------------------------------------------------------
/pip_archive/numpy/CalcVectorLength.py:
--------------------------------------------------------------------------------
1 | import numpy
2 |
3 | val = numpy.array([2.5, 1.0, 3.0])
4 | lenV = numpy.linalg.norm(val)
5 |
6 | print(str(val) + " : Length = " + str(lenV))
7 |
8 | # Normalized.
9 | lenV = numpy.linalg.norm(val)
10 | val2 = val
11 | if lenV != 0.0:
12 | val2 = val / lenV
13 |
14 | print("Normalized " + str(val) + " ==> " + str(val2))
15 |
--------------------------------------------------------------------------------
/pip_archive/numpy/CreateMatrix.py:
--------------------------------------------------------------------------------
1 | import numpy
2 |
3 | # Create 4x4 matrix (identity matrix).
4 | m = numpy.matrix(numpy.identity(4))
5 | print(m)
6 |
7 | # Set a value to a matrix.
8 | m[3,0] = 2.0
9 | m[2] = [50.0, 100.0, -20.0, 1.0]
10 | print(m)
11 |
--------------------------------------------------------------------------------
/pip_archive/numpy/readme.md:
--------------------------------------------------------------------------------
1 | # numpy
2 |
3 | numpyはベクトル・行列計算を行うモジュールです。
4 | 高速に数値計算を行うことができます。
5 | USDでは"Gf"のモジュールがベクトル・行列計算で使用され、また3DCGでよく使う計算もここに内包されているため、
6 | 別途でnumpyを深く使うということは少ないかもしれません。
7 |
8 | |ファイル|説明|
9 | |---|---|
10 | |[CalcVector.py](./CalcVector.py)|ベクトル計算を行う|
11 | |[CalcVectorLength.py](./CalcVectorLength.py)|ベクトルの長さを計算、正規化|
12 | |[CalcVectorDotCross.py](./CalcVectorDotCross.py)|ベクトルの内積、外積を計算|
13 | |[CreateMatrix.py](./CreateMatrix.py)|行列の作成/単位ベクトル|
14 | |[CalcMultiplyMatrix.py](./CalcMultiplyMatrix.py)|行列同士の乗算|
15 | |[CalcMultiplyMatrixVector.py](./CalcMultiplyMatrixVector.py)|行列とベクトルの乗算|
16 |
17 |
--------------------------------------------------------------------------------
/pip_archive/readme.md:
--------------------------------------------------------------------------------
1 | # omni.kit.pip_archive
2 |
3 | Pythonでよく使用するモジュールは、"pip_archive"として用意されています。
4 | これは"omni.kit.pip_archive"のExtensionとして提供されていますが、Pythonのこれらを使ったモジュールと同じ使い方ができます。
5 | いくつか使用してみました。
6 |
7 |
8 | |サンプル|説明|
9 | |---|---|
10 | |[numpy](./numpy)|ベクトル・行列計算を行う|
11 | |[PIL](./PIL)|2D画像操作を行う : Pillow(Python Imaging Library(PIL)).|
12 |
--------------------------------------------------------------------------------