file_path
stringlengths 21
224
| content
stringlengths 0
80.8M
|
---|---|
gigwegbe/synthetic_data_with_nvidia_replicator_and_edge_impulse/objects_position_angled_60.py | import omni.replicator.core as rep
with rep.new_layer():
# Load in asset
local_path = "/home/george/Documents/synthetic_data_with_nvidia_replicator_and_edge_impulse/"
TABLE_USD = f"{local_path}/asset/Collected_EastRural_Table/EastRural_Table.usd"
SPOON_SMALL_USD = f"{local_path}/asset/Collected_Spoon_Small/Spoon_Small.usd"
SPOON_BIG_USD = f"{local_path}/asset/Collected_Spoon_Big/Spoon_Big.usd"
FORK_SMALL_USD = f"{local_path}/asset/Collected_Fork_Small/Fork_Small.usd"
FORK_BIG_USD = f"{local_path}/asset/Collected_Fork_Big/Fork_Big.usd"
KNIFE_USD = f"{local_path}/asset/Collected_Knife/Knife.usd"
# Camera paramters
cam_position = (46, 200, 78)
cam_position2 = (46, 120, 25)
cam_position_random = rep.distribution.uniform((0, 181, 0), (0, 300, 0))
cam_rotation = (-60, 0, 0)
focus_distance = 114
focus_distance2 = 39.1
focal_length = 27
focal_length2 = 18.5
f_stop = 1.8
f_stop2 = 1.8
focus_distance_random = rep.distribution.normal(500.0, 100)
# Cultery path
current_cultery = KNIFE_USD # Change the item here e.g KNIFE_USD
output_path = current_cultery.split(".")[0].split("/")[-1]
def rect_lights(num=1):
lights = rep.create.light(
light_type="rect",
temperature=rep.distribution.normal(6500, 500),
intensity=rep.distribution.normal(0, 5000),
position=(45, 110, 0),
rotation=(-90, 0, 0),
scale=rep.distribution.uniform(50, 100),
count=num
)
return lights.node
def dome_lights(num=3):
lights = rep.create.light(
light_type="dome",
temperature=rep.distribution.normal(6500, 500),
intensity=rep.distribution.normal(0, 1000),
position=(45, 120, 18),
rotation=(225, 0, 0),
count=num
)
return lights.node
def table():
table = rep.create.from_usd(TABLE_USD, semantics=[('class', 'table')])
with table:
rep.modify.pose(
position=(46, -0.0, 20),
rotation=(0, -90, -90),
)
return table
# Define randomizer function for CULTERY assets. This randomization includes placement and rotation of the assets on the surface.
def cutlery_props(size=15):
instances = rep.randomizer.instantiate(rep.utils.get_usd_files(
current_cultery), size=size, mode='point_instance')
with instances:
rep.modify.pose(
position=rep.distribution.uniform(
(0, 76.3651, 0), (90, 76.3651, 42)),
rotation=rep.distribution.uniform(
(-90, -180, 0), (-90, 180, 0)),
)
return instances.node
# Register randomization
rep.randomizer.register(table)
rep.randomizer.register(cutlery_props)
rep.randomizer.register(rect_lights)
rep.randomizer.register(dome_lights)
# Multiple setup cameras and attach it to render products
camera = rep.create.camera(focus_distance=focus_distance, focal_length=focal_length,
position=cam_position, rotation=cam_rotation, f_stop=f_stop)
camera2 = rep.create.camera(focus_distance=focus_distance2, focal_length=focal_length2,
position=cam_position2, rotation=cam_rotation, f_stop=f_stop)
# Will render 1024x1024 images and 512x512 images
render_product = rep.create.render_product(camera, (1024, 1024))
render_product2 = rep.create.render_product(camera2, (512, 512))
# Initialize and attach writer
writer = rep.WriterRegistry.get("BasicWriter")
writer.initialize(output_dir=f"{local_path}/data/angled_60/{output_path}",
rgb=True, bounding_box_2d_tight=False, semantic_segmentation=False)
writer.attach([render_product, render_product2])
with rep.trigger.on_frame(num_frames=25):
rep.randomizer.table()
rep.randomizer.rect_lights(1)
rep.randomizer.dome_lights(1)
rep.randomizer.cutlery_props(5)
# Run the simulation graph
rep.orchestrator.run()
|
gigwegbe/synthetic_data_with_nvidia_replicator_and_edge_impulse/README.md | ---
description: Come learn how to generate photorealistic images in Nvidia Replicator and build object detection model using Edge Impulse.
---
# The Unreasonable Effectiveness of Synthetic Data
Created By:
[George Igwegbe](https://www.linkedin.com/in/george-igwegbe/)
Public Project Link:
[GitHub](https://github.com/gigwegbe/synthetic_data_with_nvidia_replicator_and_edge_impulse) | [Edge Impulse](https://studio.edgeimpulse.com/public/187851/latest)
![Header](media_assets/cover_image.gif)
## Introduction
Building an object detection model can be tricky since it requires a large dataset. Sometimes, data can be few or not diverse enough to train a robust model. Synthetic data offers an alternative to generating well-represented datasets to build a quality model. By applying domain randomization, we developed photorealistic datasets, trained a neural network, and validated the model using real datasets. To create a diverse dataset, we created a variety of simulated environments with randomized properties: changing lighting conditions, camera position, and material textures. We also show that synthetic, randomized datasets can help generalize a model to adapt to the real-world environment.
## Story
We wanted to replicate the [object detection](https://www.youtube.com/watch?v=Vwv0PJPeC4s) work by Louis Moreau, but this time using synthetic data rather than real data. The project aims to demonstrate how to build and deploy the Edge Impulse object detection model using synthetic datasets generated by Nvidia Omniverse Replicator. The Replicator is an Nvidia Omniverse extension that provides means of generating physically accurate synthetic data.
## Why Synthetic Data?
Computer vision tasks such as classification, object detection, and segmentation require a large-scale dataset. Data collected from some real-world applications tend to be narrow and less diverse, often collected from a single environment, and sometimes is unchanged and stays the same for the most time. In addition, data collected from a single field tend to have fewer examples of tail-end scenarios and rare events, and we cannot easily replicate these situations in the real world.
Andrej Karpathy's presentation - (source: Tesla AI Day, 2021) |
--- |
![](media_assets/tesla_ai_day.avif) |
Consequently, models trained in a single domain are brittle and often fail when deployed in another environment; thus, it requires another training cycle to adapt to the new environment. It raises the question, how can we efficiently and cheaply collect generalized data across several domains? A simple unreasonable effective solution is Domain Randomization, which varies the texture and colour of the foreground object, the background image, the number of lights in the scene, the pose of the lights, and the camera position etc. Domain randomization can further improve the variability in the texture of synthetic data of rare events generated in the simulator.
> The purpose of domain randomization is to provide enough simulated variability at training time such that at test time the model is able to generalize to real-world data.” - Tobin et al, Domain Randomization for Transferring Deep Neural Networks from Simulation to the Real World, 2017
Domain Randomization for Transferring Deep Neural Networks - source: Tobin et al, 2017) |
--- |
![](media_assets/research_domain_rand.avif) |
Nvidia Replicator enables us to perform Domain Randomization. The Replicator is one module within the Omniverse family, and it offers tools and workflow to generate data for various computer vision and non-visual tasks. The Replicator is a highly interoperable tool that integrates with over 40+ modelling/rendering applications across different verticals. The seamless integration is possible thanks to Pixar's Universal Scene Description(USD), which serves as a protocol for various applications such as Blender, 3DMax, Maya, Revit, C4D etc., to work with the Nvidia Replicator.
## Data-Centric Workflow
Traditional machine learning workflow is often model-centric, focusing more on the model's development by iteratively improving the algorithm design, etc. In this project, we chose the Data-centric approach, where we fixed the model and iteratively improved the quality of the generated dataset. This approach is more robust since we know our model is as good as the dataset. This method hence systematically changes the dataset performance on an AI task. At its core, it is thinking about ML in terms of data, not the model.
Data generation and model building workflow |
--- |
![](media_assets/workflow.avif) |
## Requirements
- Nvidia Omniverse Replicator
- Edge Impulse Studio
- Logitech Webcam HD Pro - C920
### Hardware and Driver Setup
Nvidia Omniverse Replicator is a computation-intensive application requiring a moderate-size GPU and decent RAM. My hardware setup consists of 32GB RAM, 1TB storage space and 8GB GPU with an Intel i9 processor.
Hardware Specification | Hardware Specification
--- | ---
![](media_assets/hardware_spec.avif) | ![](media_assets/hardware_spec2.avif)
The application can run on both Windows and Linux operating systems. For this experiment, we used Ubuntu 20.04 LTS distro, given Ubuntu 18.04 is no longer supported by Nvidia Omniverse as of November 2022. In addition, we selected the appropriate Nvidia driver, v510.108.03 and installed it on a Linux machine.
Software Specification | Software Specification
--- | ---
![](media_assets/software_spec.avif) | ![](media_assets/software_spec2.avif)
## Experiment Setup and Data Generation
The environment for the experiment consists of movable and immovable objects (dynamic and static positioning objects). The immovable object consists of Lights, a Table and two Cameras. At the same time, the movable objects are the cutlery which is a spoon, fork and knife. We will use domain randomization to alter the properties of some of the movable and immovable objects. Assets which include objects and scenes are represented in the Replicator as USD.
Experimental Setup |
--- |
![](media_assets/experiment_setup.avif) |
Every object in Omniverse Replicator is represented as USD. A 3D model file with varying extensions such as obj, fbx, and glif can be imported into the Replicator using Nvidia Omniverse's CAD Importer extension. The extension converts the 3D files into USD. We imported our assets (Table, knife, spoon and fork) into the simulator by specifying the path of the assets.
Rectangular Light | Dome Light
--- | --- |
![](media_assets/light_rect.avif) | ![](media_assets/dome_light.avif)
Lightning plays a crucial role in data generation. There are different built-in lighting types in the Nvidia replicator. We choose two rectangular lights and a dome light since they give us better lighting options and capabilities for generating photorealistic images. The rectangular light emulates light generated from a panel, and the dome light lets you dynamically lighten the entire scene. We randomized some light parameters such as temperature and intensity, and both parameters were sampled from a <strong>normal distribution</strong>. In addition, the scale parameter was sampled from a <strong>uniform distribution</strong> while keeping the rotation and position of the lights fixed.
```python
# Lightning setup for Rectangular light and Dome light
def rect_lights(num=2):
lights = rep.create.light(
light_type="rect",
temperature=rep.distribution.normal(6500, 500),
intensity=rep.distribution.normal(0, 5000),
position=(-131,150,-134),
rotation=(-90,0,0),
scale=rep.distribution.uniform(50, 100),
count=num
)
return lights.node
def dome_lights(num=1):
lights = rep.create.light(
light_type="dome",
temperature=rep.distribution.normal(6500, 500),
intensity=rep.distribution.normal(0, 1000),
position=(0,0,0),
rotation=(270,0,0),
count=num
)
return lights.node
```
We fixed the position and rotation, selected the tabletop materials, chose an additional <strong>Mahogany</strong> material, and alternated the material in the data generation process.
```python
# Import and position the table object
def table():
table = rep.create.from_usd(TABLE_USD, semantics=[('class', 'table')])
with table:
rep.modify.pose(
position=(-135.39745, 0, -140.25696),
rotation=(0,-90,-90),
)
return table
```
To improve our dataset's quality further, we chose two cameras of different resolutions, which we strategically positioned in various locations within the scene. In addition, we varied the position of the cameras in a different version of the data generation process.
```python
# Multiple setup cameras and attach it to render products
camera = rep.create.camera(focus_distance=focus_distance, focal_length=focal_length, position=cam_position, rotation=cam_rotation, f_stop=f_stop)
camera2 = rep.create.camera(focus_distance=focus_distance2, focal_length=focal_length2, position=cam_position2, rotation=cam_rotation, f_stop=f_stop)
# Will render 1024x1024 images and 512x512 images
render_product = rep.create.render_product(camera1, (1024, 1024))
render_product2 = rep.create.render_product(camera2, (512, 512))
```
Finally, for the movable objects, which include a knife, spoon and fork, we ensure that these objects can only translate within the bound of the table. So we chose a bounding position where the objects were expected to translate and rotate with the table. We sampled position and rotation from a uniform distribution while maintaining the number of movable objects generated at each iteration to be five.
```python
# Define randomizer function for CULTERY assets.
def cutlery_props(size=5):
instances = rep.randomizer.instantiate(rep.utils.get_usd_files(current_cultery), size=size, mode='point_instance')
with instances:
rep.modify.pose(
position=rep.distribution.uniform((-212, 76.2, -187), (-62, 76.2, -94)),
rotation=rep.distribution.uniform((-90,-180, 0), (-90, 180, 0)),
)
return instances.node
```
At this juncture, we have instantiated all objects in our scene. We can now run the randomizer to generate 50 images at each synthetic generation cycle.
```python
# Register randomization
with rep.trigger.on_frame(num_frames=50):
rep.randomizer.table()
rep.randomizer.rect_lights(1)
rep.randomizer.dome_lights(1)
rep.randomizer.cutlery_props(5)
# Run the simulation graph
rep.orchestrator.run()
```
To ensure we generated photorealistic images, we switched to <strong>RTXinteractive(Path Tracing)</strong> mode, which gave high-fidelity renderings.
Data generation process |
--- |
![](media_assets/data_generation_process2.gif) |
## Data Distribution and Model Building
Data Distribution of different items |
--- |
![](media_assets/data_distribution.avif) |
Following the data-centric philosophy, We generated three versions of the dataset. The first version, <strong>V1</strong>, consists of generated images normal to the camera position, and <strong>V2</strong> represents images generated at an angle of 60 degrees to the camera position with a mahogany table top. <strong>V3</strong> comprises images normal to the camera position while the cutlery were suspended in space.
V1 - Normal to the object |
--- |
![](media_assets/v1.avif) |
<table>
<tr>
<td>V2 - Angled to the object</td>
<td>V3 - Normal to the object and object suspended in space</td>
</tr>
<tr>
<td valign="top"><img src="media_assets/v2.avif"></td>
<td valign="top"><img src="media_assets/v3.avif"></td>
</tr>
</table>
<table>
<tr>
<td>Generated Dataset - V2</td>
<td>Generated Dataset - V3</td>
</tr>
<tr>
<td valign="top"><img src="media_assets/generated_dataset.avif"></td>
<td valign="top"><img src="media_assets/generated_dataset2.avif"></td>
</tr>
</table>
## Edge Impulse: Data Annotation and Model Building
<table>
<tr>
<td>Data Labeler </td>
<td>Data Annotation</td>
</tr>
<tr>
<td><img src="media_assets/annotating_image.png"></td>
<td><img src="media_assets/image_in_queue.png"></td>
</tr>
</table>
We uploaded the generated images to Edge Impulse Studio, where we annotated the dataset into different classes. We carefully annotated each dataset version and trained using the <strong>Yolov5</strong> object detection model. We tried a couple of input sizes ranging from 320, 512 and 1024 pixels before settling with <strong>320</strong>. Edge Impulse provided an excellent version control system for models, which enabled us to track model performance across different dataset versions and hyperparameters.
<table>
<tr>
<td>Create Impulse</td>
<td>Generate Feature </td>
</tr>
<tr>
<td><img src="media_assets/building_model.png"></td>
<td><img src="media_assets/feature_extraction.png"></td>
</tr>
</table>
Version Control in Edge Impulse |
--- |
![](media_assets/version_control.gif) |
### Testing of Object Detection Models with Real Objects
We used the Edge Impulse CLI tool to evaluate the model's accuracy by downloading, building and running the model locally. A Logitech C920 webcam streamed the live video of objects on a table from 50 cm to 80 cm from the camera. The position of the camera remains fixed during the experiment. The clips below show that the trained model does not generalize well to real-world objects. Thus we needed to improve the model by uploading, annotating and training the model with the V2 dataset.
V1 failure - model failed to identify objects |
--- |
![](media_assets/v1_1.gif) |
We observed improved model performance when trained with the V2 dataset. The model could identify various objects distinctly, although the model failed when we changed the objects' orientations. Thus, we trained the model with the remaining V3 dataset to mitigate these issues and increase other hyperparameters, such as epochs from 500 to 2000. We also tested the performance of our object detector on real objects with different background textures, and the model performed well in these conditions.
V2 success - model can identify objects |
--- |
![](media_assets/v2_1.gif) |
V2 failure - model failed to identify objects in different orientations |
--- |
![](media_assets/v2_2.gif) |
After several cycles of iterating over various hyperparameters, we got a model that generalizes well across different orientations.
V3 success - model can identify objects in different orientations |
--- |
![](media_assets/v3_2.gif) |
V3 success - model can identify different materials |
--- |
![](media_assets/different_material.gif) |
The core idea behind the data-centric approach to solving ML problems is to create more data around the failure points of the model. We improved the model by iteratively improving the data generation, especially in areas where the model had previously failed.
![](media_assets/variation_position.gif)
## Conclusion
In this work, we learned how the domain randomization approach helps generate quality and well-generalized datasets for the object detection task. We also demonstrated the effectiveness of data-centric machine learning workflow in improving the model performance. Although this work is restricted to visual problems, we can extend domain randomization to other sensors such as lidar, accelerometer, and ultrasonic sensors.
## Reference
- [Project on Edge Impulse](https://studio.edgeimpulse.com/public/187851/latest)
- [Introduction to Replicator](https://docs.omniverse.nvidia.com/app_code/prod_extensions/ext_replicator.html)
- [Introduction to USD](https://developer.nvidia.com/usd#usdnvidia)
- [Telsa AI Day](https://youtu.be/j0z4FweCy4M?t=5727)
- [Domain Randomization for Transferring Deep Neural Networks](https://arxiv.org/pdf/1703.06907.pdf)
- [Understanding Domain Randomization for SIM-TO-REAL Transfer](https://arxiv.org/pdf/2110.03239.pdf)
|
gigwegbe/synthetic_data_with_nvidia_replicator_and_edge_impulse/asset/mdl/Laminate_Oak.mdl | /******************************************************************************
* Copyright 2022 NVIDIA Corporation. All rights reserved.
******************************************************************************
Permission is hereby granted by NVIDIA Corporation ("NVIDIA"), free of charge,
to any person obtaining a copy of the sample definition code that uses our
Material Definition Language (the "MDL Materials"), to reproduce and distribute
the MDL Materials, including without limitation the rights to use, copy, merge,
publish, distribute, and sell modified and unmodified copies of the MDL
Materials, and to permit persons to whom the MDL Materials is furnished to do
so, in all cases solely for use with NVIDIA's Material Definition Language,
subject to the following further conditions:
1. The above copyright notices, this list of conditions, and the disclaimer
that follows shall be retained in all copies of one or more of the MDL
Materials, including in any software with which the MDL Materials are bundled,
redistributed, and/or sold, and included either as stand-alone text files,
human-readable headers or in the appropriate machine-readable metadata fields
within text or binary files as long as those fields can be easily viewed by the
user, as applicable.
2. The name of NVIDIA shall not be used to promote, endorse or advertise any
Modified Version without specific prior written permission, except a) to comply
with the notice requirements otherwise contained herein; or b) to acknowledge
the contribution(s) of NVIDIA.
THE MDL MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL,
INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE
THE MDL MATERIALS OR FROM OTHER DEALINGS IN THE MDL MATERIALS.
*/
mdl 1.4;
import ::anno::*;
import ::base::*;
import ::df::*;
import ::math::*;
import ::state::*;
import ::tex::*;
import ::nvidia::core_definitions::blend_colors;
import ::nvidia::core_definitions::dimension;
const string COPYRIGHT =
" Copyright 2022 NVIDIA Corporation. All rights reserved.\n"
" MDL MATERIALS ARE PROVIDED PURSUANT TO AN END USER LICENSE AGREEMENT,\n"
" WHICH WAS ACCEPTED IN ORDER TO GAIN ACCESS TO THIS FILE. IN PARTICULAR,\n"
" THE MDL MATERIALS ARE PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n"
" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF\n"
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF\n"
" COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL NVIDIA\n"
" CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY\n"
" GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN\n"
" AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR\n"
" INABILITY TO USE THE MDL MATERIALS OR FROM OTHER DEALINGS IN THE MDL MATERIALS.\n";
base::texture_coordinate_info vmat_transform(
uniform float2 translation = float2(0.0, 0.0),
uniform float rotation = 0.0,
uniform float2 scaling = float2(1.0, 1.0),
uniform ::base::texture_coordinate_system system = ::base::texture_coordinate_uvw,
uniform int uv_space = 0
)
{
float rotation_rad = (rotation * 3.1415926535897932384626433832f) / 180.f;
float4x4 scale =
float4x4(1.0 /scaling.x, 0. , 0. , 0.,
0. , 1.0 /scaling.y , 0. , 0.,
0. , 0. , 1.0, 0.,
translation.x , translation.y , 0.0, 1.);
float s = ::math::sin(rotation_rad);
float c = ::math::cos(rotation_rad);
float4x4 rotate =
float4x4( c , -s , 0.0 , 0.0,
s , c , 0.0 , 0.0,
0.0, 0.0 , 1.0 , 0.0,
0. , 0.0 , 0.0 , 1.);
return ::base::transform_coordinate(scale*rotate, ::base::coordinate_source(system, uv_space));
}
float histogram_range(float input, float range, float position)
{
float low = ::math::clamp(1.0 - ::math::min(((1.0 - position) + range * 0.5), (1.0 - position) * 2), 0.0, 1.0);
float high = ::math::clamp(::math::min((position + range * 0.5 ), position * 2.0), 0.0, 1.0);
return ::math::lerp(low, high, input);
}
float uint2float(int x)
{
return float(x & 0x7FFFFFFF) + (x < 0 ? 2147483648.0 : 0.0);
}
int lowbias32(int x)
{
x ^= x >>> 16;
x *= 0x7feb352d;
x ^= x >>> 15;
x *= 0x846ca68b;
x ^= x >>> 16;
return x;
}
float2 rnd22(int2 p) {
float2 ret_val = float2(
uint2float(lowbias32(p[0] + lowbias32(p[1]))) / 4294967296.f,
uint2float(lowbias32(p[0] + 32000 + lowbias32(p[1]))) / 4294967296.f
);
return ret_val;
}
float3 srgb2rgb(float3 val)
{
return ::math::pow(::math::max(val, float3(0.0f)), 2.2);
}
float2x2 invert_2x2(float2x2 M)
{
float det = M[0][0]*M[1][1] - M[0][1]*M[1][0];
//https://www.chilimath.com/lessons/advanced-algebra/inverse-of-a-2x2-matrix/
return (1.0 / det) * float2x2(M[1][1], -M[0][1], -M[1][0], M[0][0]);
}
float3 nonrepeat_lookup(
uniform texture_2d texture = texture_2d(),
::base::texture_coordinate_info uvw = ::base::coordinate_source(),
float texture_scale = 1.0,
float3 average_color = float3(0.5),
float patch_size = 8.0
)
{
float2 uv_in = float2(uvw.position[0], uvw.position[1]) * texture_scale;
float Z = patch_size; // patch scale inside example texture
float CON = 1.0f;
float3 O = float3(0.f);
float2x2 M0 = float2x2(1.f,0.f, 0.5f, ::math::sqrt(3.f)/2.f);
float2x2 M = invert_2x2(M0); // transform matrix <-> tilted space
float2 U = uv_in;
float2 V = M * uv_in; //pre-tilted hexa coordinates
int2 I = int2(::math::floor(V)); // hexa-tile id
// The mean color needs to be determined in Photoshop then to make the
// average color work out, take the float value and calculate the apropriate
// mean value as (value^(1/2.2))
float3 m = average_color;
float3 F = float3(::math::frac(V)[0], ::math::frac(V)[1], 0.f), W;
F[2] = 1.0 - F[0] - F[1]; // local hexa coordinates
if( F[2] > 0.f )
O = (W[0] = F[2]) * (( ::tex::lookup_float3(texture, U/Z-rnd22(I))) - m*float(CON))
+ (W[1] = F[1]) * (( ::tex::lookup_float3(texture, U/Z-rnd22(I+int2(0,1)))) - m*float(CON))
+ (W[2] = F[0]) * (( ::tex::lookup_float3(texture, U/Z-rnd22(I+int2(1,0)))) - m*float(CON));
else
O = (W[0] = -F[2]) * (( ::tex::lookup_float3(texture, U/Z-rnd22(I+int2(1)))) - m*float(CON))
+ (W[1] = 1.f - F[1]) * (( ::tex::lookup_float3(texture, U/Z-rnd22(I+int2(1, 0)))) - m*float(CON))
+ (W[2] = 1.f - F[0]) * (( ::tex::lookup_float3(texture, U/Z-rnd22(I+int2(0, 1)))) - m*float(CON));
O = m + O/::math::length(W);
O = ::math::clamp( (O), 0.0, 1.0);
return float3(O);
}
color endless_texture(
uniform texture_2d texture = texture_2d(),
::base::texture_coordinate_info uvw = ::base::coordinate_source(),
float texture_scale = 10.0,
float3 average_color = float3(0.5, 0.5, 1.0),
float patch_size = 8.0,
bool gamma_correct_lookup = true
)
{
return gamma_correct_lookup ? color(srgb2rgb(
nonrepeat_lookup (
texture: texture,
uvw: uvw,
texture_scale: texture_scale,
average_color: average_color,
patch_size: patch_size
))
) : color(nonrepeat_lookup (
texture: texture,
uvw: uvw,
texture_scale: texture_scale,
average_color: average_color,
patch_size: patch_size
));
}
float3 endless_normal(
uniform texture_2d texture = texture_2d(),
float factor = 1.0,
bool flip_tangent_u = false,
bool flip_tangent_v = false,
::base::texture_coordinate_info uvw = ::base::coordinate_source(),
float texture_scale = 1.0,
float3 average_color = float3(0.5, 0.5, 1.0),
float patch_size = 8.0
)
{
float3 transformed_tangent_u = flip_tangent_u ? uvw.tangent_u : - uvw.tangent_u;
float3 transformed_tangent_v = flip_tangent_v ? uvw.tangent_v : - uvw.tangent_v;
if (flip_tangent_u)
transformed_tangent_u=-transformed_tangent_u;
if (flip_tangent_v)
transformed_tangent_v=-transformed_tangent_v;
// normalized Lookup
float3 tangent_space_normal =
(nonrepeat_lookup (
texture: texture,
uvw: uvw,
texture_scale: texture_scale,
average_color: average_color,
patch_size: patch_size
) - 0.5) * (2.0 * factor);
return ::math::normalize(uvw.tangent_u * tangent_space_normal.x +
uvw.tangent_v * tangent_space_normal.y +
::state::normal()*1.0);
}
float3 normalmap_normal(
uniform texture_2d texture,
float factor = 1.0,
::base::texture_coordinate_info uvw = ::base::texture_coordinate_info()
)
{
float3 lookup = (::tex::lookup_float3(texture, float2(uvw.position.x, uvw.position.y)) - 0.5) * (factor * 2.0);
return ::math::normalize(uvw.tangent_u * lookup.x + uvw.tangent_v * lookup.y + ::state::normal());
}
export material Laminate_Oak(
uniform bool enable_infinite_tiling = false [[
::anno::description("Enables Infinite Tiling feature. Removes artifacts of repeating texture patterns when material is scaled"),
::anno::display_name("Infinite Tiling"),
::anno::in_group("Appearance")
]],
float wood_brightness = 0.7f [[
::anno::description("Adjusts the brightness of the wood material"),
::anno::display_name("Wood Brightness"),
::anno::hard_range(0.f, 1.f),
::anno::in_group("Appearance")
]],
float wood_fiber_roughness = 1.0f [[
::anno::description("Adjusts the roughness of the fibers. Lower values cause a more anisotropic appearance of the reflections"),
::anno::display_name("Wood Fiber Roughness"),
::anno::hard_range(0.f, 1.f),
::anno::in_group("Appearance")
]],
float oak_bump_factor = 1.f [[
::anno::display_name("Oak Bump Factor"),
::anno::hard_range(0.f, 1.f),
::anno::in_group("Appearance")
]],
float smudges_weight = 0.08f [[
::anno::description("Adds smudges on top of the material to create a more worn and used appearance of the material"),
::anno::display_name("Smudges Weight"),
::anno::hard_range(0.f, 1.f),
::anno::in_group("Appearance", "Wear")
]],
float smudges_roughness = 0.68 [[
::anno::description("Adjusts the roughness of the smudges on top of the material"),
::anno::display_name("Smudges Roughness"),
::anno::hard_range(0.f, 1.f),
::anno::in_group("Appearance", "Wear")
]],
float dirt_weight = 0.f [[
::anno::description("Adjusts the thickness of the dirt layer on top of the material "),
::anno::display_name("Dirt Thickness"),
::anno::hard_range(0.f, 1.f),
::anno::in_group("Appearance", "Wear")
]],
uniform float2 texture_translate = float2(0.f) [[
::anno::description("Offsets the position of the material"),
::anno::display_name("Translate"),
::anno::in_group("Transform")
]],
uniform float texture_rotate = 0.f [[
::anno::description("Rotates the material"),
::anno::display_name("Rotate"),
::anno::in_group("Transform")
]],
uniform float2 texture_scale = float2(1.f) [[
::anno::description("Scales the material"),
::anno::display_name("Scale"),
::nvidia::core_definitions::dimension(float2(1.0f, 1.0f)),
::anno::in_group("Transform")
]],
uniform int uv_space_index = 0 [[
::anno::description("Selects the UV texture space index to use for the material"),
::anno::display_name("UV Space Index"),
::anno::in_group("Advanced")
]]
)
[[
::anno::author("NVIDIA vMaterials"),
::anno::display_name("Wood Laminate Oak - New"),
::anno::description("A wood laminate material that features infinite tiling, smudges and a dirt layer"),
::anno::key_words(string[]("aec", "wood", "oak", "laminate", "floor", "polished", "artificial", "infinite tiling", "new", "brown")),
::anno::thumbnail("./.thumbs/Laminate_Oak.Laminate_Oak.png"),
::anno::copyright_notice(COPYRIGHT)
]]
=
let {
bool tmp0 = false;
material_surface tmp1(
::df::weighted_layer(histogram_range(1.f - float3(enable_infinite_tiling ? endless_texture(texture_2d("./textures/laminate_oak_multi_R_rough_G_aniso.jpg", ::tex::gamma_linear), vmat_transform(texture_translate, texture_rotate, texture_scale, ::base::texture_coordinate_uvw, uv_space_index), 10.f, float3(0.579999983f, 0.537f, 0.f), 8.f, true) : ::base::file_texture(texture_2d("./textures/laminate_oak_multi_R_rough_G_aniso.jpg", ::tex::gamma_linear), color(0.f, 0.f, 0.f), color(1.f, 1.f, 1.f), ::base::mono_average, vmat_transform(texture_translate, texture_rotate, texture_scale, ::base::texture_coordinate_uvw, uv_space_index), float2(0.f, 1.f), float2(0.f, 1.f), ::tex::wrap_repeat, ::tex::wrap_repeat, false).tint)[0], 1.f, ::math::lerp(1.f, 0.721000016f, dirt_weight)), ::df::custom_curve_layer(0.0410000011f, 1.f, 5.f, smudges_weight, ::df::microfacet_ggx_smith_bsdf(histogram_range(float3(enable_infinite_tiling ? endless_texture(texture_2d("./textures/laminate_oak_multi_R_rough_G_aniso.jpg", ::tex::gamma_linear), vmat_transform(texture_translate, texture_rotate, texture_scale, ::base::texture_coordinate_uvw, uv_space_index), 10.f, float3(0.579999983f, 0.537f, 0.f), 8.f, true) : ::base::file_texture(texture_2d("./textures/laminate_oak_multi_R_rough_G_aniso.jpg", ::tex::gamma_linear), color(0.f, 0.f, 0.f), color(1.f, 1.f, 1.f), ::base::mono_average, vmat_transform(texture_translate, texture_rotate, texture_scale, ::base::texture_coordinate_uvw, uv_space_index), float2(0.f, 1.f), float2(0.f, 1.f), ::tex::wrap_repeat, ::tex::wrap_repeat, false).tint)[0], 0.34800002f, ::math::lerp(0.300000012f, 0.649999976f, smudges_roughness)) * histogram_range(float3(enable_infinite_tiling ? endless_texture(texture_2d("./textures/laminate_oak_multi_R_rough_G_aniso.jpg", ::tex::gamma_linear), vmat_transform(texture_translate, texture_rotate, texture_scale, ::base::texture_coordinate_uvw, uv_space_index), 10.f, float3(0.579999983f, 0.537f, 0.f), 8.f, true) : ::base::file_texture(texture_2d("./textures/laminate_oak_multi_R_rough_G_aniso.jpg", ::tex::gamma_linear), color(0.f, 0.f, 0.f), color(1.f, 1.f, 1.f), ::base::mono_average, vmat_transform(texture_translate, texture_rotate, texture_scale, ::base::texture_coordinate_uvw, uv_space_index), float2(0.f, 1.f), float2(0.f, 1.f), ::tex::wrap_repeat, ::tex::wrap_repeat, false).tint)[0], 0.34800002f, ::math::lerp(0.300000012f, 0.649999976f, smudges_roughness)), histogram_range(float3(enable_infinite_tiling ? endless_texture(texture_2d("./textures/laminate_oak_multi_R_rough_G_aniso.jpg", ::tex::gamma_linear), vmat_transform(texture_translate, texture_rotate, texture_scale, ::base::texture_coordinate_uvw, uv_space_index), 10.f, float3(0.579999983f, 0.537f, 0.f), 8.f, true) : ::base::file_texture(texture_2d("./textures/laminate_oak_multi_R_rough_G_aniso.jpg", ::tex::gamma_linear), color(0.f, 0.f, 0.f), color(1.f, 1.f, 1.f), ::base::mono_average, vmat_transform(texture_translate, texture_rotate, texture_scale, ::base::texture_coordinate_uvw, uv_space_index), float2(0.f, 1.f), float2(0.f, 1.f), ::tex::wrap_repeat, ::tex::wrap_repeat, false).tint)[0], 0.34800002f, ::math::lerp(0.300000012f, 0.649999976f, smudges_roughness)) * histogram_range(float3(enable_infinite_tiling ? endless_texture(texture_2d("./textures/laminate_oak_multi_R_rough_G_aniso.jpg", ::tex::gamma_linear), vmat_transform(texture_translate, texture_rotate, texture_scale, ::base::texture_coordinate_uvw, uv_space_index), 10.f, float3(0.579999983f, 0.537f, 0.f), 8.f, true) : ::base::file_texture(texture_2d("./textures/laminate_oak_multi_R_rough_G_aniso.jpg", ::tex::gamma_linear), color(0.f, 0.f, 0.f), color(1.f, 1.f, 1.f), ::base::mono_average, vmat_transform(texture_translate, texture_rotate, texture_scale, ::base::texture_coordinate_uvw, uv_space_index), float2(0.f, 1.f), float2(0.f, 1.f), ::tex::wrap_repeat, ::tex::wrap_repeat, false).tint)[0], 0.34800002f, ::math::lerp(0.300000012f, 0.649999976f, smudges_roughness)), color(1.f, 1.f, 1.f), ::state::texture_tangent_u(0), ::df::scatter_reflect, ""), ::df::custom_curve_layer(0.0410000011f, 1.f, 5.f, 1.f, ::df::microfacet_ggx_smith_bsdf(histogram_range(float3(enable_infinite_tiling ? endless_texture(texture_2d("./textures/laminate_oak_multi_R_rough_G_aniso.jpg", ::tex::gamma_linear), vmat_transform(texture_translate, texture_rotate, texture_scale, ::base::texture_coordinate_uvw, uv_space_index), 10.f, float3(0.579999983f, 0.537f, 0.f), 8.f, true) : ::base::file_texture(texture_2d("./textures/laminate_oak_multi_R_rough_G_aniso.jpg", ::tex::gamma_linear), color(0.f, 0.f, 0.f), color(1.f, 1.f, 1.f), ::base::mono_average, vmat_transform(texture_translate, texture_rotate, texture_scale, ::base::texture_coordinate_uvw, uv_space_index), float2(0.f, 1.f), float2(0.f, 1.f), ::tex::wrap_repeat, ::tex::wrap_repeat, false).tint)[1], 0.445000023f, 0.398000032f) * histogram_range(float3(enable_infinite_tiling ? endless_texture(texture_2d("./textures/laminate_oak_multi_R_rough_G_aniso.jpg", ::tex::gamma_linear), vmat_transform(texture_translate, texture_rotate, texture_scale, ::base::texture_coordinate_uvw, uv_space_index), 10.f, float3(0.579999983f, 0.537f, 0.f), 8.f, true) : ::base::file_texture(texture_2d("./textures/laminate_oak_multi_R_rough_G_aniso.jpg", ::tex::gamma_linear), color(0.f, 0.f, 0.f), color(1.f, 1.f, 1.f), ::base::mono_average, vmat_transform(texture_translate, texture_rotate, texture_scale, ::base::texture_coordinate_uvw, uv_space_index), float2(0.f, 1.f), float2(0.f, 1.f), ::tex::wrap_repeat, ::tex::wrap_repeat, false).tint)[1], 0.445000023f, 0.398000032f), ::math::lerp(0.206000015f, 0.382000029f, wood_fiber_roughness) * ::math::lerp(0.206000015f, 0.382000029f, wood_fiber_roughness), color(0.491905004f, 0.491905004f, 0.491905004f), ::state::texture_tangent_u(0), ::df::scatter_reflect, ""), ::df::diffuse_reflection_bsdf(::nvidia::core_definitions::blend_colors(enable_infinite_tiling ? endless_texture(texture_2d("./textures/laminate_oak_diffuse.jpg", ::tex::gamma_linear), vmat_transform(texture_translate, texture_rotate, texture_scale, ::base::texture_coordinate_uvw, uv_space_index), 10.f, float3(0.611000001f, 0.451999992f, 0.287f), 8.f, true) : ::base::file_texture(texture_2d("./textures/laminate_oak_diffuse.jpg", ::tex::gamma_srgb), color(0.f, 0.f, 0.f), color(0.767768979f, 0.767768979f, 0.767768979f), ::base::mono_alpha, vmat_transform(texture_translate, texture_rotate, texture_scale, ::base::texture_coordinate_uvw, uv_space_index), float2(0.f, 1.f), float2(0.f, 1.f), ::tex::wrap_repeat, ::tex::wrap_repeat, false).tint, color(::math::lerp(0.75f, 1.f, wood_brightness)), ::base::color_layer_multiply, 1.f).tint, 0.f, ""), ::state::normal()), ::state::normal()), ::df::diffuse_reflection_bsdf(color(0.0782879964f, 0.0712279975f, 0.0564489998f), 0.f, ""), ::state::normal()),
material_emission(emission: edf(), intensity: color(0.f, 0.f, 0.f), mode: intensity_radiant_exitance));
material_surface tmp2 = material_surface(scattering: bsdf(), emission: material_emission(emission: edf(), intensity: color(0.f, 0.f, 0.f), mode: intensity_radiant_exitance));
color tmp3 = color(1.f, 1.f, 1.f);
material_volume tmp4 = material_volume(scattering: vdf(), absorption_coefficient: color(0.f, 0.f, 0.f), scattering_coefficient: color(0.f, 0.f, 0.f));
material_geometry tmp5(
float3(0.f),
1.f,
enable_infinite_tiling ? endless_normal(texture_2d("./textures/laminate_oak_normal.jpg", ::tex::gamma_linear), oak_bump_factor, false, false, vmat_transform(texture_translate, texture_rotate, texture_scale, ::base::texture_coordinate_uvw, uv_space_index), 10.f, float3(0.5f, 0.5f, 1.f), 8.f) : normalmap_normal(texture_2d("./textures/laminate_oak_normal.jpg", ::tex::gamma_linear), oak_bump_factor, vmat_transform(texture_translate, texture_rotate, texture_scale, ::base::texture_coordinate_uvw, uv_space_index)));
} in
material(
thin_walled: tmp0,
surface: tmp1,
backface: tmp2,
ior: tmp3,
volume: tmp4,
geometry: tmp5);
export material Laminate_Oak_Polished(*)
[[
::anno::author("NVIDIA vMaterials"),
::anno::display_name("Wood Laminate Oak - Polished"),
::anno::description("A wood laminate material with smudges and a dirt layer that features infinite tiling "),
::anno::key_words(string[]("aec", "wood", "oak", "laminate", "floor", "polished", "artificial", "infinite tiling", "dust", "dirt", "brown", "warm")),
::anno::thumbnail("./.thumbs/Laminate_Oak.Laminate_Oak_Polished.png"),
::anno::copyright_notice(COPYRIGHT)
]] = Laminate_Oak(
enable_infinite_tiling: false,
wood_brightness: 0.7f,
wood_fiber_roughness: 1.0f,
oak_bump_factor: 0.5f,
smudges_weight: 0.0f,
smudges_roughness: 0.0f,
dirt_weight: 0.0f,
texture_translate: float2(0.0f),
texture_rotate: 0.0f,
texture_scale: float2(1.0),
uv_space_index: 0
);
export material Laminate_Oak_Slight_Smudges(*)
[[
::anno::author("NVIDIA vMaterials"),
::anno::display_name("Wood Laminate Oak - Smudges"),
::anno::description("A wood laminate material with smudges and a dirt layer that features infinite tiling "),
::anno::key_words(string[]("aec", "wood", "oak", "laminate", "floor", "polished", "artificial", "infinite tiling", "smudges", "dust", "dirt", "brown", "warm")),
::anno::thumbnail("./.thumbs/Laminate_Oak.Laminate_Oak_Slight_Smudges.png"),
::anno::copyright_notice(COPYRIGHT)
]]
= Laminate_Oak(
enable_infinite_tiling: false,
wood_brightness: 0.7f,
wood_fiber_roughness: 1.0f,
oak_bump_factor: 1.0f,
smudges_weight: 0.8f,
smudges_roughness: 0.75f,
dirt_weight: 0.5f,
texture_translate: float2(0.0f),
texture_rotate: 0.0f,
texture_scale: float2(1.0),
uv_space_index: 0
);
export material Laminate_Oak_Dirty(*)
[[
::anno::author("NVIDIA vMaterials"),
::anno::display_name("Wood Laminate Oak - Dirty"),
::anno::description("A wood laminate material with smudges and a dirt layer that features infinite tiling "),
::anno::key_words(string[]("aec", "wood", "oak", "laminate", "floor", "polished", "artificial", "infinite tiling", "dust", "dirt", "brown", "warm")),
::anno::thumbnail("./.thumbs/Laminate_Oak.Laminate_Oak_Dirty.png"),
::anno::copyright_notice(COPYRIGHT)
]]
= Laminate_Oak(
enable_infinite_tiling: false,
wood_brightness: 0.7f,
wood_fiber_roughness: 1.0f,
oak_bump_factor: 1.0f,
smudges_weight: 0.8f,
smudges_roughness: 0.75f,
dirt_weight: 0.85f,
texture_translate: float2(0.0f),
texture_rotate: 0.0f,
texture_scale: float2(1.0),
uv_space_index: 0
);
|
gigwegbe/synthetic_data_with_nvidia_replicator_and_edge_impulse/old_setting/README_old.md |
### Synthetic data with Nvidia replicator and Edge Impulse
![alt workflow](asset/img/updated_cover.png)
- Fixed position
- Fixed Camera but not random
- Fixed Lightning and light parameters
- Changed background materials |
gigwegbe/synthetic_data_with_nvidia_replicator_and_edge_impulse/old_setting/objects_position_normal_90.py | import omni.replicator.core as rep
with rep.new_layer():
# Load in asset
local_path = "/home/george/Documents/synthetic_data_with_nvidia_replicator_and_edge_impulse/"
TABLE_USD =f"{local_path}/asset/Collected_EastRural_Table/EastRural_Table.usd"
SPOON_SMALL_USD = f"{local_path}/asset/Collected_Spoon_Small/Spoon_Small.usd"
SPOON_BIG_USD = f"{local_path}/asset/Collected_Spoon_Big/Spoon_Big.usd"
FORK_SMALL_USD = f"{local_path}/asset/Collected_Fork_Small/Fork_Small.usd"
FORK_BIG_USD = f"{local_path}/asset/Collected_Fork_Big/Fork_Big.usd"
KNIFE_USD = f"{local_path}/asset/Collected_Knife/Knife.usd"
# Camera paramters
cam_position = (-131,200,-134)
cam_position2 = (-131,120,-134)
cam_position_random = rep.distribution.uniform((0,181,0), (0, 300, 0))
cam_rotation = (-90,0,0) #(-45,0,0)
focus_distance = 120
focus_distance2 = 72
focal_length = 19.1
focal_length2 = 7.5
f_stop = 1.8
f_stop2 = 1.8
focus_distance_random = rep.distribution.normal(500.0, 100)
# Cultery path
current_cultery = SPOON_SMALL_USD # Change the item here e.g KNIFE_USD
output_path = current_cultery.split(".")[0].split("/")[-1]
def rect_lights(num=2):
lights = rep.create.light(
light_type="rect",
temperature=rep.distribution.normal(6500, 500),
intensity=rep.distribution.normal(0, 5000),
position=(-131,150,-134),
rotation=(-90,0,0),
scale=rep.distribution.uniform(50, 100),
count=num
)
return lights.node
def dome_lights(num=1):
lights = rep.create.light(
light_type="dome",
temperature=rep.distribution.normal(6500, 500),
intensity=rep.distribution.normal(0, 1000),
position=(0,0,0),
rotation=(270,0,0),
count=num
)
return lights.node
def table():
table = rep.create.from_usd(TABLE_USD, semantics=[('class', 'table')])
with table:
rep.modify.pose(
position=(-135.39745, 0, -140.25696),
rotation=(0,-90,-90),
)
return table
# Define randomizer function for CULTERY assets. This randomization includes placement and rotation of the assets on the surface.
def cutlery_props(size=15):
instances = rep.randomizer.instantiate(rep.utils.get_usd_files(current_cultery), size=size, mode='point_instance')
with instances:
rep.modify.pose(
position=rep.distribution.uniform((-212, 76.2, -187), (-62, 76.2, -94)),
rotation=rep.distribution.uniform((-90,-180, 0), (-90, 180, 0)),
)
return instances.node
# Register randomization
rep.randomizer.register(table)
rep.randomizer.register(cutlery_props)
rep.randomizer.register(rect_lights)
rep.randomizer.register(dome_lights)
# Multiple setup cameras and attach it to render products
camera = rep.create.camera(focus_distance=focus_distance, focal_length=focal_length, position=cam_position, rotation=cam_rotation, f_stop=f_stop)
camera2 = rep.create.camera(focus_distance=focus_distance2, focal_length=focal_length2, position=cam_position2, rotation=cam_rotation, f_stop=f_stop)
# Will render 1024x1024 images and 512x512 images
render_product = rep.create.render_product(camera, (1024, 1024))
render_product2 = rep.create.render_product(camera2, (512, 512))
# Initialize and attach writer
writer = rep.WriterRegistry.get("BasicWriter")
writer.initialize(output_dir=f"{local_path}/data/normal/{output_path}", rgb=True, bounding_box_2d_tight=False, semantic_segmentation=False)
writer.attach([render_product, render_product2])
with rep.trigger.on_frame(num_frames=50):
rep.randomizer.table()
rep.randomizer.rect_lights(1)
rep.randomizer.dome_lights(1)
rep.randomizer.cutlery_props(15)
# Run the simulation graph
rep.orchestrator.run()
|
gigwegbe/synthetic_data_with_nvidia_replicator_and_edge_impulse/old_setting/objects_position_random.py | import omni.replicator.core as rep
with rep.new_layer():
# Load in asset
local_path = "/home/george/Documents/synthetic_data_with_nvidia_replicator_and_edge_impulse/"
TABLE_USD =f"{local_path}/asset/Collected_EastRural_Table/EastRural_Table.usd"
SPOON_SMALL_USD = f"{local_path}/asset/Collected_Spoon_Small/Spoon_Small.usd"
SPOON_BIG_USD = f"{local_path}/asset/Collected_Spoon_Big/Spoon_Big.usd"
FORK_SMALL_USD = f"{local_path}/asset/Collected_Fork_Small/Fork_Small.usd"
FORK_BIG_USD = f"{local_path}/asset/Collected_Fork_Big/Fork_Big.usd"
KNIFE_USD = f"{local_path}/asset/Collected_Knife/Knife.usd"
# Camera paramters
cam_position = (-131,200,-134)
cam_position2 = (-131,120,-134)
cam_position_random = rep.distribution.uniform((0,181,0), (0, 300, 0))
cam_rotation = (-90,0,0) #(-45,0,0)
focus_distance = 120
focus_distance2 = 72
focal_length = 19.1
focal_length2 = 7.5
f_stop = 1.8
f_stop2 = 1.8
focus_distance_random = rep.distribution.normal(500.0, 100)
# Cultery path
current_cultery = SPOON_SMALL_USD # Change the item here e.g KNIFE_USD
output_path = current_cultery.split(".")[0].split("/")[-1]
def rect_lights(num=2):
lights = rep.create.light(
light_type="rect",
temperature=rep.distribution.normal(6500, 500),
intensity=rep.distribution.normal(0, 5000),
position=(-131,150,-134),
rotation=(-90,0,0),
scale=rep.distribution.uniform(50, 100),
count=num
)
return lights.node
def dome_lights(num=1):
lights = rep.create.light(
light_type="dome",
temperature=rep.distribution.normal(6500, 500),
intensity=rep.distribution.normal(0, 1000),
position=(0,0,0),
rotation=(270,0,0),
count=num
)
return lights.node
def table():
table = rep.create.from_usd(TABLE_USD, semantics=[('class', 'table')])
with table:
rep.modify.pose(
position=(-135.39745, 0, -140.25696),
rotation=(0,-90,-90),
)
return table
# Define randomizer function for CULTERY assets. This randomization includes placement and rotation of the assets on the surface.
def cutlery_props(size=15):
instances = rep.randomizer.instantiate(rep.utils.get_usd_files(current_cultery), size=size, mode='point_instance')
with instances:
rep.modify.pose(
position=rep.distribution.uniform((-212, 86.2, -187), (-62, 86.2, -94)),
rotation=rep.distribution.uniform((-90,-180, -90), (90, 180, 90)),
)
return instances.node
# Register randomization
rep.randomizer.register(table)
rep.randomizer.register(cutlery_props)
rep.randomizer.register(rect_lights)
rep.randomizer.register(dome_lights)
# Multiple setup cameras and attach it to render products
camera = rep.create.camera(focus_distance=focus_distance, focal_length=focal_length, position=cam_position, rotation=cam_rotation, f_stop=f_stop)
camera2 = rep.create.camera(focus_distance=focus_distance2, focal_length=focal_length2, position=cam_position2, rotation=cam_rotation, f_stop=f_stop)
# Will render 1024x1024 images and 512x512 images
render_product = rep.create.render_product(camera, (1024, 1024))
render_product2 = rep.create.render_product(camera2, (512, 512))
# Initialize and attach writer
writer = rep.WriterRegistry.get("BasicWriter")
writer.initialize(output_dir=f"{local_path}/data/random/{output_path}", rgb=True, bounding_box_2d_tight=False, semantic_segmentation=False)
writer.attach([render_product, render_product2])
with rep.trigger.on_frame(num_frames=25):
rep.randomizer.table()
rep.randomizer.rect_lights(1)
rep.randomizer.dome_lights(1)
rep.randomizer.cutlery_props(15)
# Run the simulation graph
rep.orchestrator.run()
|
gigwegbe/synthetic_data_with_nvidia_replicator_and_edge_impulse/old_setting/objects_position_normal_60.py | import omni.replicator.core as rep
with rep.new_layer():
# Load in asset
local_path = "/home/george/Documents/synthetic_data_with_nvidia_replicator_and_edge_impulse/"
TABLE_USD =f"{local_path}/asset/Collected_EastRural_Table/EastRural_Table.usd"
SPOON_SMALL_USD = f"{local_path}/asset/Collected_Spoon_Small/Spoon_Small.usd"
SPOON_BIG_USD = f"{local_path}/asset/Collected_Spoon_Big/Spoon_Big.usd"
FORK_SMALL_USD = f"{local_path}/asset/Collected_Fork_Small/Fork_Small.usd"
FORK_BIG_USD = f"{local_path}/asset/Collected_Fork_Big/Fork_Big.usd"
KNIFE_USD = f"{local_path}/asset/Collected_Knife/Knife.usd"
# Camera paramters
cam_position = (-131,200,-134)
cam_position2 = (-131,120,-134)
cam_position_random = rep.distribution.uniform((0,181,0), (0, 300, 0))
cam_rotation = (-60,0,0) #(-45,0,0)
focus_distance = 120
focus_distance2 = 72
focal_length = 19.1
focal_length2 = 7.5
f_stop = 1.8
f_stop2 = 1.8
focus_distance_random = rep.distribution.normal(500.0, 100)
# Cultery path
current_cultery = SPOON_SMALL_USD # Change the item here e.g KNIFE_USD
output_path = current_cultery.split(".")[0].split("/")[-1]
def rect_lights(num=2):
lights = rep.create.light(
light_type="rect",
temperature=rep.distribution.normal(6500, 500),
intensity=rep.distribution.normal(0, 5000),
position=(-131,150,-134),
rotation=(-90,0,0),
scale=rep.distribution.uniform(50, 100),
count=num
)
return lights.node
def dome_lights(num=1):
lights = rep.create.light(
light_type="dome",
temperature=rep.distribution.normal(6500, 500),
intensity=rep.distribution.normal(0, 1000),
position=(0,0,0),
rotation=(270,0,0),
count=num
)
return lights.node
def table():
table = rep.create.from_usd(TABLE_USD, semantics=[('class', 'table')])
with table:
rep.modify.pose(
position=(-135.39745, 0, -140.25696),
rotation=(0,-90,-90),
)
return table
# Define randomizer function for CULTERY assets. This randomization includes placement and rotation of the assets on the surface.
def cutlery_props(size=15):
instances = rep.randomizer.instantiate(rep.utils.get_usd_files(current_cultery), size=size, mode='point_instance')
with instances:
rep.modify.pose(
position=rep.distribution.uniform((-212, 76.2, -187), (-62, 76.2, -94)),
rotation=rep.distribution.uniform((-90,-180, 0), (-90, 180, 0)),
)
return instances.node
# Register randomization
rep.randomizer.register(table)
rep.randomizer.register(cutlery_props)
rep.randomizer.register(rect_lights)
rep.randomizer.register(dome_lights)
# Multiple setup cameras and attach it to render products
camera = rep.create.camera(focus_distance=focus_distance, focal_length=focal_length, position=cam_position, rotation=cam_rotation, f_stop=f_stop)
camera2 = rep.create.camera(focus_distance=focus_distance2, focal_length=focal_length2, position=cam_position2, rotation=cam_rotation, f_stop=f_stop)
# Will render 1024x1024 images and 512x512 images
render_product = rep.create.render_product(camera, (1024, 1024))
render_product2 = rep.create.render_product(camera2, (512, 512))
# Initialize and attach writer
writer = rep.WriterRegistry.get("BasicWriter")
writer.initialize(output_dir=f"{local_path}/data/normal_60/{output_path}", rgb=True, bounding_box_2d_tight=False, semantic_segmentation=False)
writer.attach([render_product, render_product2])
with rep.trigger.on_frame(num_frames=50):
rep.randomizer.table()
rep.randomizer.rect_lights(1)
rep.randomizer.dome_lights(1)
rep.randomizer.cutlery_props(15)
# Run the simulation graph
rep.orchestrator.run()
|
mati-nvidia/window-menu-add/link_app.sh | #!/bin/bash
set -e
SCRIPT_DIR=$(dirname ${BASH_SOURCE})
cd "$SCRIPT_DIR"
exec "tools/packman/python.sh" tools/scripts/link_app.py $@
|
mati-nvidia/window-menu-add/link_app.bat | @echo off
call "%~dp0tools\packman\python.bat" %~dp0tools\scripts\link_app.py %*
if %errorlevel% neq 0 ( goto Error )
:Success
exit /b 0
:Error
exit /b %errorlevel%
|
mati-nvidia/window-menu-add/README.md | # Window Menu Add
An example extension showing how to create a window and add it to the `Window` menu so that it can be shown and hidden
using the menu item in the `Window` menu.
## App Link Setup
If `app` folder link doesn't exist or broken it can be created again. For better developer experience it is recommended to create a folder link named `app` to the *Omniverse Kit* app installed from *Omniverse Launcher*. Convenience script to use is included.
Run:
```
> link_app.bat
```
If successful you should see `app` folder link in the root of this repo.
If multiple Omniverse apps is installed script will select recommended one. Or you can explicitly pass an app:
```
> link_app.bat --app create
```
You can also just pass a path to create link to:
```
> link_app.bat --path "C:/Users/bob/AppData/Local/ov/pkg/create-2021.3.4"
```
## Sharing Your Extensions
This folder is ready to be pushed to any git repository. Once pushed direct link to a git repository can be added to *Omniverse Kit* extension search paths.
Link might look like this: `git://github.com/[user]/[your_repo].git?branch=main&dir=exts`
Notice `exts` is repo subfolder with extensions. More information can be found in "Git URL as Extension Search Paths" section of developers manual.
To add a link to your *Omniverse Kit* based app go into: Extension Manager -> Gear Icon -> Extension Search Path
|
mati-nvidia/window-menu-add/tools/scripts/link_app.py | import os
import argparse
import sys
import json
import packmanapi
import urllib3
def find_omniverse_apps():
http = urllib3.PoolManager()
try:
r = http.request("GET", "http://127.0.0.1:33480/components")
except Exception as e:
print(f"Failed retrieving apps from an Omniverse Launcher, maybe it is not installed?\nError: {e}")
sys.exit(1)
apps = {}
for x in json.loads(r.data.decode("utf-8")):
latest = x.get("installedVersions", {}).get("latest", "")
if latest:
for s in x.get("settings", []):
if s.get("version", "") == latest:
root = s.get("launch", {}).get("root", "")
apps[x["slug"]] = (x["name"], root)
break
return apps
def create_link(src, dst):
print(f"Creating a link '{src}' -> '{dst}'")
packmanapi.link(src, dst)
APP_PRIORITIES = ["code", "create", "view"]
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Create folder link to Kit App installed from Omniverse Launcher")
parser.add_argument(
"--path",
help="Path to Kit App installed from Omniverse Launcher, e.g.: 'C:/Users/bob/AppData/Local/ov/pkg/create-2021.3.4'",
required=False,
)
parser.add_argument(
"--app", help="Name of Kit App installed from Omniverse Launcher, e.g.: 'code', 'create'", required=False
)
args = parser.parse_args()
path = args.path
if not path:
print("Path is not specified, looking for Omniverse Apps...")
apps = find_omniverse_apps()
if len(apps) == 0:
print(
"Can't find any Omniverse Apps. Use Omniverse Launcher to install one. 'Code' is the recommended app for developers."
)
sys.exit(0)
print("\nFound following Omniverse Apps:")
for i, slug in enumerate(apps):
name, root = apps[slug]
print(f"{i}: {name} ({slug}) at: '{root}'")
if args.app:
selected_app = args.app.lower()
if selected_app not in apps:
choices = ", ".join(apps.keys())
print(f"Passed app: '{selected_app}' is not found. Specify one of the following found Apps: {choices}")
sys.exit(0)
else:
selected_app = next((x for x in APP_PRIORITIES if x in apps), None)
if not selected_app:
selected_app = next(iter(apps))
print(f"\nSelected app: {selected_app}")
_, path = apps[selected_app]
if not os.path.exists(path):
print(f"Provided path doesn't exist: {path}")
else:
SCRIPT_ROOT = os.path.dirname(os.path.realpath(__file__))
create_link(f"{SCRIPT_ROOT}/../../app", path)
print("Success!")
|
mati-nvidia/window-menu-add/tools/packman/python.sh | #!/bin/bash
# Copyright 2019-2020 NVIDIA CORPORATION
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
PACKMAN_CMD="$(dirname "${BASH_SOURCE}")/packman"
if [ ! -f "$PACKMAN_CMD" ]; then
PACKMAN_CMD="${PACKMAN_CMD}.sh"
fi
source "$PACKMAN_CMD" init
export PYTHONPATH="${PM_MODULE_DIR}:${PYTHONPATH}"
export PYTHONNOUSERSITE=1
# workaround for our python not shipping with certs
if [[ -z ${SSL_CERT_DIR:-} ]]; then
export SSL_CERT_DIR=/etc/ssl/certs/
fi
"${PM_PYTHON}" -u "$@"
|
mati-nvidia/window-menu-add/tools/packman/python.bat | :: Copyright 2019-2020 NVIDIA CORPORATION
::
:: Licensed under the Apache License, Version 2.0 (the "License");
:: you may not use this file except in compliance with the License.
:: You may obtain a copy of the License at
::
:: http://www.apache.org/licenses/LICENSE-2.0
::
:: Unless required by applicable law or agreed to in writing, software
:: distributed under the License is distributed on an "AS IS" BASIS,
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
:: See the License for the specific language governing permissions and
:: limitations under the License.
@echo off
setlocal
call "%~dp0\packman" init
set "PYTHONPATH=%PM_MODULE_DIR%;%PYTHONPATH%"
set PYTHONNOUSERSITE=1
"%PM_PYTHON%" -u %*
|
mati-nvidia/window-menu-add/tools/packman/packman.cmd | :: Reset errorlevel status (don't inherit from caller) [xxxxxxxxxxx]
@call :ECHO_AND_RESET_ERROR
:: You can remove the call below if you do your own manual configuration of the dev machines
call "%~dp0\bootstrap\configure.bat"
if %errorlevel% neq 0 ( exit /b %errorlevel% )
:: Everything below is mandatory
if not defined PM_PYTHON goto :PYTHON_ENV_ERROR
if not defined PM_MODULE goto :MODULE_ENV_ERROR
:: Generate temporary path for variable file
for /f "delims=" %%a in ('powershell -ExecutionPolicy ByPass -NoLogo -NoProfile ^
-File "%~dp0bootstrap\generate_temp_file_name.ps1"') do set PM_VAR_PATH=%%a
if %1.==. (
set PM_VAR_PATH_ARG=
) else (
set PM_VAR_PATH_ARG=--var-path="%PM_VAR_PATH%"
)
"%PM_PYTHON%" -S -s -u -E "%PM_MODULE%" %* %PM_VAR_PATH_ARG%
if %errorlevel% neq 0 ( exit /b %errorlevel% )
:: Marshall environment variables into the current environment if they have been generated and remove temporary file
if exist "%PM_VAR_PATH%" (
for /F "usebackq tokens=*" %%A in ("%PM_VAR_PATH%") do set "%%A"
)
if %errorlevel% neq 0 ( goto :VAR_ERROR )
if exist "%PM_VAR_PATH%" (
del /F "%PM_VAR_PATH%"
)
if %errorlevel% neq 0 ( goto :VAR_ERROR )
set PM_VAR_PATH=
goto :eof
:: Subroutines below
:PYTHON_ENV_ERROR
@echo User environment variable PM_PYTHON is not set! Please configure machine for packman or call configure.bat.
exit /b 1
:MODULE_ENV_ERROR
@echo User environment variable PM_MODULE is not set! Please configure machine for packman or call configure.bat.
exit /b 1
:VAR_ERROR
@echo Error while processing and setting environment variables!
exit /b 1
:ECHO_AND_RESET_ERROR
@echo off
if /I "%PM_VERBOSITY%"=="debug" (
@echo on
)
exit /b 0
|
mati-nvidia/window-menu-add/tools/packman/config.packman.xml | <config remotes="cloudfront">
<remote2 name="cloudfront">
<transport actions="download" protocol="https" packageLocation="d4i3qtqj3r0z5.cloudfront.net/${name}@${version}" />
</remote2>
</config>
|
mati-nvidia/window-menu-add/tools/packman/bootstrap/generate_temp_file_name.ps1 | <#
Copyright 2019 NVIDIA CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
#>
$out = [System.IO.Path]::GetTempFileName()
Write-Host $out
# SIG # Begin signature block
# MIIaVwYJKoZIhvcNAQcCoIIaSDCCGkQCAQExDzANBglghkgBZQMEAg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TAvBgNV
# BAMTKERpZ2lDZXJ0IFNIQTIgQXNzdXJlZCBJRCBUaW1lc3RhbXBpbmcgQ0ECEA1C
# SuC+Ooj/YEAhzhQA8N0wDQYJYIZIAWUDBAIBBQCggZgwGgYJKoZIhvcNAQkDMQ0G
# CyqGSIb3DQEJEAEEMBwGCSqGSIb3DQEJBTEPFw0yMTA0MDgwOTExMDlaMCsGCyqG
# SIb3DQEJEAIMMRwwGjAYMBYEFOHXgqjhkb7va8oWkbWqtJSmJJvzMC8GCSqGSIb3
# DQEJBDEiBCCHEAmNNj2zWjWYRfEi4FgzZvrI16kv/U2b9b3oHw6UVDANBgkqhkiG
# 9w0BAQEFAASCAQCdefEKh6Qmwx7xGCkrYi/A+/Cla6LdnYJp38eMs3fqTTvjhyDw
# HffXrwdqWy5/fgW3o3qJXqa5o7hLxYIoWSULOCpJRGdt+w7XKPAbZqHrN9elAhWJ
# vpBTCEaj7dVxr1Ka4NsoPSYe0eidDBmmvGvp02J4Z1j8+ImQPKN6Hv/L8Ixaxe7V
# mH4VtXIiBK8xXdi4wzO+A+qLtHEJXz3Gw8Bp3BNtlDGIUkIhVTM3Q1xcSEqhOLqo
# PGdwCw9acxdXNWWPjOJkNH656Bvmkml+0p6MTGIeG4JCeRh1Wpqm1ZGSoEcXNaof
# wOgj48YzI+dNqBD9i7RSWCqJr2ygYKRTxnuU
# SIG # End signature block
|
mati-nvidia/window-menu-add/tools/packman/bootstrap/configure.bat | :: Copyright 2019 NVIDIA CORPORATION
::
:: Licensed under the Apache License, Version 2.0 (the "License");
:: you may not use this file except in compliance with the License.
:: You may obtain a copy of the License at
::
:: http://www.apache.org/licenses/LICENSE-2.0
::
:: Unless required by applicable law or agreed to in writing, software
:: distributed under the License is distributed on an "AS IS" BASIS,
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
:: See the License for the specific language governing permissions and
:: limitations under the License.
set PM_PACKMAN_VERSION=6.33.2
:: Specify where packman command is rooted
set PM_INSTALL_PATH=%~dp0..
:: The external root may already be configured and we should do minimal work in that case
if defined PM_PACKAGES_ROOT goto ENSURE_DIR
:: If the folder isn't set we assume that the best place for it is on the drive that we are currently
:: running from
set PM_DRIVE=%CD:~0,2%
set PM_PACKAGES_ROOT=%PM_DRIVE%\packman-repo
:: We use *setx* here so that the variable is persisted in the user environment
echo Setting user environment variable PM_PACKAGES_ROOT to %PM_PACKAGES_ROOT%
setx PM_PACKAGES_ROOT %PM_PACKAGES_ROOT%
if %errorlevel% neq 0 ( goto ERROR )
:: The above doesn't work properly from a build step in VisualStudio because a separate process is
:: spawned for it so it will be lost for subsequent compilation steps - VisualStudio must
:: be launched from a new process. We catch this odd-ball case here:
if defined PM_DISABLE_VS_WARNING goto ENSURE_DIR
if not defined VSLANG goto ENSURE_DIR
echo The above is a once-per-computer operation. Unfortunately VisualStudio cannot pick up environment change
echo unless *VisualStudio is RELAUNCHED*.
echo If you are launching VisualStudio from command line or command line utility make sure
echo you have a fresh launch environment (relaunch the command line or utility).
echo If you are using 'linkPath' and referring to packages via local folder links you can safely ignore this warning.
echo You can disable this warning by setting the environment variable PM_DISABLE_VS_WARNING.
echo.
:: Check for the directory that we need. Note that mkdir will create any directories
:: that may be needed in the path
:ENSURE_DIR
if not exist "%PM_PACKAGES_ROOT%" (
echo Creating directory %PM_PACKAGES_ROOT%
mkdir "%PM_PACKAGES_ROOT%"
)
if %errorlevel% neq 0 ( goto ERROR_MKDIR_PACKAGES_ROOT )
:: The Python interpreter may already be externally configured
if defined PM_PYTHON_EXT (
set PM_PYTHON=%PM_PYTHON_EXT%
goto PACKMAN
)
set PM_PYTHON_VERSION=3.7.9-windows-x86_64
set PM_PYTHON_BASE_DIR=%PM_PACKAGES_ROOT%\python
set PM_PYTHON_DIR=%PM_PYTHON_BASE_DIR%\%PM_PYTHON_VERSION%
set PM_PYTHON=%PM_PYTHON_DIR%\python.exe
if exist "%PM_PYTHON%" goto PACKMAN
if not exist "%PM_PYTHON_BASE_DIR%" call :CREATE_PYTHON_BASE_DIR
set PM_PYTHON_PACKAGE=python@%PM_PYTHON_VERSION%.cab
for /f "delims=" %%a in ('powershell -ExecutionPolicy ByPass -NoLogo -NoProfile -File "%~dp0\generate_temp_file_name.ps1"') do set TEMP_FILE_NAME=%%a
set TARGET=%TEMP_FILE_NAME%.zip
call "%~dp0fetch_file_from_packman_bootstrap.cmd" %PM_PYTHON_PACKAGE% "%TARGET%"
if %errorlevel% neq 0 (
echo !!! Error fetching python from CDN !!!
goto ERROR
)
for /f "delims=" %%a in ('powershell -ExecutionPolicy ByPass -NoLogo -NoProfile -File "%~dp0\generate_temp_folder.ps1" -parentPath "%PM_PYTHON_BASE_DIR%"') do set TEMP_FOLDER_NAME=%%a
echo Unpacking Python interpreter ...
"%SystemRoot%\system32\expand.exe" -F:* "%TARGET%" "%TEMP_FOLDER_NAME%" 1> nul
del "%TARGET%"
:: Failure during extraction to temp folder name, need to clean up and abort
if %errorlevel% neq 0 (
echo !!! Error unpacking python !!!
call :CLEAN_UP_TEMP_FOLDER
goto ERROR
)
:: If python has now been installed by a concurrent process we need to clean up and then continue
if exist "%PM_PYTHON%" (
call :CLEAN_UP_TEMP_FOLDER
goto PACKMAN
) else (
if exist "%PM_PYTHON_DIR%" ( rd /s /q "%PM_PYTHON_DIR%" > nul )
)
:: Perform atomic rename
rename "%TEMP_FOLDER_NAME%" "%PM_PYTHON_VERSION%" 1> nul
:: Failure during move, need to clean up and abort
if %errorlevel% neq 0 (
echo !!! Error renaming python !!!
call :CLEAN_UP_TEMP_FOLDER
goto ERROR
)
:PACKMAN
:: The packman module may already be externally configured
if defined PM_MODULE_DIR_EXT (
set PM_MODULE_DIR=%PM_MODULE_DIR_EXT%
) else (
set PM_MODULE_DIR=%PM_PACKAGES_ROOT%\packman-common\%PM_PACKMAN_VERSION%
)
set PM_MODULE=%PM_MODULE_DIR%\packman.py
if exist "%PM_MODULE%" goto ENSURE_7ZA
set PM_MODULE_PACKAGE=packman-common@%PM_PACKMAN_VERSION%.zip
for /f "delims=" %%a in ('powershell -ExecutionPolicy ByPass -NoLogo -NoProfile -File "%~dp0\generate_temp_file_name.ps1"') do set TEMP_FILE_NAME=%%a
set TARGET=%TEMP_FILE_NAME%
call "%~dp0fetch_file_from_packman_bootstrap.cmd" %PM_MODULE_PACKAGE% "%TARGET%"
if %errorlevel% neq 0 (
echo !!! Error fetching packman from CDN !!!
goto ERROR
)
echo Unpacking ...
"%PM_PYTHON%" -S -s -u -E "%~dp0\install_package.py" "%TARGET%" "%PM_MODULE_DIR%"
if %errorlevel% neq 0 (
echo !!! Error unpacking packman !!!
goto ERROR
)
del "%TARGET%"
:ENSURE_7ZA
set PM_7Za_VERSION=16.02.4
set PM_7Za_PATH=%PM_PACKAGES_ROOT%\7za\%PM_7ZA_VERSION%
if exist "%PM_7Za_PATH%" goto END
set PM_7Za_PATH=%PM_PACKAGES_ROOT%\chk\7za\%PM_7ZA_VERSION%
if exist "%PM_7Za_PATH%" goto END
"%PM_PYTHON%" -S -s -u -E "%PM_MODULE%" pull "%PM_MODULE_DIR%\deps.packman.xml"
if %errorlevel% neq 0 (
echo !!! Error fetching packman dependencies !!!
goto ERROR
)
goto END
:ERROR_MKDIR_PACKAGES_ROOT
echo Failed to automatically create packman packages repo at %PM_PACKAGES_ROOT%.
echo Please set a location explicitly that packman has permission to write to, by issuing:
echo.
echo setx PM_PACKAGES_ROOT {path-you-choose-for-storing-packman-packages-locally}
echo.
echo Then launch a new command console for the changes to take effect and run packman command again.
exit /B %errorlevel%
:ERROR
echo !!! Failure while configuring local machine :( !!!
exit /B %errorlevel%
:CLEAN_UP_TEMP_FOLDER
rd /S /Q "%TEMP_FOLDER_NAME%"
exit /B
:CREATE_PYTHON_BASE_DIR
:: We ignore errors and clean error state - if two processes create the directory one will fail which is fine
md "%PM_PYTHON_BASE_DIR%" > nul 2>&1
exit /B 0
:END
|
mati-nvidia/window-menu-add/tools/packman/bootstrap/fetch_file_from_packman_bootstrap.cmd | :: Copyright 2019 NVIDIA CORPORATION
::
:: Licensed under the Apache License, Version 2.0 (the "License");
:: you may not use this file except in compliance with the License.
:: You may obtain a copy of the License at
::
:: http://www.apache.org/licenses/LICENSE-2.0
::
:: Unless required by applicable law or agreed to in writing, software
:: distributed under the License is distributed on an "AS IS" BASIS,
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
:: See the License for the specific language governing permissions and
:: limitations under the License.
:: You need to specify <package-name> <target-path> as input to this command
@setlocal
@set PACKAGE_NAME=%1
@set TARGET_PATH=%2
@echo Fetching %PACKAGE_NAME% ...
@powershell -ExecutionPolicy ByPass -NoLogo -NoProfile -File "%~dp0download_file_from_url.ps1" ^
-source "http://bootstrap.packman.nvidia.com/%PACKAGE_NAME%" -output %TARGET_PATH%
:: A bug in powershell prevents the errorlevel code from being set when using the -File execution option
:: We must therefore do our own failure analysis, basically make sure the file exists and is larger than 0 bytes:
@if not exist %TARGET_PATH% goto ERROR_DOWNLOAD_FAILED
@if %~z2==0 goto ERROR_DOWNLOAD_FAILED
@endlocal
@exit /b 0
:ERROR_DOWNLOAD_FAILED
@echo Failed to download file from S3
@echo Most likely because endpoint cannot be reached or file %PACKAGE_NAME% doesn't exist
@endlocal
@exit /b 1 |
mati-nvidia/window-menu-add/tools/packman/bootstrap/download_file_from_url.ps1 | <#
Copyright 2019 NVIDIA CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
#>
param(
[Parameter(Mandatory=$true)][string]$source=$null,
[string]$output="out.exe"
)
$filename = $output
$triesLeft = 3
do
{
$triesLeft -= 1
try
{
Write-Host "Downloading from bootstrap.packman.nvidia.com ..."
$wc = New-Object net.webclient
$wc.Downloadfile($source, $fileName)
$triesLeft = 0
}
catch
{
Write-Host "Error downloading $source!"
Write-Host $_.Exception|format-list -force
}
} while ($triesLeft -gt 0)
|
mati-nvidia/window-menu-add/tools/packman/bootstrap/generate_temp_folder.ps1 | <#
Copyright 2019 NVIDIA CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
#>
param(
[Parameter(Mandatory=$true)][string]$parentPath=$null
)
[string] $name = [System.Guid]::NewGuid()
$out = Join-Path $parentPath $name
New-Item -ItemType Directory -Path ($out) | Out-Null
Write-Host $out
# SIG # Begin signature block
# MIIaVwYJKoZIhvcNAQcCoIIaSDCCGkQCAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCB29nsqMEu+VmSF
# 7ckeVTPrEZ6hsXjOgPFlJm9ilgHUB6CCCiIwggTTMIIDu6ADAgECAhBi50XpIWUh
# PJcfXEkK6hKlMA0GCSqGSIb3DQEBCwUAMIGEMQswCQYDVQQGEwJVUzEdMBsGA1UE
# ChMUU3ltYW50ZWMgQ29ycG9yYXRpb24xHzAdBgNVBAsTFlN5bWFudGVjIFRydXN0
# IE5ldHdvcmsxNTAzBgNVBAMTLFN5bWFudGVjIENsYXNzIDMgU0hBMjU2IENvZGUg
# U2lnbmluZyBDQSAtIEcyMB4XDTE4MDcwOTAwMDAwMFoXDTIxMDcwOTIzNTk1OVow
# gYMxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRQwEgYDVQQHDAtT
# YW50YSBDbGFyYTEbMBkGA1UECg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Pn2MGhAXybIHnth3+MFp1b6Blhz3WlReQyarjq
# 1f+zaFB79rg6JswXoOTJhwICBP3hO2Ua3dMAswbfl+QNXF+igKLJPYnaeSVhBbm6
# VCu2io27t4ixqvoD0RuPObNX/P3oVA38afiM
# SIG # End signature block
|
mati-nvidia/window-menu-add/tools/packman/bootstrap/install_package.py | # Copyright 2019 NVIDIA CORPORATION
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
import zipfile
import tempfile
import sys
import shutil
__author__ = "hfannar"
logging.basicConfig(level=logging.WARNING, format="%(message)s")
logger = logging.getLogger("install_package")
class TemporaryDirectory:
def __init__(self):
self.path = None
def __enter__(self):
self.path = tempfile.mkdtemp()
return self.path
def __exit__(self, type, value, traceback):
# Remove temporary data created
shutil.rmtree(self.path)
def install_package(package_src_path, package_dst_path):
with zipfile.ZipFile(
package_src_path, allowZip64=True
) as zip_file, TemporaryDirectory() as temp_dir:
zip_file.extractall(temp_dir)
# Recursively copy (temp_dir will be automatically cleaned up on exit)
try:
# Recursive copy is needed because both package name and version folder could be missing in
# target directory:
shutil.copytree(temp_dir, package_dst_path)
except OSError as exc:
logger.warning(
"Directory %s already present, packaged installation aborted" % package_dst_path
)
else:
logger.info("Package successfully installed to %s" % package_dst_path)
install_package(sys.argv[1], sys.argv[2])
|
mati-nvidia/window-menu-add/exts/maticodes.example.window.add/maticodes/example/window/add/extension.py | import carb
import omni.ext
import omni.kit.ui
from .window import MyCustomWindow, WINDOW_TITLE
class WindowMenuAddExtension(omni.ext.IExt):
def on_startup(self, ext_id):
carb.log_info("[maticodes.example.window.add] WindowMenuAddExtension startup")
# Note the "Window" part of the path that directs the new menu item to the "Window" menu.
self._menu_path = f"Window/{WINDOW_TITLE}"
self._window = None
self._menu = omni.kit.ui.get_editor_menu().add_item(self._menu_path, self._on_menu_click, True)
def on_shutdown(self):
carb.log_info("[maticodes.example.window.add] WindowMenuAddExtension shutdown")
omni.kit.ui.get_editor_menu().remove_item(self._menu)
if self._window is not None:
self._window.destroy()
self._window = None
def _on_menu_click(self, menu, toggled):
"""Handles showing and hiding the window from the 'Windows' menu."""
if toggled:
if self._window is None:
self._window = MyCustomWindow(WINDOW_TITLE, self._menu_path)
else:
self._window.show()
else:
if self._window is not None:
self._window.hide()
|
mati-nvidia/window-menu-add/exts/maticodes.example.window.add/maticodes/example/window/add/__init__.py | from .extension import *
|
mati-nvidia/window-menu-add/exts/maticodes.example.window.add/maticodes/example/window/add/window.py | import omni.kit.ui
import omni.ui as ui
WINDOW_TITLE = "My Custom Window"
class MyCustomWindow(ui.Window):
def __init__(self, title, menu_path):
super().__init__(title, width=640, height=480)
self._menu_path = menu_path
self.set_visibility_changed_fn(self._on_visibility_changed)
self._build_ui()
def on_shutdown(self):
self._win = None
def show(self):
self.visible = True
self.focus()
def hide(self):
self.visible = False
def _build_ui(self):
with self.frame:
with ui.VStack():
ui.Label("This is just an empty window", width=0, alignment=ui.Alignment.CENTER)
def _on_visibility_changed(self, visible):
omni.kit.ui.get_editor_menu().set_value(self._menu_path, visible)
|
mati-nvidia/window-menu-add/exts/maticodes.example.window.add/config/extension.toml | [package]
# Semantic Versionning is used: https://semver.org/
version = "1.0.0"
# The title and description fields are primarily for displaying extension info in UI
title = "Window Menu Add"
description="How to create a custom window and add it to the 'Window' menu"
# Path (relative to the root) or content of readme markdown file for UI.
readme = "docs/README.md"
# URL of the extension source repository.
repository = ""
# One of categories for UI.
category = "Example"
# Keywords for the extension
keywords = ["kit", "example"]
# Use omni.ui to build simple UI
[dependencies]
"omni.kit.uiapp" = {}
# Main python module this extension provides, it will be publicly available as "import omni.hello.world".
[[python.module]]
name = "maticodes.example.window.add"
|
mati-nvidia/window-menu-add/exts/maticodes.example.window.add/docs/README.md | # Window Menu Add
An example extension showing how to create a window and add it to the `Window` menu so that it can be shown and hidden
using the menu item in the `Window` menu. |
mati-nvidia/developer-office-hours/RUNBOOK.md | 1. Run make_ext.bat <YYYY-MM-DD>
1. Put script into the `scripts/` folder.
1. Add questions covered in the ext README. |
mati-nvidia/developer-office-hours/make_ext.bat | @echo off
call "%~dp0tools\packman\python.bat" %~dp0tools\scripts\make_ext.py %*
if %errorlevel% neq 0 ( goto Error )
:Success
exit /b 0
:Error
exit /b %errorlevel%
|
mati-nvidia/developer-office-hours/link_app.sh | #!/bin/bash
set -e
SCRIPT_DIR=$(dirname ${BASH_SOURCE})
cd "$SCRIPT_DIR"
exec "tools/packman/python.sh" tools/scripts/link_app.py $@
|
mati-nvidia/developer-office-hours/csv2md.bat | @echo off
call "%~dp0tools\packman\python.bat" %~dp0tools\scripts\csv2md.py %*
if %errorlevel% neq 0 ( goto Error )
:Success
exit /b 0
:Error
exit /b %errorlevel%
|
mati-nvidia/developer-office-hours/link_app.bat | @echo off
call "%~dp0tools\packman\python.bat" %~dp0tools\scripts\link_app.py %*
if %errorlevel% neq 0 ( goto Error )
:Success
exit /b 0
:Error
exit /b %errorlevel%
|
mati-nvidia/developer-office-hours/README.md | # NVIDIA Omniverse Developer Office Hour
This repository contains the sample extensions and scripts that I cover during the weekly Developer Office Hour livestreams. The livestreams take place every Friday at 10am (ET). Have a look at the [NVIDIA Omniverse Community Calendar](https://www.addevent.com/calendar/ae483892) to see when the next one will be. From AddEvent, you can add the events to your own calendar. The livestream recordings are also archived and with timestamped chapters for each question on the [NVIDIA Omniverse YouTube channel](https://www.youtube.com/playlist?list=PL3jK4xNnlCVe61X_m5qcizysvP7HphjyU) and [NVIDIA On-Demand](https://www.nvidia.com/en-us/on-demand/search/?facet.mimetype[]=event%20session&layout=list&page=1&q=developer%20office%20hour&sort=date&sortDir=desc).
## How to check what questions have been answered at a glance
I keep a list here in the [Omniverse FAQ](https://forums.developer.nvidia.com/t/omniverse-faq/229782). You can easily search the page (Ctrl+F) for keywords.
## How to navigate this repository
For every livestream date, there is a Kit extension that I worked from in `exts/maticodes.doh_YYYY_MM_DD`. If you go into one of those extension directories, you'll see a README with the questions answered on that date. You'll find code that I showed in the extension code itself and/or in the `scripts/` directory for that extension.
## Contributing
The source code for this repository is provided as-is and we are not accepting outside contributions. |
mati-nvidia/developer-office-hours/tools/scripts/csv2md.py | # SPDX-License-Identifier: Apache-2.0
import argparse
import csv
from pathlib import Path
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Convert DOH CSV to MD")
parser.add_argument(
"csvfile", help="The CSV file to convert"
)
args = parser.parse_args()
csvfile = Path(args.csvfile)
mdfile = csvfile.with_suffix(".md")
rows = []
with open(csvfile) as f:
with open(mdfile, "w") as out:
for row in csv.reader(f):
if row[2] and not row[5]:
out.write(f"1. [{row[1]}]({row[2]})\n")
print("Success!")
|
mati-nvidia/developer-office-hours/tools/scripts/make_ext.py | # SPDX-License-Identifier: Apache-2.0
import argparse
import shutil
import os
from pathlib import Path
SOURCE_PATH = Path(__file__).parent / "template" / "maticodes.doh_YYYY_MM_DD"
def text_replace(filepath, tokens_map):
with open(filepath, "r") as f:
data = f.read()
for token, fstring in tokens_map.items():
data = data.replace(token, fstring)
with open(filepath, "w") as f:
f.write(data)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Create folder link to Kit App installed from Omniverse Launcher")
parser.add_argument(
"date", help="The dates of the Office Hour in YYYY-MM-DD format."
)
args = parser.parse_args()
year, month, day = args.date.split("-")
# copy files
dest_path = Path(__file__).parent / "../.." / f"exts/maticodes.doh_{year}_{month}_{day}"
shutil.copytree(SOURCE_PATH, dest_path)
# rename folders
template_ext_folder = dest_path / "maticodes" / "doh_YYYY_MM_DD"
ext_folder = dest_path / "maticodes" / f"doh_{year}_{month}_{day}"
os.rename(template_ext_folder, ext_folder)
tokens_map = {
"[DATE_HYPHEN]": f"{year}-{month}-{day}",
"[DATE_UNDERSCORE]": f"{year}_{month}_{day}",
"[DATE_PRETTY]": f"{month}/{day}/{year}",
}
# text replace extension.toml
ext_toml = dest_path / "config" / "extension.toml"
text_replace(ext_toml, tokens_map)
# text replace README
readme = dest_path / "docs" / "README.md"
text_replace(readme, tokens_map)
# text replace extension.py
ext_py = ext_folder / "extension.py"
text_replace(ext_py, tokens_map)
print("Success!")
|
mati-nvidia/developer-office-hours/tools/scripts/link_app.py | import os
import argparse
import sys
import json
import packmanapi
import urllib3
def find_omniverse_apps():
http = urllib3.PoolManager()
try:
r = http.request("GET", "http://127.0.0.1:33480/components")
except Exception as e:
print(f"Failed retrieving apps from an Omniverse Launcher, maybe it is not installed?\nError: {e}")
sys.exit(1)
apps = {}
for x in json.loads(r.data.decode("utf-8")):
latest = x.get("installedVersions", {}).get("latest", "")
if latest:
for s in x.get("settings", []):
if s.get("version", "") == latest:
root = s.get("launch", {}).get("root", "")
apps[x["slug"]] = (x["name"], root)
break
return apps
def create_link(src, dst):
print(f"Creating a link '{src}' -> '{dst}'")
packmanapi.link(src, dst)
APP_PRIORITIES = ["code", "create", "view"]
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Create folder link to Kit App installed from Omniverse Launcher")
parser.add_argument(
"--path",
help="Path to Kit App installed from Omniverse Launcher, e.g.: 'C:/Users/bob/AppData/Local/ov/pkg/create-2021.3.4'",
required=False,
)
parser.add_argument(
"--app", help="Name of Kit App installed from Omniverse Launcher, e.g.: 'code', 'create'", required=False
)
args = parser.parse_args()
path = args.path
if not path:
print("Path is not specified, looking for Omniverse Apps...")
apps = find_omniverse_apps()
if len(apps) == 0:
print(
"Can't find any Omniverse Apps. Use Omniverse Launcher to install one. 'Code' is the recommended app for developers."
)
sys.exit(0)
print("\nFound following Omniverse Apps:")
for i, slug in enumerate(apps):
name, root = apps[slug]
print(f"{i}: {name} ({slug}) at: '{root}'")
if args.app:
selected_app = args.app.lower()
if selected_app not in apps:
choices = ", ".join(apps.keys())
print(f"Passed app: '{selected_app}' is not found. Specify one of the following found Apps: {choices}")
sys.exit(0)
else:
selected_app = next((x for x in APP_PRIORITIES if x in apps), None)
if not selected_app:
selected_app = next(iter(apps))
print(f"\nSelected app: {selected_app}")
_, path = apps[selected_app]
if not os.path.exists(path):
print(f"Provided path doesn't exist: {path}")
else:
SCRIPT_ROOT = os.path.dirname(os.path.realpath(__file__))
create_link(f"{SCRIPT_ROOT}/../../app", path)
print("Success!")
|
mati-nvidia/developer-office-hours/tools/scripts/template/maticodes.doh_YYYY_MM_DD/maticodes/doh_YYYY_MM_DD/extension.py | # SPDX-License-Identifier: Apache-2.0
import carb
import omni.ext
import omni.ui as ui
class MyWindow(ui.Window):
def __init__(self, title: str = None, **kwargs):
super().__init__(title, **kwargs)
self.frame.set_build_fn(self._build_window)
def _build_window(self):
with ui.ScrollingFrame():
with ui.VStack(height=0):
ui.Label("My Label")
def clicked():
carb.log_info("Button Clicked!")
ui.Button("Click Me", clicked_fn=clicked)
class MyExtension(omni.ext.IExt):
def on_startup(self, ext_id):
carb.log_info("[maticodes.doh_[DATE_UNDERSCORE]] Dev Office Hours Extension ([DATE_HYPHEN]) startup")
self._window = MyWindow("MyWindow", width=300, height=300)
def on_shutdown(self):
carb.log_info("[maticodes.doh_[DATE_UNDERSCORE]] Dev Office Hours Extension ([DATE_HYPHEN]) shutdown")
if self._window:
self._window.destroy()
self._window = None
|
mati-nvidia/developer-office-hours/tools/scripts/template/maticodes.doh_YYYY_MM_DD/maticodes/doh_YYYY_MM_DD/__init__.py | # SPDX-License-Identifier: Apache-2.0
from .extension import *
|
mati-nvidia/developer-office-hours/tools/scripts/template/maticodes.doh_YYYY_MM_DD/scripts/my_script.py | # SPDX-License-Identifier: Apache-2.0 |
mati-nvidia/developer-office-hours/tools/scripts/template/maticodes.doh_YYYY_MM_DD/config/extension.toml | [package]
# Semantic Versionning is used: https://semver.org/
version = "1.0.0"
# The title and description fields are primarily for displaying extension info in UI
title = "[DATE_HYPHEN]: Dev Office Hours"
description="Sample code from the Dev Office Hour held on [DATE_HYPHEN]"
# Path (relative to the root) or content of readme markdown file for UI.
readme = "docs/README.md"
# URL of the extension source repository.
repository = ""
# One of categories for UI.
category = "Example"
# Keywords for the extension
keywords = ["kit", "example"]
# Use omni.ui to build simple UI
[dependencies]
"omni.kit.uiapp" = {}
# Main python module this extension provides, it will be publicly available as "import maticodes.doh_[DATE_UNDERSCORE]".
[[python.module]]
name = "maticodes.doh_[DATE_UNDERSCORE]"
|
mati-nvidia/developer-office-hours/tools/scripts/template/maticodes.doh_YYYY_MM_DD/docs/README.md | # Developer Office Hour - [DATE_PRETTY]
This is the sample code from the Developer Office Hour held on [DATE_PRETTY], Mati answered some developer questions
from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD.
## Questions
- How do I do something?
...
|
mati-nvidia/developer-office-hours/tools/packman/python.sh | #!/bin/bash
# Copyright 2019-2020 NVIDIA CORPORATION
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
PACKMAN_CMD="$(dirname "${BASH_SOURCE}")/packman"
if [ ! -f "$PACKMAN_CMD" ]; then
PACKMAN_CMD="${PACKMAN_CMD}.sh"
fi
source "$PACKMAN_CMD" init
export PYTHONPATH="${PM_MODULE_DIR}:${PYTHONPATH}"
export PYTHONNOUSERSITE=1
# workaround for our python not shipping with certs
if [[ -z ${SSL_CERT_DIR:-} ]]; then
export SSL_CERT_DIR=/etc/ssl/certs/
fi
"${PM_PYTHON}" -u "$@"
|
mati-nvidia/developer-office-hours/tools/packman/python.bat | :: Copyright 2019-2020 NVIDIA CORPORATION
::
:: Licensed under the Apache License, Version 2.0 (the "License");
:: you may not use this file except in compliance with the License.
:: You may obtain a copy of the License at
::
:: http://www.apache.org/licenses/LICENSE-2.0
::
:: Unless required by applicable law or agreed to in writing, software
:: distributed under the License is distributed on an "AS IS" BASIS,
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
:: See the License for the specific language governing permissions and
:: limitations under the License.
@echo off
setlocal
call "%~dp0\packman" init
set "PYTHONPATH=%PM_MODULE_DIR%;%PYTHONPATH%"
set PYTHONNOUSERSITE=1
"%PM_PYTHON%" -u %*
|
mati-nvidia/developer-office-hours/tools/packman/packman.cmd | :: Reset errorlevel status (don't inherit from caller) [xxxxxxxxxxx]
@call :ECHO_AND_RESET_ERROR
:: You can remove the call below if you do your own manual configuration of the dev machines
call "%~dp0\bootstrap\configure.bat"
if %errorlevel% neq 0 ( exit /b %errorlevel% )
:: Everything below is mandatory
if not defined PM_PYTHON goto :PYTHON_ENV_ERROR
if not defined PM_MODULE goto :MODULE_ENV_ERROR
:: Generate temporary path for variable file
for /f "delims=" %%a in ('powershell -ExecutionPolicy ByPass -NoLogo -NoProfile ^
-File "%~dp0bootstrap\generate_temp_file_name.ps1"') do set PM_VAR_PATH=%%a
if %1.==. (
set PM_VAR_PATH_ARG=
) else (
set PM_VAR_PATH_ARG=--var-path="%PM_VAR_PATH%"
)
"%PM_PYTHON%" -S -s -u -E "%PM_MODULE%" %* %PM_VAR_PATH_ARG%
if %errorlevel% neq 0 ( exit /b %errorlevel% )
:: Marshall environment variables into the current environment if they have been generated and remove temporary file
if exist "%PM_VAR_PATH%" (
for /F "usebackq tokens=*" %%A in ("%PM_VAR_PATH%") do set "%%A"
)
if %errorlevel% neq 0 ( goto :VAR_ERROR )
if exist "%PM_VAR_PATH%" (
del /F "%PM_VAR_PATH%"
)
if %errorlevel% neq 0 ( goto :VAR_ERROR )
set PM_VAR_PATH=
goto :eof
:: Subroutines below
:PYTHON_ENV_ERROR
@echo User environment variable PM_PYTHON is not set! Please configure machine for packman or call configure.bat.
exit /b 1
:MODULE_ENV_ERROR
@echo User environment variable PM_MODULE is not set! Please configure machine for packman or call configure.bat.
exit /b 1
:VAR_ERROR
@echo Error while processing and setting environment variables!
exit /b 1
:ECHO_AND_RESET_ERROR
@echo off
if /I "%PM_VERBOSITY%"=="debug" (
@echo on
)
exit /b 0
|
mati-nvidia/developer-office-hours/tools/packman/config.packman.xml | <config remotes="cloudfront">
<remote2 name="cloudfront">
<transport actions="download" protocol="https" packageLocation="d4i3qtqj3r0z5.cloudfront.net/${name}@${version}" />
</remote2>
</config>
|
mati-nvidia/developer-office-hours/tools/packman/bootstrap/generate_temp_file_name.ps1 | <#
Copyright 2019 NVIDIA CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
#>
$out = [System.IO.Path]::GetTempFileName()
Write-Host $out
# SIG # Begin signature block
# MIIaVwYJKoZIhvcNAQcCoIIaSDCCGkQCAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCAK+Ewup1N0/mdf
# 1l4R58rxyumHgZvTmEhrYTb2Zf0zd6CCCiIwggTTMIIDu6ADAgECAhBi50XpIWUh
# PJcfXEkK6hKlMA0GCSqGSIb3DQEBCwUAMIGEMQswCQYDVQQGEwJVUzEdMBsGA1UE
# ChMUU3ltYW50ZWMgQ29ycG9yYXRpb24xHzAdBgNVBAsTFlN5bWFudGVjIFRydXN0
# IE5ldHdvcmsxNTAzBgNVBAMTLFN5bWFudGVjIENsYXNzIDMgU0hBMjU2IENvZGUg
# U2lnbmluZyBDQSAtIEcyMB4XDTE4MDcwOTAwMDAwMFoXDTIx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pJRGdt+w7XKPAbZqHrN9elAhWJ
# vpBTCEaj7dVxr1Ka4NsoPSYe0eidDBmmvGvp02J4Z1j8+ImQPKN6Hv/L8Ixaxe7V
# mH4VtXIiBK8xXdi4wzO+A+qLtHEJXz3Gw8Bp3BNtlDGIUkIhVTM3Q1xcSEqhOLqo
# PGdwCw9acxdXNWWPjOJkNH656Bvmkml+0p6MTGIeG4JCeRh1Wpqm1ZGSoEcXNaof
# wOgj48YzI+dNqBD9i7RSWCqJr2ygYKRTxnuU
# SIG # End signature block
|
mati-nvidia/developer-office-hours/tools/packman/bootstrap/configure.bat | :: Copyright 2019 NVIDIA CORPORATION
::
:: Licensed under the Apache License, Version 2.0 (the "License");
:: you may not use this file except in compliance with the License.
:: You may obtain a copy of the License at
::
:: http://www.apache.org/licenses/LICENSE-2.0
::
:: Unless required by applicable law or agreed to in writing, software
:: distributed under the License is distributed on an "AS IS" BASIS,
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
:: See the License for the specific language governing permissions and
:: limitations under the License.
set PM_PACKMAN_VERSION=6.33.2
:: Specify where packman command is rooted
set PM_INSTALL_PATH=%~dp0..
:: The external root may already be configured and we should do minimal work in that case
if defined PM_PACKAGES_ROOT goto ENSURE_DIR
:: If the folder isn't set we assume that the best place for it is on the drive that we are currently
:: running from
set PM_DRIVE=%CD:~0,2%
set PM_PACKAGES_ROOT=%PM_DRIVE%\packman-repo
:: We use *setx* here so that the variable is persisted in the user environment
echo Setting user environment variable PM_PACKAGES_ROOT to %PM_PACKAGES_ROOT%
setx PM_PACKAGES_ROOT %PM_PACKAGES_ROOT%
if %errorlevel% neq 0 ( goto ERROR )
:: The above doesn't work properly from a build step in VisualStudio because a separate process is
:: spawned for it so it will be lost for subsequent compilation steps - VisualStudio must
:: be launched from a new process. We catch this odd-ball case here:
if defined PM_DISABLE_VS_WARNING goto ENSURE_DIR
if not defined VSLANG goto ENSURE_DIR
echo The above is a once-per-computer operation. Unfortunately VisualStudio cannot pick up environment change
echo unless *VisualStudio is RELAUNCHED*.
echo If you are launching VisualStudio from command line or command line utility make sure
echo you have a fresh launch environment (relaunch the command line or utility).
echo If you are using 'linkPath' and referring to packages via local folder links you can safely ignore this warning.
echo You can disable this warning by setting the environment variable PM_DISABLE_VS_WARNING.
echo.
:: Check for the directory that we need. Note that mkdir will create any directories
:: that may be needed in the path
:ENSURE_DIR
if not exist "%PM_PACKAGES_ROOT%" (
echo Creating directory %PM_PACKAGES_ROOT%
mkdir "%PM_PACKAGES_ROOT%"
)
if %errorlevel% neq 0 ( goto ERROR_MKDIR_PACKAGES_ROOT )
:: The Python interpreter may already be externally configured
if defined PM_PYTHON_EXT (
set PM_PYTHON=%PM_PYTHON_EXT%
goto PACKMAN
)
set PM_PYTHON_VERSION=3.7.9-windows-x86_64
set PM_PYTHON_BASE_DIR=%PM_PACKAGES_ROOT%\python
set PM_PYTHON_DIR=%PM_PYTHON_BASE_DIR%\%PM_PYTHON_VERSION%
set PM_PYTHON=%PM_PYTHON_DIR%\python.exe
if exist "%PM_PYTHON%" goto PACKMAN
if not exist "%PM_PYTHON_BASE_DIR%" call :CREATE_PYTHON_BASE_DIR
set PM_PYTHON_PACKAGE=python@%PM_PYTHON_VERSION%.cab
for /f "delims=" %%a in ('powershell -ExecutionPolicy ByPass -NoLogo -NoProfile -File "%~dp0\generate_temp_file_name.ps1"') do set TEMP_FILE_NAME=%%a
set TARGET=%TEMP_FILE_NAME%.zip
call "%~dp0fetch_file_from_packman_bootstrap.cmd" %PM_PYTHON_PACKAGE% "%TARGET%"
if %errorlevel% neq 0 (
echo !!! Error fetching python from CDN !!!
goto ERROR
)
for /f "delims=" %%a in ('powershell -ExecutionPolicy ByPass -NoLogo -NoProfile -File "%~dp0\generate_temp_folder.ps1" -parentPath "%PM_PYTHON_BASE_DIR%"') do set TEMP_FOLDER_NAME=%%a
echo Unpacking Python interpreter ...
"%SystemRoot%\system32\expand.exe" -F:* "%TARGET%" "%TEMP_FOLDER_NAME%" 1> nul
del "%TARGET%"
:: Failure during extraction to temp folder name, need to clean up and abort
if %errorlevel% neq 0 (
echo !!! Error unpacking python !!!
call :CLEAN_UP_TEMP_FOLDER
goto ERROR
)
:: If python has now been installed by a concurrent process we need to clean up and then continue
if exist "%PM_PYTHON%" (
call :CLEAN_UP_TEMP_FOLDER
goto PACKMAN
) else (
if exist "%PM_PYTHON_DIR%" ( rd /s /q "%PM_PYTHON_DIR%" > nul )
)
:: Perform atomic rename
rename "%TEMP_FOLDER_NAME%" "%PM_PYTHON_VERSION%" 1> nul
:: Failure during move, need to clean up and abort
if %errorlevel% neq 0 (
echo !!! Error renaming python !!!
call :CLEAN_UP_TEMP_FOLDER
goto ERROR
)
:PACKMAN
:: The packman module may already be externally configured
if defined PM_MODULE_DIR_EXT (
set PM_MODULE_DIR=%PM_MODULE_DIR_EXT%
) else (
set PM_MODULE_DIR=%PM_PACKAGES_ROOT%\packman-common\%PM_PACKMAN_VERSION%
)
set PM_MODULE=%PM_MODULE_DIR%\packman.py
if exist "%PM_MODULE%" goto ENSURE_7ZA
set PM_MODULE_PACKAGE=packman-common@%PM_PACKMAN_VERSION%.zip
for /f "delims=" %%a in ('powershell -ExecutionPolicy ByPass -NoLogo -NoProfile -File "%~dp0\generate_temp_file_name.ps1"') do set TEMP_FILE_NAME=%%a
set TARGET=%TEMP_FILE_NAME%
call "%~dp0fetch_file_from_packman_bootstrap.cmd" %PM_MODULE_PACKAGE% "%TARGET%"
if %errorlevel% neq 0 (
echo !!! Error fetching packman from CDN !!!
goto ERROR
)
echo Unpacking ...
"%PM_PYTHON%" -S -s -u -E "%~dp0\install_package.py" "%TARGET%" "%PM_MODULE_DIR%"
if %errorlevel% neq 0 (
echo !!! Error unpacking packman !!!
goto ERROR
)
del "%TARGET%"
:ENSURE_7ZA
set PM_7Za_VERSION=16.02.4
set PM_7Za_PATH=%PM_PACKAGES_ROOT%\7za\%PM_7ZA_VERSION%
if exist "%PM_7Za_PATH%" goto END
set PM_7Za_PATH=%PM_PACKAGES_ROOT%\chk\7za\%PM_7ZA_VERSION%
if exist "%PM_7Za_PATH%" goto END
"%PM_PYTHON%" -S -s -u -E "%PM_MODULE%" pull "%PM_MODULE_DIR%\deps.packman.xml"
if %errorlevel% neq 0 (
echo !!! Error fetching packman dependencies !!!
goto ERROR
)
goto END
:ERROR_MKDIR_PACKAGES_ROOT
echo Failed to automatically create packman packages repo at %PM_PACKAGES_ROOT%.
echo Please set a location explicitly that packman has permission to write to, by issuing:
echo.
echo setx PM_PACKAGES_ROOT {path-you-choose-for-storing-packman-packages-locally}
echo.
echo Then launch a new command console for the changes to take effect and run packman command again.
exit /B %errorlevel%
:ERROR
echo !!! Failure while configuring local machine :( !!!
exit /B %errorlevel%
:CLEAN_UP_TEMP_FOLDER
rd /S /Q "%TEMP_FOLDER_NAME%"
exit /B
:CREATE_PYTHON_BASE_DIR
:: We ignore errors and clean error state - if two processes create the directory one will fail which is fine
md "%PM_PYTHON_BASE_DIR%" > nul 2>&1
exit /B 0
:END
|
mati-nvidia/developer-office-hours/tools/packman/bootstrap/fetch_file_from_packman_bootstrap.cmd | :: Copyright 2019 NVIDIA CORPORATION
::
:: Licensed under the Apache License, Version 2.0 (the "License");
:: you may not use this file except in compliance with the License.
:: You may obtain a copy of the License at
::
:: http://www.apache.org/licenses/LICENSE-2.0
::
:: Unless required by applicable law or agreed to in writing, software
:: distributed under the License is distributed on an "AS IS" BASIS,
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
:: See the License for the specific language governing permissions and
:: limitations under the License.
:: You need to specify <package-name> <target-path> as input to this command
@setlocal
@set PACKAGE_NAME=%1
@set TARGET_PATH=%2
@echo Fetching %PACKAGE_NAME% ...
@powershell -ExecutionPolicy ByPass -NoLogo -NoProfile -File "%~dp0download_file_from_url.ps1" ^
-source "http://bootstrap.packman.nvidia.com/%PACKAGE_NAME%" -output %TARGET_PATH%
:: A bug in powershell prevents the errorlevel code from being set when using the -File execution option
:: We must therefore do our own failure analysis, basically make sure the file exists and is larger than 0 bytes:
@if not exist %TARGET_PATH% goto ERROR_DOWNLOAD_FAILED
@if %~z2==0 goto ERROR_DOWNLOAD_FAILED
@endlocal
@exit /b 0
:ERROR_DOWNLOAD_FAILED
@echo Failed to download file from S3
@echo Most likely because endpoint cannot be reached or file %PACKAGE_NAME% doesn't exist
@endlocal
@exit /b 1 |
mati-nvidia/developer-office-hours/tools/packman/bootstrap/download_file_from_url.ps1 | <#
Copyright 2019 NVIDIA CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
#>
param(
[Parameter(Mandatory=$true)][string]$source=$null,
[string]$output="out.exe"
)
$filename = $output
$triesLeft = 3
do
{
$triesLeft -= 1
try
{
Write-Host "Downloading from bootstrap.packman.nvidia.com ..."
$wc = New-Object net.webclient
$wc.Downloadfile($source, $fileName)
$triesLeft = 0
}
catch
{
Write-Host "Error downloading $source!"
Write-Host $_.Exception|format-list -force
}
} while ($triesLeft -gt 0)
|
mati-nvidia/developer-office-hours/tools/packman/bootstrap/generate_temp_folder.ps1 | <#
Copyright 2019 NVIDIA CORPORATION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
#>
param(
[Parameter(Mandatory=$true)][string]$parentPath=$null
)
[string] $name = [System.Guid]::NewGuid()
$out = Join-Path $parentPath $name
New-Item -ItemType Directory -Path ($out) | Out-Null
Write-Host $out
# SIG # Begin signature block
# MIIaVwY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GTAXBgNVBAsTEHd3dy5kaWdpY2VydC5jb20xMTAvBgNV
# BAMTKERpZ2lDZXJ0IFNIQTIgQXNzdXJlZCBJRCBUaW1lc3RhbXBpbmcgQ0ECEA1C
# SuC+Ooj/YEAhzhQA8N0wDQYJYIZIAWUDBAIBBQCggZgwGgYJKoZIhvcNAQkDMQ0G
# CyqGSIb3DQEJEAEEMBwGCSqGSIb3DQEJBTEPFw0yMTA0MDgwOTExMDlaMCsGCyqG
# SIb3DQEJEAIMMRwwGjAYMBYEFOHXgqjhkb7va8oWkbWqtJSmJJvzMC8GCSqGSIb3
# DQEJBDEiBCDvFxQ6lYLr8vB+9czUl19rjCw1pWhhUXw/SqOmvIa/VDANBgkqhkiG
# 9w0BAQEFAASCAQB9ox2UrcUXQsBI4Uycnhl4AMpvhVXJME62tygFMppW1l7QftDy
# LvfPKRYm2YUioak/APxAS6geRKpeMkLvXuQS/Jlv0kY3BjxkeG0eVjvyjF4SvXbZ
# 3JCk9m7wLNE+xqOo0ICjYlIJJgRLudjWkC5Skpb1NpPS8DOaIYwRV+AWaSOUPd9P
# O5yVcnbl7OpK3EAEtwDrybCVBMPn2MGhAXybIHnth3+MFp1b6Blhz3WlReQyarjq
# 1f+zaFB79rg6JswXoOTJhwICBP3hO2Ua3dMAswbfl+QNXF+igKLJPYnaeSVhBbm6
# VCu2io27t4ixqvoD0RuPObNX/P3oVA38afiM
# SIG # End signature block
|
mati-nvidia/developer-office-hours/tools/packman/bootstrap/install_package.py | # Copyright 2019 NVIDIA CORPORATION
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
import zipfile
import tempfile
import sys
import shutil
__author__ = "hfannar"
logging.basicConfig(level=logging.WARNING, format="%(message)s")
logger = logging.getLogger("install_package")
class TemporaryDirectory:
def __init__(self):
self.path = None
def __enter__(self):
self.path = tempfile.mkdtemp()
return self.path
def __exit__(self, type, value, traceback):
# Remove temporary data created
shutil.rmtree(self.path)
def install_package(package_src_path, package_dst_path):
with zipfile.ZipFile(
package_src_path, allowZip64=True
) as zip_file, TemporaryDirectory() as temp_dir:
zip_file.extractall(temp_dir)
# Recursively copy (temp_dir will be automatically cleaned up on exit)
try:
# Recursive copy is needed because both package name and version folder could be missing in
# target directory:
shutil.copytree(temp_dir, package_dst_path)
except OSError as exc:
logger.warning(
"Directory %s already present, packaged installation aborted" % package_dst_path
)
else:
logger.info("Package successfully installed to %s" % package_dst_path)
install_package(sys.argv[1], sys.argv[2])
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_06/maticodes/doh_2023_01_06/extension.py | # SPDX-License-Identifier: Apache-2.0
import carb
import omni.ext
import omni.ui as ui
class MyWindow(ui.Window):
def __init__(self, title: str = None, **kwargs):
super().__init__(title, **kwargs)
self.frame.set_build_fn(self._build_window)
def _build_window(self):
with ui.ScrollingFrame():
with ui.VStack(height=0):
ui.Label("My Label")
def clicked():
carb.log_info("Button Clicked!")
ui.Button("Click Me", clicked_fn=clicked)
class MyExtension(omni.ext.IExt):
def on_startup(self, ext_id):
carb.log_info("[maticodes.doh_2023_01_06] Dev Office Hours Extension (2023-01-06) startup")
self._window = MyWindow("MyWindow", width=300, height=300)
def on_shutdown(self):
carb.log_info("[maticodes.doh_2023_01_06] Dev Office Hours Extension (2023-01-06) shutdown")
if self._window:
self._window.destroy()
self._window = None
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_06/maticodes/doh_2023_01_06/__init__.py | # SPDX-License-Identifier: Apache-2.0
from .extension import *
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_06/scripts/query_script_components.py | # SPDX-License-Identifier: Apache-2.0
from pxr import Sdf
import omni.usd
stage = omni.usd.get_context().get_stage()
prim = stage.GetPrimAtPath("/World/Cube")
attr = prim.GetAttribute("omni:scripting:scripts")
if attr.IsValid():
scripts = attr.Get()
if scripts:
for script in scripts:
print(script) |
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_06/scripts/add_script_component.py | # SPDX-License-Identifier: Apache-2.0
import omni.kit.commands
from pxr import Sdf
import omni.usd
omni.kit.commands.execute('ApplyScriptingAPICommand',
paths=[Sdf.Path('/World/Cube')])
omni.kit.commands.execute('RefreshScriptingPropertyWindowCommand')
stage = omni.usd.get_context().get_stage()
prim = stage.GetPrimAtPath("/World/Cube")
attr = prim.GetAttribute("omni:scripting:scripts")
scripts = attr.Get()
attr.Set([r"C:\Users\mcodesal\Downloads\new_script2.py"])
# attr.Set(["omniverse://localhost/Users/mcodesal/new_script2.py"])
omni.kit.commands.execute('ChangeProperty',
prop_path=Sdf.Path('/World/Cube.omni:scripting:scripts'),
value=Sdf.AssetPathArray(1, (Sdf.AssetPath('C:\\mcodesal\\Downloads\\new_script2.py'))),
prev=None)
attr = prim.GetAttribute("omni:scripting:scripts")
scripts = list(attr.Get())
scripts.append(r"C:\mcodesal\Downloads\new_script.py")
attr.Set(scripts)
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_06/scripts/interact_script_components.py | # SPDX-License-Identifier: Apache-2.0
import carb.events
import omni.kit.app
MY_CUSTOM_EVENT = carb.events.type_from_string("omni.my.extension.MY_CUSTOM_EVENT")
bus = omni.kit.app.get_app().get_message_bus_event_stream()
bus.push(MY_CUSTOM_EVENT, payload={"prim_path": "/World/Cube", "x": 1}) |
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_06/config/extension.toml | [package]
# Semantic Versionning is used: https://semver.org/
version = "1.0.0"
# The title and description fields are primarily for displaying extension info in UI
title = "2023-01-06: Dev Office Hours"
description="Sample code from the Dev Office Hour held on 2023-01-06"
# Path (relative to the root) or content of readme markdown file for UI.
readme = "docs/README.md"
# URL of the extension source repository.
repository = ""
# One of categories for UI.
category = "Example"
# Keywords for the extension
keywords = ["kit", "example"]
# Use omni.ui to build simple UI
[dependencies]
"omni.kit.uiapp" = {}
# Main python module this extension provides, it will be publicly available as "import maticodes.doh_2023_01_06".
[[python.module]]
name = "maticodes.doh_2023_01_06"
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_06/docs/README.md | # Developer Office Hour - 01/06/2023
This is the sample code from the Developer Office Hour held on 01/06/2023, Mati answered some developer questions
from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD.
## Questions
- 3:47 - How do you add an extension via the Extension Manager?
- 8:48 - How do you programmatically add a Python Script to a prim? (Python Scripting Component)
- 23:45 - How do you check what Python scripts a prim has? (Python Scripting Component)
- 27:00 - How can you have your extension interact with a Python Scripting Component?
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_21/maticodes/doh_2023_04_21/extension.py | # SPDX-License-Identifier: Apache-2.0
import carb
import omni.ext
import omni.ui as ui
class MyWindow(ui.Window):
def __init__(self, title: str = None, **kwargs):
super().__init__(title, **kwargs)
self.frame.set_build_fn(self._build_window)
def _build_window(self):
with ui.ScrollingFrame():
with ui.VStack(height=0):
ui.Label("My Label")
def clicked():
carb.log_info("Button Clicked!")
ui.Button("Click Me", clicked_fn=clicked)
class MyExtension(omni.ext.IExt):
def on_startup(self, ext_id):
carb.log_info("[maticodes.doh_2023_04_21] Dev Office Hours Extension (2023-04-21) startup")
self._window = MyWindow("MyWindow", width=300, height=300)
def on_shutdown(self):
carb.log_info("[maticodes.doh_2023_04_21] Dev Office Hours Extension (2023-04-21) shutdown")
if self._window:
self._window.destroy()
self._window = None
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_21/maticodes/doh_2023_04_21/__init__.py | # SPDX-License-Identifier: Apache-2.0
from .extension import *
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_21/scripts/pass_arg_to_callback.py | # SPDX-License-Identifier: Apache-2.0
from functools import partial
import omni.ui as ui
def do_something(p1, p2):
print(f"Hello {p1} {p2}")
window = ui.Window("My Window", width=300, height=300)
with window.frame:
ui.Button("Click Me", clicked_fn=partial(do_something, "a", "b")) |
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_21/scripts/create_mdl_mtl.py | # SPDX-License-Identifier: Apache-2.0
import omni.kit.commands
omni.kit.commands.execute('CreateAndBindMdlMaterialFromLibrary',
mdl_name='OmniPBR.mdl',
mtl_name='OmniPBR',
mtl_created_list=None) |
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_21/scripts/lock_prim.py | # SPDX-License-Identifier: Apache-2.0
import omni.kit.commands
from pxr import Sdf
omni.kit.commands.execute('LockSpecs',
spec_paths=['/Desk'],
hierarchy=False) |
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_21/config/extension.toml | [package]
# Semantic Versionning is used: https://semver.org/
version = "1.0.0"
# The title and description fields are primarily for displaying extension info in UI
title = "2023-04-21: Dev Office Hours"
description="Sample code from the Dev Office Hour held on 2023-04-21"
# Path (relative to the root) or content of readme markdown file for UI.
readme = "docs/README.md"
# URL of the extension source repository.
repository = ""
# One of categories for UI.
category = "Example"
# Keywords for the extension
keywords = ["kit", "example"]
# Use omni.ui to build simple UI
[dependencies]
"omni.kit.uiapp" = {}
# Main python module this extension provides, it will be publicly available as "import maticodes.doh_2023_04_21".
[[python.module]]
name = "maticodes.doh_2023_04_21"
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_21/docs/README.md | # Developer Office Hour - 04/21/2023
This is the sample code from the Developer Office Hour held on 04/21/2023, Mati answered some developer questions
from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD.
## Questions
- 2:02 - How do I change the label of an Action Graph UI button?
- 17:29 - How do I style and Action Graph UI Button?
- 30:36 - How do I pass extra parameters to a button's clicked_fn callback?
- 40:00 - How do I programmatically Lock Selected for a prim?
- 44:08 - How do I create an MDL material on a stage?
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_14/maticodes/doh_2023_04_14/extension.py | # SPDX-License-Identifier: Apache-2.0
import carb
import omni.ext
import omni.ui as ui
class MyWindow(ui.Window):
def __init__(self, title: str = None, **kwargs):
super().__init__(title, **kwargs)
self.frame.set_build_fn(self._build_window)
def _build_window(self):
with ui.ScrollingFrame():
with ui.VStack(height=0):
ui.Label("My Label")
def clicked():
carb.log_info("Button Clicked!")
ui.Button("Click Me", clicked_fn=clicked)
class MyExtension(omni.ext.IExt):
def on_startup(self, ext_id):
carb.log_info("[maticodes.doh_2023_04_14] Dev Office Hours Extension (2023-04-14) startup")
self._window = MyWindow("MyWindow", width=300, height=300)
def on_shutdown(self):
carb.log_info("[maticodes.doh_2023_04_14] Dev Office Hours Extension (2023-04-14) shutdown")
if self._window:
self._window.destroy()
self._window = None
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_14/maticodes/doh_2023_04_14/__init__.py | # SPDX-License-Identifier: Apache-2.0
from .extension import *
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_14/scripts/toggle_fullscreen.py | # SPDX-License-Identifier: Apache-2.0
import omni.kit.actions.core
action_registry = omni.kit.actions.core.get_action_registry()
action = action_registry.get_action("omni.kit.ui.editor_menu_bridge", "action_editor_menu_bridge_window_fullscreen_mode")
action.execute() |
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_14/scripts/move_prim_forward.py | # SPDX-License-Identifier: Apache-2.0
from pxr import Gf, UsdGeom, Usd
import omni.usd
stage = omni.usd.get_context().get_stage()
prim = stage.GetPrimAtPath("/World/Camera")
xform = UsdGeom.Xformable(prim)
local_transformation: Gf.Matrix4d = xform.GetLocalTransformation()
# Apply the local matrix to the start and end points of the camera's default forward vector (-Z)
a: Gf.Vec4d = Gf.Vec4d(0,0,0,1) * local_transformation
b: Gf.Vec4d = Gf.Vec4d(0,0,-1,1) * local_transformation
# Get the vector between those two points to get the camera's current forward vector
cam_fwd_vec = b-a
# Convert to Vec3 and then normalize to get unit vector
cam_fwd_unit_vec = Gf.Vec3d(cam_fwd_vec[:3]).GetNormalized()
# Multiply the forward direction vector with how far forward you want to move
forward_step = cam_fwd_unit_vec * 100
# Create a new matrix with the translation that you want to perform
offset_mat = Gf.Matrix4d()
offset_mat.SetTranslate(forward_step)
# Apply the translation to the current local transform
new_transform = local_transformation * offset_mat
# Extract the new translation
translate: Gf.Vec3d = new_transform.ExtractTranslation()
# Update the attribute
prim.GetAttribute("xformOp:translate").Set(translate) |
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_14/scripts/execute_action.py | # SPDX-License-Identifier: Apache-2.0
import omni.kit.actions.core
action_registry = omni.kit.actions.core.get_action_registry()
action = action_registry.get_action("ext_id", "action_id")
action.execute() |
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_14/config/extension.toml | [package]
# Semantic Versionning is used: https://semver.org/
version = "1.0.0"
# The title and description fields are primarily for displaying extension info in UI
title = "2023-04-14: Dev Office Hours"
description="Sample code from the Dev Office Hour held on 2023-04-14"
# Path (relative to the root) or content of readme markdown file for UI.
readme = "docs/README.md"
# URL of the extension source repository.
repository = ""
# One of categories for UI.
category = "Example"
# Keywords for the extension
keywords = ["kit", "example"]
# Use omni.ui to build simple UI
[dependencies]
"omni.kit.uiapp" = {}
# Main python module this extension provides, it will be publicly available as "import maticodes.doh_2023_04_14".
[[python.module]]
name = "maticodes.doh_2023_04_14"
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_14/docs/README.md | # Developer Office Hour - 04/14/2023
This is the sample code from the Developer Office Hour held on 04/14/2023, Mati answered some developer questions
from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD.
## Questions
- How do I find and execute a Kit Action?
- How do I programatically toggle fullscreen mode?
- How do I move a prim in the forward direction? |
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_13/graphs/swap_materials.usda | #usda 1.0
(
customLayerData = {
dictionary cameraSettings = {
dictionary Front = {
double3 position = (0, 0, 50000)
double radius = 500
}
dictionary Perspective = {
double3 position = (500, 500, 500)
double3 target = (-0.00000397803842133726, 0.000007956076785831101, -0.000003978038307650422)
}
dictionary Right = {
double3 position = (-50000, 0, 0)
double radius = 500
}
dictionary Top = {
double3 position = (0, 50000, 0)
double radius = 500
}
string boundCamera = "/OmniverseKit_Persp"
}
dictionary omni_layer = {
dictionary muteness = {
}
}
dictionary renderSettings = {
float3 "rtx:debugView:pixelDebug:textColor" = (0, 1e18, 0)
float3 "rtx:dynamicDiffuseGI:probeCounts" = (6, 6, 6)
float3 "rtx:dynamicDiffuseGI:probeGridOrigin" = (-210, -250, -10)
float3 "rtx:dynamicDiffuseGI:volumeSize" = (600, 440, 300)
int "rtx:externalFrameCounter" = 373484
float3 "rtx:fog:fogColor" = (0.75, 0.75, 0.75)
float3 "rtx:lightspeed:material:overrideAlbedo" = (0.5, 0.5, 0.5)
float3 "rtx:lightspeed:material:overrideEmissiveColor" = (0.5, 0.5, 0.5)
float3 "rtx:post:backgroundZeroAlpha:backgroundDefaultColor" = (0, 0, 0)
float3 "rtx:post:colorcorr:contrast" = (1, 1, 1)
float3 "rtx:post:colorcorr:gain" = (1, 1, 1)
float3 "rtx:post:colorcorr:gamma" = (1, 1, 1)
float3 "rtx:post:colorcorr:offset" = (0, 0, 0)
float3 "rtx:post:colorcorr:saturation" = (1, 1, 1)
float3 "rtx:post:colorgrad:blackpoint" = (0, 0, 0)
float3 "rtx:post:colorgrad:contrast" = (1, 1, 1)
float3 "rtx:post:colorgrad:gain" = (1, 1, 1)
float3 "rtx:post:colorgrad:gamma" = (1, 1, 1)
float3 "rtx:post:colorgrad:lift" = (0, 0, 0)
float3 "rtx:post:colorgrad:multiply" = (1, 1, 1)
float3 "rtx:post:colorgrad:offset" = (0, 0, 0)
float3 "rtx:post:colorgrad:whitepoint" = (1, 1, 1)
float3 "rtx:post:lensDistortion:lensFocalLengthArray" = (10, 30, 50)
float3 "rtx:post:lensFlares:anisoFlareFalloffX" = (450, 475, 500)
float3 "rtx:post:lensFlares:anisoFlareFalloffY" = (10, 10, 10)
float3 "rtx:post:lensFlares:cutoffPoint" = (2, 2, 2)
float3 "rtx:post:lensFlares:haloFlareFalloff" = (10, 10, 10)
float3 "rtx:post:lensFlares:haloFlareRadius" = (75, 75, 75)
float3 "rtx:post:lensFlares:isotropicFlareFalloff" = (50, 50, 50)
float3 "rtx:post:tonemap:whitepoint" = (1, 1, 1)
float3 "rtx:raytracing:inscattering:singleScatteringAlbedo" = (0.9, 0.9, 0.9)
float3 "rtx:raytracing:inscattering:transmittanceColor" = (0.5, 0.5, 0.5)
float3 "rtx:sceneDb:ambientLightColor" = (0.1, 0.1, 0.1)
}
}
defaultPrim = "World"
endTimeCode = 100
metersPerUnit = 0.01
startTimeCode = 0
timeCodesPerSecond = 24
upAxis = "Y"
)
def Xform "World"
{
def Mesh "Cube"
{
float3[] extent = [(-50, -50, -50), (50, 50, 50)]
int[] faceVertexCounts = [4, 4, 4, 4, 4, 4]
int[] faceVertexIndices = [0, 1, 3, 2, 0, 4, 5, 1, 1, 5, 6, 3, 2, 3, 6, 7, 0, 2, 7, 4, 4, 7, 6, 5]
rel material:binding = </World/Looks/Ash_Planks> (
bindMaterialAs = "weakerThanDescendants"
)
normal3f[] normals = [(0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, 0, -1), (0, 0, -1), (0, 0, -1), (0, 0, -1), (1, 0, 0), (1, 0, 0), (1, 0, 0), (1, 0, 0), (0, 0, 1), (0, 0, 1), (0, 0, 1), (0, 0, 1), (-1, 0, 0), (-1, 0, 0), (-1, 0, 0), (-1, 0, 0), (0, 1, 0), (0, 1, 0), (0, 1, 0), (0, 1, 0)] (
interpolation = "faceVarying"
)
point3f[] points = [(-50, -50, -50), (50, -50, -50), (-50, -50, 50), (50, -50, 50), (-50, 50, -50), (50, 50, -50), (50, 50, 50), (-50, 50, 50)]
bool primvars:doNotCastShadows = 0
float2[] primvars:st = [(1, 0), (0, 0), (0, 1), (1, 1), (1, 0), (1, 1), (0, 1), (0, 0), (1, 0), (0, 0), (0, 1), (1, 1), (1, 0), (0, 0), (0, 1), (1, 1), (1, 0), (1, 1), (0, 1), (0, 0), (1, 0), (1, 1), (0, 1), (0, 0)] (
interpolation = "faceVarying"
)
uniform token subdivisionScheme = "none"
double3 xformOp:rotateXYZ = (0, 0, 0)
double3 xformOp:scale = (1, 1, 1)
double3 xformOp:translate = (0, 0, 0)
uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"]
}
def Scope "Looks"
{
def Material "Adobe_Octagon_Dots"
{
token outputs:mdl:displacement.connect = </World/Looks/Adobe_Octagon_Dots/Shader.outputs:out>
token outputs:mdl:surface.connect = </World/Looks/Adobe_Octagon_Dots/Shader.outputs:out>
token outputs:mdl:volume.connect = </World/Looks/Adobe_Octagon_Dots/Shader.outputs:out>
def Shader "Shader"
{
reorder properties = ["inputs:diffuse_color_constant", "inputs:diffuse_texture", "inputs:albedo_desaturation", "inputs:albedo_add", "inputs:albedo_brightness", "inputs:diffuse_tint", "inputs:reflection_roughness_constant", "inputs:reflection_roughness_texture_influence", "inputs:reflectionroughness_texture", "inputs:metallic_constant", "inputs:metallic_texture_influence", "inputs:metallic_texture", "inputs:specular_level", "inputs:enable_ORM_texture", "inputs:ORM_texture", "inputs:ao_to_diffuse", "inputs:ao_texture", "inputs:enable_emission", "inputs:emissive_color", "inputs:emissive_color_texture", "inputs:emissive_mask_texture", "inputs:emissive_intensity", "inputs:enable_opacity", "inputs:opacity_texture", "inputs:opacity_constant", "inputs:enable_opacity_texture", "inputs:opacity_mode", "inputs:opacity_threshold", "inputs:bump_factor", "inputs:normalmap_texture", "inputs:detail_bump_factor", "inputs:detail_normalmap_texture", "inputs:flip_tangent_u", "inputs:flip_tangent_v", "inputs:project_uvw", "inputs:world_or_object", "inputs:uv_space_index", "inputs:texture_translate", "inputs:texture_rotate", "inputs:texture_scale", "inputs:detail_texture_translate", "inputs:detail_texture_rotate", "inputs:detail_texture_scale"]
uniform token info:implementationSource = "sourceAsset"
uniform asset info:mdl:sourceAsset = @http://omniverse-content-production.s3-us-west-2.amazonaws.com/Materials/Base/Stone/Adobe_Octagon_Dots.mdl@
uniform token info:mdl:sourceAsset:subIdentifier = "Adobe_Octagon_Dots"
token outputs:out (
renderType = "material"
)
}
}
def Material "Ash_Planks"
{
token outputs:mdl:displacement.connect = </World/Looks/Ash_Planks/Shader.outputs:out>
token outputs:mdl:surface.connect = </World/Looks/Ash_Planks/Shader.outputs:out>
token outputs:mdl:volume.connect = </World/Looks/Ash_Planks/Shader.outputs:out>
def Shader "Shader"
{
reorder properties = ["inputs:diffuse_color_constant", "inputs:diffuse_texture", "inputs:albedo_desaturation", "inputs:albedo_add", "inputs:albedo_brightness", "inputs:diffuse_tint", "inputs:reflection_roughness_constant", "inputs:reflection_roughness_texture_influence", "inputs:reflectionroughness_texture", "inputs:metallic_constant", "inputs:metallic_texture_influence", "inputs:metallic_texture", "inputs:specular_level", "inputs:enable_ORM_texture", "inputs:ORM_texture", "inputs:ao_to_diffuse", "inputs:ao_texture", "inputs:enable_emission", "inputs:emissive_color", "inputs:emissive_color_texture", "inputs:emissive_mask_texture", "inputs:emissive_intensity", "inputs:enable_opacity", "inputs:opacity_texture", "inputs:opacity_constant", "inputs:enable_opacity_texture", "inputs:opacity_mode", "inputs:opacity_threshold", "inputs:bump_factor", "inputs:normalmap_texture", "inputs:detail_bump_factor", "inputs:detail_normalmap_texture", "inputs:flip_tangent_u", "inputs:flip_tangent_v", "inputs:project_uvw", "inputs:world_or_object", "inputs:uv_space_index", "inputs:texture_translate", "inputs:texture_rotate", "inputs:texture_scale", "inputs:detail_texture_translate", "inputs:detail_texture_rotate", "inputs:detail_texture_scale"]
uniform token info:implementationSource = "sourceAsset"
uniform asset info:mdl:sourceAsset = @http://omniverse-content-production.s3-us-west-2.amazonaws.com/Materials/Base/Wood/Ash_Planks.mdl@
uniform token info:mdl:sourceAsset:subIdentifier = "Ash_Planks"
token outputs:out (
renderType = "material"
)
}
}
def Material "Brick_Pavers"
{
token outputs:mdl:displacement.connect = </World/Looks/Brick_Pavers/Shader.outputs:out>
token outputs:mdl:surface.connect = </World/Looks/Brick_Pavers/Shader.outputs:out>
token outputs:mdl:volume.connect = </World/Looks/Brick_Pavers/Shader.outputs:out>
def Shader "Shader"
{
reorder properties = ["inputs:diffuse_color_constant", "inputs:diffuse_texture", "inputs:albedo_desaturation", "inputs:albedo_add", "inputs:albedo_brightness", "inputs:diffuse_tint", "inputs:reflection_roughness_constant", "inputs:reflection_roughness_texture_influence", "inputs:reflectionroughness_texture", "inputs:metallic_constant", "inputs:metallic_texture_influence", "inputs:metallic_texture", "inputs:specular_level", "inputs:enable_ORM_texture", "inputs:ORM_texture", "inputs:ao_to_diffuse", "inputs:ao_texture", "inputs:enable_emission", "inputs:emissive_color", "inputs:emissive_color_texture", "inputs:emissive_mask_texture", "inputs:emissive_intensity", "inputs:enable_opacity", "inputs:opacity_texture", "inputs:opacity_constant", "inputs:enable_opacity_texture", "inputs:opacity_mode", "inputs:opacity_threshold", "inputs:bump_factor", "inputs:normalmap_texture", "inputs:detail_bump_factor", "inputs:detail_normalmap_texture", "inputs:flip_tangent_u", "inputs:flip_tangent_v", "inputs:project_uvw", "inputs:world_or_object", "inputs:uv_space_index", "inputs:texture_translate", "inputs:texture_rotate", "inputs:texture_scale", "inputs:detail_texture_translate", "inputs:detail_texture_rotate", "inputs:detail_texture_scale"]
uniform token info:implementationSource = "sourceAsset"
uniform asset info:mdl:sourceAsset = @http://omniverse-content-production.s3-us-west-2.amazonaws.com/Materials/Base/Masonry/Brick_Pavers.mdl@
uniform token info:mdl:sourceAsset:subIdentifier = "Brick_Pavers"
token outputs:out (
renderType = "material"
)
}
}
}
def OmniGraph "ActionGraph_01"
{
token evaluationMode = "Automatic"
token evaluator:type = "execution"
token fabricCacheBacking = "Shared"
int2 fileFormatVersion = (1, 5)
custom int graph:variable:index = -1 (
customData = {
token scope = "private"
}
displayName = "index"
)
token pipelineStage = "pipelineStageSimulation"
def OmniGraphNode "write_prim_material" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
custom uint inputs:execIn
prepend uint inputs:execIn.connect = </World/ActionGraph_01/on_keyboard_input.outputs:released>
custom string inputs:materialPath = ""
prepend string inputs:materialPath.connect = </World/ActionGraph_01/to_string.outputs:converted>
custom string inputs:primPath = ""
prepend string inputs:primPath.connect = </World/ActionGraph_01/constant_path.inputs:value>
token node:type = "omni.graph.nodes.WritePrimMaterial"
int node:typeVersion = 1
custom uint outputs:execOut (
customData = {
bool isExecution = 1
}
)
uniform token ui:nodegraph:node:expansionState = "open"
uniform float2 ui:nodegraph:node:pos = (1085.4962, 181.4497)
}
def OmniGraphNode "find_prims" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
custom token inputs:namePrefix
custom bool inputs:recursive = 0
custom string inputs:requiredAttributes = ""
custom token inputs:requiredRelationship
custom string inputs:requiredRelationshipTarget = ""
custom token inputs:rootPrimPath = "/World/Looks"
custom token inputs:type
token node:type = "omni.graph.nodes.FindPrims"
int node:typeVersion = 1
custom token[] outputs:primPaths = []
uniform token ui:nodegraph:node:expansionState = "open"
uniform float2 ui:nodegraph:node:pos = (-412.52438, 451.18246)
}
def OmniGraphNode "on_keyboard_input" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
custom bool inputs:altIn = 0
custom bool inputs:ctrlIn = 0
custom token inputs:keyIn = "A" (
allowedTokens = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "Apostrophe", "Backslash", "Backspace", "CapsLock", "Comma", "Del", "Down", "End", "Enter", "Equal", "Escape", "F1", "F10", "F11", "F12", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "GraveAccent", "Home", "Insert", "Key0", "Key1", "Key2", "Key3", "Key4", "Key5", "Key6", "Key7", "Key8", "Key9", "Left", "LeftAlt", "LeftBracket", "LeftControl", "LeftShift", "LeftSuper", "Menu", "Minus", "NumLock", "Numpad0", "Numpad1", "Numpad2", "Numpad3", "Numpad4", "Numpad5", "Numpad6", "Numpad7", "Numpad8", "Numpad9", "NumpadAdd", "NumpadDel", "NumpadDivide", "NumpadEnter", "NumpadEqual", "NumpadMultiply", "NumpadSubtract", "PageDown", "PageUp", "Pause", "Period", "PrintScreen", "Right", "RightAlt", "RightBracket", "RightControl", "RightShift", "RightSuper", "ScrollLock", "Semicolon", "Slash", "Space", "Tab", "Up"]
)
custom bool inputs:onlyPlayback = 1
custom bool inputs:shiftIn = 0
token node:type = "omni.graph.action.OnKeyboardInput"
int node:typeVersion = 3
custom bool outputs:isPressed
custom token outputs:keyOut
custom uint outputs:pressed (
customData = {
bool isExecution = 1
}
)
custom uint outputs:released (
customData = {
bool isExecution = 1
}
)
uniform token ui:nodegraph:node:expansionState = "open"
uniform float2 ui:nodegraph:node:pos = (59.739395, -163.04137)
}
def OmniGraphNode "array_index" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
custom token inputs:array
prepend token inputs:array.connect = </World/ActionGraph_01/find_prims.outputs:primPaths>
custom int inputs:index = 0
delete int inputs:index.connect = </World/ActionGraph_01/increment.outputs:result>
prepend int inputs:index.connect = </World/ActionGraph_01/modulo.outputs:result>
token node:type = "omni.graph.nodes.ArrayIndex"
int node:typeVersion = 1
custom token outputs:value
uniform token ui:nodegraph:node:expansionState = "open"
uniform float2 ui:nodegraph:node:pos = (334.78186, 436.3439)
}
def OmniGraphNode "to_string" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
custom token inputs:value
delete token inputs:value.connect = </World/ActionGraph_01/find_prims.outputs:primPaths>
prepend token inputs:value.connect = </World/ActionGraph_01/array_index.outputs:value>
token node:type = "omni.graph.nodes.ToString"
int node:typeVersion = 1
custom string outputs:converted
uniform token ui:nodegraph:node:expansionState = "open"
uniform float2 ui:nodegraph:node:pos = (587.9523, 455.01645)
}
def OmniGraphNode "constant_path" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
custom string inputs:value = "/World/Cube"
token node:type = "omni.graph.nodes.ConstantPath"
int node:typeVersion = 1
uniform token ui:nodegraph:node:expansionState = "open"
uniform float2 ui:nodegraph:node:pos = (891.76935, 369.4709)
}
def OmniGraphNode "read_variable" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
custom rel inputs:graph = </World/ActionGraph_01>
custom token inputs:targetPath
custom token inputs:variableName = "index"
token node:type = "omni.graph.core.ReadVariable"
int node:typeVersion = 1
custom token outputs:value
uniform token ui:nodegraph:node:expansionState = "open"
uniform float2 ui:nodegraph:node:pos = (-473.37006, 205.30212)
}
def OmniGraphNode "write_variable" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
custom uint inputs:execIn
prepend uint inputs:execIn.connect = </World/ActionGraph_01/on_keyboard_input.outputs:released>
custom rel inputs:graph = </World/ActionGraph_01>
custom token inputs:targetPath
custom token inputs:value
delete token inputs:value.connect = [
</World/ActionGraph_01/increment.outputs:result>,
</World/ActionGraph_01/modulo.outputs:result>,
]
prepend token inputs:value.connect = </World/ActionGraph_01/modulo.outputs:result>
custom token inputs:variableName = "index"
token node:type = "omni.graph.core.WriteVariable"
int node:typeVersion = 1
custom uint outputs:execOut (
customData = {
bool isExecution = 1
}
)
custom token outputs:value
uniform token ui:nodegraph:node:expansionState = "open"
uniform float2 ui:nodegraph:node:pos = (622.69165, 201.77386)
}
def OmniGraphNode "increment" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
custom double inputs:increment = 1
custom token inputs:value
prepend token inputs:value.connect = </World/ActionGraph_01/read_variable.outputs:value>
token node:type = "omni.graph.nodes.Increment"
int node:typeVersion = 1
custom token outputs:result
uniform token ui:nodegraph:node:expansionState = "open"
uniform float2 ui:nodegraph:node:pos = (-268.92194, 176.62592)
}
def OmniGraphNode "modulo" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
custom token inputs:a
prepend token inputs:a.connect = </World/ActionGraph_01/increment.outputs:result>
custom token inputs:b
delete token inputs:b.connect = </World/ActionGraph_01/increment.outputs:result>
prepend token inputs:b.connect = </World/ActionGraph_01/array_get_size.outputs:size>
token node:type = "omni.graph.nodes.Modulo"
int node:typeVersion = 1
custom token outputs:result
uniform token ui:nodegraph:node:expansionState = "open"
uniform float2 ui:nodegraph:node:pos = (110.01475, 302.82666)
}
def OmniGraphNode "array_get_size" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
custom token inputs:array
prepend token inputs:array.connect = </World/ActionGraph_01/find_prims.outputs:primPaths>
token node:type = "omni.graph.nodes.ArrayGetSize"
int node:typeVersion = 1
custom int outputs:size
uniform token ui:nodegraph:node:expansionState = "open"
uniform float2 ui:nodegraph:node:pos = (-148.30875, 386.24356)
}
}
}
def Xform "Environment"
{
double3 xformOp:rotateXYZ = (0, 0, 0)
double3 xformOp:scale = (1, 1, 1)
double3 xformOp:translate = (0, 0, 0)
uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"]
def DistantLight "defaultLight" (
prepend apiSchemas = ["ShapingAPI"]
)
{
float angle = 1
float intensity = 3000
float shaping:cone:angle = 180
float shaping:cone:softness
float shaping:focus
color3f shaping:focusTint
asset shaping:ies:file
double3 xformOp:rotateXYZ = (315, 0, 0)
double3 xformOp:scale = (1, 1, 1)
double3 xformOp:translate = (0, 0, 0)
uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"]
}
}
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_13/maticodes/doh_2023_01_13/extension.py | # SPDX-License-Identifier: Apache-2.0
import carb
import omni.ext
import omni.ui as ui
class MyWindow(ui.Window):
def __init__(self, title: str = None, **kwargs):
super().__init__(title, **kwargs)
self.frame.set_build_fn(self._build_window)
def _build_window(self):
with ui.ScrollingFrame():
with ui.VStack(height=0):
ui.Label("My Label")
def clicked():
carb.log_info("Button Clicked!")
ui.Button("Click Me", clicked_fn=clicked)
class MyExtension(omni.ext.IExt):
def on_startup(self, ext_id):
carb.log_info("[maticodes.doh_2023_01_13] Dev Office Hours Extension (2023-01-13) startup")
self._window = MyWindow("MyWindow", width=300, height=300)
def on_shutdown(self):
carb.log_info("[maticodes.doh_2023_01_13] Dev Office Hours Extension (2023-01-13) shutdown")
if self._window:
self._window.destroy()
self._window = None
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_13/maticodes/doh_2023_01_13/__init__.py | # SPDX-License-Identifier: Apache-2.0
from .extension import *
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_13/scripts/add_script_component.py | # SPDX-License-Identifier: Apache-2.0
import omni.kit.commands
from pxr import Sdf
import omni.usd
# Create the Python Scripting Component property
omni.kit.commands.execute('ApplyScriptingAPICommand',
paths=[Sdf.Path('/World/Cube')])
omni.kit.commands.execute('RefreshScriptingPropertyWindowCommand')
# Add your script to the property
stage = omni.usd.get_context().get_stage()
prim = stage.GetPrimAtPath("/World/Cube")
attr = prim.GetAttribute("omni:scripting:scripts")
scripts = attr.Get()
# Property with no script paths returns None
if scripts is None:
scripts = []
else:
# Property with scripts paths returns VtArray.
# Convert to list to make it easier to work with.
scripts = list(scripts)
scripts.append(r"C:\Users\mcodesal\Downloads\new_script.py")
attr.Set(scripts)
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_13/config/extension.toml | [package]
# Semantic Versionning is used: https://semver.org/
version = "1.0.0"
# The title and description fields are primarily for displaying extension info in UI
title = "2023-01-13: Dev Office Hours"
description="Sample code from the Dev Office Hour held on 2023-01-13"
# Path (relative to the root) or content of readme markdown file for UI.
readme = "docs/README.md"
# URL of the extension source repository.
repository = ""
# One of categories for UI.
category = "Example"
# Keywords for the extension
keywords = ["kit", "example"]
# Use omni.ui to build simple UI
[dependencies]
"omni.kit.uiapp" = {}
# Main python module this extension provides, it will be publicly available as "import maticodes.doh_2023_01_13".
[[python.module]]
name = "maticodes.doh_2023_01_13"
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_13/docs/README.md | # Developer Office Hour - 01/13/2023
This is the sample code from the Developer Office Hour held on 01/13/2023, Mati answered some developer questions
from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD.
## Questions
- 3:46 - How do you programmatically add a Python Script to a prim? (Python Scripting Component)
- 8:02 - What are the criteria for valid prim and property names in USD?
- 11:14 - How can I swap a prim's material using Action Graph? |
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_06_23/maticodes/doh_2023_06_23/extension.py | # SPDX-License-Identifier: Apache-2.0
import carb
import omni.ext
import omni.ui as ui
class MyWindow(ui.Window):
def __init__(self, title: str = None, **kwargs):
super().__init__(title, **kwargs)
self.frame.set_build_fn(self._build_window)
def _build_window(self):
with ui.ScrollingFrame():
with ui.VStack(height=0):
ui.Label("My Label")
def clicked():
carb.log_info("Button Clicked!")
ui.Button("Click Me", clicked_fn=clicked)
class MyExtension(omni.ext.IExt):
def on_startup(self, ext_id):
carb.log_info("[maticodes.doh_2023_06_23] Dev Office Hours Extension (2023-06-23) startup")
self._window = MyWindow("MyWindow", width=300, height=300)
def on_shutdown(self):
carb.log_info("[maticodes.doh_2023_06_23] Dev Office Hours Extension (2023-06-23) shutdown")
if self._window:
self._window.destroy()
self._window = None
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_06_23/maticodes/doh_2023_06_23/__init__.py | # SPDX-License-Identifier: Apache-2.0
from .extension import *
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_06_23/scripts/select_prims.py | # SPDX-License-Identifier: Apache-2.0
import omni.usd
stage = omni.usd.get_context().get_stage()
ctx = omni.usd.get_context()
selection: omni.usd.Selection = ctx.get_selection()
selection.set_selected_prim_paths(["/World/Cube", "/World/Sphere"], False)
import omni.kit.commands
import omni.usd
ctx = omni.usd.get_context()
selection: omni.usd.Selection = ctx.get_selection()
omni.kit.commands.execute('SelectPrimsCommand',
old_selected_paths=selection.get_selected_prim_paths(),
new_selected_paths=["/World/Cone"],
expand_in_stage=True)
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_06_23/config/extension.toml | [package]
# Semantic Versionning is used: https://semver.org/
version = "1.0.0"
# The title and description fields are primarily for displaying extension info in UI
title = "2023-06-23: Dev Office Hours"
description="Sample code from the Dev Office Hour held on 2023-06-23"
# Path (relative to the root) or content of readme markdown file for UI.
readme = "docs/README.md"
# URL of the extension source repository.
repository = ""
# One of categories for UI.
category = "Example"
# Keywords for the extension
keywords = ["kit", "example"]
# Use omni.ui to build simple UI
[dependencies]
"omni.kit.uiapp" = {}
# Main python module this extension provides, it will be publicly available as "import maticodes.doh_2023_06_23".
[[python.module]]
name = "maticodes.doh_2023_06_23"
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_06_23/docs/README.md | # Developer Office Hour - 06/23/2023
This is the sample code from the Developer Office Hour held on 06/23/2023, Mati answered some developer questions
from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD.
## Questions
- 03:50 - How do programmatically select a prim?
- 16:00 - How do I reset the settings and preferences for a Kit app?
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_27/graphs/rotate_cube.usda | #usda 1.0
(
customLayerData = {
dictionary cameraSettings = {
dictionary Front = {
double3 position = (0, 0, 50000)
double radius = 500
}
dictionary Perspective = {
double3 position = (744.1314891741788, 370.53971652405943, 242.8346070647735)
double3 target = (-0.0000013449548532662448, 0.00002425788107984772, -0.00003064792676354955)
}
dictionary Right = {
double3 position = (-50000, 0, 0)
double radius = 500
}
dictionary Top = {
double3 position = (0, 50000, 0)
double radius = 500
}
string boundCamera = "/OmniverseKit_Persp"
}
dictionary omni_layer = {
dictionary muteness = {
}
}
dictionary renderSettings = {
float3 "rtx:debugView:pixelDebug:textColor" = (0, 1e18, 0)
float3 "rtx:dynamicDiffuseGI:probeCounts" = (6, 6, 6)
float3 "rtx:dynamicDiffuseGI:probeGridOrigin" = (-210, -250, -10)
float3 "rtx:dynamicDiffuseGI:volumeSize" = (600, 440, 300)
int "rtx:externalFrameCounter" = 232446
float3 "rtx:fog:fogColor" = (0.75, 0.75, 0.75)
float3 "rtx:lightspeed:material:overrideAlbedo" = (0.5, 0.5, 0.5)
float3 "rtx:lightspeed:material:overrideEmissiveColor" = (0.5, 0.5, 0.5)
float3 "rtx:post:backgroundZeroAlpha:backgroundDefaultColor" = (0, 0, 0)
float3 "rtx:post:colorcorr:contrast" = (1, 1, 1)
float3 "rtx:post:colorcorr:gain" = (1, 1, 1)
float3 "rtx:post:colorcorr:gamma" = (1, 1, 1)
float3 "rtx:post:colorcorr:offset" = (0, 0, 0)
float3 "rtx:post:colorcorr:saturation" = (1, 1, 1)
float3 "rtx:post:colorgrad:blackpoint" = (0, 0, 0)
float3 "rtx:post:colorgrad:contrast" = (1, 1, 1)
float3 "rtx:post:colorgrad:gain" = (1, 1, 1)
float3 "rtx:post:colorgrad:gamma" = (1, 1, 1)
float3 "rtx:post:colorgrad:lift" = (0, 0, 0)
float3 "rtx:post:colorgrad:multiply" = (1, 1, 1)
float3 "rtx:post:colorgrad:offset" = (0, 0, 0)
float3 "rtx:post:colorgrad:whitepoint" = (1, 1, 1)
float3 "rtx:post:lensDistortion:lensFocalLengthArray" = (10, 30, 50)
float3 "rtx:post:lensFlares:anisoFlareFalloffX" = (450, 475, 500)
float3 "rtx:post:lensFlares:anisoFlareFalloffY" = (10, 10, 10)
float3 "rtx:post:lensFlares:cutoffPoint" = (2, 2, 2)
float3 "rtx:post:lensFlares:haloFlareFalloff" = (10, 10, 10)
float3 "rtx:post:lensFlares:haloFlareRadius" = (75, 75, 75)
float3 "rtx:post:lensFlares:isotropicFlareFalloff" = (50, 50, 50)
float3 "rtx:post:tonemap:whitepoint" = (1, 1, 1)
float3 "rtx:raytracing:inscattering:singleScatteringAlbedo" = (0.9, 0.9, 0.9)
float3 "rtx:raytracing:inscattering:transmittanceColor" = (0.5, 0.5, 0.5)
float3 "rtx:sceneDb:ambientLightColor" = (0.1, 0.1, 0.1)
}
}
defaultPrim = "World"
endTimeCode = 100
metersPerUnit = 0.01
startTimeCode = 0
timeCodesPerSecond = 24
upAxis = "Y"
)
def Xform "World"
{
def OmniGraph "ActionGraph"
{
token evaluationMode = "Automatic"
token evaluator:type = "execution"
token fabricCacheBacking = "Shared"
int2 fileFormatVersion = (1, 5)
custom double graph:variable:Speed = 5 (
customData = {
token scope = "private"
}
displayName = "Speed"
)
token pipelineStage = "pipelineStageSimulation"
def OmniGraphNode "on_tick" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
custom uint inputs:framePeriod = 0
custom bool inputs:onlyPlayback = 1
token node:type = "omni.graph.action.OnTick"
int node:typeVersion = 1
custom double outputs:absoluteSimTime
custom double outputs:deltaSeconds
custom double outputs:frame
custom bool outputs:isPlaying
custom uint outputs:tick (
customData = {
bool isExecution = 1
}
)
custom double outputs:time
custom double outputs:timeSinceStart
uniform token ui:nodegraph:node:expansionState = "open"
uniform float2 ui:nodegraph:node:pos = (-62.488346, -44.434006)
}
def OmniGraphNode "break_3_vector" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
custom token inputs:tuple
prepend token inputs:tuple.connect = </World/ActionGraph/CubeReadAttrib.outputs:value>
token node:type = "omni.graph.nodes.BreakVector3"
int node:typeVersion = 1
custom token outputs:x
custom token outputs:y
custom token outputs:z
uniform token ui:nodegraph:node:expansionState = "open"
uniform float2 ui:nodegraph:node:pos = (289.55432, 238.81877)
}
def OmniGraphNode "add" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
custom token inputs:a
prepend token inputs:a.connect = </World/ActionGraph/break_3_vector.outputs:y>
custom token inputs:b
delete token inputs:b.connect = [
</World/ActionGraph/read_variable.outputs:value>,
</World/ActionGraph/constant_double.inputs:value>,
]
prepend token inputs:b.connect = </World/ActionGraph/read_variable.outputs:value>
token node:type = "omni.graph.nodes.Add"
int node:typeVersion = 1
custom token outputs:sum
uniform token ui:nodegraph:node:expansionState = "open"
uniform float2 ui:nodegraph:node:pos = (598.4194, 406.26178)
}
def OmniGraphNode "make_3_vector" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
custom token inputs:x
prepend token inputs:x.connect = </World/ActionGraph/break_3_vector.outputs:x>
custom token inputs:y
prepend token inputs:y.connect = </World/ActionGraph/add.outputs:sum>
custom token inputs:z
prepend token inputs:z.connect = </World/ActionGraph/break_3_vector.outputs:z>
token node:type = "omni.graph.nodes.MakeVector3"
int node:typeVersion = 1
custom token outputs:tuple
uniform token ui:nodegraph:node:expansionState = "open"
uniform float2 ui:nodegraph:node:pos = (899.36365, 221.84807)
}
def OmniGraphNode "read_variable" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
custom rel inputs:graph = </World/ActionGraph>
custom token inputs:targetPath
custom token inputs:variableName = "Speed"
token node:type = "omni.graph.core.ReadVariable"
int node:typeVersion = 1
custom token outputs:value
uniform token ui:nodegraph:node:expansionState = "open"
uniform float2 ui:nodegraph:node:pos = (272.58438, 403.99854)
}
def OmniGraphNode "CubeReadAttrib" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
custom bool inputs:forceUSDRead = 0
custom token inputs:name = "xformOp:rotateXYZ"
custom rel inputs:prim
prepend rel inputs:prim = </World/Cube>
custom token inputs:primPath
custom timecode inputs:usdTimecode = -1
custom bool inputs:usePath = 0
token node:type = "omni.graph.nodes.ReadPrimAttribute"
int node:typeVersion = 1
custom token outputs:value
uniform token ui:nodegraph:node:expansionState = "open"
uniform float2 ui:nodegraph:node:pos = (-63.432808, 221.84807)
}
def OmniGraphNode "CubeWriteAttrib" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
custom uint inputs:execIn
prepend uint inputs:execIn.connect = </World/ActionGraph/on_tick.outputs:tick>
custom token inputs:name = "xformOp:rotateXYZ"
custom rel inputs:prim
prepend rel inputs:prim = </World/Cube>
custom token inputs:primPath
custom bool inputs:usdWriteBack = 1
custom bool inputs:usePath = 0
custom token inputs:value
prepend token inputs:value.connect = </World/ActionGraph/make_3_vector.outputs:tuple>
token node:type = "omni.graph.nodes.WritePrimAttribute"
int node:typeVersion = 1
custom uint outputs:execOut (
customData = {
bool isExecution = 1
}
)
uniform token ui:nodegraph:node:expansionState = "open"
uniform float2 ui:nodegraph:node:pos = (1175.4186, 80.4267)
}
}
def Mesh "Cube"
{
float3[] extent = [(-50, -50, -50), (50, 50, 50)]
int[] faceVertexCounts = [4, 4, 4, 4, 4, 4]
int[] faceVertexIndices = [0, 1, 3, 2, 0, 4, 5, 1, 1, 5, 6, 3, 2, 3, 6, 7, 0, 2, 7, 4, 4, 7, 6, 5]
normal3f[] normals = [(0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, 0, -1), (0, 0, -1), (0, 0, -1), (0, 0, -1), (1, 0, 0), (1, 0, 0), (1, 0, 0), (1, 0, 0), (0, 0, 1), (0, 0, 1), (0, 0, 1), (0, 0, 1), (-1, 0, 0), (-1, 0, 0), (-1, 0, 0), (-1, 0, 0), (0, 1, 0), (0, 1, 0), (0, 1, 0), (0, 1, 0)] (
interpolation = "faceVarying"
)
point3f[] points = [(-50, -50, -50), (50, -50, -50), (-50, -50, 50), (50, -50, 50), (-50, 50, -50), (50, 50, -50), (50, 50, 50), (-50, 50, 50)]
float2[] primvars:st = [(1, 0), (0, 0), (0, 1), (1, 1), (1, 0), (1, 1), (0, 1), (0, 0), (1, 0), (0, 0), (0, 1), (1, 1), (1, 0), (0, 0), (0, 1), (1, 1), (1, 0), (1, 1), (0, 1), (0, 0), (1, 0), (1, 1), (0, 1), (0, 0)] (
interpolation = "faceVarying"
)
uniform token subdivisionScheme = "none"
double3 xformOp:rotateXYZ = (0, 3458, 0)
double3 xformOp:scale = (1, 1, 1)
double3 xformOp:translate = (0, 0, 0)
uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"]
}
}
def Xform "Environment"
{
double3 xformOp:rotateXYZ = (0, 0, 0)
double3 xformOp:scale = (1, 1, 1)
double3 xformOp:translate = (0, 0, 0)
uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"]
def DistantLight "defaultLight" (
prepend apiSchemas = ["ShapingAPI"]
)
{
float angle = 1
float intensity = 3000
float shaping:cone:angle = 180
float shaping:cone:softness
float shaping:focus
color3f shaping:focusTint
asset shaping:ies:file
double3 xformOp:rotateXYZ = (315, 0, 0)
double3 xformOp:scale = (1, 1, 1)
double3 xformOp:translate = (0, 0, 0)
uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"]
}
}
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_27/maticodes/doh_2023_01_27/extension.py | # SPDX-License-Identifier: Apache-2.0
import carb
import omni.ext
import omni.ui as ui
class MyWindow(ui.Window):
def __init__(self, title: str = None, **kwargs):
super().__init__(title, **kwargs)
self.frame.set_build_fn(self._build_window)
def _build_window(self):
with ui.ScrollingFrame():
with ui.VStack(height=0):
ui.Label("My Label")
def clicked():
carb.log_info("Button Clicked!")
ui.Button("Click Me", clicked_fn=clicked)
class MyExtension(omni.ext.IExt):
def on_startup(self, ext_id):
carb.log_info("[maticodes.doh_2023_01_27] Dev Office Hours Extension (2023-01-27) startup")
self._window = MyWindow("MyWindow", width=300, height=300)
def on_shutdown(self):
carb.log_info("[maticodes.doh_2023_01_27] Dev Office Hours Extension (2023-01-27) shutdown")
if self._window:
self._window.destroy()
self._window = None
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_27/maticodes/doh_2023_01_27/__init__.py | # SPDX-License-Identifier: Apache-2.0
from .extension import *
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_27/scripts/sub_child_changes.py | # SPDX-License-Identifier: Apache-2.0
# UsdWatcher
from pxr import Sdf, Tf, Usd
import omni.usd
stage = omni.usd.get_context().get_stage()
def changed_paths(notice, stage):
print("Change fired")
for p in notice.GetChangedInfoOnlyPaths():
if str(p).startswith("/World/Parent" + "/"):
print("Something happened to a descendent of /World/Parent")
print(p)
for p in notice.GetResyncedPaths():
if str(p).startswith("/World/Parent" + "/"):
print("A descendent of /World/Parent was added or removed")
print(p)
objects_changed = Tf.Notice.Register(Usd.Notice.ObjectsChanged, changed_paths, None)
objects_changed.Revoke()
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_27/config/extension.toml | [package]
# Semantic Versionning is used: https://semver.org/
version = "1.0.0"
# The title and description fields are primarily for displaying extension info in UI
title = "2023-01-27: Dev Office Hours"
description="Sample code from the Dev Office Hour held on 2023-01-27"
# Path (relative to the root) or content of readme markdown file for UI.
readme = "docs/README.md"
# URL of the extension source repository.
repository = ""
# One of categories for UI.
category = "Example"
# Keywords for the extension
keywords = ["kit", "example"]
# Use omni.ui to build simple UI
[dependencies]
"omni.kit.uiapp" = {}
# Main python module this extension provides, it will be publicly available as "import maticodes.doh_2023_01_27".
[[python.module]]
name = "maticodes.doh_2023_01_27"
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_27/docs/README.md | # Developer Office Hour - 01/27/2023
This is the sample code from the Developer Office Hour held on 01/27/2023, Mati answered some developer questions
from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD.
## Questions
- 3:14 - How do I listen for changes to the children of a certain prim?
- 15:00 - How do I rotate a prim using Action Graph?
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_07_22/maticodes/doh_2022_07_22/extension.py | # SPDX-License-Identifier: Apache-2.0
import omni.ext
import omni.ui as ui
from omni.kit.widget.searchable_combobox import build_searchable_combo_widget
class MyWindow(ui.Window):
def __init__(self, title: str = None, delegate=None, **kwargs):
super().__init__(title, **kwargs)
self.frame.set_build_fn(self._build_window)
def _build_window(self):
with ui.ScrollingFrame():
with ui.VStack(height=0):
ui.Label("My Label")
self.proj_scale_model = ui.SimpleFloatModel()
self.proj_scale_model_sub = (
self.proj_scale_model.subscribe_value_changed_fn(
self.slider_value_changed
)
)
ui.FloatSlider(model=self.proj_scale_model, min=0, max=100)
def do_rebuild():
self.frame.rebuild()
ui.Button("Rebuild", clicked_fn=do_rebuild)
def clicked():
# Example showing how to retreive the value from the model.
print(
f"Button Clicked! Slider Value: {self.proj_scale_model.as_float}"
)
self.proj_scale_model.set_value(1.0)
ui.Button("Set Slider", clicked_fn=clicked)
def on_combo_click_fn(model):
component = model.get_value_as_string()
print(f"{component} selected")
component_list = ["Synthetic Data", "USD", "Kit", "UX", "UX / UI"]
component_index = -1
self._component_combo = build_searchable_combo_widget(
component_list,
component_index,
on_combo_click_fn,
widget_height=18,
default_value="Kit",
)
def slider_value_changed(self, model):
# Example showing how to get the value when it changes.
print("Slider Value:", model.as_float)
def destroy(self) -> None:
del self.proj_scale_model_sub
return super().destroy()
class MyExtension(omni.ext.IExt):
# ext_id is current extension id. It can be used with extension manager to query additional information, like where
# this extension is located on filesystem.
def on_startup(self, ext_id):
print(
"[maticodes.doh_2022_07_22] Dev Office Hours Extension (2022-07-22) startup"
)
self._window = MyWindow("MyWindow", width=300, height=300)
def on_shutdown(self):
print(
"[maticodes.doh_2022_07_22] Dev Office Hours Extension (2022-07-22) shutdown"
)
if self._window:
self._window.destroy()
self._window = None
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_07_22/maticodes/doh_2022_07_22/__init__.py | # SPDX-License-Identifier: Apache-2.0
from .extension import *
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_07_22/scripts/cmds_more_params.py | # SPDX-License-Identifier: Apache-2.0
import omni.kit.commands
from pxr import Gf, Usd
omni.kit.commands.execute('SetAnimCurveKey',
paths=['/World/toy_drummer.xformOp:translate'],
value=Gf.Vec3d(0.0, 0.0, 18))
omni.kit.commands.execute('SetAnimCurveKey',
paths=['/World/toy_drummer.xformOp:translate'],
value=Gf.Vec3d(0.0, 0.0, 24),
time=Usd.TimeCode(72))
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_07_22/scripts/set_current_time.py | # SPDX-License-Identifier: Apache-2.0
# https://docs.omniverse.nvidia.com/py/kit/source/extensions/omni.timeline/docs/index.html
import omni.timeline
timeline = omni.timeline.get_timeline_interface()
# set in using seconds
timeline.set_current_time(1)
# set using frame number
fps = timeline.get_time_codes_per_seconds()
timeline.set_current_time(48 / fps)
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_07_22/scripts/reference_usdz.py | # SPDX-License-Identifier: Apache-2.0
import omni.kit.commands
from pxr import Sdf
import omni.usd
omni.kit.commands.execute('CreateReference',
path_to=Sdf.Path('/World/toy_drummer2'),
asset_path='C:/Users/mcodesal/Downloads/toy_drummer.usdz',
usd_context=omni.usd.get_context())
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_07_22/scripts/run_action_graph.py | # SPDX-License-Identifier: Apache-2.0
# https://docs.omniverse.nvidia.com/py/kit/source/extensions/omni.graph/docs/index.html
import omni.graph.core as og
keys = og.Controller.Keys
og.Controller.edit("/World/ActionGraph", { keys.SET_VALUES: ("/World/ActionGraph/on_impulse_event.state:enableImpulse", True) })
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_07_22/config/extension.toml | [package]
# Semantic Versionning is used: https://semver.org/
version = "1.0.0"
# The title and description fields are primarily for displaying extension info in UI
title = "2022-07-22: Dev Office Hours"
description="Sample code from the Dev Office Hour held on 2022-07-22"
# Path (relative to the root) or content of readme markdown file for UI.
readme = "docs/README.md"
# URL of the extension source repository.
repository = ""
# One of categories for UI.
category = "Example"
# Keywords for the extension
keywords = ["kit", "example"]
# Use omni.ui to build simple UI
[dependencies]
"omni.kit.uiapp" = {}
# Main python module this extension provides, it will be publicly available as "import maticodes.doh_2022_07_22".
[[python.module]]
name = "maticodes.doh_2022_07_22"
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_07_22/docs/README.md | # Developer Office Hour - 07/22/2022
This is the sample code from the Developer Office Hour held on 07/22/2022, Mati answered some developer questions
from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD.
## Questions
- How do I reference a USDZ file?
- How do I look up all of the parameters for a Kit Command?
- How do I set the current frame using Python?
- How do I execute an Action Graph using Python?
- How do I align radio buttons horizontally?
- How do I refresh a UI window?
- How do I customize the appearance of a slider?
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_10_14/maticodes/doh_2022_10_14/extension.py | # SPDX-License-Identifier: Apache-2.0
import carb
import omni.ext
import omni.ui as ui
class MyWindow(ui.Window):
def __init__(self, title: str = None, **kwargs):
super().__init__(title, **kwargs)
self.frame.set_build_fn(self._build_window)
def _build_window(self):
def hello():
print("Hello")
ui.Button("Click Me", clicked_fn=hello)
class MyExtension(omni.ext.IExt):
def on_startup(self, ext_id):
carb.log_info("[maticodes.doh_2022_10_14] Dev Office Hours Extension (2022-10-14) startup")
self._window = MyWindow("MyWindow", width=300, height=300)
def on_shutdown(self):
carb.log_info("[maticodes.doh_2022_10_14] Dev Office Hours Extension (2022-10-14) shutdown")
if self._window:
self._window.destroy()
self._window = None
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_10_14/maticodes/doh_2022_10_14/__init__.py | # SPDX-License-Identifier: Apache-2.0
from .extension import *
|
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_10_14/scripts/context_menu_inject.py | # SPDX-License-Identifier: Apache-2.0
import omni.kit.context_menu
def show_menu(objects):
print("show it?")
return True
def hello_world(objects):
print(f"Hello Objects: {objects}")
menu_item_config = {
"name": "Hello World!",
"glyph": "menu_search.svg",
"show_fn": [show_menu],
"onclick_fn": hello_world,
}
# You must keep a reference to the menu item. Set this variable to None to remove the item from the menu
hello_world_menu_item = omni.kit.context_menu.add_menu(menu_item_config, "MENU", "omni.kit.window.viewport")
hello_world_menu_item = None |
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_10_14/config/extension.toml | [package]
# Semantic Versionning is used: https://semver.org/
version = "1.0.0"
# The title and description fields are primarily for displaying extension info in UI
title = "2022-10-14: Dev Office Hours"
description="Sample code from the Dev Office Hour held on 2022-10-14"
# Path (relative to the root) or content of readme markdown file for UI.
readme = "docs/README.md"
# URL of the extension source repository.
repository = ""
# One of categories for UI.
category = "Example"
# Keywords for the extension
keywords = ["kit", "example"]
# Use omni.ui to build simple UI
[dependencies]
"omni.kit.uiapp" = {}
#"foo.bar" = {}
# Main python module this extension provides, it will be publicly available as "import maticodes.doh_2022_10_14".
[[python.module]]
name = "maticodes.doh_2022_10_14"
|