You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Elements/extensions/Normals_USDimporter_BSP/README.md
+32-24Lines changed: 32 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,49 +3,57 @@ Authors:
3
3
Kapetanakis Ioannis - csd4641
4
4
5
5
Tests are written for pytest
6
-
-> To run all the tests, type "pytest Tests"
6
+
-> To run all the tests, type: pytest Tests
7
7
8
-
<ForProperNormalsTask:>
9
-
Implemented correct flat/smooth normal handling by detecting shared vs unique vertex indexing and converting the vertex/index buffers accordingly. Custom helper functions exist to determine whether vertices are shared or unique by analyzing index usage. This correction fixes smooth-shading artifacts caused by incorrect vertex-sharing assumptions and ensures the appropriate flat or smooth shading path is selected.
-colored Enable color visualization by using normals as colors (optional)
9
+
<ProperNormalsTask:>
10
+
Implemented correct flat/smooth normal handling by detecting shared vs unique vertex indexing and converting the vertex/index buffers accordingly. Helper utilities determine whether vertices are shared or unique by analyzing index usage. This fixes smooth-shading artifacts caused by incorrect vertex-sharing assumptions and ensures the appropriate flat or smooth shading path is selected.
22
11
23
-
Example:
24
-
python cow_example.py --shading flat -colored
12
+
Usage:
13
+
python cow_example.py
14
+
python sphere_example.py
25
15
16
+
Runtime options (ImGui):
17
+
- Shading: Smooth / Flat
18
+
- Normals as color: toggles normal-visualization by mapping normals to RGB
26
19
27
-
<ForUSDImporterTask:>
20
+
<USDImporterTask:>
28
21
The LoadScene_Blender method imports a USD scene exported from Blender and converts it into an Elements scene representation. It traverses the USD stage hierarchy, creates corresponding entities for each UsdGeom.Xform, and reconstructs parent–child relationships based on USD paths.
29
22
30
23
For each UsdGeom.Mesh, the method extracts geometry data including vertex positions, face topology, normals, and material color information. It supports both smooth and flat shading by handling different normal interpolation modes (vertex and faceVarying). Polygonal faces are triangulated appropriately, with corner-space triangulation used for flat shading.
31
24
32
25
The method uploads vertex attributes and indices to the GPU and performs coordinate system conversion from Blender’s Z-up convention to the engine’s Y-up convention.
33
26
34
27
Usage:
35
-
python usd_import_example.py [-colored]
36
-
37
-
Flags:
38
-
-colored Enable color visualization by using normals as colors (optional)
28
+
python usd_import_example.py
39
29
30
+
Runtime options (ImGui):
31
+
- Load USD (colors)
32
+
- Load USD (normals as color)
40
33
41
-
<ForBSPTask:>
34
+
<BSPTask:>
42
35
The implemented method builds an axis-aligned Binary Space Partitioning (BSP) tree for triangle meshes.
43
36
37
+
Each triangle is implicitly assigned an ID based on its position in the index buffer (every 3 consecutive indices correspond to one triangle). The search(id) function references triangles using this index-based ID.
38
+
44
39
At each node, the splitting axis is selected based on the largest spatial extent of the triangles, while the split position is chosen as the median of triangle centroids along that axis to avoid unbalanced partitions.
45
40
46
41
Triangles are classified as fully on one side of the split plane or intersecting it; intersecting triangles are propagated to all child leaf nodes to preserve spatial correctness.
47
42
48
-
During search, the BSP tree is traversed by testing each triangle against the split planes. Depending on whether the triangle lies on one side of the plane or intersects it, the traversal proceeds to the appropriate child nodes.
43
+
During search, the BSP tree is traversed by testing each triangle against the split planes. The traversal path and tree structure are printed to the terminal.
49
44
50
45
Usage:
51
-
python bsp_example.py
46
+
python bsp_example.py
47
+
48
+
What to try:
49
+
- Move the camera to view triangle placement.
50
+
- Use Triangle id = 0..4 and press Search to observe different traversal paths.
51
+
- Press Print tree to inspect the BSP structure by depth.
52
+
53
+
In each case, the result is printed to the terminal.
54
+
55
+
56
+
Runtime options (ImGui):
57
+
- Triangle id (input)
58
+
- Search (prints traversal path to the terminal)
59
+
- Print tree (prints the BSP structure by depth to the terminal)
0 commit comments