Sun Salutation moves like Tai Chi and the workout, without snaps or slides
The woman is the Jade figure of Tai Chi and the workout in the chosen auburn colours, cut slimmer, with rounded hips, finer hands and feet and upright prayer hands. No joint snaps: elbows turn gradually as the hands go flat, knees stay just soft at full reach, and every floor pose keeps the hands and feet on one spot. Stepping feet lift, the body leads and the head follows, a hold keeps breathing, Mountain stands straight, and the camera turns only while she stands. A live offscreen renderer exports the app's own drawing.
This commit is contained in:
1 parent
8f229619ff
commit
215e1b4d4e
12 files changed
+611
-103
No files matched your search
@@ -396,7 +396,7 @@ EMBEDDED_ASSET_FILES := apps/publishers.json $(INBE_BUNDLE) build/apps-ui/apps.z
|
||||
KRY_GEN_DIR := $(BUILD_DIR)/kryon/generated
|
||||
# Dependencies are imported as PACKAGE/Module through their linked packages.
|
||||
ZI_PACKAGE_PATHS := $(shell sh scripts/package-paths.sh)
|
||||
ZI_SRCS := $(shell find src -type f -name '*.zi' 2>/dev/null | LC_ALL=C sort) apps/practice/downloads_view.zi $(wildcard apps/practice/astral_projection*.zi) $(wildcard apps/practice/workout*.zi)
|
||||
ZI_SRCS := $(shell find src -type f -name '*.zi' 2>/dev/null | LC_ALL=C sort) apps/practice/downloads_view.zi $(wildcard apps/practice/astral_projection*.zi) $(wildcard apps/practice/workout*.zi) $(wildcard apps/practice/sun_salutation*.zi)
|
||||
GAME2D_DIR := build/packages/game2d
|
||||
GAME2D_MODULES := $(wildcard $(GAME2D_DIR)/src/*/*.zi)
|
||||
DAOCHI_CLIENT_MODULES := $(wildcard build/packages/daochi-client/*.zi)
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
// How the Sun Salutation figures look and where the camera stands.
|
||||
#import, file "../../src/practices/tai_chi/tai_chi_flat.zi";
|
||||
#import, file "../../src/practices/tai_chi/tai_chi_math.zi";
|
||||
#import, file "../../src/practices/tai_chi/tai_chi_solve.zi";
|
||||
#import, file "../../src/practices/tai_chi/tai_chi_rules.zi";
|
||||
#import, file "../../src/practices/tai_chi/tai_chi_view.zi";
|
||||
#import, file "../../src/practices/sun_salutation/sun_salutation_pose.zi";
|
||||
#import, file "../../src/practices/sun_salutation/sun_salutation_rules.zi";
|
||||
#import, file "workout_moves.zi";
|
||||
|
||||
SUN_SALUTATION_FRONT_YAW :: 0.0
|
||||
SUN_SALUTATION_SIDE_YAW :: -90.0
|
||||
SUN_SALUTATION_STANDING_SPAN :: 1.3
|
||||
SUN_SALUTATION_FLOOR_SPAN :: 2.2
|
||||
SUN_SALUTATION_STANDING_CENTER :: 0.25
|
||||
SUN_SALUTATION_FLOOR_CENTER :: -0.08
|
||||
|
||||
SunSalutationView :: struct {
|
||||
yaw: float64
|
||||
span: float64
|
||||
center: float64
|
||||
}
|
||||
|
||||
// The Jade woman of Tai Chi and the workout in the chosen Auburn Dawn
|
||||
// colours (design/sun-salutation/face-redesign): fair skin, auburn hair and
|
||||
// a natural face.
|
||||
SunSalutationWomanLook :: () -> TaiChiFlatLook {
|
||||
look := TaiChiFlatLookNamed("jadeWoman")
|
||||
look.skin = 0xf7c4a3
|
||||
look.hair = 0x7c3a24
|
||||
look.features = 0x3a2119
|
||||
look.mouth = 0xd9937c
|
||||
look.blush = 0xf0a08a
|
||||
look.blush_alpha = 0.3
|
||||
// The band round her bun is a darker auburn, not a bright tie.
|
||||
look.accent = 0x5a2818
|
||||
// A fitted top without a flared hem, slim sleeves and trousers over
|
||||
// rounded hips, and finer hands and feet.
|
||||
TaiChiFlatJacket(*look, 0.112, 0.106, 0.09, 0.097, 0.1, 0.07, 0.062, 0.071, 0.006)
|
||||
look.jacket_from = look.jacket[0][0]
|
||||
look.limbs = 0.92
|
||||
look.glutes = true
|
||||
look.hand_size = 0.92
|
||||
look.foot_length = 0.85
|
||||
look.foot_depth = 0.8
|
||||
return look
|
||||
}
|
||||
|
||||
SunSalutationStepView :: (step: s32) -> SunSalutationView {
|
||||
view := SunSalutationView.{.yaw = SUN_SALUTATION_SIDE_YAW, .span = SUN_SALUTATION_FLOOR_SPAN,
|
||||
.center = SUN_SALUTATION_FLOOR_CENTER}
|
||||
// Only the prayer faces the viewer; the camera turns while she stands
|
||||
// tall, never while she is bent and the inside of her top would show.
|
||||
if step == 0 || step == SUN_SALUTATION_STEP_COUNT - 1 {
|
||||
view.yaw = SUN_SALUTATION_FRONT_YAW
|
||||
}
|
||||
if step <= 2 || step >= SUN_SALUTATION_STEP_COUNT - 3 {
|
||||
view.span = SUN_SALUTATION_STANDING_SPAN
|
||||
view.center = SUN_SALUTATION_STANDING_CENTER
|
||||
}
|
||||
return view
|
||||
}
|
||||
|
||||
SunSalutationViewAt :: (state: SunSalutationPracticeState) -> SunSalutationView {
|
||||
to := SunSalutationStepView(state.step)
|
||||
if state.step <= 0 {
|
||||
return to
|
||||
}
|
||||
from := SunSalutationStepView(state.step - 1)
|
||||
amount := SunSalutationTransition(state)
|
||||
return SunSalutationView.{.yaw = from.yaw + (to.yaw - from.yaw) * amount,
|
||||
.span = from.span + (to.span - from.span) * amount,
|
||||
.center = from.center + (to.center - from.center) * amount}
|
||||
}
|
||||
|
||||
// The app and exported video use the same pose, illustration and camera.
|
||||
SunSalutationPaintPose :: (frame: *TaiChiFlatFrame, character: s32, pose: WorkoutPose,
|
||||
view: SunSalutationView, width: float64, height: float64) -> TaiChiFraming {
|
||||
rig := WorkoutRig()
|
||||
solved := WorkoutSolve(*pose, *rig)
|
||||
look := TaiChiFlatLookNamed("indigoMan")
|
||||
if character == SUN_SALUTATION_MAN {
|
||||
look.plain_top = true
|
||||
} else {
|
||||
look = SunSalutationWomanLook()
|
||||
}
|
||||
framing: TaiChiFraming
|
||||
framing.camera.yaw = view.yaw * TAI_CHI_DEGREE
|
||||
framing.camera.tilt = 6.0 * TAI_CHI_DEGREE
|
||||
framing.camera.center = TaiChiV3(0.0, 0.0, view.center)
|
||||
framing.view_height = 2.35
|
||||
framing.view_center = 1.02
|
||||
across := framing.view_height * width / height
|
||||
if across < view.span {
|
||||
framing.view_height *= view.span / across
|
||||
}
|
||||
TaiChiFlatPaintLook(frame, *solved, *rig, look, framing.camera)
|
||||
return framing
|
||||
}
|
||||
@@ -32,6 +32,9 @@ WorkoutHand :: struct {
|
||||
pole: TaiChiVector3
|
||||
// 1 lays the hand flat on what it rests on, fingers ahead.
|
||||
flat: float64
|
||||
// 1 stands the hand upright, fingers up and the palm toward her middle,
|
||||
// as when the palms press together in prayer.
|
||||
upright: float64
|
||||
}
|
||||
|
||||
WorkoutPose :: struct {
|
||||
@@ -492,6 +495,7 @@ WorkoutBlend :: (a: *WorkoutPose, b: *WorkoutPose, u: float64, rig: *TaiChiRig)
|
||||
to := b.hands[side]
|
||||
pose.hands[side].pole = TaiChiLerp3(from.pole, to.pole, u)
|
||||
pose.hands[side].flat = from.flat + (to.flat - from.flat) * u
|
||||
pose.hands[side].upright = from.upright + (to.upright - from.upright) * u
|
||||
if from.mode == to.mode {
|
||||
pose.hands[side].at = TaiChiLerp3(from.at, to.at, u)
|
||||
} else {
|
||||
@@ -657,6 +661,12 @@ WorkoutSolve :: (pose: *WorkoutPose, rig: *TaiChiRig) -> TaiChiSolved {
|
||||
ahead := TaiChiForwardOf(pose.yaw * TAI_CHI_DEGREE)
|
||||
fingers := TaiChiNormalize3(TaiChiLerp3(along, ahead, hand.flat))
|
||||
palm := TaiChiNormalize3(TaiChiLerp3(inward, TaiChiV3(0.0, -1.0, 0.0), hand.flat))
|
||||
if hand.upright > 0.0 {
|
||||
up := TaiChiAxis(trunk.chest_quat, 0.0, 1.0, 0.0)
|
||||
middle := TaiChiRotate(TaiChiV3(-sign, 0.0, 0.0), trunk.chest_quat)
|
||||
fingers = TaiChiNormalize3(TaiChiLerp3(fingers, up, hand.upright))
|
||||
palm = TaiChiNormalize3(TaiChiLerp3(palm, middle, hand.upright))
|
||||
}
|
||||
hand_quat := TaiChiFrameQuat(TaiChiScale3(fingers, -1.0), palm, inward, true)
|
||||
solved.hand_quats[side] = hand_quat
|
||||
solved.palms[side] = TaiChiAddScaled3(TaiChiAddScaled3(arm.end, fingers, rig.palm_offset), palm, 0.008 * rig.height)
|
||||
|
||||
@@ -104,6 +104,12 @@ sun-salutation-pose-test: $(ZI2C_BIN)
|
||||
|
||||
test: sun-salutation-pose-test
|
||||
|
||||
.PHONY: sun-salutation-artwork-test
|
||||
sun-salutation-artwork-test: $(ZI2C_BIN)
|
||||
sh tests/practice_figure_test.sh $(ZIRAN_BUILD_DIR)/bin tests/sun_salutation_artwork_behavior.zi
|
||||
|
||||
test: sun-salutation-artwork-test
|
||||
|
||||
practice-narration-keys-test:
|
||||
python3 tests/practice_narration_keys_test.py
|
||||
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Render the player's actual Sun Salutation artwork and poses, offscreen.
|
||||
|
||||
Default: two complete rounds, including both leading legs, at 1536x1024/30fps.
|
||||
No desktop capture or browser is involved. Native Ziran supplies the same
|
||||
paint operations, pose solver, timing and framing as the app.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import ctypes
|
||||
import math
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
import cairo
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
BUILD = ROOT / "build/sun-salutation-auburn"
|
||||
|
||||
|
||||
class Point(ctypes.Structure):
|
||||
_fields_ = [("x", ctypes.c_double), ("y", ctypes.c_double)]
|
||||
|
||||
|
||||
class Operation(ctypes.Structure):
|
||||
_fields_ = [
|
||||
("kind", ctypes.c_int32), ("color", ctypes.c_uint32),
|
||||
("alpha", ctypes.c_double), ("width", ctypes.c_double),
|
||||
("first", ctypes.c_int32), ("count", ctypes.c_int32),
|
||||
]
|
||||
|
||||
|
||||
class Frame(ctypes.Structure):
|
||||
_fields_ = [
|
||||
("ops", Operation * 512), ("op_count", ctypes.c_int32),
|
||||
("points", Point * 16384), ("point_count", ctypes.c_int32),
|
||||
]
|
||||
|
||||
|
||||
def compile_renderer():
|
||||
generated = BUILD / "c"
|
||||
if generated.exists():
|
||||
shutil.rmtree(generated)
|
||||
generated.mkdir(parents=True, exist_ok=True)
|
||||
subprocess.run(["make", "build-laws"], cwd=ROOT, check=True)
|
||||
subprocess.run([
|
||||
str(ROOT / "build/ziran-toolchain/bin/zi2c"), "--no-main", "--root", "scripts",
|
||||
"--module-path", "src", "--module-path", "build/packages/ziran/std",
|
||||
"-o", str(generated), "scripts/sun_salutation_preview.zi",
|
||||
], cwd=ROOT, check=True)
|
||||
library = BUILD / "preview.so"
|
||||
subprocess.run([
|
||||
os.environ.get("CC", "cc"), "-std=c11", "-O2", "-shared", "-fPIC",
|
||||
"-I" + str(ROOT / "build/packages/ziran/include"), "-I" + str(generated),
|
||||
*map(str, sorted(generated.glob("*.c"))),
|
||||
str(ROOT / "build/ziran-toolchain/libziran.a"), "-lm", "-lz", "-o", str(library),
|
||||
], cwd=ROOT, check=True)
|
||||
return library
|
||||
|
||||
|
||||
class Renderer:
|
||||
def __init__(self, width, height):
|
||||
self.width = width
|
||||
self.height = height
|
||||
self.native = ctypes.CDLL(str(compile_renderer()))
|
||||
self.native.PreviewFrame.argtypes = [ctypes.c_double, ctypes.c_int32, ctypes.c_int32]
|
||||
self.native.PreviewFrame.restype = ctypes.POINTER(Frame)
|
||||
for name in ("PreviewDuration", "PreviewHeight", "PreviewCenter"):
|
||||
function = getattr(self.native, name)
|
||||
function.argtypes = []
|
||||
function.restype = ctypes.c_double
|
||||
self.duration = self.native.PreviewDuration()
|
||||
self.surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
|
||||
self.context = cairo.Context(self.surface)
|
||||
|
||||
def frame(self, second):
|
||||
frame = self.native.PreviewFrame(second, self.width, self.height).contents
|
||||
if not 0 < frame.op_count < 512 or not 0 < frame.point_count < 16384:
|
||||
raise RuntimeError(f"Paint capacity exceeded at {second:.3f}s")
|
||||
scale = self.height / self.native.PreviewHeight()
|
||||
center = self.native.PreviewCenter()
|
||||
context = self.context
|
||||
context.set_source_rgb(0.9725, 0.9647, 0.9451)
|
||||
context.paint()
|
||||
for operation in frame.ops[:frame.op_count]:
|
||||
points = []
|
||||
for point in frame.points[operation.first:operation.first + operation.count]:
|
||||
if not math.isfinite(point.x) or not math.isfinite(point.y):
|
||||
raise RuntimeError(f"Non-finite geometry at {second:.3f}s")
|
||||
points.append((self.width / 2 + point.x * scale,
|
||||
self.height / 2 - (point.y - center) * scale))
|
||||
context.new_path()
|
||||
for index, point in enumerate(points):
|
||||
if index == 0:
|
||||
context.move_to(*point)
|
||||
else:
|
||||
context.line_to(*point)
|
||||
color = operation.color
|
||||
context.set_source_rgba(((color >> 16) & 255) / 255,
|
||||
((color >> 8) & 255) / 255,
|
||||
(color & 255) / 255, operation.alpha)
|
||||
if operation.kind == 0:
|
||||
context.close_path()
|
||||
context.fill()
|
||||
else:
|
||||
context.set_line_width(max(operation.width * scale, 1.2) * 1.5)
|
||||
context.set_line_cap(cairo.LINE_CAP_ROUND)
|
||||
context.set_line_join(cairo.LINE_JOIN_ROUND)
|
||||
context.stroke()
|
||||
self.surface.flush()
|
||||
return self.surface.get_data()
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--output", type=Path, default=BUILD / "auburn-dawn-full.mp4")
|
||||
parser.add_argument("--width", type=int, default=1536)
|
||||
parser.add_argument("--height", type=int, default=1024)
|
||||
parser.add_argument("--fps", type=int, default=30)
|
||||
parser.add_argument("--still", type=float, action="append")
|
||||
parser.add_argument("--review", action="store_true", help="save review poses before the complete video")
|
||||
options = parser.parse_args()
|
||||
if options.width <= 0 or options.height <= 0 or options.fps <= 0:
|
||||
parser.error("Width, height and frame rate must be positive")
|
||||
if not options.still and (options.width % 2 or options.height % 2):
|
||||
parser.error("H.264 dimensions must be even")
|
||||
renderer = Renderer(options.width, options.height)
|
||||
options.output.parent.mkdir(parents=True, exist_ok=True)
|
||||
if options.still or options.review:
|
||||
for second in options.still or [0, 11, 41]:
|
||||
renderer.frame(second)
|
||||
target = options.output.with_name(f"{options.output.stem}-{second:g}.png")
|
||||
renderer.surface.write_to_png(str(target))
|
||||
print(target, flush=True)
|
||||
if options.still:
|
||||
return
|
||||
encoder = subprocess.Popen([
|
||||
"ffmpeg", "-hide_banner", "-loglevel", "error", "-nostdin", "-y",
|
||||
"-f", "rawvideo", "-pixel_format", "bgra",
|
||||
"-video_size", f"{options.width}x{options.height}",
|
||||
"-framerate", str(options.fps), "-i", "pipe:0", "-an",
|
||||
"-c:v", "libx264", "-crf", "18", "-preset", "medium", "-threads", "4",
|
||||
"-pix_fmt", "yuv420p", "-movflags", "+faststart", str(options.output),
|
||||
], stdin=subprocess.PIPE)
|
||||
try:
|
||||
for index in range(round(renderer.duration * options.fps)):
|
||||
encoder.stdin.write(renderer.frame(index / options.fps))
|
||||
if index % (options.fps * 10) == 0:
|
||||
print(f"Rendered {index / options.fps:.0f}/{renderer.duration:.0f}s", flush=True)
|
||||
finally:
|
||||
encoder.stdin.close()
|
||||
if encoder.wait() != 0:
|
||||
raise RuntimeError("Video encoding failed")
|
||||
print(f"Saved {options.output}", flush=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,43 @@
|
||||
// Offscreen entry for the same renderer and artwork used by the player.
|
||||
#import, file "../apps/practice/sun_salutation_artwork.zi";
|
||||
#import, file "../apps/practice/workout_moves.zi";
|
||||
#import, file "../src/practices/sun_salutation/sun_salutation_pose.zi";
|
||||
#import, file "../src/practices/sun_salutation/sun_salutation_rules.zi";
|
||||
#import, file "../src/practices/tai_chi/tai_chi_flat.zi";
|
||||
#import, file "../src/practices/tai_chi/tai_chi_rules.zi";
|
||||
|
||||
preview_frame: TaiChiFlatFrame;
|
||||
preview_framing: TaiChiFraming;
|
||||
|
||||
PreviewState :: () -> SunSalutationPracticeState {
|
||||
state: SunSalutationPracticeState
|
||||
state.repetitions = 2
|
||||
state.start_seconds = 6
|
||||
state.end_seconds = 6
|
||||
return SalutationStart(state)
|
||||
}
|
||||
|
||||
#program_export
|
||||
PreviewDuration :: () -> float64 {
|
||||
return cast(float64)SalutationDurationSeconds(PreviewState())
|
||||
}
|
||||
|
||||
#program_export
|
||||
PreviewFrame :: (second: float64, width: s32, height: s32) -> *TaiChiFlatFrame {
|
||||
state := SalutationAdvance(PreviewState(), second).state
|
||||
rig := WorkoutRig()
|
||||
pose := SunSalutationPoseAt(state, *rig)
|
||||
preview_framing = SunSalutationPaintPose(*preview_frame, state.character, pose, SunSalutationViewAt(state),
|
||||
cast(float64)width, cast(float64)height)
|
||||
return *preview_frame
|
||||
}
|
||||
|
||||
#program_export
|
||||
PreviewHeight :: () -> float64 {
|
||||
return preview_framing.view_height
|
||||
}
|
||||
|
||||
#program_export
|
||||
PreviewCenter :: () -> float64 {
|
||||
return preview_framing.view_center
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
#import, file "sun_salutation_pose.zi";
|
||||
#import, file "sun_salutation_rules.zi";
|
||||
#import, file "../../../apps/practice/workout_moves.zi";
|
||||
#import, file "../../../apps/practice/sun_salutation_artwork.zi";
|
||||
#import, file "../tai_chi/tai_chi_math.zi";
|
||||
#import, file "../tai_chi/tai_chi_solve.zi";
|
||||
#import, file "../tai_chi/tai_chi_flat.zi";
|
||||
@@ -11,55 +12,8 @@
|
||||
#import, file "../tai_chi/tai_chi_view.zi";
|
||||
|
||||
SUN_SALUTATION_EDGE_PATH :: "assets/practices/sunsalutation/flat-edge.png"
|
||||
// Camera turns in degrees, as in the classic sequence charts: prayer and the
|
||||
// last upward salute face the viewer, and every other pose is seen from the
|
||||
// side so the angles of the back, arms and legs read clearly.
|
||||
SUN_SALUTATION_FRONT_YAW :: 0.0
|
||||
SUN_SALUTATION_SIDE_YAW :: -90.0
|
||||
// The width in metres the view keeps clear: standing poses fill the page, and
|
||||
// the view widens for the poses on the floor.
|
||||
SUN_SALUTATION_STANDING_SPAN :: 1.3
|
||||
SUN_SALUTATION_FLOOR_SPAN :: 2.2
|
||||
// Where along the mat the view is centred, in metres forward: on her when
|
||||
// she stands, and between her hands and feet when she is on the floor.
|
||||
SUN_SALUTATION_STANDING_CENTER :: 0.25
|
||||
SUN_SALUTATION_FLOOR_CENTER :: -0.08
|
||||
sun_salutation_figure: TaiChiFlatFrame;
|
||||
|
||||
// Where the camera stands for a pose: its turn in degrees and the width it
|
||||
// keeps in view.
|
||||
SunSalutationView :: struct {
|
||||
yaw: float64
|
||||
span: float64
|
||||
center: float64
|
||||
}
|
||||
|
||||
SunSalutationStepView :: (step: s32) -> SunSalutationView {
|
||||
view := SunSalutationView.{.yaw = SUN_SALUTATION_SIDE_YAW, .span = SUN_SALUTATION_FLOOR_SPAN,
|
||||
.center = SUN_SALUTATION_FLOOR_CENTER}
|
||||
if step == 0 || step == SUN_SALUTATION_STEP_COUNT - 2 || step == SUN_SALUTATION_STEP_COUNT - 1 {
|
||||
view.yaw = SUN_SALUTATION_FRONT_YAW
|
||||
}
|
||||
if step <= 2 || step >= SUN_SALUTATION_STEP_COUNT - 3 {
|
||||
view.span = SUN_SALUTATION_STANDING_SPAN
|
||||
view.center = SUN_SALUTATION_STANDING_CENTER
|
||||
}
|
||||
return view
|
||||
}
|
||||
|
||||
// The camera turns and widens with the move into each step.
|
||||
SunSalutationViewAt :: (state: SunSalutationPracticeState) -> SunSalutationView {
|
||||
to := SunSalutationStepView(state.step)
|
||||
if state.step <= 0 {
|
||||
return to
|
||||
}
|
||||
from := SunSalutationStepView(state.step - 1)
|
||||
amount := SunSalutationTransition(state)
|
||||
return SunSalutationView.{.yaw = from.yaw + (to.yaw - from.yaw) * amount,
|
||||
.span = from.span + (to.span - from.span) * amount,
|
||||
.center = from.center + (to.center - from.center) * amount}
|
||||
}
|
||||
|
||||
SunSalutationDrawState :: (session: Session, state: SunSalutationPracticeState,
|
||||
area: Rectangle, key: u64, alt_text: string) {
|
||||
rig := WorkoutRig()
|
||||
@@ -79,22 +33,8 @@ SunSalutationDrawPose :: (session: Session, character: s32, pose: WorkoutPose, v
|
||||
if area.width <= 0.0 || area.height <= 0.0 {
|
||||
return
|
||||
}
|
||||
rig := WorkoutRig()
|
||||
solved := WorkoutSolve(*pose, *rig)
|
||||
framing: TaiChiFraming
|
||||
framing.camera.yaw = view.yaw * TAI_CHI_DEGREE
|
||||
framing.camera.tilt = 6.0 * TAI_CHI_DEGREE
|
||||
framing.camera.center = TaiChiV3(0.0, 0.0, view.center)
|
||||
framing.view_height = 2.35
|
||||
framing.view_center = 1.02
|
||||
across := framing.view_height * cast(float64)area.width / cast(float64)area.height
|
||||
if across < view.span {
|
||||
framing.view_height *= view.span / across
|
||||
}
|
||||
look := TaiChiFlatLookNamed(ifx character == SUN_SALUTATION_MAN then "indigoMan" else "jadeWoman")
|
||||
// His top is a plain sweater, as in the classic sequence charts.
|
||||
look.plain_top = character == SUN_SALUTATION_MAN
|
||||
TaiChiFlatPaintLook(*sun_salutation_figure, *solved, *rig, look, framing.camera)
|
||||
framing := SunSalutationPaintPose(*sun_salutation_figure, character, pose, view,
|
||||
cast(float64)area.width, cast(float64)area.height)
|
||||
TaiChiPaintFlatEdge(session, *sun_salutation_figure, framing, false, area, key,
|
||||
alt_text, SUN_SALUTATION_EDGE_PATH)
|
||||
}
|
||||
@@ -1,11 +1,16 @@
|
||||
// The classic sequence on the same articulated body as Tai Chi and Workout.
|
||||
// Positions preserve the original yoga choreography in metres, with +Y up
|
||||
// and +Z forward. The two lunges exchange legs on alternating rounds.
|
||||
#import "math"
|
||||
#import, file "sun_salutation_rules.zi";
|
||||
#import, file "../../../apps/practice/workout_moves.zi";
|
||||
#import, file "../tai_chi/tai_chi_math.zi";
|
||||
#import, file "../tai_chi/tai_chi_solve.zi";
|
||||
|
||||
// Hands flat on the floor, the elbows point back along the ribs and a
|
||||
// little up, never down into the floor when the chest lowers between them.
|
||||
SUN_SALUTATION_ELBOW_RISE :: 0.6
|
||||
|
||||
// A forward fold turns the pelvis through a half turn. Joint directions
|
||||
// must stay in the body's sagittal plane instead of following that turn;
|
||||
// otherwise a bent knee or elbow swings sideways through the camera.
|
||||
@@ -17,10 +22,14 @@ SunSalutationJointPlanes :: (pose: WorkoutPose) -> WorkoutPose {
|
||||
knee := TaiChiRotate(TaiChiV3(sign * 0.025, 0.0, 1.0),
|
||||
WorkoutConjugate(trunk.pelvis_quat))
|
||||
pose.knees[side] = TaiChiV3(sign * knee.x, knee.y, knee.z)
|
||||
if pose.hands[side].flat > 0.0 {
|
||||
elbow := TaiChiRotate(TaiChiV3(sign * 0.08, 0.0, -1.0),
|
||||
// As the hands come down flat the elbows turn into that plane by the
|
||||
// same share, so they never flip from one frame to the next.
|
||||
flat := pose.hands[side].flat
|
||||
if flat > 0.0 {
|
||||
elbow := TaiChiRotate(TaiChiV3(sign * 0.08, SUN_SALUTATION_ELBOW_RISE, -1.0),
|
||||
WorkoutConjugate(trunk.chest_quat))
|
||||
pose.hands[side].pole = TaiChiV3(sign * elbow.x, elbow.y, elbow.z)
|
||||
pose.hands[side].pole = TaiChiLerp3(pose.hands[side].pole,
|
||||
TaiChiV3(sign * elbow.x, elbow.y, elbow.z), flat)
|
||||
}
|
||||
}
|
||||
return pose
|
||||
@@ -29,12 +38,20 @@ SunSalutationJointPlanes :: (pose: WorkoutPose) -> WorkoutPose {
|
||||
SunSalutationPose :: (step: s32, other_side: bool) -> WorkoutPose {
|
||||
step = SalutationClamp(step, 0, SUN_SALUTATION_STEP_COUNT - 1)
|
||||
pose := WorkoutStanding()
|
||||
// Standing tall: the legs straight, just short of the rig's full reach.
|
||||
pose.pelvis.y = SUN_SALUTATION_STANDING_PELVIS
|
||||
pose.pelvis.z = 0.284
|
||||
WorkoutFeet(*pose, 0.075, 0.301, 0.0, 0.0, 0.0)
|
||||
// Prayer: palms together upright before the chest, elbows low and out,
|
||||
// so seen from the front the forearms rise to meet like a steeple.
|
||||
WorkoutHandsAt(*pose, WORKOUT_AT_WORLD, 0.012, 1.26, 0.5)
|
||||
WorkoutElbows(*pose, 0.7, -0.7, 0.1)
|
||||
pose.hands[0].upright = 1.0
|
||||
pose.hands[1].upright = 1.0
|
||||
if step != 0 && step != SUN_SALUTATION_STEP_COUNT - 1 {
|
||||
pose.hands[0].upright = 0.0
|
||||
pose.hands[1].upright = 0.0
|
||||
}
|
||||
if step == 1 {
|
||||
// On the way up the salute arches back: hips forward, chest open,
|
||||
// arms reaching up and back, eyes following the hands.
|
||||
@@ -48,59 +65,147 @@ SunSalutationPose :: (step: s32, other_side: bool) -> WorkoutPose {
|
||||
WorkoutHandsAt(*pose, WORKOUT_AT_WORLD, 0.17, 0.055, 0.447)
|
||||
WorkoutFlatHands(*pose, 1.0)
|
||||
} else if step == 3 || step == 8 {
|
||||
WorkoutBody(*pose, 0.0, 0.45, -0.086, 0.0, 63.0, 0.0, 0.0, 0.0, -70.0)
|
||||
// The back knee down, low enough over the front thigh that the hands
|
||||
// rest flat on the floor.
|
||||
WorkoutBody(*pose, 0.0, 0.45, -0.086, 0.0, 73.0, 0.0, 0.0, 0.0, -79.0)
|
||||
WorkoutHandsAt(*pose, WORKOUT_AT_WORLD, 0.17, 0.055, 0.447)
|
||||
WorkoutFlatHands(*pose, 1.0)
|
||||
WorkoutFoot(*pose, 0, 0.075, 0.301, 0.0, 0.0, 0.0)
|
||||
WorkoutFoot(*pose, 1, -0.075, -0.783, 0.0, -75.0, 0.0)
|
||||
WorkoutFoot(*pose, 1, -0.075, SUN_SALUTATION_BACK_FOOT, 0.0, -75.0, 0.0)
|
||||
if (step == 8) != other_side {
|
||||
pose = WorkoutMirror(pose)
|
||||
}
|
||||
} else if step == 4 {
|
||||
pose = WorkoutPushUp(false)
|
||||
// Plank on the same spots as the lunge and the lowering around it,
|
||||
// so nothing slides: the front foot steps back beside the other, the
|
||||
// body long with the knees just soft and the shoulders a little
|
||||
// ahead of the hands, ready to lower.
|
||||
WorkoutBody(*pose, 0.0, 0.415, 0.18, 0.0, 71.0, 0.0, 0.0, 0.0, -12.0)
|
||||
WorkoutHandsAt(*pose, WORKOUT_AT_WORLD, 0.17, 0.055, 0.447)
|
||||
WorkoutElbows(*pose, 0.55, -0.7, -0.35)
|
||||
WorkoutFlatHands(*pose, 1.0)
|
||||
WorkoutFeet(*pose, 0.075, SUN_SALUTATION_BACK_FOOT, 0.0, -75.0, 0.0)
|
||||
} else if step == 5 {
|
||||
// Shift the chest forward over the planted hands before lowering;
|
||||
// hands ahead of the chest force the elbows to point forwards.
|
||||
WorkoutBody(*pose, 0.0, 0.31, 0.094, 0.0, 116.0, 0.0, 0.0, 0.0, -96.0)
|
||||
WorkoutHandsAt(*pose, WORKOUT_AT_WORLD, 0.17, 0.055, 0.447)
|
||||
WorkoutFlatHands(*pose, 1.0)
|
||||
WorkoutFeet(*pose, 0.075, -0.783, 0.0, -75.0, 0.0)
|
||||
WorkoutFeet(*pose, 0.075, SUN_SALUTATION_BACK_FOOT, 0.0, -75.0, 0.0)
|
||||
} else if step == 6 {
|
||||
// Cobra lifts the chest high on long arms, looking ahead and up.
|
||||
WorkoutBody(*pose, 0.0, 0.14, 0.082, 0.0, 46.0, 0.0, 0.0, -14.0, -72.0)
|
||||
WorkoutBody(*pose, 0.0, 0.135, 0.042, 0.0, 46.0, 0.0, 0.0, -14.0, -72.0)
|
||||
WorkoutHandsAt(*pose, WORKOUT_AT_WORLD, 0.17, 0.055, 0.447)
|
||||
WorkoutFlatHands(*pose, 1.0)
|
||||
WorkoutFeet(*pose, 0.075, -0.774, 0.0, 0.0, 0.0)
|
||||
WorkoutFeet(*pose, 0.075, SUN_SALUTATION_BACK_FOOT + 0.009, 0.0, 0.0, 0.0)
|
||||
} else if step == 7 {
|
||||
WorkoutBody(*pose, 0.0, 0.744, -0.258, 0.0, 132.0, 0.0, 0.0, 0.0, -22.0)
|
||||
WorkoutBody(*pose, 0.0, 0.744, -0.268, 0.0, 132.0, 0.0, 0.0, 0.0, -22.0)
|
||||
WorkoutHandsAt(*pose, WORKOUT_AT_WORLD, 0.17, 0.055, 0.447)
|
||||
WorkoutFlatHands(*pose, 1.0)
|
||||
WorkoutFeet(*pose, 0.075, -0.783, 0.0, -22.0, 0.0)
|
||||
WorkoutFeet(*pose, 0.075, SUN_SALUTATION_BACK_FOOT, 0.0, -22.0, 0.0)
|
||||
}
|
||||
return SunSalutationJointPlanes(pose)
|
||||
}
|
||||
|
||||
// How far the move into the current step has come, eased: 0 as the step
|
||||
// begins and 1 once its pose is reached. The first step has no move.
|
||||
SunSalutationTransition :: (state: SunSalutationPracticeState) -> float64 {
|
||||
if state.step <= 0 {
|
||||
return 1.0
|
||||
}
|
||||
transition := SUN_SALUTATION_TRANSITION_SECONDS * 60
|
||||
// Where the feet stand on the floor from the lunge's back foot through
|
||||
// Down Dog: one spot, so they never slide between poses.
|
||||
SUN_SALUTATION_BACK_FOOT :: -0.783
|
||||
// The pelvis height that leaves her legs straight in Mountain pose.
|
||||
SUN_SALUTATION_STANDING_PELVIS :: 0.904
|
||||
// The body leads each move, the arms follow and the head comes last, as
|
||||
// shares of the move, so the figure never starts and stops as one block.
|
||||
SUN_SALUTATION_ARMS_LAG :: 0.08
|
||||
SUN_SALUTATION_HEAD_LAG :: 0.16
|
||||
// How high a stepping foot lifts at most, metres.
|
||||
SUN_SALUTATION_STEP_LIFT :: 0.12
|
||||
// On the step back into plank the hips pike up to let the front leg pass
|
||||
// under them, turning about the shoulders so the hands stay planted:
|
||||
// degrees of extra lean, and the pelvis's rise and shift back in metres.
|
||||
SUN_SALUTATION_PLANK_PIKE :: 10.0
|
||||
SUN_SALUTATION_PLANK_RISE :: 0.081
|
||||
SUN_SALUTATION_PLANK_BACK :: 0.022
|
||||
// While holding a pose the chest opens this far with each breath, degrees.
|
||||
SUN_SALUTATION_BREATH_CURL :: 2.0
|
||||
SUN_SALUTATION_BREATH_NOD :: 1.5
|
||||
|
||||
// How long the move into a step takes, in ticks.
|
||||
SunSalutationMoveTicks :: (state: SunSalutationPracticeState) -> s32 {
|
||||
transition: s32 = SUN_SALUTATION_TRANSITION_SECONDS * 60
|
||||
breath := SalutationBreathSeconds(state) * 60
|
||||
if transition > breath * 3 / 4 {
|
||||
transition = breath * 3 / 4
|
||||
}
|
||||
amount := TaiChiClamp(cast(float64)state.step_ticks / cast(float64)transition, 0.0, 1.0)
|
||||
return TaiChiSmoothstep(amount)
|
||||
return transition
|
||||
}
|
||||
|
||||
// How far the move into the current step has come: 0 as the step begins
|
||||
// and 1 once its pose is reached. The first step has no move.
|
||||
SunSalutationProgress :: (state: SunSalutationPracticeState) -> float64 {
|
||||
if state.step <= 0 {
|
||||
return 1.0
|
||||
}
|
||||
return TaiChiClamp(cast(float64)state.step_ticks / cast(float64)SunSalutationMoveTicks(state), 0.0, 1.0)
|
||||
}
|
||||
|
||||
// The same, eased; the camera turns and widens along it.
|
||||
SunSalutationTransition :: (state: SunSalutationPracticeState) -> float64 {
|
||||
return TaiChiSmoothstep(SunSalutationProgress(state))
|
||||
}
|
||||
|
||||
// How far one part of the body has come, starting `lag` into the move and
|
||||
// still arriving with the rest.
|
||||
SunSalutationPartAmount :: (progress: float64, lag: float64) -> float64 {
|
||||
return TaiChiSmoothstep(TaiChiClamp((progress - lag) / (1.0 - SUN_SALUTATION_HEAD_LAG), 0.0, 1.0))
|
||||
}
|
||||
|
||||
// Holding a pose she keeps breathing: the chest opens and the chin lifts
|
||||
// a little with each breath, from stillness to stillness, so a hold never
|
||||
// freezes her and the next move starts from rest.
|
||||
SunSalutationBreathe :: (pose: *WorkoutPose, state: SunSalutationPracticeState) {
|
||||
start := ifx state.step <= 0 then 0 else SunSalutationMoveTicks(state)
|
||||
length := SalutationStepSeconds(state) * 60 - start
|
||||
held := state.step_ticks - start
|
||||
if length <= 0 || held <= 0 || held >= length {
|
||||
return
|
||||
}
|
||||
breaths := TaiChiMax(1.0, cast(float64)((length + 120) / 240))
|
||||
swell := Sin(TAI_CHI_PI * breaths * cast(float64)held / cast(float64)length)
|
||||
swell *= swell
|
||||
pose.curl -= SUN_SALUTATION_BREATH_CURL * swell
|
||||
pose.head -= SUN_SALUTATION_BREATH_NOD * swell
|
||||
}
|
||||
|
||||
SunSalutationPoseAt :: (state: SunSalutationPracticeState, rig: *TaiChiRig) -> WorkoutPose {
|
||||
other_side := SalutationOtherSide(state)
|
||||
to := SunSalutationPose(state.step, other_side)
|
||||
if state.step <= 0 {
|
||||
SunSalutationBreathe(*to, state)
|
||||
return to
|
||||
}
|
||||
from := SunSalutationPose(state.step - 1, other_side)
|
||||
return SunSalutationJointPlanes(WorkoutBlend(*from, *to, SunSalutationTransition(state), rig))
|
||||
progress := SunSalutationProgress(state)
|
||||
body := SunSalutationPartAmount(progress, 0.0)
|
||||
pose := WorkoutBlend(*from, *to, body, rig)
|
||||
// A foot that steps to a new place lifts clear of the floor on the way,
|
||||
// highest halfway, instead of sliding along it.
|
||||
for side: cast(s32)0..1 {
|
||||
travel := TaiChiHypot(to.feet[side].x - from.feet[side].x, to.feet[side].z - from.feet[side].z)
|
||||
if travel > 0.05 {
|
||||
arc := Sin(TAI_CHI_PI * body)
|
||||
pose.feet[side].lift += TaiChiMin(SUN_SALUTATION_STEP_LIFT, travel * 0.15) * arc * arc
|
||||
}
|
||||
}
|
||||
if state.step == 4 {
|
||||
arc := Sin(TAI_CHI_PI * body)
|
||||
pose.lean += SUN_SALUTATION_PLANK_PIKE * arc * arc
|
||||
pose.pelvis.y += SUN_SALUTATION_PLANK_RISE * arc * arc
|
||||
pose.pelvis.z -= SUN_SALUTATION_PLANK_BACK * arc * arc
|
||||
}
|
||||
arms := WorkoutBlend(*from, *to, SunSalutationPartAmount(progress, SUN_SALUTATION_ARMS_LAG), rig)
|
||||
for side: cast(s32)0..1 {
|
||||
pose.hands[side] = arms.hands[side]
|
||||
}
|
||||
pose.head = WorkoutLerpAngle(from.head, to.head, SunSalutationPartAmount(progress, SUN_SALUTATION_HEAD_LAG))
|
||||
SunSalutationBreathe(*pose, state)
|
||||
return SunSalutationJointPlanes(pose)
|
||||
}
|
||||
@@ -103,6 +103,12 @@ TaiChiFlatLook :: struct {
|
||||
sash_to: [TAI_CHI_FLAT_SASH_CAPACITY]float64
|
||||
sash_color: [TAI_CHI_FLAT_SASH_CAPACITY]u32
|
||||
limbs: float64
|
||||
// Rounded buttocks that run into the thighs, rather than one ball.
|
||||
glutes: bool
|
||||
// Hand size, foot length and foot thickness as shares of the usual.
|
||||
hand_size: float64
|
||||
foot_length: float64
|
||||
foot_depth: float64
|
||||
neck: float64
|
||||
head_scale: float64
|
||||
blush_alpha: float64
|
||||
@@ -230,6 +236,9 @@ TaiChiFlatLookNamed :: (id: string) -> TaiChiFlatLook {
|
||||
look: TaiChiFlatLook
|
||||
look.collar_width = 0.006
|
||||
look.limbs = 1.0
|
||||
look.hand_size = 1.0
|
||||
look.foot_length = 1.0
|
||||
look.foot_depth = 1.0
|
||||
TaiChiFlatLegs(*look, false)
|
||||
look.accent = 0xf2a65e
|
||||
if id == "indigoMan" {
|
||||
@@ -893,14 +902,20 @@ TaiChiFlatLegFor :: (painter: *TaiChiFlatPainter, solved: *TaiChiSolved, side: s
|
||||
TaiChiFlatSphere(painter, *scratch, ankle, 0.0185 * height)
|
||||
TaiChiFlatSphere(painter, *scratch, TaiChiAddScaled3(ankle, up, 0.045 * height), 0.0175 * height)
|
||||
leg.ankle = TaiChiFlatHull(painter.frame, *scratch)
|
||||
// The bare foot: heel, ball and toes sit on the sole.
|
||||
// The bare foot: heel, ball and toes sit on the sole. A shorter foot
|
||||
// shrinks toward the sole under the ankle, which stays where it stands.
|
||||
foot_up := TaiChiAxis(solved.foot_quats[side], 0.0, 1.0, 0.0)
|
||||
toes_up := TaiChiAxis(solved.toes_quats[side], 0.0, 1.0, 0.0)
|
||||
under := TaiChiLerp3(solved.heels[side], solved.balls[side], 0.26)
|
||||
heel := TaiChiLerp3(under, solved.heels[side], look.foot_length)
|
||||
ball := TaiChiLerp3(under, solved.balls[side], look.foot_length)
|
||||
toes := TaiChiAddScaled3(ball, TaiChiSub3(solved.toes[side], solved.balls[side]), look.foot_length)
|
||||
depth := look.foot_depth * height
|
||||
scratch.count = 0
|
||||
TaiChiFlatSphere(painter, *scratch, ankle, 0.02 * height)
|
||||
TaiChiFlatSphere(painter, *scratch, TaiChiAddScaled3(solved.heels[side], foot_up, 0.019 * height), 0.019 * height)
|
||||
TaiChiFlatSphere(painter, *scratch, TaiChiAddScaled3(solved.balls[side], foot_up, 0.021 * height), 0.021 * height)
|
||||
TaiChiFlatSphere(painter, *scratch, TaiChiAddScaled3(solved.toes[side], toes_up, 0.013 * height), 0.013 * height)
|
||||
TaiChiFlatSphere(painter, *scratch, ankle, 0.02 * depth)
|
||||
TaiChiFlatSphere(painter, *scratch, TaiChiAddScaled3(heel, foot_up, 0.019 * depth), 0.019 * depth)
|
||||
TaiChiFlatSphere(painter, *scratch, TaiChiAddScaled3(ball, foot_up, 0.021 * depth), 0.021 * depth)
|
||||
TaiChiFlatSphere(painter, *scratch, TaiChiAddScaled3(toes, toes_up, 0.013 * depth), 0.013 * depth)
|
||||
leg.foot = TaiChiFlatHull(painter.frame, *scratch)
|
||||
leg.depth = (TaiChiFlatDepth(painter, hip) + TaiChiFlatDepth(painter, knee) + TaiChiFlatDepth(painter, ankle)) / 3.0
|
||||
return leg
|
||||
@@ -932,11 +947,12 @@ TaiChiFlatHand :: (painter: *TaiChiFlatPainter, solved: *TaiChiSolved, side: s32
|
||||
hook := solved.hand_shapes[side][2]
|
||||
wrist_point := solved.wrists[side]
|
||||
wrist := TaiChiFlatProject(painter, wrist_point)
|
||||
tip := TaiChiFlatProject(painter, TaiChiAddScaled3(wrist_point, fingers, painter.hand_length))
|
||||
tip := TaiChiFlatProject(painter, TaiChiAddScaled3(wrist_point, fingers,
|
||||
painter.hand_length * painter.look.hand_size))
|
||||
reach := 1.0 - 0.42 * fist - 0.25 * hook
|
||||
along := TaiChiV2((tip.x - wrist.x) * reach, (tip.y - wrist.y) * reach)
|
||||
open := TaiChiAbs(TaiChiDot3(palm_normal, painter.view.toward))
|
||||
half := (0.0125 + (0.023 - 0.0125) * open) * height * painter.look.limbs
|
||||
half := (0.0125 + (0.023 - 0.0125) * open) * height * painter.look.limbs * painter.look.hand_size
|
||||
scratch: TaiChiFlatScratch
|
||||
TaiChiFlatCircle(*scratch, wrist, half * 0.8)
|
||||
TaiChiFlatCircle(*scratch, TaiChiAdd2(wrist, TaiChiScale2(along, 0.38)), half)
|
||||
@@ -1463,10 +1479,32 @@ TaiChiFlatPaintLook :: (frame: *TaiChiFlatFrame, solved: *TaiChiSolved, rig: *Ta
|
||||
TaiChiFlatLoft(*painter, *spine, bottom, top, TAI_CHI_FLAT_CLIP_STATIONS, 0, clips[:])
|
||||
scratch: TaiChiFlatScratch
|
||||
pelvis_up := TaiChiAxis(solved.pelvis_quat, 0.0, 1.0, 0.0)
|
||||
TaiChiFlatSphere(*painter, *scratch, solved.hips[0], 0.05 * height * painter.look.limbs)
|
||||
TaiChiFlatSphere(*painter, *scratch, solved.hips[1], 0.05 * height * painter.look.limbs)
|
||||
TaiChiFlatSphere(*painter, *scratch, TaiChiAddScaled3(spine.hip_center, pelvis_up, -0.03 * height), 0.04 * height * painter.look.limbs)
|
||||
seat := TaiChiFlatHull(frame, *scratch)
|
||||
seat_k := height * painter.look.limbs
|
||||
seats: [2]TaiChiFlatShape
|
||||
seat_count: s32 = 1
|
||||
if painter.look.glutes {
|
||||
// Each buttock rounds back from its hip and on down into its own
|
||||
// thigh, so a bent hip shows a seat rather than a ball.
|
||||
pelvis_back := TaiChiAxis(solved.pelvis_quat, 0.0, 0.0, -1.0)
|
||||
for side: cast(s32)0..1 {
|
||||
hip := solved.hips[side]
|
||||
glute := TaiChiAddScaled3(TaiChiAddScaled3(hip, pelvis_back, 0.022 * height), pelvis_up, -0.03 * height)
|
||||
scratch.count = 0
|
||||
TaiChiFlatSphere(*painter, *scratch, hip, 0.05 * seat_k)
|
||||
TaiChiFlatSphere(*painter, *scratch, glute, 0.046 * seat_k)
|
||||
TaiChiFlatSphere(*painter, *scratch, TaiChiLerp3(hip, solved.knees[side], 0.3),
|
||||
painter.look.leg_thigh[1] * seat_k)
|
||||
TaiChiFlatSphere(*painter, *scratch, TaiChiAddScaled3(spine.hip_center, pelvis_up, -0.03 * height),
|
||||
0.04 * seat_k)
|
||||
seats[side] = TaiChiFlatHull(frame, *scratch)
|
||||
}
|
||||
seat_count = 2
|
||||
} else {
|
||||
TaiChiFlatSphere(*painter, *scratch, solved.hips[0], 0.05 * seat_k)
|
||||
TaiChiFlatSphere(*painter, *scratch, solved.hips[1], 0.05 * seat_k)
|
||||
TaiChiFlatSphere(*painter, *scratch, TaiChiAddScaled3(spine.hip_center, pelvis_up, -0.03 * height), 0.04 * seat_k)
|
||||
seats[0] = TaiChiFlatHull(frame, *scratch)
|
||||
}
|
||||
head := TaiChiFlatHeadFor(*painter, solved)
|
||||
scratch.count = 0
|
||||
TaiChiFlatSphere(*painter, *scratch, solved.neck_base, painter.look.neck * height)
|
||||
@@ -1481,7 +1519,9 @@ TaiChiFlatPaintLook :: (frame: *TaiChiFlatFrame, solved: *TaiChiSolved, rig: *Ta
|
||||
TaiChiFlatArmPaint(*painter, *arms[side], no_clips)
|
||||
}
|
||||
}
|
||||
TaiChiFlatFill(*painter, seat, palette.pants, 1.0)
|
||||
for index: cast(s32)0..seat_count - 1 {
|
||||
TaiChiFlatFill(*painter, seats[index], palette.pants, 1.0)
|
||||
}
|
||||
// The farther leg first.
|
||||
far_first := ifx legs[0].depth <= legs[1].depth then 0 else 1
|
||||
TaiChiFlatLegPaint(*painter, *legs[far_first])
|
||||
|
||||
@@ -35,7 +35,7 @@ FigureSound :: (pose: *WorkoutPose, rig: *TaiChiRig, exercise: s32) -> bool {
|
||||
return false
|
||||
}
|
||||
if solved.heels[side].y < -0.02 || solved.balls[side].y < -0.02 || solved.toes[side].y < -0.02 ||
|
||||
solved.knees[side].y < -0.02 || solved.wrists[side].y < -0.02 {
|
||||
solved.knees[side].y < -0.02 || solved.elbows[side].y < -0.02 || solved.wrists[side].y < -0.02 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
// Both Sun Salutation figures paint every pose of both rounds soundly.
|
||||
#import "math"
|
||||
#import, file "../apps/practice/sun_salutation_artwork.zi";
|
||||
#import, file "../apps/practice/workout_moves.zi";
|
||||
#import, file "../src/practices/sun_salutation/sun_salutation_pose.zi";
|
||||
#import, file "../src/practices/sun_salutation/sun_salutation_rules.zi";
|
||||
#import, file "../src/practices/tai_chi/tai_chi_flat.zi";
|
||||
#import, file "../src/practices/tai_chi/tai_chi_math.zi";
|
||||
|
||||
artwork_frame: TaiChiFlatFrame;
|
||||
|
||||
#program_export
|
||||
Answer :: () -> s32 {
|
||||
// The Sun Salutation woman is the Jade woman of Tai Chi and the workout:
|
||||
// the same clothes and hair, cut slimmer.
|
||||
original := TaiChiFlatLookNamed("jadeWoman")
|
||||
chosen := SunSalutationWomanLook()
|
||||
if chosen.top != original.top || chosen.pants != original.pants || chosen.cuff != original.cuff ||
|
||||
chosen.hair_style != original.hair_style || chosen.head_scale != original.head_scale {
|
||||
return 501
|
||||
}
|
||||
if !(chosen.limbs < original.limbs && chosen.jacket[7][2] < original.jacket[7][2] && chosen.glutes) {
|
||||
return 502
|
||||
}
|
||||
rig := WorkoutRig()
|
||||
state := SalutationStart(SunSalutationPracticeState.{})
|
||||
for character: cast(s32)0..1 {
|
||||
state.character = character
|
||||
for round: cast(s32)0..1 {
|
||||
state.repetition = round
|
||||
for step: cast(s32)0..11 {
|
||||
state.step = step
|
||||
for sample: cast(s32)0..12 {
|
||||
state.step_ticks = sample * 30
|
||||
pose := SunSalutationPoseAt(state, *rig)
|
||||
SunSalutationPaintPose(*artwork_frame, state.character, pose, SunSalutationViewAt(state), 1536.0, 1024.0)
|
||||
if artwork_frame.op_count < 30 || artwork_frame.op_count >= TAI_CHI_FLAT_OP_CAPACITY ||
|
||||
artwork_frame.point_count >= TAI_CHI_FLAT_POINT_CAPACITY {
|
||||
return 503
|
||||
}
|
||||
for index: cast(s32)0..artwork_frame.point_count - 1 {
|
||||
point := artwork_frame.points[index]
|
||||
if !Finite64(point.x) || !Finite64(point.y) {
|
||||
return 507
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 42
|
||||
}
|
||||
@@ -7,6 +7,18 @@
|
||||
#import, file "../src/practices/tai_chi/tai_chi_solve.zi";
|
||||
#import, file "figure_test_support.zi";
|
||||
|
||||
// The joints whose motion must stay smooth.
|
||||
SnapJoints :: (solved: *TaiChiSolved) -> [7]TaiChiVector3 {
|
||||
joints: [7]TaiChiVector3
|
||||
for side: cast(s32)0..1 {
|
||||
joints[side] = solved.elbows[side]
|
||||
joints[2 + side] = solved.wrists[side]
|
||||
joints[4 + side] = solved.knees[side]
|
||||
}
|
||||
joints[6] = solved.head_center
|
||||
return joints
|
||||
}
|
||||
|
||||
CheckMoves :: (start_seconds: s32, end_seconds: s32) -> s32 {
|
||||
rig := WorkoutRig()
|
||||
// Every transition and held pose, with alternating leading legs.
|
||||
@@ -18,7 +30,8 @@ CheckMoves :: (start_seconds: s32, end_seconds: s32) -> s32 {
|
||||
state.step = step
|
||||
state.repetition = round
|
||||
previous: TaiChiSolved
|
||||
for ticks: cast(s32)0..SUN_SALUTATION_TRANSITION_SECONDS * 60 {
|
||||
steps: [7]TaiChiVector3
|
||||
for ticks: cast(s32)0..SalutationStepSeconds(state) * 60 - 1 {
|
||||
state.step_ticks = ticks
|
||||
pose := SunSalutationPoseAt(state, *rig)
|
||||
if !FigureSound(*pose, *rig, WORKOUT_PLANK) {
|
||||
@@ -36,7 +49,11 @@ CheckMoves :: (start_seconds: s32, end_seconds: s32) -> s32 {
|
||||
TaiChiAbs(knee.x) > 0.04 {
|
||||
return 420 + step
|
||||
}
|
||||
if step == 3 && pose.feet[side].z > 0.2 {
|
||||
// The front foot stays planted while the other
|
||||
// steps back.
|
||||
planted := SunSalutationPose(step - 1, round == 1).feet[side].z ==
|
||||
SunSalutationPose(step, round == 1).feet[side].z
|
||||
if step == 3 && planted {
|
||||
ground := TaiChiMin(solved.heels[side].y,
|
||||
TaiChiMin(solved.balls[side].y, solved.toes[side].y))
|
||||
if TaiChiAbs(ground) > 0.005 {
|
||||
@@ -45,10 +62,14 @@ CheckMoves :: (start_seconds: s32, end_seconds: s32) -> s32 {
|
||||
}
|
||||
}
|
||||
if step == 5 || step == 6 {
|
||||
// Keep the elbows beside the ribs and behind the
|
||||
// hands while lowering the chest and lifting cobra.
|
||||
// Keep the elbows beside the ribs and never ahead
|
||||
// of the hands while lowering the chest and lifting
|
||||
// cobra; once clearly bent they point well back.
|
||||
reach := TaiChiDistance3(solved.shoulders[side], solved.wrists[side])
|
||||
bent := reach < 0.9 * (rig.upper_arm + rig.fore_arm)
|
||||
behind := ifx bent then 0.04 else -0.005
|
||||
if TaiChiAbs(solved.elbows[side].x - solved.shoulders[side].x) > 0.05 ||
|
||||
solved.elbows[side].z > solved.wrists[side].z - 0.04 {
|
||||
solved.elbows[side].z > solved.wrists[side].z - behind {
|
||||
return 440 + step
|
||||
}
|
||||
}
|
||||
@@ -59,8 +80,39 @@ CheckMoves :: (start_seconds: s32, end_seconds: s32) -> s32 {
|
||||
}
|
||||
}
|
||||
}
|
||||
// No joint snaps: from one tick to the next its step may
|
||||
// grow or shrink only gradually, through every move and hold,
|
||||
// never by a large share of the step itself.
|
||||
joints := SnapJoints(*solved)
|
||||
if ticks > 0 {
|
||||
before := SnapJoints(*previous)
|
||||
for index: cast(s32)0..6 {
|
||||
moved := TaiChiSub3(joints[index], before[index])
|
||||
change := TaiChiDistance3(moved, steps[index])
|
||||
largest := TaiChiMax(TaiChiLength3(moved), TaiChiLength3(steps[index]))
|
||||
if ticks > 1 && change > 0.003 && change > 0.25 * largest {
|
||||
return 470 + step
|
||||
}
|
||||
steps[index] = moved
|
||||
}
|
||||
}
|
||||
previous = solved
|
||||
}
|
||||
// Each step ends exactly where the next begins.
|
||||
if step < 11 {
|
||||
next := state
|
||||
next.step = step + 1
|
||||
next.step_ticks = 0
|
||||
next_pose := SunSalutationPoseAt(next, *rig)
|
||||
after := WorkoutSolve(*next_pose, *rig)
|
||||
end := SnapJoints(*previous)
|
||||
start := SnapJoints(*after)
|
||||
for index: cast(s32)0..6 {
|
||||
if TaiChiDistance3(end[index], start[index]) > 0.004 {
|
||||
return 490 + step
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
first_lunge := SunSalutationPose(3, false)
|
||||
|
||||
Reference in new issue
Block a user