Skip to content

Commit d256eb3

Browse files
committed
Replace G4MF vertex instances with bindings
1 parent 89826db commit d256eb3

15 files changed

+608
-188
lines changed

addons/4d/doc_classes/G4MFMaterialChannel4D.xml

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,6 @@
2525
Checks if the [G4MFMaterialChannel4D] is equal to another [G4MFMaterialChannel4D] exactly by checking if the properties are equal and all accessor indices refer to the same accessors. If a material channel refers to a different accessor, even if the data is the same, this will return [code]false[/code]. The name of the material channel is not checked, and any metadata is ignored.
2626
</description>
2727
</method>
28-
<method name="load_edge_colors" qualifiers="const">
29-
<return type="PackedColorArray" />
30-
<param index="0" name="g4mf_state" type="G4MFState4D" />
31-
<description>
32-
Loads the edge colors from the [G4MFAccessor4D] at [member per_edge_accessor_index] in the [G4MFState4D]'s accessors array. This is a low-level function that will fail if the index does not refer to a valid [G4MFAccessor4D] or if the accessor does not contain valid color data.
33-
</description>
34-
</method>
35-
<method name="load_simplex_colors" qualifiers="const">
36-
<return type="PackedColorArray" />
37-
<param index="0" name="g4mf_state" type="G4MFState4D" />
38-
<description>
39-
Loads the simplex cell colors from the [G4MFAccessor4D] at [member per_simplex_accessor_index] in the [G4MFState4D]'s accessors array. This is a low-level function that will fail if the index does not refer to a valid [G4MFAccessor4D] or if the accessor does not contain valid color data.
40-
</description>
41-
</method>
42-
<method name="load_vertex_colors" qualifiers="const">
43-
<return type="PackedColorArray" />
44-
<param index="0" name="g4mf_state" type="G4MFState4D" />
45-
<description>
46-
Loads the vertex colors from the [G4MFAccessor4D] at [member per_vertex_accessor_index] in the [G4MFState4D]'s accessors array. This is a low-level function that will fail if the index does not refer to a valid [G4MFAccessor4D] or if the accessor does not contain valid color data.
47-
</description>
48-
</method>
4928
<method name="to_dictionary" qualifiers="const">
5029
<return type="Dictionary" />
5130
<description>
@@ -54,30 +33,18 @@
5433
</method>
5534
</methods>
5635
<members>
36+
<member name="element_map_binding" type="G4MFMeshSurfaceBinding4D" setter="set_element_map_binding" getter="get_element_map_binding">
37+
The binding that defines per-item values (such as colors), and indices which map these to elements, for this material channel. If not defined, the surface uses only the [member factor] and/or the mapped texture for its values or colors.
38+
</member>
5739
<member name="factor" type="Color" setter="set_factor" getter="get_factor" default="Color(-1, -1, -1, -1)">
5840
The modulate factor of the surface, also known as the value or single base color. If non-negative, this is per-component multiplied with other properties to get the final color of the cells and edges, or if no other properties are defined, this is the only color used.
5941
</member>
60-
<member name="per_edge_accessor_index" type="int" setter="set_edge_colors_accessor_index" getter="get_per_edge_accessor_index" default="-1">
61-
The index of the [G4MFAccessor4D] in the [G4MFState4D]'s accessors array that contains the per-edge color data for this surface. These may be per-component multiplied with the [member single_color] to get the final color of the edges. If not defined, the surface does not have per-edge colors. If defined (set to a valid index), the amount of edge colors MUST match or exceed the amount of edges in the surface.
62-
</member>
63-
<member name="per_simplex_accessor_index" type="int" setter="set_per_simplex_accessor_index" getter="get_per_simplex_accessor_index" default="-1">
64-
The index of the [G4MFAccessor4D] in the [G4MFState4D]'s accessors array that contains the per-simplex color data for this surface. These may be per-component multiplied with the [member single_color] to get the final color of the simplex cells. If not defined, the surface does not have per-simplex colors. If defined (set to a valid index), the amount of simplex colors MUST match or exceed the amount of simplex cells in the surface.
65-
</member>
66-
<member name="per_vertex_accessor_index" type="int" setter="set_per_vertex_accessor_index" getter="get_per_vertex_accessor_index" default="-1">
67-
The index of the [G4MFAccessor4D] in the [G4MFState4D]'s accessors array that contains the per-vertex color data for this surface. These may be per-component multiplied with the [member single_color] to get the final color of the vertices. If not defined, the surface does not have per-vertex colors. If defined (set to a valid index), the amount of vertex colors MUST match or exceed the amount of vertices in the surface.
68-
[b]Note:[/b] This property is currently not used when generating a [Material4D] from a [G4MFMaterial4D].
69-
</member>
7042
<member name="texture_index" type="int" setter="set_texture_index" getter="get_texture_index" default="-1">
7143
The index of the [G4MFTexture4D] in the [G4MFState4D]'s textures array that contains the texture for this surface. This is per-component multiplied with the [member single_color] and the cell colors to get the final color of the cells. If not defined, the surface does not have a texture.
7244
[b]Note:[/b] This property is currently not used when generating a [Material4D] from a [G4MFMaterial4D].
7345
</member>
74-
<member name="texture_map_accessor_index" type="int" setter="set_texture_map_accessor_index" getter="get_texture_map_accessor_index" default="-1">
75-
The index of the [G4MFAccessor4D] in the [G4MFState4D]'s accessors array that contains the per-vertex-instance texture map data for this surface, also known as a UV map or UVW map. This is used to map the texture to the surface vertex instances, such as simplex cells or edges. If not defined (set to a negative index), the surface does not have a texture map. If defined, the amount of texture map data MUST match or exceed the amount of vertex instances in the surface.
76-
[b]Note:[/b] This property is currently not used when generating a [Material4D] from a [G4MFMaterial4D].
77-
</member>
78-
<member name="topology_texture_map_accessor_index" type="int" setter="set_topology_texture_map_accessor_index" getter="get_topology_texture_map_accessor_index" default="-1">
79-
The index of the [G4MFAccessor4D] in the [G4MFState4D]'s accessors array that contains the per-topology-vertex-instance texture map data for this surface, also known as a UV map or UVW map. This is used to map the texture to the surface topology vertex instances, such as polytope cells. If not defined (set to a negative index), the surface does not have a texture map. If defined, the amount of texture map data MUST match or exceed the amount of topology vertex instances in the surface.
80-
[b]Note:[/b] This property is currently not used when generating a [Material4D] from a [G4MFMaterial4D].
46+
<member name="texture_map_binding" type="G4MFMeshSurfaceBinding4D" setter="set_texture_map_binding" getter="get_texture_map_binding">
47+
Override for the mesh surface's texture map binding. If defined, this binding is used instead of the mesh surface's [member G4MFMeshSurface4D.texture_map_binding] to map the texture onto the surface.
8148
</member>
8249
</members>
8350
</class>

