sceneIndices
sphereAdapter
sphereLightAdapter
+ tetMeshAdapter
textureUtils
volumeAdapter
"isInternal": true,
"primTypeName": "Mesh"
},
+ "UsdImagingTetMeshAdapter": {
+ "bases": [
+ "UsdImagingGprimAdapter"
+ ],
+ "isInternal": true,
+ "primTypeName": "TetMesh"
+ },
"UsdImagingNurbsCurvesAdapter": {
"bases": [
"UsdImagingGprimAdapter"
--- /dev/null
+//
+// Copyright 2023 Pixar
+//
+// Licensed under the Apache License, Version 2.0 (the "Apache License")
+// with the following modification; you may not use this file except in
+// compliance with the Apache License and the following modification to it:
+// Section 6. Trademarks. is deleted and replaced with:
+//
+// 6. Trademarks. This License does not grant permission to use the trade
+// names, trademarks, service marks, or product names of the Licensor
+// and its affiliates, except as required to comply with Section 4(c) of
+// the License and to reproduce the content of the NOTICE file.
+//
+// You may obtain a copy of the Apache License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the Apache License with the above modification is
+// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the Apache License for the specific
+// language governing permissions and limitations under the Apache License.
+#include "pxr/usdImaging/usdImaging/tetMeshAdapter.h"
+
+#include "pxr/usdImaging/usdImaging/dataSourceMesh.h"
+#include "pxr/usdImaging/usdImaging/indexProxy.h"
+#include "pxr/usdImaging/usdImaging/tokens.h"
+
+#include "pxr/imaging/hd/mesh.h"
+#include "pxr/imaging/hd/tokens.h"
+
+#include "pxr/imaging/pxOsd/meshTopology.h"
+#include "pxr/imaging/pxOsd/tokens.h"
+
+#include "pxr/base/tf/type.h"
+
+PXR_NAMESPACE_OPEN_SCOPE
+
+
+TF_REGISTRY_FUNCTION(TfType)
+{
+ using Adapter = UsdImagingTetMeshAdapter;
+ TfType t = TfType::Define<Adapter, TfType::Bases<Adapter::BaseAdapter> >();
+ t.SetFactory< UsdImagingPrimAdapterFactory<Adapter> >();
+}
+
+UsdImagingTetMeshAdapter::~UsdImagingTetMeshAdapter() = default;
+
+SdfPath
+UsdImagingTetMeshAdapter::Populate(UsdPrim const& prim,
+ UsdImagingIndexProxy* index,
+ UsdImagingInstancerContext const* instancerContext)
+{
+ return _AddRprim(HdPrimTypeTokens->mesh,
+ prim, index, GetMaterialUsdPath(prim), instancerContext);
+}
+
+bool
+UsdImagingTetMeshAdapter::IsSupported(UsdImagingIndexProxy const* index) const
+{
+ return index->IsRprimTypeSupported(HdPrimTypeTokens->mesh);
+}
+
+void
+UsdImagingTetMeshAdapter::TrackVariability(UsdPrim const& prim,
+ SdfPath const& cachePath,
+ HdDirtyBits* timeVaryingBits,
+ UsdImagingInstancerContext const* instancerContext) const
+{
+ BaseAdapter::TrackVariability(
+ prim, cachePath, timeVaryingBits, instancerContext);
+
+ // Discover time-varying points.
+ _IsVarying(prim,
+ UsdGeomTokens->points,
+ HdChangeTracker::DirtyPoints,
+ UsdImagingTokens->usdVaryingPrimvar,
+ timeVaryingBits,
+ /*isInherited*/false);
+
+ _IsVarying(prim,
+ UsdGeomTokens->tetVertexIndices,
+ HdChangeTracker::DirtyTopology,
+ UsdImagingTokens->usdVaryingTopology,
+ timeVaryingBits,
+ /*isInherited*/false);
+}
+
+/*virtual*/
+VtValue
+UsdImagingTetMeshAdapter::GetTopology(UsdPrim const& prim,
+ SdfPath const& cachePath,
+ UsdTimeCode time) const
+{
+ TRACE_FUNCTION();
+ HF_MALLOC_TAG_FUNCTION();
+
+ // Compute the surfaceFaceIndices for the Tet Mesh
+ VtVec3iArray surfaceFaceIndices;
+ UsdGeomTetMesh::ComputeSurfaceFaces(
+ UsdGeomTetMesh(prim), &surfaceFaceIndices, time);
+
+ // Compute faceVertexIndices and faceVertexCounts for the HdMeshTopology
+ const size_t numCounts = surfaceFaceIndices.size();
+ VtIntArray faceVertexIndices;
+ VtIntArray faceVertexCounts(numCounts);
+ for (size_t i = 0; i < numCounts; ++i) {
+ faceVertexIndices.push_back(surfaceFaceIndices[i][0]);
+ faceVertexIndices.push_back(surfaceFaceIndices[i][1]);
+ faceVertexIndices.push_back(surfaceFaceIndices[i][2]);
+ faceVertexCounts[i] = 3;
+ }
+
+ // Create and return the HdMeshTopology
+ HdMeshTopology tetMeshTopology(
+ PxOsdOpenSubdivTokens->catmullClark,
+ _Get<TfToken>(prim, UsdGeomTokens->orientation, time),
+ faceVertexCounts,
+ faceVertexIndices);
+
+ return VtValue(tetMeshTopology);
+}
+
+
+PXR_NAMESPACE_CLOSE_SCOPE
\ No newline at end of file
--- /dev/null
+//
+// Copyright 2023 Pixar
+//
+// Licensed under the Apache License, Version 2.0 (the "Apache License")
+// with the following modification; you may not use this file except in
+// compliance with the Apache License and the following modification to it:
+// Section 6. Trademarks. is deleted and replaced with:
+//
+// 6. Trademarks. This License does not grant permission to use the trade
+// names, trademarks, service marks, or product names of the Licensor
+// and its affiliates, except as required to comply with Section 4(c) of
+// the License and to reproduce the content of the NOTICE file.
+//
+// You may obtain a copy of the Apache License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the Apache License with the above modification is
+// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the Apache License for the specific
+// language governing permissions and limitations under the Apache License.
+//
+#ifndef PXR_USD_IMAGING_USD_IMAGING_TET_MESH_ADAPTER_H
+#define PXR_USD_IMAGING_USD_IMAGING_TET_MESH_ADAPTER_H
+
+/// \file usdImaging/tetMeshAdapter.h
+
+#include "pxr/pxr.h"
+#include "pxr/usdImaging/usdImaging/api.h"
+#include "pxr/usdImaging/usdImaging/primAdapter.h"
+#include "pxr/usdImaging/usdImaging/gprimAdapter.h"
+
+PXR_NAMESPACE_OPEN_SCOPE
+
+
+/// \class UsdImagingTetMeshAdapter
+///
+/// Delegate support for UsdGeomTetMesh.
+///
+class UsdImagingTetMeshAdapter : public UsdImagingGprimAdapter
+{
+public:
+ using BaseAdapter = UsdImagingGprimAdapter;
+
+ UsdImagingTetMeshAdapter()
+ : UsdImagingGprimAdapter()
+ {}
+
+ USDIMAGING_API
+ ~UsdImagingTetMeshAdapter() override;
+
+ // ---------------------------------------------------------------------- //
+ /// \name Initialization
+ // ---------------------------------------------------------------------- //
+
+ USDIMAGING_API
+ SdfPath Populate(
+ UsdPrim const& prim,
+ UsdImagingIndexProxy* index,
+ UsdImagingInstancerContext const* instancerContext = nullptr) override;
+
+ USDIMAGING_API
+ bool IsSupported(UsdImagingIndexProxy const* index) const override;
+
+ // ---------------------------------------------------------------------- //
+ /// \name Parallel Setup and Resolve
+ // ---------------------------------------------------------------------- //
+
+ /// Thread Safe.
+ USDIMAGING_API
+ void TrackVariability(UsdPrim const& prim,
+ SdfPath const& cachePath,
+ HdDirtyBits* timeVaryingBits,
+ UsdImagingInstancerContext const*
+ instancerContext = nullptr) const;
+
+ // ---------------------------------------------------------------------- //
+ /// \name Data access
+ // ---------------------------------------------------------------------- //
+
+ USDIMAGING_API
+ VtValue GetTopology(UsdPrim const& prim,
+ SdfPath const& cachePath,
+ UsdTimeCode time) const override;
+
+};
+
+PXR_NAMESPACE_CLOSE_SCOPE
+
+#endif // PXR_USD_IMAGING_USD_IMAGING_TET_MESH_ADAPTER_H
\ No newline at end of file
DEST testUsdImagingGLEmptyMesh
)
+pxr_install_test_dir(
+ SRC testenv/testUsdImagingGLTetMesh
+ DEST testUsdImagingGLTetMesh
+)
+
pxr_install_test_dir(
SRC testenv/testUsdImagingGLPrimitiveDrawing
DEST testUsdImagingGLPrimitiveDrawing
TESTENV testUsdImagingGLEmptyMesh
)
+pxr_register_test(testUsdImagingGLTetMesh
+ COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdImagingGLBasicDrawing -lighting -offscreen -times 0 10 -stage tetMesh.usda -camera /Camera -write testUsdImagingGLTetMesh.png"
+ IMAGE_DIFF_COMPARE
+ testUsdImagingGLTetMesh_000.png
+ testUsdImagingGLTetMesh_010.png
+ FAIL 1
+ FAIL_PERCENT 1
+ PERCEPTUAL
+ EXPECTED_RETURN_CODE 0
+ TESTENV testUsdImagingGLTetMesh
+)
+
pxr_register_test(testUsdImagingGLPrimitiveDrawing
COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdImagingGLBasicDrawing -offscreen -frameAll -stage primitives.usda -write testUsdImagingGLPrimitiveDrawing.png"
IMAGE_DIFF_COMPARE
--- /dev/null
+#usda 1.0
+(
+ upAxis = "Y"
+ endTimeCode = 15
+ startTimeCode = 0
+)
+
+def TetMesh "tetMesh1"
+{
+ color3f[] primvars:displayColor = [(0, 1, 0)]
+ point3f[] points.timeSamples = {
+ 0: [(0, 0, 0), (2, 0, 0), (0, -2, 0), (0, 0, 2), (0, 0, -2)],
+ 10: [(0, 0, 3), (2, 0, 3), (0, -2, 3), (0, 0, 5), (0, 0, -3), (2, 0, -3), (0, -2, -3), (0, 0, -5)],
+ }
+ int4[] tetVertexIndices.timeSamples = {
+ 0: [(0, 1, 2, 3), (0, 2, 1, 4)],
+ 10: [(0, 1, 2, 3), (4, 6, 5, 7)],
+ }
+
+ double3 xformOp:translate = (-2.5, 0, 0)
+ float xformOp:rotateX:Zup = 90
+ uniform token[] xformOpOrder = ["xformOp:rotateX:Zup","xformOp:translate"]
+}
+
+def TetMesh "tetMesh2"
+{
+ color3f[] primvars:displayColor = [(0, 0, 1)]
+ point3f[] points = [(0, 0, 0), (2, 0, 0), (0, -2, 0), (0, 0, 2), (0, 0, -2)]
+ int4[] tetVertexIndices = [(0, 1, 2, 3), (0, 2, 1, 4)]
+
+ float xformOp:rotateX:Zup = 90
+ uniform token[] xformOpOrder = ["xformOp:rotateX:Zup"]
+}
+
+def Mesh "regMesh"
+{
+ color3f[] primvars:displayColor = [(1, 0, 0)]
+ int[] faceVertexCounts.timeSamples = {
+ 0: [3, 3, 3, 3, 3, 3],
+ 10: [3, 3, 3, 3, 3, 3, 3, 3],
+ }
+ int[] faceVertexIndices.timeSamples = {
+ 0: [0, 1, 3, 0, 2, 4, 0, 3, 2, 0, 4, 1, 1, 2, 3, 2, 1, 4],
+ 10: [0, 1, 3, 0, 2, 1, 0, 3, 2, 1, 2, 3, 4, 5, 6, 4, 6, 7, 4, 7, 5, 6, 5, 7],
+ }
+ point3f[] points.timeSamples = {
+ 0: [(0, 0, 0), (2, 0, 0), (0, -2, 0), (0, 0, 2), (0, 0, -2)],
+ 10: [(0, 0, 3), (2, 0, 3), (0, -2, 3), (0, 0, 5), (0, 0, -3), (2, 0, -3), (0, -2, -3), (0, 0, -5)],
+ }
+ double3 xformOp:translate = (2.5, 0, 0)
+ float xformOp:rotateX:Zup = 90
+ uniform token[] xformOpOrder = ["xformOp:rotateX:Zup","xformOp:translate"]
+}
+
+
+def Camera "Camera"
+{
+ double3 xformOp:translate = (1.25, 0, 35)
+ uniform token[] xformOpOrder = ["xformOp:translate"]
+}