Big update
This commit is contained in:
@@ -45,6 +45,8 @@ def _make_torus_knot(
|
||||
bevel_resolution: int,
|
||||
knot_scale: float,
|
||||
scene=None,
|
||||
turbulence: float = 0.0,
|
||||
smooth_shading: bool = True,
|
||||
) -> bpy.types.Object:
|
||||
"""Procedurally build / update the AnimKnot NURBS curve in-place.
|
||||
|
||||
@@ -99,6 +101,9 @@ def _make_torus_knot(
|
||||
# 3. Resolve shape parameters
|
||||
shape_type = config.get('shape_type', 'TORUS_KNOT')
|
||||
|
||||
rP = config.get('torus_rP', 0.0) * math.pi * 2.0
|
||||
sP = config.get('torus_sP', 0.0) * math.pi * 2.0
|
||||
|
||||
if shape_type == 'TORUS_KNOT':
|
||||
p = config.get('torus_p', 2)
|
||||
q = config.get('torus_q', 3)
|
||||
@@ -117,8 +122,6 @@ def _make_torus_knot(
|
||||
|
||||
u = config.get('torus_u', 1)
|
||||
v = config.get('torus_v', 1)
|
||||
rP = config.get('torus_rP', 0.0) * math.pi * 2.0
|
||||
sP = config.get('torus_sP', 0.0) * math.pi * 2.0
|
||||
h = config.get('torus_h', 1.0)
|
||||
|
||||
multiple_links = config.get('multiple_links', False)
|
||||
@@ -197,20 +200,23 @@ def _make_torus_knot(
|
||||
t_param = (i / steps) * t_max
|
||||
w_eff = w if link == 0 else -w
|
||||
|
||||
x = (R + w_eff * math.cos(twists * t_param / 2.0)) * math.cos(t_param)
|
||||
y = (R + w_eff * math.cos(twists * t_param / 2.0)) * math.sin(t_param)
|
||||
z = w_eff * math.sin(twists * t_param / 2.0)
|
||||
t_param_rot = t_param + rP
|
||||
twist_angle = twists * t_param_rot / 2.0 + sP
|
||||
|
||||
x = (R + w_eff * math.cos(twist_angle)) * math.cos(t_param_rot)
|
||||
y = (R + w_eff * math.cos(twist_angle)) * math.sin(t_param_rot)
|
||||
z = w_eff * math.sin(twist_angle)
|
||||
|
||||
elif shape_type == 'LISSAJOUS':
|
||||
t_param = (i / steps) * TAU
|
||||
x = amp * math.sin(kx * t_param)
|
||||
y = amp * math.sin(ky * t_param + (TAU / 4.0))
|
||||
z = amp * math.sin(kz * t_param)
|
||||
x = amp * math.sin(kx * t_param + rP)
|
||||
y = amp * math.sin(ky * t_param + (TAU / 4.0) + sP)
|
||||
z = amp * math.sin(kz * t_param + rP + sP)
|
||||
|
||||
elif shape_type == 'SPIRAL':
|
||||
t_param = -math.pi / 2.0 + (i / max(1, steps - 1)) * math.pi
|
||||
theta = t_param
|
||||
phi = turns * 2.0 * t_param
|
||||
phi = turns * 2.0 * t_param + rP + sP
|
||||
x = R * math.cos(theta) * math.cos(phi)
|
||||
y = R * math.cos(theta) * math.sin(phi)
|
||||
z = R * math.sin(theta)
|
||||
@@ -218,6 +224,14 @@ def _make_torus_knot(
|
||||
else:
|
||||
x, y, z = 0.0, 0.0, 0.0
|
||||
|
||||
if turbulence > 0.0:
|
||||
nx = math.sin(i * 1.345 + rP) * turbulence
|
||||
ny = math.cos(i * 0.932 - sP) * turbulence
|
||||
nz = math.sin(i * 1.777 + rP + sP) * turbulence
|
||||
x += nx
|
||||
y += ny
|
||||
z += nz
|
||||
|
||||
spline.points[i].co = (x, y, z, 1.0)
|
||||
|
||||
# 6. Transform and material
|
||||
|
||||
Reference in New Issue
Block a user