addons/4d/doc_classes/G4MFMeshSurface4D.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,17 @@
8080
<member name="material_index" type="int" setter="set_material_index" getter="get_material_index" default="-1">
8181
The index of the [G4MFMaterial4D] in the [G4MFState4D]'s materials array that contains the material for this surface. This is used to define the appearance of the surface. If not defined, the surface should render with a default white material.
8282
</member>
83+
<member name="normals_binding" type="G4MFMeshSurfaceBinding4D" setter="set_normals_binding" getter="get_normals_binding">
84+
The binding that defines the vertex normals for this mesh surface. If not defined, the surface implicitly uses flat shading.
85+
</member>
8386
<member name="polytope_simplexes" type="bool" setter="set_polytope_simplexes" getter="get_polytope_simplexes" default="false">
8487
If [code]true[/code], allow treating the tetrahedral cells as part of a larger polytope instead of just simplexes. Each polytope is defined by a set of consecutive simplex cells that share the same starting vertex. This is not used by Godot 4D when importing the mesh.
8588
</member>
8689
<member name="simplexes_accessor_index" type="int" setter="set_simplexes_accessor_index" getter="get_simplexes_accessor_index" default="-1">
8790
The index of the [G4MFAccessor4D] in the [G4MFState4D]'s accessors array that contains the simplex cell indices for this surface. Each integer in the array is an index of a vertex in the mesh's vertices array, and MUST NOT exceed the bounds of the mesh's vertices array. If not defined, the surface does not have explicit simplexes, and may be a wireframe-only surface.
8891
</member>
92+
<member name="texture_map_binding" type="G4MFMeshSurfaceBinding4D" setter="set_texture_map_binding" getter="get_texture_map_binding">
93+
The binding that defines the texture map coordinates for this mesh surface. If not defined, the surface does not have texture mapping.
94+
</member>
8995
</members>
9096
</class>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<class name="G4MFMeshSurfaceBinding4D" inherits="G4MFItem4D" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
3+
<brief_description>
4+
Bindings for data added to mesh surface elements.
5+
</brief_description>
6+
<description>
7+
Mesh surface bindings define how data is associated with mesh elements such as vertices, edges, and simplexes. For example, the tetrahedra of a 4D mesh surface may have texture map coordinates, normals, colors, or other data associated with each corner of the tetrahedra. Bindings define an array of data, and indices which sample that data for specific mesh elements.
8+
</description>
9+
<tutorials>
10+
</tutorials>
11+
<methods>
12+
<method name="from_dictionary" qualifiers="static">
13+
<return type="G4MFMeshSurfaceBinding4D" />
14+
<param index="0" name="dict" type="Dictionary" />
15+
<description>
16+
Converts the given [Dictionary] representing the JSON of a G4MF mesh surface binding to a [G4MFMeshSurfaceBinding4D]. This will set the fields of the [G4MFMeshSurfaceBinding4D] and [G4MFItem4D] classes based on the data in the [Dictionary].
17+
</description>
18+
</method>
19+
<method name="is_equal_exact" qualifiers="const">
20+
<return type="bool" />
21+
<param index="0" name="other" type="G4MFMeshSurfaceBinding4D" />
22+
<description>
23+
Checks if the [G4MFMeshSurfaceBinding4D] is equal to another [G4MFMeshSurfaceBinding4D] exactly by checking if the properties are equal and all accessor indices refer to the same accessors. If a mesh surface binding refers to a different accessor, even if the data is the same, this will return [code]false[/code]. The name of the mesh surface binding is not checked, and any metadata is ignored.
24+
</description>
25+
</method>
26+
<method name="to_dictionary" qualifiers="const">
27+
<return type="Dictionary" />
28+
<description>
29+
Converts the [G4MFMeshSurfaceBinding4D] into a [Dictionary] representing the JSON of a G4MF mesh surface binding.
30+
</description>
31+
</method>
32+
</methods>
33+
<members>
34+
<member name="edges_accessor_index" type="int" setter="set_edges_accessor_index" getter="get_edges_accessor_index" default="-1">
35+
The index of the accessor that contains indices into this binding's values corresponding to the edges of the mesh surface (see [member G4MFMeshSurface4D.edges_accessor_index]). If defined, this MUST point to a valid accessor, which MUST have an integer [member G4MFAccessor4D.component_type], MUST have a [member G4MFAccessor4D.vector_size] of 2 (matching the mesh surface's edges accessor), and MUST have the same number of elements as the mesh surface's edges accessor. Each component in the accessor is an index into this binding's values array. This property is only valid if the mesh surface defines edges.
36+
</member>
37+
<member name="geometry_decompositions" type="G4MFMeshSurfaceBindingGeometry4D[]" setter="set_geometry_decompositions" getter="get_geometry_decompositions" default="[]">
38+
An array of geometry decomposition objects that define how binding values are associated with specific geometry's decomposed polytope elements of the mesh surface. Usually, this will have one item referring to vertex instances of boundary geometry items, meaning for a 3D mesh surface, `index` will be set to 0 (the 2D faces), and for a 4D mesh surface, `index` will be set to 1 (the 3D cells).
39+
</member>
40+
<member name="per_edge_accessor_index" type="int" setter="set_per_edge_accessor_index" getter="get_per_edge_accessor_index" default="-1">
41+
The index of the accessor that contains indices into this binding's values corresponding to each edge of the mesh surface (see [member G4MFMeshSurface4D.edges_accessor_index]). If defined, this MUST point to a valid accessor, which MUST have an integer [member G4MFAccessor4D.component_type], MUST have a [member G4MFAccessor4D.vector_size] of 1, and MUST have the same number of elements as the mesh surface's edges accessor (half the number of component indices). Each component in the accessor is an index into this binding's values array. This property is only valid if the mesh surface defines edges.
42+
</member>
43+
<member name="per_simplex_accessor_index" type="int" setter="set_per_simplex_accessor_index" getter="get_per_simplex_accessor_index" default="-1">
44+
The index of the accessor that contains indices into this binding's values corresponding to each simplex cell of the mesh surface (see [member G4MFMeshSurface4D.simplexes_accessor_index]). If defined, this MUST point to a valid accessor, which MUST have an integer [member G4MFAccessor4D.component_type], MUST have a [member G4MFAccessor4D.vector_size] of 1, and MUST have the same number of elements as the mesh surface's simplexes accessor (the number of simplex cells). Each component in the accessor is an index into this binding's values array. This property is only valid if the mesh surface defines simplexes.
45+
</member>
46+
<member name="simplexes_accessor_index" type="int" setter="set_simplexes_accessor_index" getter="get_simplexes_accessor_index" default="-1">
47+
The index of the accessor that contains indices into this binding's values corresponding to the simplexes of the mesh surface (see [member G4MFMeshSurface4D.simplexes_accessor_index]). If defined, this MUST point to a valid accessor, which MUST have an integer [member G4MFAccessor4D.component_type], MUST have a [member G4MFAccessor4D.vector_size] matching the mesh surface's simplexes accessor (3 for the triangles of a 3D mesh, 4 for the tetrahedra of a 4D mesh, and so on), and MUST have the same number of elements as the mesh surface's simplexes accessor. Each component in the accessor is an index into this binding's values array. This property is only valid if the mesh surface defines simplexes.
48+
</member>
49+
<member name="values_accessor_index" type="int" setter="set_values_accessor_index" getter="get_values_accessor_index" default="-1">
50+
The index of the accessor that contains the values associated with this binding. The type and structure of the values depend on the specific use case of the binding. For example, the texture mapping of a 3D mesh surface would typically use a floating-point accessor with a [member G4MFAccessor4D.vector_size] of 2 or 3, the texture mapping of a 4D mesh surface would typically use a floating-point accessor with a [member G4MFAccessor4D.vector_size] of 3 or 4, the vertex normals of a 5D mesh would use a floating-point accessor with a [member G4MFAccessor4D.vector_size] of 5, and so on.
51+
</member>
52+
<member name="vertices_accessor_index" type="int" setter="set_vertices_accessor_index" getter="get_vertices_accessor_index" default="-1">
53+
The index of the accessor that contains indices into this binding's values corresponding to the vertices shared between all mesh surfaces (see [member G4MFMesh4D.vertices_accessor_index]). If defined, this MUST point to a valid accessor, which MUST have an integer [member G4MFAccessor4D.component_type], MUST have a [member G4MFAccessor4D.vector_size] of 1, and MUST have the same number of elements as the mesh's vertices accessor. Each component in the accessor is an index into this binding's values array. This property is always valid because the `vertices` property of the mesh is required.
54+
</member>
55+
</members>
56+
</class>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<class name="G4MFMeshSurfaceBindingGeometry4D" inherits="G4MFItem4D" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
3+
<brief_description>
4+
Geometry decomposition for mesh surface bindings.
5+
</brief_description>
6+
<description>
7+
Defines how binding values are associated with specific geometry's decomposed polytope elements of the mesh surface.
8+
</description>
9+
<tutorials>
10+
</tutorials>
11+
<methods>
12+
<method name="from_dictionary" qualifiers="static">
13+
<return type="G4MFMeshSurfaceBindingGeometry4D" />
14+
<param index="0" name="dict" type="Dictionary" />
15+
<description>
16+
Converts the given [Dictionary] representing the JSON of a G4MF mesh surface binding geometry to a [G4MFMeshSurfaceBindingGeometry4D]. This will set the fields of the [G4MFMeshSurfaceBindingGeometry4D] and [G4MFItem4D] classes based on the data in the [Dictionary].
17+
</description>
18+
</method>
19+
<method name="is_equal_exact" qualifiers="const">
20+
<return type="bool" />
21+
<param index="0" name="other" type="G4MFMeshSurfaceBindingGeometry4D" />
22+
<description>
23+
Checks if the [G4MFMeshSurfaceBindingGeometry4D] is equal to another [G4MFMeshSurfaceBindingGeometry4D] exactly by checking if the properties are equal and all accessor indices refer to the same accessors. If a mesh surface binding geometry refers to a different accessor, even if the data is the same, this will return [code]false[/code]. The name of the mesh surface binding geometry is not checked, and any metadata is ignored.
24+
</description>
25+
</method>
26+
<method name="to_dictionary" qualifiers="const">
27+
<return type="Dictionary" />
28+
<description>
29+
Converts the [G4MFMeshSurfaceBindingGeometry4D] into a [Dictionary] representing the JSON of a G4MF mesh surface binding geometry.
30+
</description>
31+
</method>
32+
</methods>
33+
<members>
34+
<member name="decomposition_dimension" type="int" setter="set_decomposition_dimension" getter="get_decomposition_dimension" default="0">
35+
The dimensional level to decompose to. 0 for vertices, 1 for edges, 2 for polygons, 3 for volumes, and so on. MUST NOT be greater than [member geometry_index] + 2.
36+
</member>
37+
<member name="geometry_index" type="int" setter="set_geometry_index" getter="get_geometry_index" default="-1">
38+
The index into the mesh surface's geometry array that this binding references.
39+
</member>
40+
<member name="indices_accessor_index" type="int" setter="set_indices_accessor_index" getter="get_indices_accessor_index" default="-1">
41+
The index of the accessor that contains indices into this binding's values. Each element corresponds to a decomposed element at the specified dimension.
42+
</member>
43+
</members>
44+
</class>

config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,10 @@ def get_doc_classes():
7979
"G4MFTexture4D",
8080
"G4MFMaterialChannel4D",
8181
"G4MFMaterial4D",
82-
"G4MFMeshSurface4D",
8382
"G4MFMesh4D",
83+
"G4MFMeshSurface4D",
84+
"G4MFMeshSurfaceBinding4D",
85+
"G4MFMeshSurfaceBindingGeometry4D",
8486
"G4MFModel4D",
8587
"G4MFLight4D",
8688
"G4MFCamera4D",

0 commit comments

Comments
 (0)