Files
breeze/apps/practice/astral_technique.zi
waozi 685dd672e9 Model the six astral techniques for the native figure painter
astral_technique.zi turns each exercise's session cue timeline into the
still physical pose, the double's offset and roll, rope, attention marks
and return, tested across all 88 cue boundaries. The practice figure's
prepare script now folds MakeHuman's CC0 default rig weights onto its 46
bones and cuts clothing hems exactly along their planes.
2026-11-17 16:12:35 -03:00

239 lines
8.7 KiB
Ziran

// Six visual techniques sampled from the loaded session's actual cue boundaries.
// This model is independent of rendering, narration and clock ownership.
#import, file "astral_projection_rules.zi";
#import, file "workout_moves.zi";
#import, file "../../src/practices/tai_chi/tai_chi_math.zi";
#import, file "../../src/practices/tai_chi/tai_chi_view.zi";
#import "std/math"
#import "std/byte_text_linux"
#import, file "../../src/practices/tai_chi/tai_chi_solve.zi";
AstralTechniqueScene :: struct {
physical: WorkoutPose
awareness: WorkoutPose
camera: TaiChiCamera
cue: s32
progress: float64
// The physical figure stays supported. Only the astral double receives
// this rigid translation and longitudinal rotation, including its limbs.
double_offset: TaiChiVector3
double_roll: float64
double_visible: bool
returning: bool
marker: TaiChiVector3
marker_visible: bool
path: s32
stroke: float64
elevator: float64
orbit: float64
rope: bool
}
AstralTechniqueIndex :: (id: string) -> s32 {
if id == "bruce_foundation_touch" {
return 0
}
if id == "bruce_full_body_current" {
return 1
}
if id == "bruce_elevator_trance" {
return 2
}
if id == "bruce_spin_loosening" {
return 3
}
if id == "bruce_rope_exit" {
return 4
}
if id == "bruce_roll_out_exit" {
return 5
}
return -1
}
AstralRestingPose :: () -> WorkoutPose {
pose := WorkoutStanding()
WorkoutBody(*pose, 0.0, 0.18, 0.0, 0.0, -90.0, 0.0, 0.0, 0.0, 2.0)
WorkoutHandsAt(*pose, WORKOUT_AT_WORLD, 0.28, 0.17, -0.2)
WorkoutElbows(*pose, 0.5, 0.1, -0.4)
WorkoutFeet(*pose, 0.1, 0.8, 4.0, 65.0, 0.1)
WorkoutKnees(*pose, 0.12, 0.0, 1.0)
return pose
}
AstralTechniqueAt :: (id: string, course: *AstralCourse, milliseconds: s64) -> AstralTechniqueScene {
scene: AstralTechniqueScene
scene.physical = AstralRestingPose()
scene.awareness = scene.physical
scene.camera.yaw = -64.0 * TAI_CHI_DEGREE
scene.camera.tilt = 26.0 * TAI_CHI_DEGREE
scene.cue = -1
technique := AstralTechniqueIndex(id)
if technique < 0 || course.count < 1 || course.duration <= 0 {
return scene
}
time := TaiChiClamp(cast(float64)milliseconds / 1000.0, 0.0, cast(float64)course.duration)
scene.cue = AstralCueAt(course, cast(s32)time)
cue := *course.cues[scene.cue]
end := course.duration
if scene.cue + 1 < course.count {
end = course.cues[scene.cue + 1].second
}
span := end - cue.second
if span <= 0 {
return scene
}
scene.progress = TaiChiClamp((time - cast(float64)cue.second) / cast(float64)span, 0.0, 1.0)
key := TextFromCString(*cue.key[0])
if key.count < 2 {
return scene
}
tens := key[key.count - 2]
units := key[key.count - 1]
if tens < cast(u8)48 || tens > cast(u8)57 || units < cast(u8)48 || units > cast(u8)57 {
return scene
}
step := cast(s32)(tens - cast(u8)48) * 10 + cast(s32)(units - cast(u8)48)
// Absolute time keeps pause, seeking and repeated samples deterministic.
scene.stroke = time / 2.6 - cast(float64)cast(s64)(time / 2.6)
rig := WorkoutRig()
body := WorkoutSolve(*scene.physical, *rig)
if technique == 0 {
if step >= 2 && step <= 5 {
scene.marker_visible = true
scene.path = 1
radius := ifx step == 2 then 0.008 else 0.016
angle := time * TAI_CHI_PI * 2.4
scene.marker = TaiChiAdd3(body.palms[1], TaiChiV3(Cos(angle) * radius, 0.04, Sin(angle) * radius))
if step == 5 {
scene.marker = TaiChiLerp3(body.palms[1], body.wrists[1], scene.stroke)
scene.marker.y += 0.04
}
} else if step >= 6 && step <= 9 {
scene.path = ifx step == 6 then 2 else ifx step == 7 then 3 else 4
}
} else if technique == 1 {
if step >= 2 && step <= 3 {
scene.path = ifx step == 2 then 3 else 4
scene.stroke = 0.5 + 0.5 * Sin(time * TAI_CHI_PI * 1.4)
} else if step == 4 {
scene.path = 5
scene.stroke = 0.5 + 0.5 * Sin(time * TAI_CHI_PI * 1.4)
} else if step == 5 {
scene.path = 4
} else if step == 6 {
scene.path = 5
} else if step >= 7 && step <= 11 {
scene.path = 6
scene.stroke = time / 8.0 - cast(float64)cast(s64)(time / 8.0)
}
} else if technique == 2 {
if step >= 7 && step <= 13 {
// Moving shaft marks rise past a supported figure: felt descent.
// Trance/rest cues pause it rather than lifting the physical body.
if step <= 9 || step == 12 {
scene.elevator = time / 9.0 - cast(float64)cast(s64)(time / 9.0)
} else {
scene.elevator = 0.5
}
scene.path = 7
}
} else if technique == 3 {
if step >= 5 && step <= 13 {
scene.marker_visible = true
if step <= 6 {
scene.marker = TaiChiAdd3(body.head_center,
TaiChiV3(0.0, 0.2 + (0.5 + 0.5 * Sin(time * 2.0)) * 0.75, 0.0))
} else {
scene.orbit = time * TAI_CHI_PI
if step == 13 {
scene.orbit = time * TAI_CHI_PI / 3.0
}
scene.marker = TaiChiAdd3(body.pelvis,
TaiChiV3(Cos(scene.orbit) * 1.0, 0.45 + Sin(scene.orbit) * 0.3, Sin(scene.orbit) * 0.9))
}
scene.path = 8
}
} else if technique == 4 {
if step == 8 {
scene.path = 4
}
if step == 9 {
scene.path = 6
}
if step == 10 {
scene.path = 8
scene.marker_visible = true
scene.marker = TaiChiAdd3(body.head_center, TaiChiV3(Sin(time) * 0.4, 0.7, 0.0))
}
if step >= 12 && step <= 19 {
scene.rope = true
scene.double_visible = true
climb := TaiChiClamp((time - cast(float64)AstralTechniqueSecond(course, 12)) / 45.0, 0.0, 1.0)
scene.double_offset.y = 0.65 * AstralTechniqueEase(climb)
scene.double_offset.x = 0.12 * AstralTechniqueEase(climb)
phase := time * TAI_CHI_PI * (ifx step >= 14 then 2.0 else 1.25)
for side: cast(s32)0..1 {
reach := 0.5 + Sin(phase + cast(float64)side * TAI_CHI_PI) * 0.15
WorkoutHandAt(*scene.awareness, side, WORKOUT_AT_WORLD,
TaiChiSideSign(side) * 0.10, body.chest.y + reach, body.chest.z)
}
if step == 19 {
scene.returning = true
fade := 1.0 - AstralTechniqueEase(scene.progress)
scene.double_offset = TaiChiScale3(scene.double_offset, fade)
scene.awareness = WorkoutBlend(*scene.awareness, *scene.physical, 1.0 - fade, *rig)
}
}
} else if technique == 5 {
if step == 5 {
scene.path = 6
}
if step >= 7 && step <= 14 {
scene.double_visible = true
direction: float64 = 1.0
if step == 9 {
direction = -1.0
}
cycle := 0.5 - 0.5 * Cos(time * TAI_CHI_PI / 3.0)
distance := ifx step >= 11 then 0.72 else 0.40
scene.double_offset = TaiChiV3(direction * distance * cycle, 0.15 * cycle, 0.0)
scene.double_roll = direction * cycle * TAI_CHI_PI * 0.85
if step == 13 {
settle := AstralTechniqueEase(TaiChiClamp((time - cast(float64)cue.second) / 6.0, 0.0, 1.0))
scene.double_offset = TaiChiV3(0.72 * settle, 0.15 * settle, 0.0)
scene.double_roll = TAI_CHI_PI * 0.85 * settle
}
if step == 14 {
scene.returning = true
fade := 1.0 - AstralTechniqueEase(scene.progress)
scene.double_offset = TaiChiV3(0.72 * fade, 0.15 * fade, 0.0)
scene.double_roll = TAI_CHI_PI * 0.85 * fade
}
}
}
if time >= cast(float64)course.duration {
scene.double_visible = false
scene.rope = false
scene.marker_visible = false
scene.path = 0
}
return scene
}
#scope_file
AstralTechniqueSecond :: (course: *AstralCourse, step: s32) -> s32 {
for index: cast(s32)0..course.count - 1 {
key := TextFromCString(*course.cues[index].key[0])
if key.count >= 2 && cast(s32)key[key.count - 2] - 48 == step / 10 &&
cast(s32)key[key.count - 1] - 48 == step % 10 {
return course.cues[index].second
}
}
return course.duration
}
AstralTechniqueEase :: (value: float64) -> float64 {
return value * value * (3.0 - 2.0 * value)
}