Skip to content

Commit

Permalink
Adding Hydra Generative Procedural Example of a simple Triangle
Browse files Browse the repository at this point in the history
Signed-off-by: Seb Schmidt <[email protected]>
  • Loading branch information
SebSchmidtWetaFx committed Aug 6, 2024
1 parent aad3a75 commit 37fc7c4
Show file tree
Hide file tree
Showing 10 changed files with 464 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Huge thanks to Pixar's USD team for providing a highly extensible platform!
- [usdTriImagingHd2](./src/usdTriImagingHd2): A *Hydra 2 only* prim adapter which images the **Triangle** prim type. [*]
- [usdTriFileFormat](./src/usdTriFileFormat): A file format plugin which authors a triangular mesh for a `.triangle` payload.
- [hdTri](./src/hdTri): A hydra renderer plugin which images a triangle (in the most direct sense).
- [hdGpTri](./src/hdGpTri): A generative procedural plugin which creates a triangle (in the most direct sense).
- [usdviewTri](./src/usdviewTri): An usdview plugin providing a menu command to define child Triangle prim(s) under selected paths.

[*] We deliberatly split the Hydra 1 & 2 Triangle Prim Adapters into two plugins/sources to outline the differences
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ endif()

add_subdirectory(usdTriFileFormat)
add_subdirectory(hdTri)
add_subdirectory(hdGpTri)

# Install top-level plugInfo for including per-library plugInfo(s).
install(
Expand Down
25 changes: 25 additions & 0 deletions src/hdGpTri/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
usd_plugin(hdGpTri

PUBLIC_HEADERS_INSTALL_PREFIX
${ORGANIZATION}

PYTHON_INSTALL_PREFIX
${ORGANIZATION}

LIBRARIES
js
plug
tf
sdf
vt
gf
hdGp
arch

CPPFILES
triGenerative.cpp
debugCodes.cpp

RESOURCE_FILES
plugInfo.json
)
18 changes: 18 additions & 0 deletions src/hdGpTri/debugCodes.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// Copyright © 2024 Weta Digital Limited
//
// SPDX-License-Identifier: Apache-2.0
//
#include "debugCodes.h"
#include "pxr/base/tf/debug.h"
#include <pxr/base/tf/registryManager.h>

PXR_NAMESPACE_OPEN_SCOPE

TF_REGISTRY_FUNCTION(TfDebug)
{
TF_DEBUG_ENVIRONMENT_SYMBOL(
USDTRI_GENERATIVE, "Debug symbol for the usdTri GenerativeProcedural.");
}

PXR_NAMESPACE_CLOSE_SCOPE
15 changes: 15 additions & 0 deletions src/hdGpTri/debugCodes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// Copyright © 2024 Weta Digital Limited
//
// SPDX-License-Identifier: Apache-2.0
//
#pragma once

#include <pxr/pxr.h>
#include <pxr/base/tf/debug.h>

PXR_NAMESPACE_OPEN_SCOPE

TF_DEBUG_CODES(USDTRI_GENERATIVE);

PXR_NAMESPACE_CLOSE_SCOPE
22 changes: 22 additions & 0 deletions src/hdGpTri/plugInfo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"Plugins": [
{
"Info": {
"Types": {
"TriProceduralPlugin": {
"bases": [
"HdGpGenerativeProceduralPlugin"
],
"displayName": "triangle",
"priority" : 0
}
}
},
"LibraryPath": "../../hdGpTri.so",
"Name": "hdGpTri",
"ResourcePath": "resources",
"Root": "..",
"Type": "library"
}
]
}
42 changes: 42 additions & 0 deletions src/hdGpTri/scenes/triangle.usda
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#usda 1.0


def Scope "World"
{
def GenerativeProcedural "myGenerativeProc" (
prepend apiSchemas = ["HydraGenerativeProceduralAPI"]
)
{
token primvars:hdGp:proceduralType = "triangle"
double primvars:sideLength = 1.0
}

def Scope "leaf_transformed"
{

def GenerativeProcedural "myGenerativeProcTransformed" (
prepend apiSchemas = ["HydraGenerativeProceduralAPI"]
)
{
token primvars:hdGp:proceduralType = "triangle"
double primvars:sideLength = 1.0

matrix4d xformOp:transform:transform1 = ( (1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (15, 15, 15, 1) )
uniform token[] xformOpOrder = ["xformOp:transform:transform1"]
}
}
def Xform "transformed"
{
matrix4d xformOp:transform:transform1 = ( (1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (15, 15, 15, 1) )
uniform token[] xformOpOrder = ["xformOp:transform:transform1"]

def GenerativeProcedural "myGenerativeProcTransformed" (
prepend apiSchemas = ["HydraGenerativeProceduralAPI"]
)
{
token primvars:hdGp:proceduralType = "triangle"
double primvars:sideLength = 1.0

}
}
}
23 changes: 23 additions & 0 deletions src/hdGpTri/scenes/triangleAnimated.usda
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#usda 1.0
(
startFrame = 1
endFrame = 10
)

def Scope "World"
{
def GenerativeProcedural "myGenerativeProcAnimated" (
prepend apiSchemas = ["HydraGenerativeProceduralAPI"]
)
{
token primvars:hdGp:proceduralType = "triangle"
double primvars:sideLength = 1.0
double primvars:sideLength.timeSamples = {
1: 1,
10: 10
}

matrix4d xformOp:transform:transform1 = ( (1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (30, 30, 30, 1) )
uniform token[] xformOpOrder = ["xformOp:transform:transform1"]
}
}
Loading

0 comments on commit 37fc7c4

Please sign in to comment.