Translate field value segment helper
This commit is contained in:
parent
aa1353d75b
commit
97e43eed46
8 changed files with 188 additions and 10 deletions
|
|
@ -124,10 +124,12 @@ Completed pie chart entry:
|
|||
Completed field value helper entry:
|
||||
|
||||
- `docs/research/translations/shriinivas-fieldvalue-digit-at.md`
|
||||
- Source groups: `Create Decimal`, `Digit At`
|
||||
- Source groups: `Create Decimal`, `Create Segment`, `Digit At`
|
||||
- Verification: decimal glyph geometry matches source with sorted max vertex
|
||||
delta `0.0`; digit scalar helper matches source behavior across four
|
||||
number/position cases by driving `Mesh Line.Count` with the result.
|
||||
delta `0.0`; segment geometry matches horizontal and vertical source cases
|
||||
with sorted max vertex delta `0.0`; digit scalar helper matches source
|
||||
behavior across four number/position cases by driving `Mesh Line.Count` with
|
||||
the result.
|
||||
|
||||
## Extraction Workflow
|
||||
|
||||
|
|
|
|||
|
|
@ -137,6 +137,22 @@ part instead of another anonymous mesh primitive.
|
|||
|
||||
Tiny named parts are not overengineering when they carry stable intent.
|
||||
|
||||
## Field Masks Are Chisels
|
||||
|
||||
You can sculpt simple meshes by combining a regular seed mesh with field masks.
|
||||
`Create Segment` starts with a tiny grid, reads each vertex position, and uses
|
||||
comparisons to decide which corners receive a tip offset.
|
||||
|
||||
The useful pattern is:
|
||||
|
||||
```text
|
||||
regular mesh -> position field -> boolean/math masks -> gated offset -> set position
|
||||
```
|
||||
|
||||
This is how a rectangle becomes a seven-segment bar with pointed ends. No custom
|
||||
mesh coordinates need to be hard-coded; the graph says which local conditions
|
||||
cause movement.
|
||||
|
||||
## Stack Abstractions Carefully
|
||||
|
||||
There are two abstraction layers available:
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
- Source file: `fieldvalue.blend`
|
||||
- Source groups:
|
||||
- `Create Decimal`
|
||||
- `Create Segment`
|
||||
- `Digit At`
|
||||
- Geometry Script recreation:
|
||||
`examples/geometry_script/shriinivas_fieldvalue.py`
|
||||
|
|
@ -16,8 +17,8 @@
|
|||
`Field Value` graph has 176 nodes, so the first honest targets are small
|
||||
helpers: `Create Decimal` and `Digit At`.
|
||||
|
||||
Together they show both sides of a display system: tiny glyph geometry and
|
||||
value-only digit extraction.
|
||||
Together they show the first display-system layers: tiny glyph geometry,
|
||||
field-sculpted segment geometry, and value-only digit extraction.
|
||||
|
||||
## Create Decimal Map
|
||||
|
||||
|
|
@ -60,6 +61,33 @@ Metaphor: the group is a little inspection window sliding over a number. It
|
|||
moves to the requested decimal place, crops the surrounding digits away, then
|
||||
decides whether to round or floor the exposed digit.
|
||||
|
||||
## Create Segment Map
|
||||
|
||||
Source group: `Create Segment`
|
||||
|
||||
Geometry Script group: `VG Create Segment`
|
||||
|
||||
Mechanism:
|
||||
|
||||
- Build a `Grid` with either `2x3` or `3x2` vertices depending on `X Major`.
|
||||
- Read each vertex `Position`.
|
||||
- Split the position into major-axis and secondary-axis coordinates.
|
||||
- Build a tip vector along the major axis:
|
||||
|
||||
```text
|
||||
tip = 0.5 * Sharpness * Secondary Axis Segment Thickness
|
||||
```
|
||||
|
||||
- Detect vertices on the secondary axis and at the positive/negative segment
|
||||
ends.
|
||||
- Push only those gated vertices inward/outward to make pointed segment tips.
|
||||
- Add the user `offset`.
|
||||
- Move the grid vertices with `Set Position`.
|
||||
|
||||
Metaphor: the segment starts as a plain rectangular tile. The position field is
|
||||
a stencil laid over its vertices. The end-corner vertices get pinched into tips,
|
||||
while the middle vertices stay put. It is a chisel, not a sculpting spree.
|
||||
|
||||
## Verification
|
||||
|
||||
Run:
|
||||
|
|
@ -77,6 +105,8 @@ Results from Blender 5.1.1:
|
|||
| Case | Source | Translated | Delta | Status |
|
||||
| --- | ---: | ---: | ---: | --- |
|
||||
| Create Decimal vertices | 32 | 32 | 0.0 | accepted |
|
||||
| Create Segment horizontal vertices | 6 | 6 | 0.0 | accepted |
|
||||
| Create Segment vertical vertices | 6 | 6 | 0.0 | accepted |
|
||||
| Digit At `1234.0`, position `0` | 4 | 4 | 0 | accepted |
|
||||
| Digit At `1234.0`, position `1` | 3 | 3 | 0 | accepted |
|
||||
| Digit At `98765.0`, position `2` | 7 | 7 | 0 | accepted |
|
||||
|
|
@ -94,3 +124,6 @@ Results from Blender 5.1.1:
|
|||
- Tiny glyph marks are still worth isolating as named groups. A decimal point is
|
||||
just a dot, but a named dot with scale and placement controls is a reusable
|
||||
punctuation part.
|
||||
- Field masks can act as chisels. In `Create Segment`, comparisons over
|
||||
position decide which vertices are allowed to move, creating pointed tips
|
||||
without hand-authoring mesh coordinates.
|
||||
|
|
|
|||
|
|
@ -55,15 +55,93 @@ def vg_digit_at(number: Float = 0.0, position: Int = 0):
|
|||
)
|
||||
|
||||
|
||||
@tree("VG Create Segment")
|
||||
def vg_create_segment(
|
||||
x_major: Bool = False,
|
||||
segment_length_along_x: Float = 0.0,
|
||||
segment_length_along_y: Float = 0.0,
|
||||
secondary_axis_segment_thickness: Float = 0.0,
|
||||
sharpness: Float = 0.0,
|
||||
offset: Vector = (0.0, 0.0, 0.0),
|
||||
):
|
||||
position_parts = separate_xyz(vector=position())
|
||||
major_axis = switch(input_type=Switch.InputType.FLOAT, switch=x_major, false=position_parts.y, true=position_parts.x)
|
||||
secondary_axis = switch(
|
||||
input_type=Switch.InputType.FLOAT,
|
||||
switch=x_major,
|
||||
false=position_parts.x,
|
||||
true=position_parts.y,
|
||||
)
|
||||
|
||||
not_x_major = math(operation=Math.Operation.SUBTRACT, value=(1.0, x_major))
|
||||
vertices_x = math(operation=Math.Operation.ADD, value=(2.0, not_x_major))
|
||||
vertices_y = math(operation=Math.Operation.ADD, value=(2.0, x_major))
|
||||
|
||||
tip_amount = math(
|
||||
operation=Math.Operation.MULTIPLY,
|
||||
value=(
|
||||
math(operation=Math.Operation.MULTIPLY, value=(0.5, sharpness)),
|
||||
secondary_axis_segment_thickness,
|
||||
),
|
||||
)
|
||||
tip_vector = combine_xyz(
|
||||
x=math(operation=Math.Operation.MULTIPLY, value=(x_major, tip_amount)),
|
||||
y=math(operation=Math.Operation.MULTIPLY, value=(not_x_major, tip_amount)),
|
||||
z=0.0,
|
||||
)
|
||||
|
||||
has_secondary_axis = compare(
|
||||
operation=Compare.Operation.NOT_EQUAL,
|
||||
data_type=Compare.DataType.FLOAT,
|
||||
mode=Compare.Mode.ELEMENT,
|
||||
a=secondary_axis,
|
||||
b=0.0,
|
||||
)
|
||||
negative_tip_gate = math(
|
||||
operation=Math.Operation.MULTIPLY,
|
||||
value=(math(operation=Math.Operation.LESS_THAN, value=(major_axis, 0.0)), has_secondary_axis),
|
||||
)
|
||||
positive_tip_gate = math(
|
||||
operation=Math.Operation.MULTIPLY,
|
||||
value=(math(operation=Math.Operation.GREATER_THAN, value=(major_axis, 0.0)), has_secondary_axis),
|
||||
)
|
||||
negative_tip = vector_math(operation=VectorMath.Operation.MULTIPLY, vector=(-1.0, tip_vector))
|
||||
positive_gate_vector = combine_xyz(x=positive_tip_gate, y=positive_tip_gate, z=positive_tip_gate)
|
||||
negative_gate_vector = combine_xyz(x=negative_tip_gate, y=negative_tip_gate, z=negative_tip_gate)
|
||||
positive_end_offset = vector_math(operation=VectorMath.Operation.MULTIPLY, vector=(negative_tip, positive_gate_vector))
|
||||
negative_end_offset = vector_math(operation=VectorMath.Operation.MULTIPLY, vector=(tip_vector, negative_gate_vector))
|
||||
total_offset = vector_math(
|
||||
operation=VectorMath.Operation.ADD,
|
||||
vector=(
|
||||
vector_math(operation=VectorMath.Operation.ADD, vector=(offset, positive_end_offset)),
|
||||
negative_end_offset,
|
||||
),
|
||||
)
|
||||
|
||||
segment = grid(
|
||||
size_x=segment_length_along_x,
|
||||
size_y=segment_length_along_y,
|
||||
vertices_x=vertices_x,
|
||||
vertices_y=vertices_y,
|
||||
).mesh
|
||||
return {"Segment": segment.set_position(offset=total_offset)}
|
||||
|
||||
|
||||
def _finalize_groups():
|
||||
import bpy
|
||||
|
||||
groups = []
|
||||
for name in ("VG Create Decimal", "VG Digit At"):
|
||||
for name in ("VG Create Decimal", "VG Digit At", "VG Create Segment"):
|
||||
group = bpy.data.node_groups.get(name)
|
||||
if not group:
|
||||
continue
|
||||
group.use_fake_user = True
|
||||
if hasattr(group, "interface"):
|
||||
for item in group.interface.items_tree:
|
||||
if item.item_type == "SOCKET" and item.in_out == "INPUT" and item.name == "X Major":
|
||||
item.name = "X Major"
|
||||
if item.item_type == "SOCKET" and item.in_out == "INPUT" and item.name in {"Radius", "Offset"}:
|
||||
item.name = item.name.lower()
|
||||
groups.append(group)
|
||||
return groups
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ The completed pie chart translation is
|
|||
|
||||
The completed field-value helper translation is
|
||||
`docs/research/translations/shriinivas-fieldvalue-digit-at.md`. It covers
|
||||
`Create Decimal` and `Digit At` from `fieldvalue.blend`.
|
||||
`Create Decimal`, `Create Segment`, and `Digit At` from `fieldvalue.blend`.
|
||||
|
||||
`docs/research/procedural-doctrine.md` now stores the current intuitive model
|
||||
for mapping geometric ideas to Geometry Script: curves as rails, fields as
|
||||
|
|
@ -54,8 +54,8 @@ Run `.\tools\setup_geometry_script_clone.ps1` if `external/geometry-script` is
|
|||
missing in a fresh workspace.
|
||||
|
||||
The current next action is to continue `fieldvalue.blend` by translating the
|
||||
next bounded seven-segment display helper, `Create Segment`, before attempting
|
||||
the full `Field Value` graph.
|
||||
next composition helper, likely `Seven Segments` or `Delete Segments`, before
|
||||
attempting the full `Field Value` graph.
|
||||
|
||||
## Important Invariants
|
||||
|
||||
|
|
|
|||
|
|
@ -9,3 +9,4 @@
|
|||
{"ts": "2026-05-04T12:48:18+00:00", "type": "implementation", "status": "accepted", "note": "Translated and verified Shriinivas/piechart.blend small graph family: NodeGroup -> VG Pie Segment and Pie Chart -> VG Pie Chart. Segment and chart evaluated mesh comparisons both passed in Blender 5.1.1 with sorted max vertex delta 0.0. Doctrine added: reusable groups can pass invisible scalar state such as End angle alongside visible geometry."}
|
||||
{"ts": "2026-05-04T12:50:55+00:00", "type": "implementation", "status": "accepted", "note": "Translated and verified Shriinivas/fieldvalue.blend Digit At scalar helper as VG Digit At. Verification wraps source and translation by driving Mesh Line.Count and matches four number/position cases, including zero output. Doctrine added: value-only node groups need geometry-producing verification harnesses."}
|
||||
{"ts": "2026-05-04T12:53:00+00:00", "type": "implementation", "status": "accepted", "note": "Extended fieldvalue translation with Create Decimal -> VG Create Decimal. Verified against source by comparing evaluated dot geometry: both source and translation produce 32 vertices with sorted max vertex delta 0.0. Doctrine added: tiny glyph marks such as decimal points should be isolated as named reusable parts when they carry stable display intent."}
|
||||
{"ts": "2026-05-04T12:56:02+00:00", "type": "implementation", "status": "accepted", "note": "Extended fieldvalue translation with Create Segment -> VG Create Segment. Verified horizontal and vertical segment cases against source with 6 vertices each and sorted max vertex delta 0.0. Doctrine added: field masks can act as chisels over regular seed meshes, gating vertex offsets by local position conditions."}
|
||||
|
|
|
|||
|
|
@ -83,4 +83,4 @@ data_flow:
|
|||
|
||||
current_status:
|
||||
summary: VibeGeometry has an initial persistence scaffold plus verified Geometry Script translations for inspected Shriinivas cartesian, pie chart, and field-value helper graph families.
|
||||
next_action: Continue fieldvalue.blend by translating `Create Segment`, the next bounded seven-segment display helper, before attempting the full `Field Value` graph.
|
||||
next_action: Continue fieldvalue.blend by translating the next composition helper, likely `Seven Segments` or `Delete Segments`, before attempting the full `Field Value` graph.
|
||||
|
|
|
|||
|
|
@ -22,6 +22,24 @@ CASES = [
|
|||
]
|
||||
|
||||
DECIMAL_CASE = {"Vertical Segment Size": 2.4, "radius": 0.18}
|
||||
SEGMENT_CASES = [
|
||||
{
|
||||
"X Major": True,
|
||||
"Segment Length Along X": 2.0,
|
||||
"Segment Length Along Y": 0.45,
|
||||
"Secondary Axis Segment Thickness": 0.45,
|
||||
"Sharpness": 0.75,
|
||||
"offset": (0.2, -0.1, 0.0),
|
||||
},
|
||||
{
|
||||
"X Major": False,
|
||||
"Segment Length Along X": 0.4,
|
||||
"Segment Length Along Y": 1.8,
|
||||
"Secondary Axis Segment Thickness": 0.4,
|
||||
"Sharpness": 1.0,
|
||||
"offset": (-0.3, 0.25, 0.0),
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
def _load_translation() -> None:
|
||||
|
|
@ -144,6 +162,36 @@ def main() -> int:
|
|||
results[-1]["source_vertex_count"] == results[-1]["translated_vertex_count"]
|
||||
and results[-1]["max_sorted_vertex_delta"] <= 1e-6
|
||||
)
|
||||
for index, inputs in enumerate(SEGMENT_CASES):
|
||||
source_segment = _evaluated_vertices(
|
||||
_build_geometry_wrapper(
|
||||
f"VG Verify Source Segment {index}",
|
||||
bpy.data.node_groups["Create Segment"],
|
||||
inputs,
|
||||
"Segment",
|
||||
)
|
||||
)
|
||||
translated_segment = _evaluated_vertices(
|
||||
_build_geometry_wrapper(
|
||||
f"VG Verify Translated Segment {index}",
|
||||
bpy.data.node_groups["VG Create Segment"],
|
||||
inputs,
|
||||
"Segment",
|
||||
)
|
||||
)
|
||||
max_delta = max(
|
||||
(math.dist(a, b) for a, b in zip(sorted(source_segment), sorted(translated_segment))),
|
||||
default=0.0,
|
||||
)
|
||||
results.append(
|
||||
{
|
||||
"case": {"create_segment": index, **inputs},
|
||||
"source_vertex_count": len(source_segment),
|
||||
"translated_vertex_count": len(translated_segment),
|
||||
"max_sorted_vertex_delta": max_delta,
|
||||
"ok": len(source_segment) == len(translated_segment) and max_delta <= 1e-6,
|
||||
}
|
||||
)
|
||||
for index, inputs in enumerate(CASES):
|
||||
source_count = _evaluated_vertex_count(_build_count_wrapper(f"VG Verify Source Digit {index}", source, inputs))
|
||||
translated_count = _evaluated_vertex_count(
|
||||
|
|
|
|||
Loading…
Reference in a new issue