Draw Tai Chi in Inner Breeze with the flat Jade woman and Indigo man
The app now draws the course studio's flat figures: tai_chi_flat.zi turns the solved skeleton into the same paint operations as design/tai-chi's shapes.js, and tai_chi_draw.zi draws each shape and line as a tinted image mesh over one soft-edged texture. The painted monk and Tibetan woman, their parts and the painted layout are gone; the parity test now compares every paint operation with the studio's reference. Tai Chi opens seen from the front, mirrored, and Front, Back, Side and Angled buttons under the figure change the angle; the choice is kept in the tai_chi_view setting and the course thumbnails follow it. Indigo man speaks with the male voice. The new names and labels are translated in every language, with the font subsets regenerated for their characters.
No files matched your search
|
After Width: | Height: | Size: 78 B |
|
Before Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 6.5 KiB |
|
Before Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 8.0 KiB |
|
Before Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 8.1 KiB |
|
Before Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 7.2 KiB |
|
Before Width: | Height: | Size: 7.5 KiB |
|
Before Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 7.4 KiB |
|
Before Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 8.1 KiB |
|
Before Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 7.4 KiB |
|
Before Width: | Height: | Size: 7.2 KiB |
|
Before Width: | Height: | Size: 7.8 KiB |
|
Before Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 7.2 KiB |
|
Before Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 6.2 KiB |
|
Before Width: | Height: | Size: 9.5 KiB |
|
Before Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 9.7 KiB |
|
Before Width: | Height: | Size: 9.5 KiB |
|
Before Width: | Height: | Size: 9.0 KiB |
|
Before Width: | Height: | Size: 9.6 KiB |
|
Before Width: | Height: | Size: 9.5 KiB |
|
Before Width: | Height: | Size: 9.4 KiB |
|
Before Width: | Height: | Size: 6.7 KiB |
|
Before Width: | Height: | Size: 8.5 KiB |
|
Before Width: | Height: | Size: 6.5 KiB |
|
Before Width: | Height: | Size: 6.7 KiB |
|
Before Width: | Height: | Size: 9.4 KiB |
|
Before Width: | Height: | Size: 9.5 KiB |
|
Before Width: | Height: | Size: 8.7 KiB |
|
Before Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 17 KiB |
@@ -859,7 +859,8 @@ export function createFlatShapes(look, rig) {
|
||||
for (const item of frontArms) {
|
||||
armOps(item, ops, body.clip)
|
||||
}
|
||||
return ops
|
||||
// A shape whose points all fall in a line has nothing to fill.
|
||||
return ops.filter((op) => op.kind !== 'fill' || op.points.length >= 3)
|
||||
}
|
||||
|
||||
return { paint, colors }
|
||||
|
||||
@@ -319,6 +319,9 @@ Zatažení: sedněte si zpět a stáhněte obě ruce dolů kolem břicha
|
||||
[tai_chi_text_46591ef8]
|
||||
Zahájení (druhá strana)
|
||||
---
|
||||
[tai_chi_text_467b4722]
|
||||
Indigový muž
|
||||
---
|
||||
[tai_chi_text_46bf6666]
|
||||
Přeneste váhu doprava, zvedněte levou špičku a otevřete hák
|
||||
---
|
||||
@@ -472,9 +475,6 @@ Tvary rukou
|
||||
[tai_chi_text_6471ef0a]
|
||||
Odhánění opice (druhá strana)
|
||||
---
|
||||
[tai_chi_text_664dce00]
|
||||
Tibetský mnich
|
||||
---
|
||||
[tai_chi_text_66753428]
|
||||
Kroky vzad
|
||||
---
|
||||
@@ -802,9 +802,6 @@ Sedněte si zpět, přední špička nahoru, a stáhněte ruce zpět k břichu
|
||||
[tai_chi_text_b2a8d2a1]
|
||||
Dýchejte přirozeně nosem
|
||||
---
|
||||
[tai_chi_text_b3b5932b]
|
||||
Tibetská žena
|
||||
---
|
||||
[tai_chi_text_b3e0a103]
|
||||
Hák
|
||||
---
|
||||
@@ -1078,6 +1075,9 @@ Otočte obě dlaně nahoru a oddělte je
|
||||
[tai_chi_text_eb693390]
|
||||
Otočte se doleva a vysuňte levou patu dopředu
|
||||
---
|
||||
[tai_chi_text_eb9b2fda]
|
||||
Nefritová žena
|
||||
---
|
||||
[tai_chi_text_ebb21af0]
|
||||
Celá sestava
|
||||
---
|
||||
|
||||
@@ -319,6 +319,9 @@ Rolle zurück: setz dich zurück und zieh beide Hände am Bauch vorbei nach unte
|
||||
[tai_chi_text_46591ef8]
|
||||
Eröffnung (andere Seite)
|
||||
---
|
||||
[tai_chi_text_467b4722]
|
||||
Indigoblauer Mann
|
||||
---
|
||||
[tai_chi_text_46bf6666]
|
||||
Verlagere das Gewicht nach rechts, hebe die linken Zehen und öffne den Haken
|
||||
---
|
||||
@@ -472,9 +475,6 @@ Handformen
|
||||
[tai_chi_text_6471ef0a]
|
||||
Den Affen zurückdrängen (andere Seite)
|
||||
---
|
||||
[tai_chi_text_664dce00]
|
||||
Tibetischer Mönch
|
||||
---
|
||||
[tai_chi_text_66753428]
|
||||
Rückwärtsschritte
|
||||
---
|
||||
@@ -802,9 +802,6 @@ Setz dich zurück, vordere Zehen oben, und zieh die Hände zurück zum Bauch
|
||||
[tai_chi_text_b2a8d2a1]
|
||||
Atme natürlich durch die Nase
|
||||
---
|
||||
[tai_chi_text_b3b5932b]
|
||||
Tibetische Frau
|
||||
---
|
||||
[tai_chi_text_b3e0a103]
|
||||
Haken
|
||||
---
|
||||
@@ -1078,6 +1075,9 @@ Dreh beide Handflächen nach oben und öffne sie
|
||||
[tai_chi_text_eb693390]
|
||||
Dreh nach links und setze die linke Ferse nach vorn
|
||||
---
|
||||
[tai_chi_text_eb9b2fda]
|
||||
Jadegrüne Frau
|
||||
---
|
||||
[tai_chi_text_ebb21af0]
|
||||
Ganze Form
|
||||
---
|
||||
|
||||
@@ -319,6 +319,9 @@ Roll back: sit back and draw both hands down past the belly
|
||||
[tai_chi_text_46591ef8]
|
||||
Commencing (other side)
|
||||
---
|
||||
[tai_chi_text_467b4722]
|
||||
Indigo man
|
||||
---
|
||||
[tai_chi_text_46bf6666]
|
||||
Shift the weight right, raise the left toes and open the hook
|
||||
---
|
||||
@@ -472,9 +475,6 @@ Hand shapes
|
||||
[tai_chi_text_6471ef0a]
|
||||
Repulse the Monkey (other side)
|
||||
---
|
||||
[tai_chi_text_664dce00]
|
||||
Tibetan monk
|
||||
---
|
||||
[tai_chi_text_66753428]
|
||||
Backward stepping
|
||||
---
|
||||
@@ -802,9 +802,6 @@ Sit back, front toes up, and draw the hands back to the belly
|
||||
[tai_chi_text_b2a8d2a1]
|
||||
Breathe naturally through the nose
|
||||
---
|
||||
[tai_chi_text_b3b5932b]
|
||||
Tibetan woman
|
||||
---
|
||||
[tai_chi_text_b3e0a103]
|
||||
Hook
|
||||
---
|
||||
@@ -1078,6 +1075,9 @@ Turn both palms up and separate them
|
||||
[tai_chi_text_eb693390]
|
||||
Turn left and step the left heel out to the front
|
||||
---
|
||||
[tai_chi_text_eb9b2fda]
|
||||
Jade woman
|
||||
---
|
||||
[tai_chi_text_ebb21af0]
|
||||
Full form
|
||||
---
|
||||
|
||||
@@ -319,6 +319,9 @@ Retroceso: siéntate atrás y baja ambas manos junto al vientre
|
||||
[tai_chi_text_46591ef8]
|
||||
Inicio (lado contrario)
|
||||
---
|
||||
[tai_chi_text_467b4722]
|
||||
Hombre índigo
|
||||
---
|
||||
[tai_chi_text_46bf6666]
|
||||
Pasa el peso a la derecha, levanta la punta izquierda y abre el gancho
|
||||
---
|
||||
@@ -472,9 +475,6 @@ Formas de la mano
|
||||
[tai_chi_text_6471ef0a]
|
||||
Hacer retroceder al mono (lado contrario)
|
||||
---
|
||||
[tai_chi_text_664dce00]
|
||||
Monje tibetano
|
||||
---
|
||||
[tai_chi_text_66753428]
|
||||
Pasos hacia atrás
|
||||
---
|
||||
@@ -802,9 +802,6 @@ Siéntate atrás, con la punta del pie delantero arriba, y lleva las manos al vi
|
||||
[tai_chi_text_b2a8d2a1]
|
||||
Respira con naturalidad por la nariz
|
||||
---
|
||||
[tai_chi_text_b3b5932b]
|
||||
Mujer tibetana
|
||||
---
|
||||
[tai_chi_text_b3e0a103]
|
||||
Gancho
|
||||
---
|
||||
@@ -1078,6 +1075,9 @@ Gira ambas palmas hacia arriba y sepáralas
|
||||
[tai_chi_text_eb693390]
|
||||
Gira a la izquierda y pon el talón izquierdo al frente
|
||||
---
|
||||
[tai_chi_text_eb9b2fda]
|
||||
Mujer de jade
|
||||
---
|
||||
[tai_chi_text_ebb21af0]
|
||||
Forma completa
|
||||
---
|
||||
|
||||
@@ -319,6 +319,9 @@ Roulez en arrière : asseyez-vous en arrière et ramenez les deux mains devant l
|
||||
[tai_chi_text_46591ef8]
|
||||
Commencement (autre côté)
|
||||
---
|
||||
[tai_chi_text_467b4722]
|
||||
Homme indigo
|
||||
---
|
||||
[tai_chi_text_46bf6666]
|
||||
Transférez le poids à droite, relevez les orteils gauches et ouvrez le crochet
|
||||
---
|
||||
@@ -472,9 +475,6 @@ Formes de la main
|
||||
[tai_chi_text_6471ef0a]
|
||||
Repousser le singe (autre côté)
|
||||
---
|
||||
[tai_chi_text_664dce00]
|
||||
Moine tibétain
|
||||
---
|
||||
[tai_chi_text_66753428]
|
||||
Pas en arrière
|
||||
---
|
||||
@@ -802,9 +802,6 @@ Asseyez-vous en arrière, orteils avant relevés, et ramenez les mains vers le v
|
||||
[tai_chi_text_b2a8d2a1]
|
||||
Respirez naturellement par le nez
|
||||
---
|
||||
[tai_chi_text_b3b5932b]
|
||||
Femme tibétaine
|
||||
---
|
||||
[tai_chi_text_b3e0a103]
|
||||
Crochet
|
||||
---
|
||||
@@ -1078,6 +1075,9 @@ Tournez les deux paumes vers le haut et écartez-les
|
||||
[tai_chi_text_eb693390]
|
||||
Tournez à gauche et avancez le talon gauche
|
||||
---
|
||||
[tai_chi_text_eb9b2fda]
|
||||
Femme jade
|
||||
---
|
||||
[tai_chi_text_ebb21af0]
|
||||
Forme complète
|
||||
---
|
||||
|
||||
@@ -319,6 +319,9 @@ Tarik mundur: duduk ke belakang dan turunkan kedua tangan melewati perut
|
||||
[tai_chi_text_46591ef8]
|
||||
Pembukaan (sisi lain)
|
||||
---
|
||||
[tai_chi_text_467b4722]
|
||||
Laki-laki nila
|
||||
---
|
||||
[tai_chi_text_46bf6666]
|
||||
Pindahkan berat badan ke kanan, angkat ujung kaki kiri, dan buka kait
|
||||
---
|
||||
@@ -472,9 +475,6 @@ Bentuk tangan
|
||||
[tai_chi_text_6471ef0a]
|
||||
Mengusir monyet (sisi lain)
|
||||
---
|
||||
[tai_chi_text_664dce00]
|
||||
Biksu Tibet
|
||||
---
|
||||
[tai_chi_text_66753428]
|
||||
Melangkah mundur
|
||||
---
|
||||
@@ -802,9 +802,6 @@ Duduk ke belakang, ujung kaki depan terangkat, dan tarik kedua tangan ke perut
|
||||
[tai_chi_text_b2a8d2a1]
|
||||
Bernapas secara alami lewat hidung
|
||||
---
|
||||
[tai_chi_text_b3b5932b]
|
||||
Perempuan Tibet
|
||||
---
|
||||
[tai_chi_text_b3e0a103]
|
||||
Kait
|
||||
---
|
||||
@@ -1078,6 +1075,9 @@ Putar kedua telapak ke atas dan pisahkan
|
||||
[tai_chi_text_eb693390]
|
||||
Putar ke kiri dan julurkan tumit kiri ke depan
|
||||
---
|
||||
[tai_chi_text_eb9b2fda]
|
||||
Perempuan giok
|
||||
---
|
||||
[tai_chi_text_ebb21af0]
|
||||
Rangkaian lengkap
|
||||
---
|
||||
|
||||
@@ -319,6 +319,9 @@ Tirare indietro: siediti indietro e porta entrambe le mani giù accanto al ventr
|
||||
[tai_chi_text_46591ef8]
|
||||
Inizio (lato opposto)
|
||||
---
|
||||
[tai_chi_text_467b4722]
|
||||
Uomo indaco
|
||||
---
|
||||
[tai_chi_text_46bf6666]
|
||||
Sposta il peso a destra, solleva la punta sinistra e apri il gancio
|
||||
---
|
||||
@@ -472,9 +475,6 @@ Forme della mano
|
||||
[tai_chi_text_6471ef0a]
|
||||
Respingere la scimmia (lato opposto)
|
||||
---
|
||||
[tai_chi_text_664dce00]
|
||||
Monaco tibetano
|
||||
---
|
||||
[tai_chi_text_66753428]
|
||||
Passi indietro
|
||||
---
|
||||
@@ -802,9 +802,6 @@ Siediti indietro, punta del piede avanti in alto, e porta le mani indietro al ve
|
||||
[tai_chi_text_b2a8d2a1]
|
||||
Respira naturalmente dal naso
|
||||
---
|
||||
[tai_chi_text_b3b5932b]
|
||||
Donna tibetana
|
||||
---
|
||||
[tai_chi_text_b3e0a103]
|
||||
Gancio
|
||||
---
|
||||
@@ -1078,6 +1075,9 @@ Ruota entrambi i palmi verso l'alto e separali
|
||||
[tai_chi_text_eb693390]
|
||||
Ruota a sinistra e porta il tallone sinistro in avanti
|
||||
---
|
||||
[tai_chi_text_eb9b2fda]
|
||||
Donna di giada
|
||||
---
|
||||
[tai_chi_text_ebb21af0]
|
||||
Forma completa
|
||||
---
|
||||
|
||||
@@ -319,6 +319,9 @@
|
||||
[tai_chi_text_46591ef8]
|
||||
起勢(反対側)
|
||||
---
|
||||
[tai_chi_text_467b4722]
|
||||
藍色の男性
|
||||
---
|
||||
[tai_chi_text_46bf6666]
|
||||
体重を右へ移し、左のつま先を上げて勾手を開く
|
||||
---
|
||||
@@ -472,9 +475,6 @@
|
||||
[tai_chi_text_6471ef0a]
|
||||
倒巻肱(反対側)
|
||||
---
|
||||
[tai_chi_text_664dce00]
|
||||
チベットの僧
|
||||
---
|
||||
[tai_chi_text_66753428]
|
||||
後退の歩法
|
||||
---
|
||||
@@ -802,9 +802,6 @@
|
||||
[tai_chi_text_b2a8d2a1]
|
||||
鼻から自然に呼吸する
|
||||
---
|
||||
[tai_chi_text_b3b5932b]
|
||||
チベットの女性
|
||||
---
|
||||
[tai_chi_text_b3e0a103]
|
||||
勾手
|
||||
---
|
||||
@@ -1078,6 +1075,9 @@
|
||||
[tai_chi_text_eb693390]
|
||||
左へ回り、左のかかとを前へ出す
|
||||
---
|
||||
[tai_chi_text_eb9b2fda]
|
||||
翡翠の女性
|
||||
---
|
||||
[tai_chi_text_ebb21af0]
|
||||
全体の形
|
||||
---
|
||||
|
||||
@@ -319,6 +319,9 @@
|
||||
[tai_chi_text_46591ef8]
|
||||
기세 (반대쪽)
|
||||
---
|
||||
[tai_chi_text_467b4722]
|
||||
남색 남성
|
||||
---
|
||||
[tai_chi_text_46bf6666]
|
||||
체중을 오른쪽으로 옮기고 왼발끝을 들며 구수를 펴세요
|
||||
---
|
||||
@@ -472,9 +475,6 @@
|
||||
[tai_chi_text_6471ef0a]
|
||||
도권굉 (반대쪽)
|
||||
---
|
||||
[tai_chi_text_664dce00]
|
||||
티베트 승려
|
||||
---
|
||||
[tai_chi_text_66753428]
|
||||
뒤로 걷기
|
||||
---
|
||||
@@ -802,9 +802,6 @@
|
||||
[tai_chi_text_b2a8d2a1]
|
||||
코로 자연스럽게 호흡하세요
|
||||
---
|
||||
[tai_chi_text_b3b5932b]
|
||||
티베트 여인
|
||||
---
|
||||
[tai_chi_text_b3e0a103]
|
||||
구수
|
||||
---
|
||||
@@ -1078,6 +1075,9 @@
|
||||
[tai_chi_text_eb693390]
|
||||
왼쪽으로 돌며 왼발뒤꿈치를 앞으로 내딛으세요
|
||||
---
|
||||
[tai_chi_text_eb9b2fda]
|
||||
비취색 여성
|
||||
---
|
||||
[tai_chi_text_ebb21af0]
|
||||
전체 투로
|
||||
---
|
||||
|
||||
@@ -319,6 +319,9 @@ Recuar: sente-se para trás e traga as duas mãos para baixo, passando pela barr
|
||||
[tai_chi_text_46591ef8]
|
||||
Início (outro lado)
|
||||
---
|
||||
[tai_chi_text_467b4722]
|
||||
Homem índigo
|
||||
---
|
||||
[tai_chi_text_46bf6666]
|
||||
Passe o peso para a direita, levante os dedos do pé esquerdo e abra o gancho
|
||||
---
|
||||
@@ -472,9 +475,6 @@ Formas das mãos
|
||||
[tai_chi_text_6471ef0a]
|
||||
Repelir o macaco (outro lado)
|
||||
---
|
||||
[tai_chi_text_664dce00]
|
||||
Monge tibetano
|
||||
---
|
||||
[tai_chi_text_66753428]
|
||||
Passos para trás
|
||||
---
|
||||
@@ -802,9 +802,6 @@ Sente-se para trás, dedos da frente para cima, e traga as mãos de volta à bar
|
||||
[tai_chi_text_b2a8d2a1]
|
||||
Respire naturalmente pelo nariz
|
||||
---
|
||||
[tai_chi_text_b3b5932b]
|
||||
Mulher tibetana
|
||||
---
|
||||
[tai_chi_text_b3e0a103]
|
||||
Gancho
|
||||
---
|
||||
@@ -1078,6 +1075,9 @@ Vire as duas palmas para cima e separe-as
|
||||
[tai_chi_text_eb693390]
|
||||
Gire para a esquerda e leve o calcanhar esquerdo para a frente
|
||||
---
|
||||
[tai_chi_text_eb9b2fda]
|
||||
Mulher de jade
|
||||
---
|
||||
[tai_chi_text_ebb21af0]
|
||||
Forma completa
|
||||
---
|
||||
|
||||
@@ -319,6 +319,9 @@
|
||||
[tai_chi_text_46591ef8]
|
||||
Начало (другая сторона)
|
||||
---
|
||||
[tai_chi_text_467b4722]
|
||||
Мужчина в индиго
|
||||
---
|
||||
[tai_chi_text_46bf6666]
|
||||
Перенесите вес вправо, поднимите левый носок и раскройте крюк
|
||||
---
|
||||
@@ -472,9 +475,6 @@
|
||||
[tai_chi_text_6471ef0a]
|
||||
Отгонять обезьяну (другая сторона)
|
||||
---
|
||||
[tai_chi_text_664dce00]
|
||||
Тибетский монах
|
||||
---
|
||||
[tai_chi_text_66753428]
|
||||
Шаги назад
|
||||
---
|
||||
@@ -802,9 +802,6 @@
|
||||
[tai_chi_text_b2a8d2a1]
|
||||
Дышите естественно через нос
|
||||
---
|
||||
[tai_chi_text_b3b5932b]
|
||||
Тибетская женщина
|
||||
---
|
||||
[tai_chi_text_b3e0a103]
|
||||
Крюк
|
||||
---
|
||||
@@ -1078,6 +1075,9 @@
|
||||
[tai_chi_text_eb693390]
|
||||
Повернитесь влево и выставите левую пятку вперёд
|
||||
---
|
||||
[tai_chi_text_eb9b2fda]
|
||||
Женщина в нефритовом
|
||||
---
|
||||
[tai_chi_text_ebb21af0]
|
||||
Весь комплекс
|
||||
---
|
||||
|
||||
@@ -319,6 +319,9 @@
|
||||
[tai_chi_text_46591ef8]
|
||||
起势(另一侧)
|
||||
---
|
||||
[tai_chi_text_467b4722]
|
||||
靛蓝男子
|
||||
---
|
||||
[tai_chi_text_46bf6666]
|
||||
重心右移,抬起左脚尖,松开勾手
|
||||
---
|
||||
@@ -472,9 +475,6 @@
|
||||
[tai_chi_text_6471ef0a]
|
||||
左右倒卷肱(另一侧)
|
||||
---
|
||||
[tai_chi_text_664dce00]
|
||||
藏族僧人
|
||||
---
|
||||
[tai_chi_text_66753428]
|
||||
向后步法
|
||||
---
|
||||
@@ -802,9 +802,6 @@
|
||||
[tai_chi_text_b2a8d2a1]
|
||||
用鼻子自然呼吸
|
||||
---
|
||||
[tai_chi_text_b3b5932b]
|
||||
藏族女子
|
||||
---
|
||||
[tai_chi_text_b3e0a103]
|
||||
勾
|
||||
---
|
||||
@@ -1078,6 +1075,9 @@
|
||||
[tai_chi_text_eb693390]
|
||||
向左转,左脚跟向前迈出
|
||||
---
|
||||
[tai_chi_text_eb9b2fda]
|
||||
翡翠女子
|
||||
---
|
||||
[tai_chi_text_ebb21af0]
|
||||
整套动作
|
||||
---
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
// Exports the course for Inner Breeze: the key poses and timing the app
|
||||
// samples and solves itself, the two painted characters, the words to
|
||||
// translate, and a reference for the app's parity test.
|
||||
// samples and solves itself, the two flat characters (src/flat/shapes.js),
|
||||
// the words to translate, and a reference for the app's parity test.
|
||||
//
|
||||
// node tools/export-app.mjs
|
||||
//
|
||||
// Writes (paths from the Inbe repository root):
|
||||
// assets/practices/taichi/course.bin keys, course outline, rigs, parts
|
||||
// assets/practices/taichi/<character>/*.png painted parts, scaled down
|
||||
// assets/practices/taichi/course.bin keys, course outline, rigs
|
||||
// assets/practices/taichi/flat-edge.png soft edges of the figure's shapes
|
||||
// design/tai-chi/text/en.txt course words as locale entries
|
||||
// tests/fixtures/tai-chi-reference.json sampled poses, joints, pieces
|
||||
// tests/fixtures/tai-chi-reference.json sampled poses, joints, shapes
|
||||
//
|
||||
// course.bin is little-endian. Every string is a u16 byte length and UTF-8
|
||||
// bytes; a string index of -1 means none. Sections in order:
|
||||
@@ -20,9 +20,10 @@
|
||||
// only), 3 pad bytes, f32 look yaw (degrees), f32 look pitch (degrees),
|
||||
// f32[CHANNELS.length] channels
|
||||
// characters: u32 count; each s32 id, s32 name, f32[RIG_FIELDS.length] rig,
|
||||
// u32 image count; per image s32 role, s32 path, f32 width, f32 height,
|
||||
// f32[16] points (8 named points by role, see IMAGE_POINTS), f32[4]
|
||||
// values (anterior, thickness, sign, across thumb)
|
||||
// u32 image count (0: the flat characters are drawn, not painted); per
|
||||
// image s32 role, s32 path, f32 width, f32 height, f32[16] points (8
|
||||
// named points by role), f32[4] values (anterior, thickness, sign,
|
||||
// across thumb)
|
||||
// outline: u32 module count; each s32 title, u32 lesson count; each s32
|
||||
// title, s32 subtitle, s32 summary, u32 item count; each s32 id,
|
||||
// s32 title, s32 version, u8 kind, u8 view, u8 mirror, u8 source
|
||||
@@ -37,7 +38,8 @@ import { execFileSync } from 'node:child_process'
|
||||
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'
|
||||
import { dirname, join, resolve } from 'node:path'
|
||||
import { buildCourse, readingTime, timelineFor } from '../src/course.js'
|
||||
import { createPaintedLayout, imageFromSpec, pieceVertices, pieceImage } from '../src/painted/layout.js'
|
||||
import { FLAT_LOOKS, createFlatShapes } from '../src/flat/shapes.js'
|
||||
import { FlatView } from '../src/painted/layout.js'
|
||||
import { makeRig } from '../src/rig.js'
|
||||
import { solvePose } from '../src/solve.js'
|
||||
import { STUDIO_ROOT } from './serve.mjs'
|
||||
@@ -46,14 +48,11 @@ const INBE_ROOT = resolve(STUDIO_ROOT, '..', '..')
|
||||
const ASSET_DIR = join(INBE_ROOT, 'assets', 'practices', 'taichi')
|
||||
const TEXT_FILE = join(STUDIO_ROOT, 'text', 'en.txt')
|
||||
const REFERENCE_FILE = join(INBE_ROOT, 'tests', 'fixtures', 'tai-chi-reference.json')
|
||||
// Painted parts are drawn about two thirds of their painted size on a
|
||||
// phone. Smaller copies with 256-colour palettes keep the package small;
|
||||
// at that size the palette is not visible.
|
||||
const PART_SCALE = 0.65
|
||||
|
||||
// The app's characters, in the order it lists them: the woman first, the
|
||||
// man (who speaks with the male voice) second.
|
||||
const CHARACTERS = [
|
||||
{ id: 'monk', dir: 'monk', name: 'Tibetan monk' },
|
||||
{ id: 'tibetanWoman', dir: 'tibetan-woman', name: 'Tibetan woman' },
|
||||
{ id: 'jadeWoman', name: 'Jade woman' },
|
||||
{ id: 'indigoMan', name: 'Indigo man' },
|
||||
]
|
||||
|
||||
const KINDS = ['drill', 'lesson', 'demo', 'breakdown', 'follow', 'full']
|
||||
@@ -105,16 +104,6 @@ function channelValue(pose, name) {
|
||||
return pose[name]
|
||||
}
|
||||
|
||||
// Named points per image role, in slot order.
|
||||
const IMAGE_POINTS = {
|
||||
head: ['neck', 'crown'],
|
||||
torso: ['neck', 'hip', 'shoulder0', 'shoulder1'],
|
||||
limb: ['root', 'end'],
|
||||
hand: ['wrist', 'tip'],
|
||||
shoeSide: ['heel', 'toe'],
|
||||
shoe: ['ankle'],
|
||||
}
|
||||
|
||||
// --- Strings ---------------------------------------------------------------
|
||||
|
||||
const strings = []
|
||||
@@ -288,115 +277,36 @@ for (const set of keySets) {
|
||||
|
||||
// --- Characters ----------------------------------------------------------------
|
||||
|
||||
function pngSize(path) {
|
||||
const data = readFileSync(path)
|
||||
return { width: data.readUInt32BE(16), height: data.readUInt32BE(20) }
|
||||
}
|
||||
const characters = CHARACTERS.map((entry) => ({ ...entry, rig: makeRig(entry.id), look: FLAT_LOOKS[entry.id] }))
|
||||
|
||||
function loadCharacter(entry) {
|
||||
const base = join(STUDIO_ROOT, 'characters', entry.dir)
|
||||
const definition = JSON.parse(readFileSync(join(base, 'character.json'), 'utf8'))
|
||||
const images = []
|
||||
const image = (role, kind, spec) => {
|
||||
const size = pngSize(join(base, spec.file))
|
||||
const { file, ...points } = spec
|
||||
const described = imageFromSpec(points, size.width, size.height)
|
||||
images.push({ role, kind, file, size, described })
|
||||
return described
|
||||
}
|
||||
const group = (prefix, kind, specs) => Object.fromEntries(Object.entries(specs)
|
||||
.filter(([, spec]) => spec && typeof spec === 'object' && spec.file)
|
||||
.map(([name, spec]) => [name, image(`${prefix}.${name}`, kind(name), spec)]))
|
||||
const character = {
|
||||
head: group('head', () => 'head', definition.head.views),
|
||||
torso: group('torso', () => 'torso', definition.torso.views),
|
||||
arm: image('arm', 'limb', definition.arm),
|
||||
leg: image('leg', 'limb', definition.leg),
|
||||
hands: group('hands', () => 'hand', definition.hands),
|
||||
shoes: group('shoes', (name) => (name === 'outer' || name === 'inner' ? 'shoeSide' : 'shoe'), definition.shoes),
|
||||
}
|
||||
return { definition, base, character, images }
|
||||
}
|
||||
|
||||
const characters = CHARACTERS.map((entry) => ({ ...entry, ...loadCharacter(entry), rig: makeRig(entry.id) }))
|
||||
|
||||
// Scaled copies of the painted parts.
|
||||
for (const entry of characters) {
|
||||
const target = join(ASSET_DIR, entry.dir)
|
||||
mkdirSync(target, { recursive: true })
|
||||
const script = `
|
||||
// Shapes and lines are drawn as tinted meshes over this one-row image,
|
||||
// clear at both ends and opaque between: a fan from a shape's middle out
|
||||
// past its edge, a strip across a line. With smooth scaling the fade gives
|
||||
// every edge a soft, even border.
|
||||
const edgeScript = `
|
||||
import sys
|
||||
from PIL import Image
|
||||
scale = float(sys.argv[1])
|
||||
for source, target in zip(sys.argv[2::2], sys.argv[3::2]):
|
||||
image = Image.open(source).convert('RGBA')
|
||||
size = (max(1, round(image.width * scale)), max(1, round(image.height * scale)))
|
||||
small = image.resize(size, Image.LANCZOS)
|
||||
small.quantize(colors=256, method=Image.Quantize.FASTOCTREE, dither=Image.Dither.FLOYDSTEINBERG).save(target, optimize=True)
|
||||
`
|
||||
const pairs = entry.images.flatMap((image) => [join(entry.base, image.file), join(target, image.file.replace(/^parts\//, ''))])
|
||||
execFileSync('python3', ['-I', '-c', script, String(PART_SCALE), ...pairs])
|
||||
}
|
||||
|
||||
// The soft floor shadow, as the studio paints it on a canvas: warm brown
|
||||
// fading out from the middle.
|
||||
const shadowScript = `
|
||||
import sys
|
||||
from PIL import Image
|
||||
size = 128
|
||||
image = Image.new('RGBA', (size, size), (60, 45, 30, 0))
|
||||
pixels = image.load()
|
||||
for y in range(size):
|
||||
for x in range(size):
|
||||
r = ((x + 0.5 - size / 2) ** 2 + (y + 0.5 - size / 2) ** 2) ** 0.5 / (size / 2)
|
||||
if r < 0.55:
|
||||
a = 0.42 + (0.2 - 0.42) * r / 0.55
|
||||
elif r < 1:
|
||||
a = 0.2 * (1 - (r - 0.55) / 0.45)
|
||||
else:
|
||||
a = 0
|
||||
pixels[x, y] = (60, 45, 30, round(a * 255))
|
||||
alphas = (0, 255, 255, 255, 255, 0)
|
||||
image = Image.new('RGBA', (len(alphas), 1))
|
||||
for x, alpha in enumerate(alphas):
|
||||
image.putpixel((x, 0), (255, 255, 255, alpha))
|
||||
image.save(sys.argv[1], optimize=True)
|
||||
`
|
||||
execFileSync('python3', ['-I', '-c', shadowScript, join(ASSET_DIR, 'shadow.png')])
|
||||
mkdirSync(ASSET_DIR, { recursive: true })
|
||||
execFileSync('python3', ['-I', '-c', edgeScript, join(ASSET_DIR, 'flat-edge.png')])
|
||||
|
||||
function rigValue(rig, field) {
|
||||
const match = /^spine(\d)$/.exec(field)
|
||||
return match ? rig.spine[Number(match[1])] : rig[field]
|
||||
}
|
||||
|
||||
function imageRecord(image, entry) {
|
||||
const described = image.described
|
||||
const slots = new Array(16).fill(0)
|
||||
const names = IMAGE_POINTS[image.kind]
|
||||
names.forEach((name, slot) => {
|
||||
let point = described[name]
|
||||
if (name.startsWith('shoulder')) {
|
||||
point = described.shoulders[Number(name.slice('shoulder'.length))]
|
||||
}
|
||||
if (name === 'crown' && !point) {
|
||||
point = { x: 0, y: 0.02 * image.size.height }
|
||||
}
|
||||
slots[slot * 2] = point.x
|
||||
slots[slot * 2 + 1] = point.y
|
||||
})
|
||||
return {
|
||||
role: stringId(image.role),
|
||||
path: stringId(`assets/practices/taichi/${entry.dir}/${image.file.replace(/^parts\//, '')}`),
|
||||
width: image.size.width,
|
||||
height: image.size.height,
|
||||
slots,
|
||||
values: [described.anterior ?? 1, described.thickness ?? 1, described.sign ?? 1, described.across === 'thumb' ? 1 : 0],
|
||||
}
|
||||
}
|
||||
|
||||
// --- Write course.bin --------------------------------------------------------
|
||||
|
||||
const characterRecords = characters.map((entry) => ({
|
||||
id: stringId(entry.id),
|
||||
name: textKey(entry.name),
|
||||
rig: RIG_FIELDS.map((field) => rigValue(entry.rig, field)),
|
||||
images: entry.images.map((image) => imageRecord(image, entry)),
|
||||
images: [],
|
||||
}))
|
||||
|
||||
const writer = new Writer()
|
||||
@@ -493,13 +403,14 @@ writeFileSync(join(STUDIO_ROOT, 'narration-lines.json'), `${JSON.stringify(narra
|
||||
// --- Parity reference ------------------------------------------------------------
|
||||
|
||||
// For a handful of items and times: the sampled channels, solved joints and
|
||||
// the painted pieces seen from a fixed camera, laid out with no memory of
|
||||
// earlier frames, so the app's port can be checked number for number.
|
||||
const REFERENCE_ITEMS = ['foundations/hook', 'lesson-2/brush-knee/breakdown', 'lesson-6/snake-left/follow', 'full/normal']
|
||||
// the flat figure's paint operations seen from a fixed camera, so the app's
|
||||
// port can be checked number for number. A fill is compared by its area,
|
||||
// centroid and bounds (hull corners may differ where points are in line),
|
||||
// a line by its ends and its number of points.
|
||||
const REFERENCE_ITEMS = ['foundations/hook', 'lesson-1/wild-horse/demo', 'lesson-2/brush-knee/breakdown', 'lesson-6/snake-left/follow', 'full/normal']
|
||||
const REFERENCE_JOINTS = ['pelvis', 'neckBase', 'shoulderCenter', 'shoulderL', 'elbowR', 'wristL', 'wristR', 'kneeL', 'kneeR',
|
||||
'ankleL', 'heelR', 'toeL', 'headTop', 'com']
|
||||
const REFERENCE_PIECES = ['shadowL', 'shadowBody', 'torso', 'head', 'armL', 'armR', 'handL', 'handR', 'legL', 'legR', 'shoeL', 'shoeR']
|
||||
const reference = { channels: CHANNELS, joints: REFERENCE_JOINTS, pieces: REFERENCE_PIECES, grid: [2, 6], samples: [] }
|
||||
const reference = { channels: CHANNELS, joints: REFERENCE_JOINTS, samples: [] }
|
||||
const itemIds = []
|
||||
for (const module of course.modules) {
|
||||
for (const lesson of module.lessons) {
|
||||
@@ -508,8 +419,31 @@ for (const module of course.modules) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function fillSummary(points) {
|
||||
let area = 0
|
||||
let cx = 0
|
||||
let cy = 0
|
||||
for (let index = 0; index < points.length; index += 1) {
|
||||
const a = points[index]
|
||||
const b = points[(index + 1) % points.length]
|
||||
const cross = a.x * b.y - b.x * a.y
|
||||
area += cross
|
||||
cx += (a.x + b.x) * cross
|
||||
cy += (a.y + b.y) * cross
|
||||
}
|
||||
area /= 2
|
||||
const xs = points.map((point) => point.x)
|
||||
const ys = points.map((point) => point.y)
|
||||
return {
|
||||
area,
|
||||
center: Math.abs(area) > 1e-12 ? [cx / (6 * area), cy / (6 * area)] : [xs[0], ys[0]],
|
||||
box: [Math.min(...xs), Math.min(...ys), Math.max(...xs), Math.max(...ys)],
|
||||
}
|
||||
}
|
||||
|
||||
for (const entry of characters) {
|
||||
const imageGroups = { ...entry.character }
|
||||
const shapes = createFlatShapes(entry.look, entry.rig)
|
||||
for (const id of REFERENCE_ITEMS) {
|
||||
const item = course.items.get(id)
|
||||
const { timeline } = timelineFor(item)
|
||||
@@ -517,27 +451,26 @@ for (const entry of characters) {
|
||||
const time = timeline.duration * fraction
|
||||
const pose = timeline.sample(timeline.start + time).pose
|
||||
const solved = solvePose(pose, entry.rig)
|
||||
const camera = { yaw: 0.6 + fraction, tilt: 0.12, center: solved.joints.pelvis.clone().setY(0) }
|
||||
const placement = createPaintedLayout(imageGroups, entry.rig)
|
||||
const frame = placement.layout(solved, camera)
|
||||
const camera = { yaw: 0.6 + fraction * 2.5, tilt: 0.12, center: solved.joints.pelvis.clone().setY(0) }
|
||||
const view = new FlatView()
|
||||
view.set(camera.yaw, camera.tilt, camera.center)
|
||||
const ops = shapes.paint(solved, view)
|
||||
reference.samples.push({
|
||||
character: entry.id,
|
||||
item: itemIds.indexOf(id),
|
||||
time,
|
||||
look: pose.look,
|
||||
channels: CHANNELS.map((channel) => channelValue(pose, channel)),
|
||||
joints: REFERENCE_JOINTS.map((name) => [solved.joints[name].x, solved.joints[name].y, solved.joints[name].z]),
|
||||
camera: { yaw: camera.yaw, tilt: camera.tilt, center: [camera.center.x, camera.center.z] },
|
||||
order: frame.order,
|
||||
pieces: REFERENCE_PIECES.map((name) => {
|
||||
const piece = frame.pieces[name]
|
||||
const image = pieceImage({ ...imageGroups, shadow: { width: 128, height: 128 } }, piece.image)
|
||||
return {
|
||||
name,
|
||||
image: piece.image,
|
||||
points: pieceVertices(piece, image, reference.grid[0], reference.grid[1]).map((point) => [point.x, point.y]),
|
||||
}
|
||||
}),
|
||||
ops: ops.map((op) => (op.kind === 'fill'
|
||||
? { fill: op.color, alpha: op.alpha, ...fillSummary(op.points) }
|
||||
: {
|
||||
line: op.color,
|
||||
alpha: op.alpha,
|
||||
width: op.width,
|
||||
count: op.points.length,
|
||||
ends: [op.points[0].x, op.points[0].y, op.points[op.points.length - 1].x, op.points[op.points.length - 1].y],
|
||||
})),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4155,8 +4155,8 @@ Tvary rukou
|
||||
Odhánění opice (druhá strana)
|
||||
---
|
||||
|
||||
[tai_chi_text_664dce00]
|
||||
Tibetský mnich
|
||||
[tai_chi_text_eb9b2fda]
|
||||
Nefritová žena
|
||||
---
|
||||
|
||||
[tai_chi_text_66753428]
|
||||
@@ -4595,8 +4595,8 @@ Sedněte si zpět, přední špička nahoru, a stáhněte ruce zpět k břichu
|
||||
Dýchejte přirozeně nosem
|
||||
---
|
||||
|
||||
[tai_chi_text_b3b5932b]
|
||||
Tibetská žena
|
||||
[tai_chi_text_467b4722]
|
||||
Indigový muž
|
||||
---
|
||||
|
||||
[tai_chi_text_b3e0a103]
|
||||
@@ -5279,6 +5279,22 @@ Pošli Monero na tuto adresu. Dew se objeví po %d potvrzeních.
|
||||
Hlasový doprovod
|
||||
---
|
||||
|
||||
[tai_chi_view_front]
|
||||
Zepředu
|
||||
---
|
||||
|
||||
[tai_chi_view_back]
|
||||
Zezadu
|
||||
---
|
||||
|
||||
[tai_chi_view_side]
|
||||
Z boku
|
||||
---
|
||||
|
||||
[tai_chi_view_angled]
|
||||
Šikmo
|
||||
---
|
||||
|
||||
[practice_voice_female]
|
||||
Ženský hlas
|
||||
---
|
||||
|
||||
@@ -4149,8 +4149,8 @@ Handformen
|
||||
Den Affen zurückdrängen (andere Seite)
|
||||
---
|
||||
|
||||
[tai_chi_text_664dce00]
|
||||
Tibetischer Mönch
|
||||
[tai_chi_text_eb9b2fda]
|
||||
Jadegrüne Frau
|
||||
---
|
||||
|
||||
[tai_chi_text_66753428]
|
||||
@@ -4589,8 +4589,8 @@ Setz dich zurück, vordere Zehen oben, und zieh die Hände zurück zum Bauch
|
||||
Atme natürlich durch die Nase
|
||||
---
|
||||
|
||||
[tai_chi_text_b3b5932b]
|
||||
Tibetische Frau
|
||||
[tai_chi_text_467b4722]
|
||||
Indigoblauer Mann
|
||||
---
|
||||
|
||||
[tai_chi_text_b3e0a103]
|
||||
@@ -5273,6 +5273,22 @@ Sende Monero an diese Adresse. Dew erscheint nach %d Bestätigungen.
|
||||
Sprachausgabe
|
||||
---
|
||||
|
||||
[tai_chi_view_front]
|
||||
Vorne
|
||||
---
|
||||
|
||||
[tai_chi_view_back]
|
||||
Hinten
|
||||
---
|
||||
|
||||
[tai_chi_view_side]
|
||||
Seite
|
||||
---
|
||||
|
||||
[tai_chi_view_angled]
|
||||
Schräg
|
||||
---
|
||||
|
||||
[practice_voice_female]
|
||||
Weibliche Stimme
|
||||
---
|
||||
|
||||
@@ -4173,8 +4173,8 @@ Hand shapes
|
||||
Repulse the Monkey (other side)
|
||||
---
|
||||
|
||||
[tai_chi_text_664dce00]
|
||||
Tibetan monk
|
||||
[tai_chi_text_eb9b2fda]
|
||||
Jade woman
|
||||
---
|
||||
|
||||
[tai_chi_text_66753428]
|
||||
@@ -4613,8 +4613,8 @@ Sit back, front toes up, and draw the hands back to the belly
|
||||
Breathe naturally through the nose
|
||||
---
|
||||
|
||||
[tai_chi_text_b3b5932b]
|
||||
Tibetan woman
|
||||
[tai_chi_text_467b4722]
|
||||
Indigo man
|
||||
---
|
||||
|
||||
[tai_chi_text_b3e0a103]
|
||||
@@ -5297,6 +5297,22 @@ Send Monero to this address. Dew appears after %d confirmations.
|
||||
Voice narration
|
||||
---
|
||||
|
||||
[tai_chi_view_front]
|
||||
Front
|
||||
---
|
||||
|
||||
[tai_chi_view_back]
|
||||
Back
|
||||
---
|
||||
|
||||
[tai_chi_view_side]
|
||||
Side
|
||||
---
|
||||
|
||||
[tai_chi_view_angled]
|
||||
Angled
|
||||
---
|
||||
|
||||
[practice_voice_female]
|
||||
Female voice
|
||||
---
|
||||
|
||||
@@ -4149,8 +4149,8 @@ Formas de la mano
|
||||
Hacer retroceder al mono (lado contrario)
|
||||
---
|
||||
|
||||
[tai_chi_text_664dce00]
|
||||
Monje tibetano
|
||||
[tai_chi_text_eb9b2fda]
|
||||
Mujer de jade
|
||||
---
|
||||
|
||||
[tai_chi_text_66753428]
|
||||
@@ -4589,8 +4589,8 @@ Siéntate atrás, con la punta del pie delantero arriba, y lleva las manos al vi
|
||||
Respira con naturalidad por la nariz
|
||||
---
|
||||
|
||||
[tai_chi_text_b3b5932b]
|
||||
Mujer tibetana
|
||||
[tai_chi_text_467b4722]
|
||||
Hombre índigo
|
||||
---
|
||||
|
||||
[tai_chi_text_b3e0a103]
|
||||
@@ -5273,6 +5273,22 @@ Envía Monero a esta dirección. Dew aparece tras %d confirmaciones.
|
||||
Narración de voz
|
||||
---
|
||||
|
||||
[tai_chi_view_front]
|
||||
Frente
|
||||
---
|
||||
|
||||
[tai_chi_view_back]
|
||||
Espalda
|
||||
---
|
||||
|
||||
[tai_chi_view_side]
|
||||
Lado
|
||||
---
|
||||
|
||||
[tai_chi_view_angled]
|
||||
En ángulo
|
||||
---
|
||||
|
||||
[practice_voice_female]
|
||||
Voz femenina
|
||||
---
|
||||
|
||||
@@ -4137,8 +4137,8 @@ Formes de la main
|
||||
Repousser le singe (autre côté)
|
||||
---
|
||||
|
||||
[tai_chi_text_664dce00]
|
||||
Moine tibétain
|
||||
[tai_chi_text_eb9b2fda]
|
||||
Femme jade
|
||||
---
|
||||
|
||||
[tai_chi_text_66753428]
|
||||
@@ -4577,8 +4577,8 @@ Asseyez-vous en arrière, orteils avant relevés, et ramenez les mains vers le v
|
||||
Respirez naturellement par le nez
|
||||
---
|
||||
|
||||
[tai_chi_text_b3b5932b]
|
||||
Femme tibétaine
|
||||
[tai_chi_text_467b4722]
|
||||
Homme indigo
|
||||
---
|
||||
|
||||
[tai_chi_text_b3e0a103]
|
||||
@@ -5261,6 +5261,22 @@ Envoyez des Monero à cette adresse. Les Dew apparaissent après %d confirmation
|
||||
Narration vocale
|
||||
---
|
||||
|
||||
[tai_chi_view_front]
|
||||
Face
|
||||
---
|
||||
|
||||
[tai_chi_view_back]
|
||||
Dos
|
||||
---
|
||||
|
||||
[tai_chi_view_side]
|
||||
Profil
|
||||
---
|
||||
|
||||
[tai_chi_view_angled]
|
||||
De biais
|
||||
---
|
||||
|
||||
[practice_voice_female]
|
||||
Voix féminine
|
||||
---
|
||||
|
||||
@@ -4138,8 +4138,8 @@ Bentuk tangan
|
||||
Mengusir monyet (sisi lain)
|
||||
---
|
||||
|
||||
[tai_chi_text_664dce00]
|
||||
Biksu Tibet
|
||||
[tai_chi_text_eb9b2fda]
|
||||
Perempuan giok
|
||||
---
|
||||
|
||||
[tai_chi_text_66753428]
|
||||
@@ -4578,8 +4578,8 @@ Duduk ke belakang, ujung kaki depan terangkat, dan tarik kedua tangan ke perut
|
||||
Bernapas secara alami lewat hidung
|
||||
---
|
||||
|
||||
[tai_chi_text_b3b5932b]
|
||||
Perempuan Tibet
|
||||
[tai_chi_text_467b4722]
|
||||
Laki-laki nila
|
||||
---
|
||||
|
||||
[tai_chi_text_b3e0a103]
|
||||
@@ -5262,6 +5262,22 @@ Kirim Monero ke alamat ini. Dew muncul setelah %d konfirmasi.
|
||||
Narasi suara
|
||||
---
|
||||
|
||||
[tai_chi_view_front]
|
||||
Depan
|
||||
---
|
||||
|
||||
[tai_chi_view_back]
|
||||
Belakang
|
||||
---
|
||||
|
||||
[tai_chi_view_side]
|
||||
Samping
|
||||
---
|
||||
|
||||
[tai_chi_view_angled]
|
||||
Miring
|
||||
---
|
||||
|
||||
[practice_voice_female]
|
||||
Suara perempuan
|
||||
---
|
||||
|
||||
@@ -4138,8 +4138,8 @@ Forme della mano
|
||||
Respingere la scimmia (lato opposto)
|
||||
---
|
||||
|
||||
[tai_chi_text_664dce00]
|
||||
Monaco tibetano
|
||||
[tai_chi_text_eb9b2fda]
|
||||
Donna di giada
|
||||
---
|
||||
|
||||
[tai_chi_text_66753428]
|
||||
@@ -4578,8 +4578,8 @@ Siediti indietro, punta del piede avanti in alto, e porta le mani indietro al ve
|
||||
Respira naturalmente dal naso
|
||||
---
|
||||
|
||||
[tai_chi_text_b3b5932b]
|
||||
Donna tibetana
|
||||
[tai_chi_text_467b4722]
|
||||
Uomo indaco
|
||||
---
|
||||
|
||||
[tai_chi_text_b3e0a103]
|
||||
@@ -5262,6 +5262,22 @@ Invia Monero a questo indirizzo. Dew appare dopo %d conferme.
|
||||
Narrazione vocale
|
||||
---
|
||||
|
||||
[tai_chi_view_front]
|
||||
Fronte
|
||||
---
|
||||
|
||||
[tai_chi_view_back]
|
||||
Dietro
|
||||
---
|
||||
|
||||
[tai_chi_view_side]
|
||||
Lato
|
||||
---
|
||||
|
||||
[tai_chi_view_angled]
|
||||
Di sbieco
|
||||
---
|
||||
|
||||
[practice_voice_female]
|
||||
Voce femminile
|
||||
---
|
||||
|
||||
@@ -4134,8 +4134,8 @@ Inner Breezeの接続コードではありません。
|
||||
倒巻肱(反対側)
|
||||
---
|
||||
|
||||
[tai_chi_text_664dce00]
|
||||
チベットの僧
|
||||
[tai_chi_text_eb9b2fda]
|
||||
翡翠の女性
|
||||
---
|
||||
|
||||
[tai_chi_text_66753428]
|
||||
@@ -4574,8 +4574,8 @@ Inner Breezeの接続コードではありません。
|
||||
鼻から自然に呼吸する
|
||||
---
|
||||
|
||||
[tai_chi_text_b3b5932b]
|
||||
チベットの女性
|
||||
[tai_chi_text_467b4722]
|
||||
藍色の男性
|
||||
---
|
||||
|
||||
[tai_chi_text_b3e0a103]
|
||||
@@ -5258,6 +5258,22 @@ Moneroアドレスを取得できませんでした。もう一度お試しく
|
||||
音声ガイド
|
||||
---
|
||||
|
||||
[tai_chi_view_front]
|
||||
正面
|
||||
---
|
||||
|
||||
[tai_chi_view_back]
|
||||
背面
|
||||
---
|
||||
|
||||
[tai_chi_view_side]
|
||||
側面
|
||||
---
|
||||
|
||||
[tai_chi_view_angled]
|
||||
斜め
|
||||
---
|
||||
|
||||
[practice_voice_female]
|
||||
女性の声
|
||||
---
|
||||
|
||||
@@ -4144,8 +4144,8 @@ Inner Breeze 연결 코드가 아닙니다.
|
||||
도권굉 (반대쪽)
|
||||
---
|
||||
|
||||
[tai_chi_text_664dce00]
|
||||
티베트 승려
|
||||
[tai_chi_text_eb9b2fda]
|
||||
비취색 여성
|
||||
---
|
||||
|
||||
[tai_chi_text_66753428]
|
||||
@@ -4584,8 +4584,8 @@ Inner Breeze 연결 코드가 아닙니다.
|
||||
코로 자연스럽게 호흡하세요
|
||||
---
|
||||
|
||||
[tai_chi_text_b3b5932b]
|
||||
티베트 여인
|
||||
[tai_chi_text_467b4722]
|
||||
남색 남성
|
||||
---
|
||||
|
||||
[tai_chi_text_b3e0a103]
|
||||
@@ -5268,6 +5268,22 @@ Monero 주소를 가져오지 못했습니다. 다시 시도하세요.
|
||||
음성 안내
|
||||
---
|
||||
|
||||
[tai_chi_view_front]
|
||||
정면
|
||||
---
|
||||
|
||||
[tai_chi_view_back]
|
||||
뒤
|
||||
---
|
||||
|
||||
[tai_chi_view_side]
|
||||
옆
|
||||
---
|
||||
|
||||
[tai_chi_view_angled]
|
||||
비스듬히
|
||||
---
|
||||
|
||||
[practice_voice_female]
|
||||
여성 목소리
|
||||
---
|
||||
|
||||
@@ -4147,8 +4147,8 @@ Formas das mãos
|
||||
Repelir o macaco (outro lado)
|
||||
---
|
||||
|
||||
[tai_chi_text_664dce00]
|
||||
Monge tibetano
|
||||
[tai_chi_text_eb9b2fda]
|
||||
Mulher de jade
|
||||
---
|
||||
|
||||
[tai_chi_text_66753428]
|
||||
@@ -4587,8 +4587,8 @@ Sente-se para trás, dedos da frente para cima, e traga as mãos de volta à bar
|
||||
Respire naturalmente pelo nariz
|
||||
---
|
||||
|
||||
[tai_chi_text_b3b5932b]
|
||||
Mulher tibetana
|
||||
[tai_chi_text_467b4722]
|
||||
Homem índigo
|
||||
---
|
||||
|
||||
[tai_chi_text_b3e0a103]
|
||||
@@ -5271,6 +5271,22 @@ Envie Monero para este endereço. Dew aparece após %d confirmações.
|
||||
Narração por voz
|
||||
---
|
||||
|
||||
[tai_chi_view_front]
|
||||
Frente
|
||||
---
|
||||
|
||||
[tai_chi_view_back]
|
||||
Costas
|
||||
---
|
||||
|
||||
[tai_chi_view_side]
|
||||
Lado
|
||||
---
|
||||
|
||||
[tai_chi_view_angled]
|
||||
Em ângulo
|
||||
---
|
||||
|
||||
[practice_voice_female]
|
||||
Voz feminina
|
||||
---
|
||||
|
||||
@@ -4143,8 +4143,8 @@ Lumi остаётся без сети, пока вы не примете её у
|
||||
Отгонять обезьяну (другая сторона)
|
||||
---
|
||||
|
||||
[tai_chi_text_664dce00]
|
||||
Тибетский монах
|
||||
[tai_chi_text_eb9b2fda]
|
||||
Женщина в нефритовом
|
||||
---
|
||||
|
||||
[tai_chi_text_66753428]
|
||||
@@ -4583,8 +4583,8 @@ Lumi остаётся без сети, пока вы не примете её у
|
||||
Дышите естественно через нос
|
||||
---
|
||||
|
||||
[tai_chi_text_b3b5932b]
|
||||
Тибетская женщина
|
||||
[tai_chi_text_467b4722]
|
||||
Мужчина в индиго
|
||||
---
|
||||
|
||||
[tai_chi_text_b3e0a103]
|
||||
@@ -5267,6 +5267,22 @@ Lumi остаётся без сети, пока вы не примете её у
|
||||
Голосовое сопровождение
|
||||
---
|
||||
|
||||
[tai_chi_view_front]
|
||||
Спереди
|
||||
---
|
||||
|
||||
[tai_chi_view_back]
|
||||
Сзади
|
||||
---
|
||||
|
||||
[tai_chi_view_side]
|
||||
Сбоку
|
||||
---
|
||||
|
||||
[tai_chi_view_angled]
|
||||
Наискосок
|
||||
---
|
||||
|
||||
[practice_voice_female]
|
||||
Женский голос
|
||||
---
|
||||
|
||||
@@ -4149,8 +4149,8 @@ Daochi 节点
|
||||
左右倒卷肱(另一侧)
|
||||
---
|
||||
|
||||
[tai_chi_text_664dce00]
|
||||
藏族僧人
|
||||
[tai_chi_text_eb9b2fda]
|
||||
翡翠女子
|
||||
---
|
||||
|
||||
[tai_chi_text_66753428]
|
||||
@@ -4589,8 +4589,8 @@ Daochi 节点
|
||||
用鼻子自然呼吸
|
||||
---
|
||||
|
||||
[tai_chi_text_b3b5932b]
|
||||
藏族女子
|
||||
[tai_chi_text_467b4722]
|
||||
靛蓝男子
|
||||
---
|
||||
|
||||
[tai_chi_text_b3e0a103]
|
||||
@@ -5273,6 +5273,22 @@ Dew不足,请先使用Monero充值。
|
||||
语音讲解
|
||||
---
|
||||
|
||||
[tai_chi_view_front]
|
||||
正面
|
||||
---
|
||||
|
||||
[tai_chi_view_back]
|
||||
背面
|
||||
---
|
||||
|
||||
[tai_chi_view_side]
|
||||
侧面
|
||||
---
|
||||
|
||||
[tai_chi_view_angled]
|
||||
斜侧
|
||||
---
|
||||
|
||||
[practice_voice_female]
|
||||
女声
|
||||
---
|
||||
|
||||
@@ -277,6 +277,7 @@ save_settings :: (app: *InnerBreeze) {
|
||||
save_setting_int("sun_salutation_breath_tempo", 1)
|
||||
save_setting_int("sun_salutation_voice", app.sun_salutation_voice)
|
||||
save_setting_int("tai_chi_character", app.tai_chi.character)
|
||||
save_setting_int("tai_chi_view", app.tai_chi.view)
|
||||
save_setting_int("tai_chi_voice", app.tai_chi.voice)
|
||||
save_setting_int("tai_chi_item", app.tai_chi.item)
|
||||
save_setting_int("tai_chi_habit_made", app.tai_chi.habit_made)
|
||||
@@ -645,6 +646,8 @@ app_load_settings :: (app: *InnerBreeze) -> s32 {
|
||||
load_clamped_setting(*app.sun_salutation_voice, "sun_salutation_voice", -1, -1, 1)
|
||||
load_clamped_setting(*app.tai_chi.character,
|
||||
"tai_chi_character", 0, 0, TAI_CHI_CHARACTER_COUNT - 1)
|
||||
load_clamped_setting(*app.tai_chi.view,
|
||||
"tai_chi_view", TAI_CHI_VIEW_FRONT, 0, TAI_CHI_VIEW_COUNT - 1)
|
||||
load_clamped_setting(*app.tai_chi.voice, "tai_chi_voice", -1, -1, 1)
|
||||
load_clamped_setting(*app.tai_chi.item,
|
||||
"tai_chi_item", -1, -1, TAI_CHI_ITEM_CAPACITY - 1)
|
||||
|
||||
@@ -715,7 +715,7 @@ setup_screenshot_scene :: (app: *InnerBreeze, request: *ScreenshotRequest) {
|
||||
app.session_paused = 1
|
||||
}
|
||||
} else if scene_text == "tai_chi_full_form" {
|
||||
// The full form from the front, mirrored, with the Tibetan woman.
|
||||
// The full form from the front, mirrored, with Indigo man.
|
||||
app.main_tab = APP_MAIN_TAB_PRACTICE
|
||||
app.exercise_type = EXERCISE_TAI_CHI
|
||||
if TaiChiCourseLoad() {
|
||||
|
||||
@@ -39,6 +39,10 @@ TAI_CHI_KIND_FOLLOW :: 4
|
||||
TAI_CHI_KIND_FULL :: 5
|
||||
TAI_CHI_VIEW_FRONT :: 0
|
||||
TAI_CHI_VIEW_BEHIND :: 1
|
||||
TAI_CHI_VIEW_SIDE :: 2
|
||||
TAI_CHI_VIEW_THREE_QUARTER :: 3
|
||||
// The angles the practice offers, in the order of its view buttons.
|
||||
TAI_CHI_VIEW_COUNT :: 4
|
||||
TAI_CHI_SOURCE_FORM :: 0
|
||||
TAI_CHI_SOURCE_KEY_SET :: 1
|
||||
|
||||
@@ -431,19 +435,6 @@ TaiChiCourseString :: (index: s32) -> string {
|
||||
return TextFromBytes(tai_chi_course.string_bytes[start:start + tai_chi_course.string_lengths[index]])
|
||||
}
|
||||
|
||||
TaiChiCourseImage :: (character: s32, role: string) -> s32 {
|
||||
if character < 0 || character >= tai_chi_course.character_count {
|
||||
return -1
|
||||
}
|
||||
entry := tai_chi_course.characters[character]
|
||||
for index: entry.image_first..entry.image_first + entry.image_count - 1 {
|
||||
if TaiChiCourseString(tai_chi_course.images[index].role) == role {
|
||||
return index
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
TaiChiCourseItemIndex :: (id: string) -> s32 {
|
||||
for index: cast(s32)0..tai_chi_course.item_count - 1 {
|
||||
if TaiChiCourseString(tai_chi_course.items[index].id) == id {
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
// Draws the painted Tai Chi figure: the pose at the practice's time, solved
|
||||
// and laid out as the course studio does, each painted piece warped onto
|
||||
// its place with Kryon's image mesh.
|
||||
// Draws the flat Tai Chi figure: the pose at the practice's time, solved and
|
||||
// turned into paint operations as the course studio does (tai_chi_flat.zi),
|
||||
// each filled shape and line drawn as a tinted mesh with Kryon's image mesh
|
||||
// over flat-edge.png, one row of texels clear at both ends and opaque
|
||||
// between. A shape is a fan from its middle out past its edge, a line a
|
||||
// strip across it; with smooth scaling every edge gets a soft, even border.
|
||||
// The image's middle columns are the shape's inside: textures repeat, so
|
||||
// its two ends blend into each other and are only ever its outer edge.
|
||||
#import "geometry"
|
||||
#import "image_props"
|
||||
#import "image_widget"
|
||||
@@ -10,38 +15,19 @@
|
||||
#import, file "tai_chi_course.zi";
|
||||
#import, file "tai_chi_timeline.zi";
|
||||
#import, file "tai_chi_solve.zi";
|
||||
#import, file "tai_chi_layout.zi";
|
||||
#import, file "tai_chi_view.zi";
|
||||
#import, file "tai_chi_flat.zi";
|
||||
#import, file "tai_chi_rules.zi";
|
||||
#import, file "tai_chi_entry.zi";
|
||||
|
||||
TAI_CHI_SHADOW_PATH :: "assets/practices/taichi/shadow.png"
|
||||
// Rows along a bending strip and columns across a bending shoe.
|
||||
TAI_CHI_STRIP_ROWS :: 20
|
||||
TAI_CHI_SHOE_COLUMNS :: 8
|
||||
TAI_CHI_MESH_CAPACITY :: 64
|
||||
TAI_CHI_FLAT_EDGE_PATH :: "assets/practices/taichi/flat-edge.png"
|
||||
// Half the soft border of a filled shape, in pixels.
|
||||
TAI_CHI_FLAT_FEATHER :: 0.75
|
||||
// The thinnest line drawn, in pixels.
|
||||
TAI_CHI_FLAT_THINNEST :: 1.2
|
||||
TAI_CHI_FLAT_MESH_CAPACITY :: 4 * (TAI_CHI_FLAT_SCRATCH * 2 + 1)
|
||||
|
||||
tai_chi_figure_images: [TAI_CHI_CHARACTER_COUNT]TaiChiFigureImages;
|
||||
tai_chi_figure_images_ready: [TAI_CHI_CHARACTER_COUNT]bool;
|
||||
|
||||
TaiChiImagesFor :: (character: s32) -> TaiChiFigureImages {
|
||||
if !tai_chi_figure_images_ready[character] {
|
||||
tai_chi_figure_images[character] = TaiChiFigureImagesFor(character)
|
||||
tai_chi_figure_images_ready[character] = true
|
||||
}
|
||||
return tai_chi_figure_images[character]
|
||||
}
|
||||
|
||||
TaiChiMeshGrid :: (piece: *TaiChiPiece) -> [2]s32 {
|
||||
grid: [2]s32
|
||||
grid[0] = 2
|
||||
grid[1] = 2
|
||||
if piece.kind == TAI_CHI_PIECE_LIMB || piece.kind == TAI_CHI_PIECE_STRIP_TORSO {
|
||||
grid[1] = TAI_CHI_STRIP_ROWS
|
||||
} else if piece.kind == TAI_CHI_PIECE_SHOE_SIDE {
|
||||
grid[0] = TAI_CHI_SHOE_COLUMNS
|
||||
}
|
||||
return grid
|
||||
}
|
||||
tai_chi_flat_frame: TaiChiFlatFrame;
|
||||
|
||||
// Draws the figure at the practice's current time into `area`, following
|
||||
// it with the camera. `dt` moves the camera; `snap` places it at once.
|
||||
@@ -54,25 +40,19 @@ TaiChiDrawFigure :: (session: Session, state: *TaiChiPracticeState, area: Rectan
|
||||
if character < 0 || character >= tai_chi_course.character_count {
|
||||
character = 0
|
||||
}
|
||||
images := TaiChiImagesFor(character)
|
||||
if !images.valid {
|
||||
return
|
||||
}
|
||||
item := tai_chi_course.items[state.built_item]
|
||||
view := TaiChiViewSpecFor(item.view)
|
||||
view := TaiChiViewSpecFor(state.view)
|
||||
pose := TaiChiTimelineSample(*tai_chi_timeline, state.time)
|
||||
rig := TaiChiRigFor(character)
|
||||
solved := TaiChiSolvePose(*pose, *rig)
|
||||
state.camera = TaiChiCameraUpdate(state.camera, view, solved.pelvis, pose.channels[TAI_CHI_FACING], dt, snap)
|
||||
framing := TaiChiFramingFor(state.camera, view)
|
||||
frame := TaiChiLayout(*solved, *rig, *images, framing.camera, *state.memory)
|
||||
|
||||
TaiChiPaintFrame(session, *frame, framing, item.mirror, area,
|
||||
TaiChiFlatPaint(*tai_chi_flat_frame, *solved, *rig, character, framing.camera)
|
||||
TaiChiPaintFlat(session, *tai_chi_flat_frame, framing, TaiChiViewMirrored(state.view), area,
|
||||
KeyHash("inbe/practices/tai_chi/figure"), alt_text)
|
||||
}
|
||||
|
||||
// Shared painting for the live player and cached course thumbnails.
|
||||
TaiChiPaintFrame :: (session: Session, frame: *TaiChiFrame, framing: TaiChiFraming,
|
||||
// Shared painting for the live player and the course thumbnails.
|
||||
TaiChiPaintFlat :: (session: Session, frame: *TaiChiFlatFrame, framing: TaiChiFraming,
|
||||
mirrored: bool, area: Rectangle, key: u64, alt_text: string) {
|
||||
// Metres on the picture plane to pixels in the area: the view's height
|
||||
// fills the area's height, centred on its middle.
|
||||
@@ -83,56 +63,106 @@ TaiChiPaintFrame :: (session: Session, frame: *TaiChiFrame, framing: TaiChiFrami
|
||||
if mirrored {
|
||||
mirror = -1.0
|
||||
}
|
||||
points: [TAI_CHI_MESH_CAPACITY]TaiChiVector2
|
||||
screen: [TAI_CHI_MESH_CAPACITY]Vector2
|
||||
for index: cast(s32)0..TAI_CHI_PIECE_COUNT - 1 {
|
||||
piece := frame.pieces[frame.order[index]]
|
||||
grid := TaiChiMeshGrid(*piece)
|
||||
count := grid[0] * grid[1]
|
||||
TaiChiPieceVertices(*piece, grid[0], grid[1], points[:count])
|
||||
screen: [TAI_CHI_FLAT_MESH_CAPACITY]Vector2
|
||||
for index: cast(s32)0..frame.op_count - 1 {
|
||||
op := frame.ops[index]
|
||||
points := frame.points[op.first:op.first + op.count]
|
||||
count: s32 = 0
|
||||
columns: s32 = 0
|
||||
if op.kind == TAI_CHI_FLAT_FILL {
|
||||
count = TaiChiFlatFanMesh(points, TAI_CHI_FLAT_FEATHER / pixels, screen[:])
|
||||
columns = 4
|
||||
} else {
|
||||
width := TaiChiMax(op.width, TAI_CHI_FLAT_THINNEST / pixels)
|
||||
count = TaiChiFlatStripMesh(points, width * 0.75, screen[:])
|
||||
columns = 2
|
||||
}
|
||||
if count == 0 {
|
||||
continue
|
||||
}
|
||||
for point: cast(s32)0..count - 1 {
|
||||
screen[point].x = cast(float32)(middle_x + points[point].x * pixels * mirror)
|
||||
screen[point].y = cast(float32)(middle_y - (points[point].y - framing.view_center) * pixels)
|
||||
screen[point].x = cast(float32)(middle_x + cast(float64)screen[point].x * pixels * mirror)
|
||||
screen[point].y = cast(float32)(middle_y - (cast(float64)screen[point].y - framing.view_center) * pixels)
|
||||
}
|
||||
alpha := cast(u32)(TaiChiClamp(op.alpha, 0.0, 1.0) * 255.0 + 0.5)
|
||||
if alpha == cast(u32)0 {
|
||||
continue
|
||||
}
|
||||
picture: ImageProps
|
||||
picture.key = key + cast(u64)index
|
||||
picture.bounds = area
|
||||
picture.smooth = true
|
||||
picture.alt_text = ifx index == TAI_CHI_PIECE_COUNT - 1 then alt_text else ""
|
||||
if piece.image < 0 {
|
||||
picture.asset_path = TAI_CHI_SHADOW_PATH
|
||||
alpha := cast(u32)(TaiChiClamp(piece.opacity, 0.0, 1.0) * 255.0)
|
||||
picture.tint = (cast(u32)0xffffff00) | alpha
|
||||
if alpha == cast(u32)0 {
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
picture.asset_path = TaiChiCourseString(tai_chi_course.images[piece.image].path)
|
||||
}
|
||||
picture.mesh.columns = grid[0]
|
||||
picture.mesh.rows = grid[1]
|
||||
picture.alt_text = ifx index == frame.op_count - 1 then alt_text else ""
|
||||
picture.asset_path = TAI_CHI_FLAT_EDGE_PATH
|
||||
picture.tint = (op.color << cast(u32)8) | alpha
|
||||
picture.mesh.columns = columns
|
||||
picture.mesh.rows = count / columns
|
||||
picture.mesh.points = screen[:count]
|
||||
Image(session, picture)
|
||||
}
|
||||
}
|
||||
|
||||
// Each thumbnail is a solved frame of its actual item. Building these uses
|
||||
// a separate timeline, so opening a chooser cannot overwrite playback.
|
||||
// A filled convex shape as a fan of 4 columns (its middle twice, just
|
||||
// inside the edge, just outside it) by one row per point and the first
|
||||
// again, in metres; `feather` is half the soft border.
|
||||
TaiChiFlatFanMesh :: (points: []TaiChiVector2, feather: float64, mesh: []Vector2) -> s32 {
|
||||
count := cast(s32)points.count
|
||||
if count < 3 || (count + 1) * 4 > cast(s32)mesh.count {
|
||||
return 0
|
||||
}
|
||||
middle := TaiChiV2(0.0, 0.0)
|
||||
for point: points {
|
||||
middle = TaiChiAdd2(middle, point)
|
||||
}
|
||||
middle = TaiChiScale2(middle, 1.0 / cast(float64)count)
|
||||
for row: cast(s32)0..count {
|
||||
point := points[row % count]
|
||||
out := TaiChiUnit2(TaiChiSub2(point, middle), TaiChiV2(0.0, 1.0))
|
||||
inside := TaiChiSub2(point, TaiChiScale2(out, feather))
|
||||
outside := TaiChiAdd2(point, TaiChiScale2(out, feather))
|
||||
mesh[row * 4] = Vector2.{cast(float32)middle.x, cast(float32)middle.y}
|
||||
mesh[row * 4 + 1] = mesh[row * 4]
|
||||
mesh[row * 4 + 2] = Vector2.{cast(float32)inside.x, cast(float32)inside.y}
|
||||
mesh[row * 4 + 3] = Vector2.{cast(float32)outside.x, cast(float32)outside.y}
|
||||
}
|
||||
return (count + 1) * 4
|
||||
}
|
||||
|
||||
// A line as a strip two points wide along it, `half` to each side.
|
||||
TaiChiFlatStripMesh :: (points: []TaiChiVector2, half: float64, mesh: []Vector2) -> s32 {
|
||||
count := cast(s32)points.count
|
||||
if count < 2 || count * 2 > cast(s32)mesh.count {
|
||||
return 0
|
||||
}
|
||||
for row: cast(s32)0..count - 1 {
|
||||
before := points[ifx row > 0 then row - 1 else row]
|
||||
after := points[ifx row < count - 1 then row + 1 else row]
|
||||
along := TaiChiUnit2(TaiChiSub2(after, before), TaiChiV2(1.0, 0.0))
|
||||
side := TaiChiV2(-along.y, along.x)
|
||||
left := TaiChiAdd2(points[row], TaiChiScale2(side, half))
|
||||
right := TaiChiSub2(points[row], TaiChiScale2(side, half))
|
||||
mesh[row * 2] = Vector2.{cast(float32)left.x, cast(float32)left.y}
|
||||
mesh[row * 2 + 1] = Vector2.{cast(float32)right.x, cast(float32)right.y}
|
||||
}
|
||||
return count * 2
|
||||
}
|
||||
|
||||
// Each thumbnail is a solved pose of its actual item, seen from the chosen
|
||||
// angle. Building these uses a separate timeline, so opening a chooser
|
||||
// cannot overwrite playback.
|
||||
TaiChiPreview :: struct {
|
||||
generation: u64
|
||||
ready: bool
|
||||
frame: TaiChiFrame
|
||||
view: s32
|
||||
solved: TaiChiSolved
|
||||
framing: TaiChiFraming
|
||||
half_width: float64
|
||||
// The pose's lowest and highest points on the picture plane.
|
||||
low: float64
|
||||
high: float64
|
||||
}
|
||||
|
||||
tai_chi_previews: [TAI_CHI_ITEM_CAPACITY * TAI_CHI_CHARACTER_COUNT]TaiChiPreview;
|
||||
tai_chi_preview_timeline: TaiChiTimeline;
|
||||
|
||||
TaiChiDrawPreview :: (session: Session, item_index: s32, character: s32,
|
||||
TaiChiDrawPreview :: (session: Session, item_index: s32, character: s32, angle: s32,
|
||||
area: Rectangle, key: u64, alt_text: string) {
|
||||
if item_index < 0 || item_index >= tai_chi_course.item_count ||
|
||||
character < 0 || character >= tai_chi_course.character_count {
|
||||
@@ -140,44 +170,36 @@ TaiChiDrawPreview :: (session: Session, item_index: s32, character: s32,
|
||||
}
|
||||
preview := *tai_chi_previews[item_index * TAI_CHI_CHARACTER_COUNT + character]
|
||||
item := tai_chi_course.items[item_index]
|
||||
if !preview.ready || preview.generation != tai_chi_course_generation {
|
||||
rig := TaiChiRigFor(character)
|
||||
if !preview.ready || preview.generation != tai_chi_course_generation || preview.view != angle {
|
||||
if !TaiChiTimelineForItem(*tai_chi_preview_timeline, item) {
|
||||
return
|
||||
}
|
||||
pose := TaiChiTimelineSample(*tai_chi_preview_timeline,
|
||||
tai_chi_preview_timeline.duration * 0.45)
|
||||
rig := TaiChiRigFor(character)
|
||||
solved := TaiChiSolvePose(*pose, *rig)
|
||||
view := TaiChiViewSpecFor(item.view)
|
||||
preview.solved = TaiChiSolvePose(*pose, *rig)
|
||||
view := TaiChiViewSpecFor(angle)
|
||||
camera: TaiChiCameraState
|
||||
camera = TaiChiCameraUpdate(camera, view, solved.pelvis,
|
||||
camera = TaiChiCameraUpdate(camera, view, preview.solved.pelvis,
|
||||
pose.channels[TAI_CHI_FACING], 0.0, true)
|
||||
preview.framing = TaiChiFramingFor(camera, view)
|
||||
images := TaiChiImagesFor(character)
|
||||
memory: TaiChiLayoutMemory
|
||||
preview.frame = TaiChiLayout(*solved, *rig, *images,
|
||||
preview.framing.camera, *memory)
|
||||
TaiChiFlatPaint(*tai_chi_flat_frame, *preview.solved, *rig, character, preview.framing.camera)
|
||||
preview.half_width = 0.0
|
||||
preview.low = 1000.0
|
||||
preview.high = -1000.0
|
||||
points: [TAI_CHI_MESH_CAPACITY]TaiChiVector2
|
||||
for index: cast(s32)0..TAI_CHI_PIECE_COUNT - 1 {
|
||||
piece := preview.frame.pieces[index]
|
||||
grid := TaiChiMeshGrid(*piece)
|
||||
count := grid[0] * grid[1]
|
||||
TaiChiPieceVertices(*piece, grid[0], grid[1], points[:count])
|
||||
for point: cast(s32)0..count - 1 {
|
||||
preview.half_width = TaiChiMax(preview.half_width, TaiChiAbs(points[point].x))
|
||||
preview.low = TaiChiMin(preview.low, points[point].y)
|
||||
preview.high = TaiChiMax(preview.high, points[point].y)
|
||||
}
|
||||
low: float64 = 1000.0
|
||||
high: float64 = -1000.0
|
||||
for index: cast(s32)0..tai_chi_flat_frame.point_count - 1 {
|
||||
point := tai_chi_flat_frame.points[index]
|
||||
preview.half_width = TaiChiMax(preview.half_width, TaiChiAbs(point.x))
|
||||
low = TaiChiMin(low, point.y)
|
||||
high = TaiChiMax(high, point.y)
|
||||
}
|
||||
// The pose fills its card with a little room above and below.
|
||||
if preview.high > preview.low {
|
||||
preview.framing.view_center = (preview.low + preview.high) / 2.0
|
||||
preview.framing.view_height = (preview.high - preview.low) * 1.15
|
||||
if high > low {
|
||||
preview.framing.view_center = (low + high) / 2.0
|
||||
preview.framing.view_height = (high - low) * 1.15
|
||||
}
|
||||
preview.generation = tai_chi_course_generation
|
||||
preview.view = angle
|
||||
preview.ready = true
|
||||
}
|
||||
// Fit the full pose horizontally as well as vertically on narrow
|
||||
@@ -187,6 +209,7 @@ TaiChiDrawPreview :: (session: Session, item_index: s32, character: s32,
|
||||
width_height := preview.half_width * 2.1 * cast(float64)area.height / cast(float64)area.width
|
||||
framing.view_height = TaiChiMax(framing.view_height, width_height)
|
||||
}
|
||||
TaiChiPaintFrame(session, *preview.frame, framing, item.mirror,
|
||||
TaiChiFlatPaint(*tai_chi_flat_frame, *preview.solved, *rig, character, framing.camera)
|
||||
TaiChiPaintFlat(session, *tai_chi_flat_frame, framing, TaiChiViewMirrored(angle),
|
||||
area, key, alt_text)
|
||||
}
|
||||
@@ -1,705 +0,0 @@
|
||||
// Where the painted pieces of a Tai Chi character go, as the course studio
|
||||
// lays them out (design/tai-chi/src/painted/layout.js).
|
||||
//
|
||||
// Every joint is projected onto the picture plane of a camera that looks
|
||||
// along a view yaw with a slight downward tilt. Arms and legs are painted
|
||||
// straight and bend along their projected bones; the torso follows the
|
||||
// projected spine; the head, hands and shoes are rigid drawings picked by
|
||||
// how each part is turned toward the viewer, mirrored for the other side.
|
||||
// Units are metres; screen y points up.
|
||||
#import "math"
|
||||
#import, file "tai_chi_math.zi";
|
||||
#import, file "tai_chi_course.zi";
|
||||
#import, file "tai_chi_solve.zi";
|
||||
|
||||
// Degrees past a view boundary before a drawing changes, so a part that
|
||||
// hovers on a boundary does not flicker between two drawings.
|
||||
TAI_CHI_VIEW_HYSTERESIS :: 5.0
|
||||
TAI_CHI_TORSO_ROWS :: 32
|
||||
TAI_CHI_SHADOW_SIZE :: 128.0
|
||||
|
||||
TAI_CHI_PIECE_SHADOW_LEFT :: 0
|
||||
TAI_CHI_PIECE_SHADOW_RIGHT :: 1
|
||||
TAI_CHI_PIECE_SHADOW_BODY :: 2
|
||||
TAI_CHI_PIECE_TORSO :: 3
|
||||
TAI_CHI_PIECE_HEAD :: 4
|
||||
TAI_CHI_PIECE_ARM :: 5
|
||||
TAI_CHI_PIECE_HAND :: 7
|
||||
TAI_CHI_PIECE_LEG :: 9
|
||||
TAI_CHI_PIECE_SHOE :: 11
|
||||
TAI_CHI_PIECE_COUNT :: 13
|
||||
|
||||
TAI_CHI_PIECE_AFFINE :: 0
|
||||
TAI_CHI_PIECE_LIMB :: 1
|
||||
TAI_CHI_PIECE_STRIP_TORSO :: 2
|
||||
TAI_CHI_PIECE_SHOE_SIDE :: 3
|
||||
|
||||
// Drawing names, in the order of `TaiChiFigureImages`.
|
||||
TAI_CHI_VIEW_COUNT :: 5
|
||||
TAI_CHI_HAND_PALM :: 0
|
||||
TAI_CHI_HAND_BACK :: 1
|
||||
TAI_CHI_HAND_EDGE :: 2
|
||||
TAI_CHI_HAND_FIST_FRONT :: 3
|
||||
TAI_CHI_HAND_FIST_SIDE :: 4
|
||||
TAI_CHI_HAND_HOOK :: 5
|
||||
TAI_CHI_SHOE_OUTER :: 0
|
||||
TAI_CHI_SHOE_INNER :: 1
|
||||
// Rigid shoes by view: front, three-quarter, (side has none), three-
|
||||
// quarter back, back.
|
||||
TAI_CHI_SHOE_FRONT :: 2
|
||||
TAI_CHI_SHOE_THREE_QUARTER :: 3
|
||||
TAI_CHI_SHOE_THREE_QUARTER_BACK :: 4
|
||||
TAI_CHI_SHOE_BACK :: 5
|
||||
|
||||
// The course images of one character, found once by role.
|
||||
TaiChiFigureImages :: struct {
|
||||
valid: bool
|
||||
head: [TAI_CHI_VIEW_COUNT]s32
|
||||
torso: [TAI_CHI_VIEW_COUNT]s32
|
||||
arm: s32
|
||||
leg: s32
|
||||
hands: [6]s32
|
||||
shoes: [6]s32
|
||||
}
|
||||
|
||||
TaiChiFlatView :: struct {
|
||||
yaw: float64
|
||||
tilt: float64
|
||||
center: TaiChiVector3
|
||||
toward: TaiChiVector3
|
||||
flat_toward: TaiChiVector3
|
||||
right: TaiChiVector3
|
||||
up: TaiChiVector3
|
||||
}
|
||||
|
||||
TaiChiViewChoice :: struct {
|
||||
set: bool
|
||||
index: s32
|
||||
mirror: bool
|
||||
}
|
||||
|
||||
// Drawing choices kept between frames for hysteresis.
|
||||
TaiChiLayoutMemory :: struct {
|
||||
torso: TaiChiViewChoice
|
||||
head: TaiChiViewChoice
|
||||
shoes: [2]TaiChiViewChoice
|
||||
arm_flips: [2]float64
|
||||
leg_flips: [2]float64
|
||||
hand_flips: [2]float64
|
||||
// The last hand drawing plus one; zero before the first frame.
|
||||
hands: [2]s32
|
||||
}
|
||||
|
||||
// One placed piece. Affine pieces put the image point `anchor` on `at`,
|
||||
// one pixel right moving by `x_axis` and one pixel down by `y_axis`. Limbs
|
||||
// bend along root → joint → end. The torso follows its spine points. Side
|
||||
// shoes bend at the ball.
|
||||
TaiChiPiece :: struct {
|
||||
kind: s32
|
||||
// A course image, or -1 for the shadow.
|
||||
image: s32
|
||||
opacity: float64
|
||||
at: TaiChiVector2
|
||||
anchor: TaiChiVector2
|
||||
x_axis: TaiChiVector2
|
||||
y_axis: TaiChiVector2
|
||||
root: TaiChiVector2
|
||||
joint: TaiChiVector2
|
||||
end: TaiChiVector2
|
||||
upper_share: float64
|
||||
pixel: float64
|
||||
flip: float64
|
||||
mirror: bool
|
||||
spine: [5]TaiChiVector2
|
||||
lengths: [5]float64
|
||||
heel: TaiChiVector2
|
||||
ball: TaiChiVector2
|
||||
toe: TaiChiVector2
|
||||
foot_up: TaiChiVector2
|
||||
toes_up: TaiChiVector2
|
||||
ball_share: float64
|
||||
}
|
||||
|
||||
TaiChiFrame :: struct {
|
||||
pieces: [TAI_CHI_PIECE_COUNT]TaiChiPiece
|
||||
// Pieces back to front.
|
||||
order: [TAI_CHI_PIECE_COUNT]s32
|
||||
}
|
||||
|
||||
TaiChiCamera :: struct {
|
||||
yaw: float64
|
||||
tilt: float64
|
||||
center: TaiChiVector3
|
||||
}
|
||||
|
||||
// --- Images ----------------------------------------------------------------------
|
||||
|
||||
TaiChiFigureImagesFor :: (character: s32) -> TaiChiFigureImages {
|
||||
images: TaiChiFigureImages
|
||||
views: [TAI_CHI_VIEW_COUNT]string = .["front", "threeQuarter", "side", "threeQuarterBack", "back"]
|
||||
hands: [6]string = .["hands.palm", "hands.back", "hands.edge", "hands.fistFront", "hands.fistSide", "hands.hook"]
|
||||
shoes: [6]string = .["shoes.outer", "shoes.inner", "shoes.front", "shoes.threeQuarter", "shoes.threeQuarterBack", "shoes.back"]
|
||||
heads: [TAI_CHI_VIEW_COUNT]string = .["head.front", "head.threeQuarter", "head.side", "head.threeQuarterBack", "head.back"]
|
||||
torsos: [TAI_CHI_VIEW_COUNT]string = .["torso.front", "torso.threeQuarter", "torso.side", "torso.threeQuarterBack", "torso.back"]
|
||||
images.valid = true
|
||||
for index: cast(s32)0..TAI_CHI_VIEW_COUNT - 1 {
|
||||
images.head[index] = TaiChiCourseImage(character, heads[index])
|
||||
images.torso[index] = TaiChiCourseImage(character, torsos[index])
|
||||
images.valid = images.valid && images.head[index] >= 0 && images.torso[index] >= 0
|
||||
}
|
||||
for index: cast(s32)0..5 {
|
||||
images.hands[index] = TaiChiCourseImage(character, hands[index])
|
||||
images.shoes[index] = TaiChiCourseImage(character, shoes[index])
|
||||
images.valid = images.valid && images.hands[index] >= 0 && images.shoes[index] >= 0
|
||||
}
|
||||
images.arm = TaiChiCourseImage(character, "arm")
|
||||
images.leg = TaiChiCourseImage(character, "leg")
|
||||
images.valid = images.valid && images.arm >= 0 && images.leg >= 0
|
||||
return images
|
||||
}
|
||||
|
||||
// Named point `slot` of an image, in pixels.
|
||||
TaiChiImagePoint :: (image: s32, slot: s32) -> TaiChiVector2 {
|
||||
points := tai_chi_course.images[image].points
|
||||
return TaiChiV2(points[slot * 2], points[slot * 2 + 1])
|
||||
}
|
||||
|
||||
TaiChiImageWidth :: (image: s32) -> float64 {
|
||||
if image < 0 {
|
||||
return TAI_CHI_SHADOW_SIZE
|
||||
}
|
||||
return tai_chi_course.images[image].width
|
||||
}
|
||||
|
||||
TaiChiImageHeight :: (image: s32) -> float64 {
|
||||
if image < 0 {
|
||||
return TAI_CHI_SHADOW_SIZE
|
||||
}
|
||||
return tai_chi_course.images[image].height
|
||||
}
|
||||
|
||||
// --- Flat view -------------------------------------------------------------------
|
||||
|
||||
TaiChiFlatViewSet :: (view: *TaiChiFlatView, camera: TaiChiCamera) {
|
||||
view.yaw = camera.yaw
|
||||
view.tilt = camera.tilt
|
||||
view.center = TaiChiFlat3(camera.center)
|
||||
view.toward = TaiChiV3(Sin(camera.yaw) * Cos(camera.tilt), Sin(camera.tilt), Cos(camera.yaw) * Cos(camera.tilt))
|
||||
view.flat_toward = TaiChiV3(Sin(camera.yaw), 0.0, Cos(camera.yaw))
|
||||
view.right = TaiChiV3(Cos(camera.yaw), 0.0, -Sin(camera.yaw))
|
||||
view.up = TaiChiCross3(view.toward, view.right)
|
||||
}
|
||||
|
||||
TaiChiProject :: (view: *TaiChiFlatView, point: TaiChiVector3) -> TaiChiVector2 {
|
||||
offset := TaiChiSub3(point, view.center)
|
||||
return TaiChiV2(TaiChiDot3(offset, view.right), TaiChiDot3(offset, view.up))
|
||||
}
|
||||
|
||||
TaiChiProjectVector :: (view: *TaiChiFlatView, vector: TaiChiVector3) -> TaiChiVector2 {
|
||||
return TaiChiV2(TaiChiDot3(vector, view.right), TaiChiDot3(vector, view.up))
|
||||
}
|
||||
|
||||
TaiChiDepth :: (view: *TaiChiFlatView, point: TaiChiVector3) -> float64 {
|
||||
return TaiChiDot3(TaiChiSub3(point, view.center), view.toward)
|
||||
}
|
||||
|
||||
// Where a horizontal direction points: 0 at the viewer, +90° to the
|
||||
// screen's right, ±180° away.
|
||||
TaiChiFacing :: (view: *TaiChiFlatView, direction: TaiChiVector3) -> float64 {
|
||||
return Atan2(TaiChiDot3(direction, view.right), TaiChiDot3(direction, view.flat_toward))
|
||||
}
|
||||
|
||||
// --- View choice -----------------------------------------------------------------
|
||||
|
||||
// The drawing for a part facing `angle`. Front and back drawings keep their
|
||||
// last mirroring so they do not flip while facing straight on.
|
||||
TaiChiPickView :: (angle: float64, memory: *TaiChiViewChoice) -> TaiChiViewChoice {
|
||||
degrees := TaiChiAbs(angle) / TAI_CHI_DEGREE
|
||||
// Rounded to the nearest view; the angle is never negative here.
|
||||
index := cast(s32)(degrees / 45.0 + 0.5)
|
||||
if index > 4 {
|
||||
index = 4
|
||||
}
|
||||
if memory.set && TaiChiAbs(degrees - cast(float64)memory.index * 45.0) < 22.5 + TAI_CHI_VIEW_HYSTERESIS {
|
||||
index = memory.index
|
||||
}
|
||||
mirror := angle < 0.0
|
||||
if (index == 0 || index == 4) && memory.set && memory.index == index {
|
||||
mirror = memory.mirror
|
||||
}
|
||||
memory.set = true
|
||||
memory.index = index
|
||||
memory.mirror = mirror
|
||||
return memory.*
|
||||
}
|
||||
|
||||
// A sign that keeps its last value while `value` is close to zero.
|
||||
TaiChiStickySign :: (value: float64, memory: *float64, dead: float64) -> float64 {
|
||||
if TaiChiAbs(value) > dead || memory.* == 0.0 {
|
||||
memory.* = ifx value >= 0.0 then 1.0 else -1.0
|
||||
}
|
||||
return memory.*
|
||||
}
|
||||
|
||||
// --- Pieces ----------------------------------------------------------------------
|
||||
|
||||
TaiChiShadowPiece :: (view: *TaiChiFlatView, center: TaiChiVector3, width: float64, depth: float64, strength: float64) -> TaiChiPiece {
|
||||
piece: TaiChiPiece
|
||||
piece.kind = TAI_CHI_PIECE_AFFINE
|
||||
piece.image = -1
|
||||
piece.at = TaiChiProject(view, center)
|
||||
piece.anchor = TaiChiV2(TAI_CHI_SHADOW_SIZE / 2.0, TAI_CHI_SHADOW_SIZE / 2.0)
|
||||
piece.x_axis = TaiChiV2(width / TAI_CHI_SHADOW_SIZE, 0.0)
|
||||
piece.y_axis = TaiChiV2(0.0, -(depth * Sin(TaiChiMax(view.tilt, 4.0 * TAI_CHI_DEGREE)) + 0.012) / TAI_CHI_SHADOW_SIZE)
|
||||
piece.opacity = strength
|
||||
return piece
|
||||
}
|
||||
|
||||
TaiChiLimbPiece :: (image: s32, root: TaiChiVector2, joint: TaiChiVector2, end: TaiChiVector2, upper_length: float64,
|
||||
lower_length: float64, anterior: TaiChiVector2, memory: *float64) -> TaiChiPiece {
|
||||
upper := TaiChiSub2(joint, root)
|
||||
lower := TaiChiSub2(end, joint)
|
||||
upper_direction := TaiChiUnit2(upper, TaiChiUnit2(lower, TaiChiV2(0.0, -1.0)))
|
||||
lower_direction := TaiChiUnit2(lower, upper_direction)
|
||||
// The painting's +x is the limb's front when its anterior value is 1.
|
||||
joint_normal := TaiChiClockwise(TaiChiScale2(TaiChiUnit2(TaiChiAdd2(upper_direction, lower_direction), upper_direction), -1.0))
|
||||
values := tai_chi_course.images[image].values
|
||||
piece: TaiChiPiece
|
||||
piece.kind = TAI_CHI_PIECE_LIMB
|
||||
piece.image = image
|
||||
piece.opacity = 1.0
|
||||
piece.root = root
|
||||
piece.joint = joint
|
||||
piece.end = end
|
||||
piece.upper_share = upper_length / (upper_length + lower_length)
|
||||
piece.pixel = (upper_length + lower_length) / (TaiChiImagePoint(image, 1).y - TaiChiImagePoint(image, 0).y)
|
||||
piece.flip = TaiChiStickySign(TaiChiDot2(joint_normal, anterior), memory, 0.08) * values[0]
|
||||
return piece
|
||||
}
|
||||
|
||||
TaiChiPieceOpaque :: (image: s32) -> TaiChiPiece {
|
||||
piece: TaiChiPiece
|
||||
piece.kind = TAI_CHI_PIECE_AFFINE
|
||||
piece.image = image
|
||||
piece.opacity = 1.0
|
||||
return piece
|
||||
}
|
||||
|
||||
// The torso's spine path at a share of its real length (below 0 above the
|
||||
// neck, beyond 1 below the hips).
|
||||
TaiChiSpineAt :: (piece: *TaiChiPiece, share: float64) -> TaiChiVector2 {
|
||||
total := piece.lengths[4]
|
||||
target := share * total
|
||||
index: s32 = 1
|
||||
while index < 4 && piece.lengths[index] < target {
|
||||
index += 1
|
||||
}
|
||||
span := piece.lengths[index] - piece.lengths[index - 1]
|
||||
if span == 0.0 {
|
||||
span = 1.0
|
||||
}
|
||||
u := (target - piece.lengths[index - 1]) / span
|
||||
return TaiChiLerp2(piece.spine[index - 1], piece.spine[index], u)
|
||||
}
|
||||
|
||||
TaiChiTorsoRow :: struct {
|
||||
center: TaiChiVector2
|
||||
across: TaiChiVector2
|
||||
axis_x: float64
|
||||
}
|
||||
|
||||
// The torso strip's row `row` of `rows`: its centre on the spine, the
|
||||
// direction of the image's +x and the image x of the spine there.
|
||||
TaiChiTorsoRowAt :: (piece: *TaiChiPiece, row: s32, rows: s32) -> TaiChiTorsoRow {
|
||||
image := piece.image
|
||||
neck := TaiChiImagePoint(image, 0)
|
||||
hip := TaiChiImagePoint(image, 1)
|
||||
height := TaiChiImageHeight(image)
|
||||
span := hip.y - neck.y
|
||||
before_row := ifx row > 0 then row - 1 else 0
|
||||
after_row := ifx row < rows - 1 then row + 1 else rows - 1
|
||||
y := (cast(float64)row / cast(float64)(rows - 1)) * height
|
||||
before_y := (cast(float64)before_row / cast(float64)(rows - 1)) * height
|
||||
after_y := (cast(float64)after_row / cast(float64)(rows - 1)) * height
|
||||
before := TaiChiSpineAt(piece, (before_y - neck.y) / span)
|
||||
after := TaiChiSpineAt(piece, (after_y - neck.y) / span)
|
||||
// Down the spine; its clockwise normal is the image's right.
|
||||
down := TaiChiUnit2(TaiChiSub2(after, before), TaiChiV2(0.0, -1.0))
|
||||
across := TaiChiClockwise(TaiChiScale2(down, -1.0))
|
||||
if piece.mirror {
|
||||
across = TaiChiScale2(across, -1.0)
|
||||
}
|
||||
share := TaiChiClamp((y - neck.y) / span, 0.0, 1.0)
|
||||
result: TaiChiTorsoRow
|
||||
result.center = TaiChiSpineAt(piece, (y - neck.y) / span)
|
||||
result.across = across
|
||||
result.axis_x = neck.x + (hip.x - neck.x) * share
|
||||
return result
|
||||
}
|
||||
|
||||
// An image point on the placed torso, found between its rows.
|
||||
TaiChiTorsoPoint :: (piece: *TaiChiPiece, point: TaiChiVector2) -> TaiChiVector2 {
|
||||
rows: s32 = TAI_CHI_TORSO_ROWS
|
||||
row_float := (point.y / TaiChiImageHeight(piece.image)) * cast(float64)(rows - 1)
|
||||
row := cast(s32)row_float
|
||||
if row > rows - 2 {
|
||||
row = rows - 2
|
||||
}
|
||||
if row < 0 {
|
||||
row = 0
|
||||
}
|
||||
u := row_float - cast(float64)row
|
||||
a := TaiChiTorsoRowAt(piece, row, rows)
|
||||
b := TaiChiTorsoRowAt(piece, row + 1, rows)
|
||||
center := TaiChiLerp2(a.center, b.center, u)
|
||||
across := TaiChiLerp2(a.across, b.across, u)
|
||||
axis_x := a.axis_x + (b.axis_x - a.axis_x) * u
|
||||
return TaiChiAdd2(center, TaiChiScale2(across, (point.x - axis_x) * piece.pixel))
|
||||
}
|
||||
|
||||
TaiChiHandPiece :: (side: s32, solved: *TaiChiSolved, view: *TaiChiFlatView, images: *TaiChiFigureImages,
|
||||
memory: *TaiChiLayoutMemory, hand_scale: float64) -> TaiChiPiece {
|
||||
quat := solved.hand_quats[side]
|
||||
fingers := TaiChiAxis(quat, 0.0, -1.0, 0.0)
|
||||
palm_normal := TaiChiAxis(quat, 0.0, 0.0, 1.0)
|
||||
thumb := TaiChiScale3(TaiChiAxis(quat, 1.0, 0.0, 0.0), TaiChiSideSign(side))
|
||||
shape := solved.hand_shapes[side]
|
||||
facing := TaiChiDot3(palm_normal, view.toward)
|
||||
name: s32 = TAI_CHI_HAND_EDGE
|
||||
if shape[2] > 0.5 {
|
||||
name = TAI_CHI_HAND_HOOK
|
||||
} else if shape[1] > 0.5 {
|
||||
name = ifx TaiChiAbs(facing) > 0.45 then TAI_CHI_HAND_FIST_FRONT else TAI_CHI_HAND_FIST_SIDE
|
||||
} else {
|
||||
previous := memory.hands[side] - 1
|
||||
palm_limit := ifx previous == TAI_CHI_HAND_PALM then 0.27 else 0.35
|
||||
back_limit := ifx previous == TAI_CHI_HAND_BACK then 0.27 else 0.35
|
||||
if facing > palm_limit {
|
||||
name = TAI_CHI_HAND_PALM
|
||||
} else if facing < -back_limit {
|
||||
name = TAI_CHI_HAND_BACK
|
||||
}
|
||||
}
|
||||
memory.hands[side] = name + 1
|
||||
image := images.hands[name]
|
||||
values := tai_chi_course.images[image].values
|
||||
wrist := TaiChiProject(view, solved.wrists[side])
|
||||
main := TaiChiProjectVector(view, fingers)
|
||||
forearm := TaiChiUnit2(TaiChiSub2(wrist, TaiChiProject(view, solved.elbows[side])), TaiChiV2(0.0, -1.0))
|
||||
// Fingers pointing at the viewer: lean the drawing along the forearm.
|
||||
reach := TaiChiLength2(main)
|
||||
if reach < 0.35 {
|
||||
main = TaiChiLerp2(forearm, TaiChiUnit2(main, forearm), reach / 0.35)
|
||||
}
|
||||
along := TaiChiUnit2(main, forearm)
|
||||
shorten := TaiChiClamp(reach, 0.6, 1.0)
|
||||
across_thumb := values[3] > 0.5
|
||||
target := TaiChiProjectVector(view, ifx across_thumb then thumb else palm_normal)
|
||||
flip := TaiChiStickySign(TaiChiDot2(TaiChiClockwise(along), target), *memory.hand_flips[side], 0.05) * values[2]
|
||||
image_wrist := TaiChiImagePoint(image, 0)
|
||||
image_tip := TaiChiImagePoint(image, 1)
|
||||
// Image axes: from the wrist to the tip is "main"; its clockwise
|
||||
// normal is "across".
|
||||
image_main := TaiChiUnit2(TaiChiV2(image_tip.x - image_wrist.x, -(image_tip.y - image_wrist.y)), TaiChiV2(0.0, 1.0))
|
||||
image_across := TaiChiClockwise(image_main)
|
||||
screen_across := TaiChiScale2(TaiChiClockwise(along), flip)
|
||||
piece := TaiChiPieceOpaque(image)
|
||||
piece.at = wrist
|
||||
piece.anchor = image_wrist
|
||||
piece.x_axis = TaiChiAdd2(TaiChiScale2(along, image_main.x * hand_scale * shorten),
|
||||
TaiChiScale2(screen_across, image_across.x * hand_scale))
|
||||
piece.y_axis = TaiChiAdd2(TaiChiScale2(along, -image_main.y * hand_scale * shorten),
|
||||
TaiChiScale2(screen_across, -image_across.y * hand_scale))
|
||||
return piece
|
||||
}
|
||||
|
||||
TaiChiShoePiece :: (side: s32, solved: *TaiChiSolved, view: *TaiChiFlatView, images: *TaiChiFigureImages,
|
||||
memory: *TaiChiLayoutMemory, rig: *TaiChiRig, shoe_scale: float64) -> TaiChiPiece {
|
||||
foot_quat := solved.foot_quats[side]
|
||||
toes_quat := solved.toes_quats[side]
|
||||
forward := TaiChiFlat3(TaiChiAxis(foot_quat, 0.0, 0.0, 1.0))
|
||||
choice := TaiChiPickView(TaiChiFacing(view, forward), *memory.shoes[side])
|
||||
if choice.index == 2 {
|
||||
outward := TaiChiScale3(TaiChiAxis(foot_quat, 1.0, 0.0, 0.0), TaiChiSideSign(side))
|
||||
name := ifx TaiChiDot3(outward, view.toward) >= 0.0 then TAI_CHI_SHOE_OUTER else TAI_CHI_SHOE_INNER
|
||||
piece := TaiChiPieceOpaque(images.shoes[name])
|
||||
piece.kind = TAI_CHI_PIECE_SHOE_SIDE
|
||||
piece.heel = TaiChiProject(view, solved.heels[side])
|
||||
piece.ball = TaiChiProject(view, solved.balls[side])
|
||||
piece.toe = TaiChiProject(view, solved.toes[side])
|
||||
piece.foot_up = TaiChiProjectVector(view, TaiChiAxis(foot_quat, 0.0, 1.0, 0.0))
|
||||
piece.toes_up = TaiChiProjectVector(view, TaiChiAxis(toes_quat, 0.0, 1.0, 0.0))
|
||||
piece.ball_share = (rig.heel_back + rig.ball) / (rig.heel_back + rig.toe_tip)
|
||||
piece.pixel = shoe_scale
|
||||
return piece
|
||||
}
|
||||
shoe_by_view: [5]s32 = .[TAI_CHI_SHOE_FRONT, TAI_CHI_SHOE_THREE_QUARTER, TAI_CHI_SHOE_FRONT,
|
||||
TAI_CHI_SHOE_THREE_QUARTER_BACK, TAI_CHI_SHOE_BACK]
|
||||
image := images.shoes[shoe_by_view[choice.index]]
|
||||
up := TaiChiUnit2(TaiChiProjectVector(view, TaiChiAxis(foot_quat, 0.0, 1.0, 0.0)), TaiChiV2(0.0, 1.0))
|
||||
right := TaiChiClockwise(up)
|
||||
if choice.mirror {
|
||||
right = TaiChiScale2(right, -1.0)
|
||||
}
|
||||
piece := TaiChiPieceOpaque(image)
|
||||
piece.at = TaiChiProject(view, solved.ankles[side])
|
||||
piece.anchor = TaiChiImagePoint(image, 0)
|
||||
piece.x_axis = TaiChiScale2(right, shoe_scale)
|
||||
piece.y_axis = TaiChiScale2(up, -shoe_scale)
|
||||
return piece
|
||||
}
|
||||
|
||||
TaiChiDepthOfArm :: (view: *TaiChiFlatView, solved: *TaiChiSolved, side: s32) -> float64 {
|
||||
return (TaiChiDepth(view, solved.shoulders[side]) + TaiChiDepth(view, solved.elbows[side]) +
|
||||
TaiChiDepth(view, solved.wrists[side])) / 3.0
|
||||
}
|
||||
|
||||
TaiChiDepthOfLeg :: (view: *TaiChiFlatView, solved: *TaiChiSolved, side: s32) -> float64 {
|
||||
return (TaiChiDepth(view, solved.hips[side]) + TaiChiDepth(view, solved.knees[side]) +
|
||||
TaiChiDepth(view, solved.ankles[side])) / 3.0
|
||||
}
|
||||
|
||||
// The pieces of one frame and the order to draw them, back to front.
|
||||
TaiChiLayout :: (solved: *TaiChiSolved, rig: *TaiChiRig, images: *TaiChiFigureImages, camera: TaiChiCamera,
|
||||
memory: *TaiChiLayoutMemory) -> TaiChiFrame {
|
||||
frame: TaiChiFrame
|
||||
view: TaiChiFlatView
|
||||
TaiChiFlatViewSet(*view, camera)
|
||||
|
||||
// Scales in metres per image pixel. The torso maps its neck-to-hip span
|
||||
// onto the spine; the head is drawn to the rig's neck-to-crown height;
|
||||
// hands and shoes share one scale per sheet.
|
||||
front_torso := images.torso[0]
|
||||
torso_scale := (rig.spine[0] + rig.spine[1] + rig.spine[2] + rig.hip_drop) /
|
||||
(TaiChiImagePoint(front_torso, 1).y - TaiChiImagePoint(front_torso, 0).y)
|
||||
front_head := images.head[0]
|
||||
head_scale := (rig.neck + rig.head_height) / (TaiChiImagePoint(front_head, 0).y - TaiChiImagePoint(front_head, 1).y)
|
||||
palm := images.hands[TAI_CHI_HAND_PALM]
|
||||
hand_scale := rig.hand_length / TaiChiLength2(TaiChiSub2(TaiChiImagePoint(palm, 1), TaiChiImagePoint(palm, 0)))
|
||||
outer := images.shoes[TAI_CHI_SHOE_OUTER]
|
||||
shoe_scale := (rig.heel_back + rig.toe_tip) / TaiChiLength2(TaiChiSub2(TaiChiImagePoint(outer, 1), TaiChiImagePoint(outer, 0)))
|
||||
|
||||
order_count: s32 = 0
|
||||
// Shadows on the floor.
|
||||
for side: cast(s32)0..1 {
|
||||
ankle := solved.ankles[side]
|
||||
lift := TaiChiMax(0.0, ankle.y - rig.ankle_height)
|
||||
strength := TaiChiMax(0.0, 1.0 - lift / 0.25) * 0.8
|
||||
frame.pieces[TAI_CHI_PIECE_SHADOW_LEFT + side] = TaiChiShadowPiece(*view, TaiChiFlat3(ankle), 0.32, 0.18, strength)
|
||||
frame.order[order_count] = TAI_CHI_PIECE_SHADOW_LEFT + side
|
||||
order_count += 1
|
||||
}
|
||||
frame.pieces[TAI_CHI_PIECE_SHADOW_BODY] = TaiChiShadowPiece(*view, TaiChiFlat3(solved.pelvis), 0.7, 0.4, 0.55)
|
||||
frame.order[order_count] = TAI_CHI_PIECE_SHADOW_BODY
|
||||
order_count += 1
|
||||
|
||||
// Torso along the spine from the neck base to the middle of the hips.
|
||||
chest_forward := TaiChiFlat3(TaiChiAxis(solved.chest_quat, 0.0, 0.0, 1.0))
|
||||
torso_choice := TaiChiPickView(TaiChiFacing(*view, chest_forward), *memory.torso)
|
||||
torso := TaiChiPieceOpaque(images.torso[torso_choice.index])
|
||||
torso.kind = TAI_CHI_PIECE_STRIP_TORSO
|
||||
torso.mirror = torso_choice.mirror
|
||||
torso.pixel = torso_scale
|
||||
hip_center := TaiChiAdd3(solved.pelvis, TaiChiRotate(TaiChiV3(0.0, -rig.hip_drop, 0.0), solved.pelvis_quat))
|
||||
spine: [5]TaiChiVector3 = .[solved.neck_base, solved.chest, solved.spine1, solved.pelvis, hip_center]
|
||||
torso.lengths[0] = 0.0
|
||||
for index: cast(s32)0..4 {
|
||||
torso.spine[index] = TaiChiProject(*view, spine[index])
|
||||
if index > 0 {
|
||||
torso.lengths[index] = torso.lengths[index - 1] + TaiChiDistance3(spine[index], spine[index - 1])
|
||||
}
|
||||
}
|
||||
frame.pieces[TAI_CHI_PIECE_TORSO] = torso
|
||||
torso_image := torso.image
|
||||
neck_at := TaiChiTorsoPoint(*torso, TaiChiImagePoint(torso_image, 0))
|
||||
armholes: [2]TaiChiVector2
|
||||
armholes[0] = TaiChiTorsoPoint(*torso, TaiChiImagePoint(torso_image, 2))
|
||||
armholes[1] = TaiChiTorsoPoint(*torso, TaiChiImagePoint(torso_image, 3))
|
||||
chest_depth := TaiChiDepth(*view, solved.shoulder_center)
|
||||
|
||||
// Arms start at the painted armholes nearest their real shoulders.
|
||||
real_left := TaiChiProject(*view, solved.shoulders[0])
|
||||
real_right := TaiChiProject(*view, solved.shoulders[1])
|
||||
straight := TaiChiLength2(TaiChiSub2(real_left, armholes[0])) + TaiChiLength2(TaiChiSub2(real_right, armholes[1]))
|
||||
crossed := TaiChiLength2(TaiChiSub2(real_left, armholes[1])) + TaiChiLength2(TaiChiSub2(real_right, armholes[0]))
|
||||
arm_front: [2]bool
|
||||
for side: cast(s32)0..1 {
|
||||
root := armholes[side]
|
||||
if straight > crossed {
|
||||
root = armholes[1 - side]
|
||||
}
|
||||
shoulder := solved.shoulders[side]
|
||||
elbow := solved.elbows[side]
|
||||
wrist := solved.wrists[side]
|
||||
inside := TaiChiSub3(TaiChiScale3(TaiChiAdd3(shoulder, wrist), 0.5), elbow)
|
||||
anterior := TaiChiAxis(solved.chest_quat, 0.0, 0.0, 1.0)
|
||||
if TaiChiLength3(inside) > 0.02 {
|
||||
anterior = TaiChiNormalize3(inside)
|
||||
}
|
||||
frame.pieces[TAI_CHI_PIECE_ARM + side] = TaiChiLimbPiece(images.arm, root, TaiChiProject(*view, elbow),
|
||||
TaiChiProject(*view, wrist), rig.upper_arm, rig.fore_arm, TaiChiProjectVector(*view, anterior), *memory.arm_flips[side])
|
||||
frame.pieces[TAI_CHI_PIECE_HAND + side] = TaiChiHandPiece(side, solved, *view, images, memory, hand_scale)
|
||||
arm_front[side] = TaiChiDepthOfArm(*view, solved, side) > chest_depth - 0.05
|
||||
}
|
||||
|
||||
leg_depths: [2]float64
|
||||
for side: cast(s32)0..1 {
|
||||
hip := solved.hips[side]
|
||||
knee := solved.knees[side]
|
||||
ankle := solved.ankles[side]
|
||||
outward := TaiChiSub3(knee, TaiChiScale3(TaiChiAdd3(hip, ankle), 0.5))
|
||||
anterior := TaiChiAxis(solved.foot_quats[side], 0.0, 0.0, 1.0)
|
||||
if TaiChiLength3(outward) > 0.02 {
|
||||
anterior = TaiChiNormalize3(outward)
|
||||
}
|
||||
frame.pieces[TAI_CHI_PIECE_LEG + side] = TaiChiLimbPiece(images.leg, TaiChiProject(*view, hip), TaiChiProject(*view, knee),
|
||||
TaiChiProject(*view, ankle), rig.thigh, rig.shin, TaiChiProjectVector(*view, anterior), *memory.leg_flips[side])
|
||||
frame.pieces[TAI_CHI_PIECE_SHOE + side] = TaiChiShoePiece(side, solved, *view, images, memory, rig, shoe_scale)
|
||||
leg_depths[side] = TaiChiDepthOfLeg(*view, solved, side)
|
||||
}
|
||||
|
||||
head_forward := TaiChiFlat3(TaiChiAxis(solved.head_quat, 0.0, 0.0, 1.0))
|
||||
head_choice := TaiChiPickView(TaiChiFacing(*view, head_forward), *memory.head)
|
||||
head_image := images.head[head_choice.index]
|
||||
head_up := TaiChiUnit2(TaiChiProjectVector(*view, TaiChiAxis(solved.head_quat, 0.0, 1.0, 0.0)), TaiChiV2(0.0, 1.0))
|
||||
head_right := TaiChiClockwise(head_up)
|
||||
if head_choice.mirror {
|
||||
head_right = TaiChiScale2(head_right, -1.0)
|
||||
}
|
||||
head := TaiChiPieceOpaque(head_image)
|
||||
head.at = neck_at
|
||||
head.anchor = TaiChiImagePoint(head_image, 0)
|
||||
head.x_axis = TaiChiScale2(head_right, head_scale)
|
||||
head.y_axis = TaiChiScale2(head_up, -head_scale)
|
||||
frame.pieces[TAI_CHI_PIECE_HEAD] = head
|
||||
|
||||
for side: cast(s32)0..1 {
|
||||
if !arm_front[side] {
|
||||
frame.order[order_count] = TAI_CHI_PIECE_ARM + side
|
||||
frame.order[order_count + 1] = TAI_CHI_PIECE_HAND + side
|
||||
order_count += 2
|
||||
}
|
||||
}
|
||||
back_leg: s32 = 0
|
||||
if leg_depths[1] < leg_depths[0] {
|
||||
back_leg = 1
|
||||
}
|
||||
for step: cast(s32)0..1 {
|
||||
side := ifx step == 0 then back_leg else 1 - back_leg
|
||||
frame.order[order_count] = TAI_CHI_PIECE_SHOE + side
|
||||
frame.order[order_count + 1] = TAI_CHI_PIECE_LEG + side
|
||||
order_count += 2
|
||||
}
|
||||
frame.order[order_count] = TAI_CHI_PIECE_HEAD
|
||||
frame.order[order_count + 1] = TAI_CHI_PIECE_TORSO
|
||||
order_count += 2
|
||||
// Front arms, the one with the farther elbow first.
|
||||
first_front: s32 = 0
|
||||
if arm_front[0] && arm_front[1] && TaiChiDepth(*view, solved.elbows[1]) < TaiChiDepth(*view, solved.elbows[0]) {
|
||||
first_front = 1
|
||||
}
|
||||
for step: cast(s32)0..1 {
|
||||
side := ifx step == 0 then first_front else 1 - first_front
|
||||
if arm_front[side] {
|
||||
frame.order[order_count] = TAI_CHI_PIECE_ARM + side
|
||||
frame.order[order_count + 1] = TAI_CHI_PIECE_HAND + side
|
||||
order_count += 2
|
||||
}
|
||||
}
|
||||
return frame
|
||||
}
|
||||
|
||||
// --- Vertices --------------------------------------------------------------------
|
||||
|
||||
TaiChiLimbCenter :: struct {
|
||||
point: TaiChiVector2
|
||||
tangent: TaiChiVector2
|
||||
}
|
||||
|
||||
// A straight painted limb bent along root → joint → end: the centre of the
|
||||
// strip at image row `y` and the direction along the limb there.
|
||||
TaiChiLimbCenterAt :: (piece: *TaiChiPiece, y: float64) -> TaiChiLimbCenter {
|
||||
root_y := TaiChiImagePoint(piece.image, 0).y
|
||||
end_y := TaiChiImagePoint(piece.image, 1).y
|
||||
joint_y := root_y + (end_y - root_y) * piece.upper_share
|
||||
half_width := TaiChiImageWidth(piece.image) * 0.5
|
||||
upper := TaiChiSub2(piece.joint, piece.root)
|
||||
lower := TaiChiSub2(piece.end, piece.joint)
|
||||
upper_direction := TaiChiUnit2(upper, TaiChiUnit2(lower, TaiChiV2(0.0, -1.0)))
|
||||
lower_direction := TaiChiUnit2(lower, upper_direction)
|
||||
// Round the joint over about a limb's half width, less on short
|
||||
// (foreshortened) bones.
|
||||
round := TaiChiMin(half_width * 0.9, TaiChiMin(0.45 * (joint_y - root_y), 0.45 * (end_y - joint_y)))
|
||||
result: TaiChiLimbCenter
|
||||
if y <= joint_y - round {
|
||||
result.point = TaiChiAdd2(piece.root, TaiChiScale2(upper, (y - root_y) / (joint_y - root_y)))
|
||||
result.tangent = upper_direction
|
||||
return result
|
||||
}
|
||||
if y >= joint_y + round {
|
||||
result.point = TaiChiAdd2(piece.joint, TaiChiScale2(lower, (y - joint_y) / (end_y - joint_y)))
|
||||
result.tangent = lower_direction
|
||||
return result
|
||||
}
|
||||
before := TaiChiAdd2(piece.root, TaiChiScale2(upper, (joint_y - round - root_y) / (joint_y - root_y)))
|
||||
after := TaiChiAdd2(piece.joint, TaiChiScale2(lower, round / (end_y - joint_y)))
|
||||
u := (y - (joint_y - round)) / (2.0 * round)
|
||||
result.point = TaiChiAdd2(TaiChiAdd2(TaiChiScale2(before, (1.0 - u) * (1.0 - u)), TaiChiScale2(piece.joint, 2.0 * u * (1.0 - u))),
|
||||
TaiChiScale2(after, u * u))
|
||||
tangent := TaiChiAdd2(TaiChiScale2(TaiChiSub2(piece.joint, before), 2.0 * (1.0 - u)), TaiChiScale2(TaiChiSub2(after, piece.joint), 2.0 * u))
|
||||
result.tangent = TaiChiUnit2(tangent, upper_direction)
|
||||
return result
|
||||
}
|
||||
|
||||
// Grid points (`columns` × `rows`, row by row from the image's top) of a
|
||||
// piece over its image. `points` must hold columns × rows entries.
|
||||
TaiChiPieceVertices :: (piece: *TaiChiPiece, columns: s32, rows: s32, points: []TaiChiVector2) {
|
||||
width := TaiChiImageWidth(piece.image)
|
||||
height := TaiChiImageHeight(piece.image)
|
||||
for row: cast(s32)0..rows - 1 {
|
||||
y := (cast(float64)row / cast(float64)(rows - 1)) * height
|
||||
center: TaiChiVector2
|
||||
across: TaiChiVector2
|
||||
axis_x: float64 = 0.0
|
||||
width_scale: float64 = 0.0
|
||||
if piece.kind == TAI_CHI_PIECE_LIMB {
|
||||
limb := TaiChiLimbCenterAt(piece, y)
|
||||
values := tai_chi_course.images[piece.image].values
|
||||
center = limb.point
|
||||
across = TaiChiScale2(TaiChiClockwise(TaiChiScale2(limb.tangent, -1.0)), piece.flip)
|
||||
axis_x = TaiChiImagePoint(piece.image, 0).x
|
||||
width_scale = piece.pixel * values[1]
|
||||
} else if piece.kind == TAI_CHI_PIECE_STRIP_TORSO {
|
||||
torso_row := TaiChiTorsoRowAt(piece, row, rows)
|
||||
center = torso_row.center
|
||||
across = torso_row.across
|
||||
axis_x = torso_row.axis_x
|
||||
width_scale = piece.pixel
|
||||
}
|
||||
for column: cast(s32)0..columns - 1 {
|
||||
x := (cast(float64)column / cast(float64)(columns - 1)) * width
|
||||
point: TaiChiVector2
|
||||
if piece.kind == TAI_CHI_PIECE_AFFINE {
|
||||
point = TaiChiAdd2(piece.at, TaiChiAdd2(TaiChiScale2(piece.x_axis, x - piece.anchor.x),
|
||||
TaiChiScale2(piece.y_axis, y - piece.anchor.y)))
|
||||
} else if piece.kind == TAI_CHI_PIECE_SHOE_SIDE {
|
||||
image_heel := TaiChiImagePoint(piece.image, 0)
|
||||
image_toe := TaiChiImagePoint(piece.image, 1)
|
||||
ball_x := image_heel.x + (image_toe.x - image_heel.x) * piece.ball_share
|
||||
base: TaiChiVector2
|
||||
up: TaiChiVector2
|
||||
if x <= ball_x {
|
||||
base = TaiChiLerp2(piece.heel, piece.ball, (x - image_heel.x) / (ball_x - image_heel.x))
|
||||
up = piece.foot_up
|
||||
} else {
|
||||
base = TaiChiLerp2(piece.ball, piece.toe, (x - ball_x) / (image_toe.x - ball_x))
|
||||
up = TaiChiLerp2(piece.foot_up, piece.toes_up, TaiChiMin(1.0, (x - ball_x) / ((image_toe.x - ball_x) * 0.5)))
|
||||
}
|
||||
point = TaiChiAdd2(base, TaiChiScale2(up, (image_heel.y - y) * piece.pixel))
|
||||
} else {
|
||||
point = TaiChiAdd2(center, TaiChiScale2(across, (x - axis_x) * width_scale))
|
||||
}
|
||||
points[row * columns + column] = point
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -103,7 +103,7 @@ TaiChiPreviewCard :: (app: *InnerBreeze, bounds: Rectangle, item: s32,
|
||||
preview := Rectangle.{bounds.x + padding, bounds.y + padding,
|
||||
bounds.width - padding * 2.0,
|
||||
bounds.height - cast(float32)AppScale(94)}
|
||||
TaiChiDrawPreview(session, item, character, preview, key + cast(u64)1000, title)
|
||||
TaiChiDrawPreview(session, item, character, app.tai_chi.view, preview, key + cast(u64)1000, title)
|
||||
Text(session, TextProps.{
|
||||
.bounds = Rectangle.{bounds.x + padding, text_y,
|
||||
bounds.width - padding * 2.0, cast(float32)AppScale(44)},
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#import, file "tai_chi_course.zi";
|
||||
#import, file "tai_chi_timeline.zi";
|
||||
#import, file "tai_chi_solve.zi";
|
||||
#import, file "tai_chi_layout.zi";
|
||||
#import, file "tai_chi_view.zi";
|
||||
|
||||
TAI_CHI_CHARACTER_COUNT :: 2
|
||||
// Lesson progress is saved as hexadecimal digits, four items per digit.
|
||||
@@ -30,6 +30,9 @@ TaiChiCameraState :: struct {
|
||||
|
||||
TaiChiPracticeState :: struct {
|
||||
character: s32
|
||||
// The angle she is seen from (TAI_CHI_VIEW_*): front, mirrored like a
|
||||
// mirror, unless another is chosen.
|
||||
view: s32
|
||||
// Narration voice: 0 the default voice, 1 male, -1 the character's own.
|
||||
voice: s32
|
||||
// The course item last chosen and not yet finished; -1 suggests the
|
||||
@@ -44,11 +47,12 @@ TaiChiPracticeState :: struct {
|
||||
habit_made: s32
|
||||
built_item: s32
|
||||
camera: TaiChiCameraState
|
||||
memory: TaiChiLayoutMemory
|
||||
}
|
||||
|
||||
tai_chi_timeline: TaiChiTimeline;
|
||||
|
||||
// The studio's camera views (design/tai-chi/src/view/stage.js). The front
|
||||
// stays with the audience; the others travel with her facing.
|
||||
TaiChiViewSpecFor :: (view: s32) -> TaiChiViewSpec {
|
||||
spec: TaiChiViewSpec
|
||||
if view == TAI_CHI_VIEW_FRONT {
|
||||
@@ -59,6 +63,22 @@ TaiChiViewSpecFor :: (view: s32) -> TaiChiViewSpec {
|
||||
spec.target = 0.88
|
||||
return spec
|
||||
}
|
||||
if view == TAI_CHI_VIEW_SIDE {
|
||||
spec.yaw = -TAI_CHI_PI / 2.0
|
||||
spec.fixed = false
|
||||
spec.distance = 4.6
|
||||
spec.height = 1.2
|
||||
spec.target = 0.85
|
||||
return spec
|
||||
}
|
||||
if view == TAI_CHI_VIEW_THREE_QUARTER {
|
||||
spec.yaw = TAI_CHI_PI / 4.0
|
||||
spec.fixed = false
|
||||
spec.distance = 4.8
|
||||
spec.height = 1.6
|
||||
spec.target = 0.85
|
||||
return spec
|
||||
}
|
||||
spec.yaw = TAI_CHI_PI
|
||||
spec.fixed = false
|
||||
spec.distance = 4.4
|
||||
@@ -162,6 +182,9 @@ TaiChiNormalizeSettings :: (state: TaiChiPracticeState) -> TaiChiPracticeState {
|
||||
if state.character < 0 || state.character >= TAI_CHI_CHARACTER_COUNT {
|
||||
state.character = 0
|
||||
}
|
||||
if state.view < 0 || state.view >= TAI_CHI_VIEW_COUNT {
|
||||
state.view = TAI_CHI_VIEW_FRONT
|
||||
}
|
||||
if state.item < -1 || state.item >= TAI_CHI_ITEM_CAPACITY {
|
||||
state.item = -1
|
||||
}
|
||||
@@ -177,8 +200,6 @@ TaiChiStartItem :: (state: TaiChiPracticeState, item: s32) -> TaiChiPracticeStat
|
||||
state.practised = 0.0
|
||||
state.built_item = -1
|
||||
state.camera.initialized = false
|
||||
memory: TaiChiLayoutMemory
|
||||
state.memory = memory
|
||||
if item >= 0 && item < tai_chi_course.item_count &&
|
||||
TaiChiTimelineForItem(*tai_chi_timeline, tai_chi_course.items[item]) {
|
||||
state.built_item = item
|
||||
@@ -298,10 +319,17 @@ TaiChiFramingFor :: (camera: TaiChiCameraState, view: TaiChiViewSpec) -> TaiChiF
|
||||
return framing
|
||||
}
|
||||
|
||||
// The monk (character 0) speaks with the male voice unless another is chosen.
|
||||
// Seen from the front she is mirrored, so her left is on your left, as in
|
||||
// a mirror.
|
||||
TaiChiViewMirrored :: (view: s32) -> bool {
|
||||
return view == TAI_CHI_VIEW_FRONT
|
||||
}
|
||||
|
||||
// Indigo man (character 1) speaks with the male voice unless another is
|
||||
// chosen.
|
||||
TaiChiMaleVoice :: (state: TaiChiPracticeState) -> bool {
|
||||
if state.voice >= 0 {
|
||||
return state.voice == 1
|
||||
}
|
||||
return state.character == 0
|
||||
return state.character == 1
|
||||
}
|
||||
@@ -32,6 +32,8 @@ save_settings :: (app: *InnerBreeze) #foreign c3 "save_settings";
|
||||
#import "image_props"
|
||||
#import "progress_props"
|
||||
#import "progress_widget"
|
||||
#import "segmented_control_widget"
|
||||
#import "segmented_control_props"
|
||||
#import "text_props"
|
||||
#import "text_align"
|
||||
#import, file "../../app/exercise_types.zi";
|
||||
@@ -277,6 +279,33 @@ TaiChiDrawProgress :: (app: *InnerBreeze, y: s32) {
|
||||
Progress(CurrentApp().ui.session, bar)
|
||||
}
|
||||
|
||||
// Buttons to see her from the front, back, side or at an angle; the choice
|
||||
// is kept for later sessions.
|
||||
TaiChiDrawAngles :: (app: *InnerBreeze, y: s32, height: s32) {
|
||||
width := app.ui.view_width - AppScale(48)
|
||||
if width > AppScale(440) {
|
||||
width = AppScale(440)
|
||||
}
|
||||
options: [TAI_CHI_VIEW_COUNT]SegmentOption = .[
|
||||
SegmentOption.{.label = LocaleText("tai_chi_view_front")},
|
||||
SegmentOption.{.label = LocaleText("tai_chi_view_back")},
|
||||
SegmentOption.{.label = LocaleText("tai_chi_view_side")},
|
||||
SegmentOption.{.label = LocaleText("tai_chi_view_angled")}]
|
||||
props: SegmentedControlProps
|
||||
props.key = KeyHash("inbe/practices/tai_chi/angle")
|
||||
props.bounds = Rectangle.{cast(float32)((app.ui.view_width - width) / 2), cast(float32)y,
|
||||
cast(float32)width, cast(float32)height}
|
||||
props.height = height
|
||||
props.selected_index = app.tai_chi.view
|
||||
props.has_selection = true
|
||||
choice := SegmentedControl(app.ui.session, props, options[:])
|
||||
if choice.changed && choice.selected_index != app.tai_chi.view {
|
||||
app.tai_chi.view = choice.selected_index
|
||||
app.settings_dirty = 1
|
||||
save_settings(app)
|
||||
}
|
||||
}
|
||||
|
||||
#program_export
|
||||
tai_chi_draw_screen :: (app: *InnerBreeze, center_x: s32, center_y: s32) {
|
||||
if app == null {
|
||||
@@ -314,8 +343,11 @@ tai_chi_draw_screen :: (app: *InnerBreeze, center_x: s32, center_y: s32) {
|
||||
|
||||
figure_top := TaiChiDrawCue(app, title_h + AppScale(12)) + AppScale(8)
|
||||
progress_y := row.y - AppScale(22)
|
||||
figure_bottom := progress_y - AppScale(12)
|
||||
angle_h := AppScale(40)
|
||||
angle_y := progress_y - AppScale(12) - angle_h
|
||||
figure_bottom := angle_y - AppScale(12)
|
||||
TaiChiDrawProgress(app, progress_y)
|
||||
TaiChiDrawAngles(app, angle_y, angle_h)
|
||||
snap := app.tai_chi.time <= 0.0
|
||||
TaiChiDrawFigure(app.ui.session, *app.tai_chi,
|
||||
Rectangle.{cast(float32)AppScale(12), cast(float32)figure_top,
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
// The picture plane of the Tai Chi figures, as the course studio's
|
||||
// FlatView (design/tai-chi/src/painted/layout.js): every joint is projected
|
||||
// onto the plane of a camera that looks along a view yaw with a slight
|
||||
// downward tilt. Units are metres; screen y points up.
|
||||
#import "math"
|
||||
#import, file "tai_chi_math.zi";
|
||||
|
||||
TaiChiFlatView :: struct {
|
||||
yaw: float64
|
||||
tilt: float64
|
||||
center: TaiChiVector3
|
||||
toward: TaiChiVector3
|
||||
flat_toward: TaiChiVector3
|
||||
right: TaiChiVector3
|
||||
up: TaiChiVector3
|
||||
}
|
||||
|
||||
TaiChiCamera :: struct {
|
||||
yaw: float64
|
||||
tilt: float64
|
||||
center: TaiChiVector3
|
||||
}
|
||||
|
||||
TaiChiFlatViewSet :: (view: *TaiChiFlatView, camera: TaiChiCamera) {
|
||||
view.yaw = camera.yaw
|
||||
view.tilt = camera.tilt
|
||||
view.center = TaiChiFlat3(camera.center)
|
||||
view.toward = TaiChiV3(Sin(camera.yaw) * Cos(camera.tilt), Sin(camera.tilt), Cos(camera.yaw) * Cos(camera.tilt))
|
||||
view.flat_toward = TaiChiV3(Sin(camera.yaw), 0.0, Cos(camera.yaw))
|
||||
view.right = TaiChiV3(Cos(camera.yaw), 0.0, -Sin(camera.yaw))
|
||||
view.up = TaiChiCross3(view.toward, view.right)
|
||||
}
|
||||
|
||||
TaiChiProject :: (view: *TaiChiFlatView, point: TaiChiVector3) -> TaiChiVector2 {
|
||||
offset := TaiChiSub3(point, view.center)
|
||||
return TaiChiV2(TaiChiDot3(offset, view.right), TaiChiDot3(offset, view.up))
|
||||
}
|
||||
|
||||
TaiChiProjectVector :: (view: *TaiChiFlatView, vector: TaiChiVector3) -> TaiChiVector2 {
|
||||
return TaiChiV2(TaiChiDot3(vector, view.right), TaiChiDot3(vector, view.up))
|
||||
}
|
||||
|
||||
TaiChiDepth :: (view: *TaiChiFlatView, point: TaiChiVector3) -> float64 {
|
||||
return TaiChiDot3(TaiChiSub3(point, view.center), view.toward)
|
||||
}
|
||||
@@ -183,7 +183,7 @@ setting_key_importable :: (key: string) -> s32 {
|
||||
import_custom_audio_key(key, "audio_custom_music_") {
|
||||
return 1
|
||||
}
|
||||
keys: [101]string = .[
|
||||
keys: [102]string = .[
|
||||
"launcher_favorite_count", "launcher_favorite_0", "launcher_favorite_1",
|
||||
"speed", "max_rounds", "max_breaths", "pause_seconds",
|
||||
"sound_volume", "music_volume", "voice_narration_enabled", "audio_cue_breath_in",
|
||||
@@ -197,7 +197,7 @@ setting_key_importable :: (key: string) -> s32 {
|
||||
"progressive_speed", "progressive_start_speed", "breath_animation",
|
||||
"double_tap_to_breathe", "advanced_session_controls", "exercise_type",
|
||||
"sun_salutation_character", "sun_salutation_repetitions", "sun_salutation_start_seconds",
|
||||
"sun_salutation_end_seconds", "sun_salutation_voice", "tai_chi_character", "tai_chi_voice", "tai_chi_item", "tai_chi_progress", "tai_chi_habit_made",
|
||||
"sun_salutation_end_seconds", "sun_salutation_voice", "tai_chi_character", "tai_chi_view", "tai_chi_voice", "tai_chi_item", "tai_chi_progress", "tai_chi_habit_made",
|
||||
"meditation_duration_mode", "meditation_custom_minutes",
|
||||
"meditation_show_extend_controls", "meditation_interval_bell",
|
||||
"meditation_music_track", "practice_music_mask",
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"channels":["facing","load","sink","hips","chest","lean","bend","shiftF","shiftS","footL.yaw","footL.pitch","footL.lift","footL.x","footL.z","shapeL0","shapeL1","shapeL2","footR.yaw","footR.pitch","footR.lift","footR.x","footR.z","shapeR0","shapeR1","shapeR2","L.at0","L.at1","L.at2","L.palm0","L.palm1","L.palm2","L.fingers0","L.fingers1","L.fingers2","L.elbow0","L.elbow1","L.elbow2","R.at0","R.at1","R.at2","R.palm0","R.palm1","R.palm2","R.fingers0","R.fingers1","R.fingers2","R.elbow0","R.elbow1","R.elbow2"],"joints":["pelvis","neckBase","shoulderCenter","shoulderL","elbowR","wristL","wristR","kneeL","kneeR","ankleL","heelR","toeL","headTop","com"],"pieces":["shadowL","shadowBody","torso","head","armL","armR","handL","handR","legL","legR","shoeL","shoeR"],"grid":[2,6],"samples":[{"character":"monk","item":16,"time":0,"look":{"from":"fwd","to":"fwd","u":0},"channels":[0,0.5,0,0,0,0,0,0,0,0,0,0,0.05,0,1,0,0,0,0,0,-0.05,0,1,0,0,0.2,-0.58,0.03,-1,0,0,0,-1,0,0.35,-1,-0.25,0.2,-0.58,0.03,-1,0,0,0,-1,0,0.35,-1,-0.25],"joints":[[0,0.938804,0.026888],[0,1.420404,0.026888],[0,1.396324,0.026888],[0.172674,1.388274,0.020577],[-0.255314,1.108938,-0.031034],[0.216113,0.8697,0.057241],[-0.216113,0.8697,0.057241],[0.074267,0.492834,0.054505],[-0.074267,0.492834,0.054505],[0.050588,0.07912,0],[-0.050588,0,-0.0516],[0.050588,0,0.2064],[0,1.714524,0.026888],[0,1.09713,0.030473]],"camera":{"yaw":0.6,"tilt":0.12,"center":[0,0.026888]},"order":["shadowL","shadowR","shadowBody","armR","handR","shoeR","legR","shoeL","legL","head","torso","armL","handL"],"pieces":[{"name":"shadowL","image":"shadow","points":[[-0.103066,0.016011],[0.216934,0.016011],[-0.103066,0.009302],[0.216934,0.009302],[-0.103066,0.002592],[0.216934,0.002592],[-0.103066,-0.004118],[0.216934,-0.004118],[-0.103066,-0.010827],[0.216934,-0.010827],[-0.103066,-0.017537],[0.216934,-0.017537]]},{"name":"shadowBody","image":"shadow","points":[[-0.35,0.029942],[0.35,0.029942],[-0.35,0.017965],[0.35,0.017965],[-0.35,0.005988],[0.35,0.005988],[-0.35,-0.005988],[0.35,-0.005988],[-0.35,-0.017965],[0.35,-0.017965],[-0.35,-0.029942],[0.35,-0.029942]]},{"name":"torso","image":"torso.threeQuarter","points":[[0.200255,1.472939],[-0.177585,1.472939],[0.198889,1.347439],[-0.17895,1.347439],[0.196158,1.221938],[-0.181682,1.221938],[0.193427,1.096437],[-0.184413,1.096437],[0.190695,0.970937],[-0.187145,0.970937],[0.18892,0.845436],[-0.18892,0.845436]]},{"name":"head","image":"head.threeQuarter","points":[[0.093182,1.713813],[-0.128774,1.713813],[0.093182,1.65121],[-0.128774,1.65121],[0.093182,1.588607],[-0.128774,1.588607],[0.093182,1.526004],[-0.128774,1.526004],[0.093182,1.463401],[-0.128774,1.463401],[0.093182,1.400798],[-0.128774,1.400798]]},{"name":"armL","image":"arm","points":[[0.177663,1.437419],[0.07756,1.402335],[0.219419,1.318278],[0.119315,1.283195],[0.261174,1.199138],[0.161071,1.164054],[0.282007,1.055646],[0.176735,1.068655],[0.24393,0.925048],[0.143425,0.958963],[0.203367,0.80484],[0.102862,0.838754]]},{"name":"armR","image":"arm","points":[[-0.176421,1.437412],[-0.071969,1.418934],[-0.195825,1.327725],[-0.091373,1.309247],[-0.215229,1.218037],[-0.110778,1.199559],[-0.232099,1.100694],[-0.126563,1.090026],[-0.241506,0.977031],[-0.135693,0.969596],[-0.250137,0.854208],[-0.144324,0.846772]]},{"name":"handL","image":"hands.back","points":[[0.112693,0.659024],[0.21385,0.660118],[0.112272,0.697429],[0.213428,0.698524],[0.11185,0.735835],[0.213007,0.736929],[0.111429,0.774241],[0.212585,0.775335],[0.111007,0.812647],[0.212164,0.813741],[0.110586,0.851052],[0.211742,0.852147]]},{"name":"handR","image":"hands.palm","points":[[-0.141056,0.69015],[-0.23996,0.687534],[-0.142086,0.728544],[-0.24099,0.725928],[-0.143116,0.766939],[-0.24202,0.764323],[-0.144146,0.805333],[-0.24305,0.802717],[-0.145177,0.843727],[-0.244081,0.841112],[-0.146207,0.882122],[-0.245111,0.879506]]},{"name":"legL","image":"leg","points":[[0.179224,0.922076],[-0.025162,0.936379],[0.166372,0.738429],[-0.038014,0.752732],[0.154241,0.557007],[-0.050391,0.567208],[0.151146,0.382793],[-0.053717,0.379727],[0.155862,0.205569],[-0.048945,0.199872],[0.160828,0.027095],[-0.043979,0.021397]]},{"name":"legR","image":"leg","points":[[0.028973,0.940774],[-0.175907,0.942332],[0.027569,0.75619],[-0.177311,0.757748],[0.026941,0.574536],[-0.177906,0.570548],[0.037778,0.401341],[-0.165957,0.379655],[0.059529,0.223121],[-0.143809,0.197979],[0.081772,0.043231],[-0.121566,0.018089]]},{"name":"shoeL","image":"shoes.threeQuarter","points":[[0.132696,0.186034],[-0.119842,0.186034],[0.132696,0.144401],[-0.119842,0.144401],[0.132696,0.102768],[-0.119842,0.102768],[0.132696,0.061135],[-0.119842,0.061135],[0.132696,0.019502],[-0.119842,0.019502],[0.132696,-0.022131],[-0.119842,-0.022131]]},{"name":"shoeR","image":"shoes.threeQuarter","points":[[0.049191,0.192873],[-0.203347,0.192873],[0.049191,0.15124],[-0.203347,0.15124],[0.049191,0.109607],[-0.203347,0.109607],[0.049191,0.067974],[-0.203347,0.067974],[0.049191,0.026341],[-0.203347,0Line truncated
|
||||
{"channels":["facing","load","sink","hips","chest","lean","bend","shiftF","shiftS","footL.yaw","footL.pitch","footL.lift","footL.x","footL.z","shapeL0","shapeL1","shapeL2","footR.yaw","footR.pitch","footR.lift","footR.x","footR.z","shapeR0","shapeR1","shapeR2","L.at0","L.at1","L.at2","L.palm0","L.palm1","L.palm2","L.fingers0","L.fingers1","L.fingers2","L.elbow0","L.elbow1","L.elbow2","R.at0","R.at1","R.at2","R.palm0","R.palm1","R.palm2","R.fingers0","R.fingers1","R.fingers2","R.elbow0","R.elbow1","R.elbow2"],"joints":["pelvis","neckBase","shoulderCenter","shoulderL","elbowR","wristL","wristR","kneeL","kneeR","ankleL","heelR","toeL","headTop","com"],"samples":[{"character":"jadeWoman","item":16,"time":0,"channels":[0,0.5,0,0,0,0,0,0,0,0,0,0,0.05,0,1,0,0,0,0,0,-0.05,0,1,0,0,0.2,-0.58,0.03,-1,0,0,0,-1,0,0.35,-1,-0.25,0.2,-0.58,0.03,-1,0,0,0,-1,0,0.35,-1,-0.25],"joints":[[0,0.900432,0.025794],[0,1.362432,0.025794],[0,1.339332,0.025794],[0.168889,1.331711,0.019733],[-0.247396,1.063419,-0.02924],[0.207318,0.834141,0.054911],[-0.207318,0.834141,0.054911],[0.072908,0.472678,0.052288],[-0.072908,0.472678,0.052288],[0.048529,0.0759,0],[-0.048529,0,-0.0495],[0.048529,0,0.198],[0,1.644582,0.025794],[0,1.05232,0.029232]],"camera":{"yaw":0.6,"tilt":0.12,"center":[0,0.025794]},"ops":[{"fill":"#3c2d1e","alpha":0.13,"area":0.022954,"center":[0.007282,0.001274],"box":[-0.258727,-0.02739,0.273292,0.029939]},{"fill":"#327262","alpha":1,"area":0.027737,"center":[-0.156302,1.194146],"box":[-0.21766,1.033382,-0.092575,1.351253]},{"fill":"#327262","alpha":1,"area":0.024115,"center":[-0.179072,0.978736],"box":[-0.235584,0.848483,-0.129385,1.121657]},{"fill":"#25314f","alpha":1,"area":0.004435,"center":[-0.185429,0.874109],"box":[-0.235584,0.848483,-0.1361,0.899863]},{"fill":"#d9b395","alpha":1,"area":0.010624,"center":[-0.187548,0.759571],"box":[-0.217885,0.652347,-0.157211,0.863549]},{"fill":"#d9b395","alpha":1,"area":0.001922,"center":[-0.202423,0.766337],"box":[-0.233441,0.733279,-0.172379,0.797834]},{"fill":"#2e3d63","alpha":1,"area":0.048664,"center":[-0.000282,0.846507],"box":[-0.156037,0.73786,0.156037,0.941526]},{"fill":"#d9b395","alpha":1,"area":0.015157,"center":[-0.05671,0.043889],"box":[-0.158738,-0.013888,0.033811,0.114183]},{"fill":"#d9b395","alpha":1,"area":0.007022,"center":[-0.02996,0.115943],"box":[-0.063557,0.050658,0.005036,0.182355]},{"fill":"#24304d","alpha":1,"area":0.078452,"center":[-0.074261,0.686068],"box":[-0.159337,0.405589,0.012263,0.944826]},{"fill":"#24304d","alpha":1,"area":0.047918,"center":[-0.057052,0.330258],"box":[-0.139483,0.124642,0.022869,0.535939]},{"fill":"#24304d","alpha":1,"area":0.009102,"center":[-0.036701,0.169184],"box":[-0.095503,0.124454,0.023686,0.214263]},{"fill":"#f1c7a6","alpha":1,"area":0.015157,"center":[0.023396,0.037329],"box":[-0.078632,-0.020449,0.113917,0.107622]},{"fill":"#f1c7a6","alpha":1,"area":0.006986,"center":[0.05377,0.10908],"box":[0.024001,0.044097,0.085142,0.175184]},{"fill":"#2e3d63","alpha":1,"area":0.078111,"center":[0.060688,0.67507],"box":[-0.020786,0.395733,0.159337,0.932781]},{"fill":"#2e3d63","alpha":1,"area":0.047846,"center":[0.048671,0.320559],"box":[-0.019136,0.115769,0.11038,0.526083]},{"fill":"#273353","alpha":1,"area":0.009667,"center":[0.052478,0.161808],"box":[-0.003504,0.115554,0.11003,0.208496]},{"fill":"#f1c7a6","alpha":1,"area":0.012336,"center":[0,1.396323],"box":[-0.04125,1.311385,0.04125,1.482332]},{"fill":"#3f8f7a","alpha":1,"area":0.023994,"center":[0.005246,0.792604],"box":[-0.196698,0.757109,0.207878,0.828425]},{"fill":"#3f8f7a","alpha":1,"area":0.022456,"center":[0.004568,0.821305],"box":[-0.191063,0.786812,0.200319,0.856332]},{"fill":"#3f8f7a","alpha":1,"area":0.020887,"center":[0.00352,0.850599],"box":[-0.181007,0.81699,0.188937,0.884572]},{"fill":"#3f8f7a","alpha":1,"area":0.019844,"center":[0.002545,0.879766],"box":[-0.17518,0.846798,0.181571,0.913]},{"fill":"#3f8f7a","alpha":1,"area":0.018972,"center":[0.00199,0.908771],"box":[-0.171727,0.876398,0.17646,0.941426]},{"fill":"#3f8f7a","alpha":1,"area":0.018048,"center":[0.001564,0.937769],"box":[-0.167361,0.905999,0.170436,0.969848]},{"fill":"#3f8f7a","alpha":1,"area":0.01717,"center":[0.000661,0.966844],"box":[-0.161588,0.935604,0.163005,0.998357]},{"fill":"#3f8f7a","alpha":1,"area":0.016769,"center":[-0.000536,0.996247],"box":[-0.157609,0.965123,0.156538,1.027371]},{"fill":"#3f8f7a","alpha":1,"area":0.016769,"center":[-0.001365,1.025261],"box":[-0.158438,0.994137,0.155708,1.056384]},{"fill":"#3f8f7a","alpha":1,"area":0.016765,"center":[-0.002661,1.054255],"box":[-0.160994,1.02315,0.154879,1.08531]},{"fill":"#3f8f7a","alpha":1,"area":0.0169,"center":[-0.00466,1.083071],"box":[-0.163744,1.05186,0.153541,1.114227]},{"fill":"#3f8f7a","alpha":1,"area":0.017108,"center":[-0.006562,1.111939],"box":[-0.16675,1.080536,0.152145,1.143251]},{"fill":"#3f8f7a","alpha":1,"area":0.017392,"center":[-0.008424,1.140793],"box":[-0.169893,1.109145,0.151236,1.172332]},{"fill":"#3f8f7a","alpha":1,"aLine truncated
|
||||
@@ -294,8 +294,8 @@ with tempfile.TemporaryDirectory(prefix='inbe-downloads-ui-') as temporary:
|
||||
time.sleep(.5)
|
||||
_, text = capture(window, 'taichi-unowned-manager')
|
||||
assert 'Tai Chi' in text and 'Dew' in text and 'Download size' in text, text
|
||||
# A locked practice offers no narration; the monk's male voice is absent.
|
||||
assert 'Male voice' not in text, text
|
||||
# A locked practice offers no narration; Jade woman's female voice is absent.
|
||||
assert 'Female voice' not in text, text
|
||||
finally:
|
||||
stop(process)
|
||||
# The account's purchase, remembered on this device; sync stays off, so
|
||||
@@ -327,13 +327,13 @@ with tempfile.TemporaryDirectory(prefix='inbe-downloads-ui-') as temporary:
|
||||
if name == 'desktop-manager':
|
||||
# Each narration is chosen per language under its practice, in
|
||||
# the voice from Customize, and Lumi's guide has its own.
|
||||
assert 'Male voice' in text and 'On this device: English' in text, text
|
||||
assert 'Female voice' in text and 'On this device: English' in text, text
|
||||
assert "Lumi's guide" in text and 'Tap a language' in text, text
|
||||
close_manager(window)
|
||||
click_word(window, name + '-customize', 'Customize')
|
||||
time.sleep(1)
|
||||
_, text = capture(window, name + '-customize-open')
|
||||
# The monk speaks with the male voice in its downloaded language.
|
||||
# Jade woman speaks with the female voice in its downloaded language.
|
||||
assert 'Female voice' in text and 'Male voice' in text, text
|
||||
assert 'Plays in English' in text, text
|
||||
finally:
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
// The Tai Chi course loads, and the app's motion matches the course
|
||||
// studio's: sampled poses, solved joints and painted pieces are compared with
|
||||
// tests/fixtures/tai-chi-reference.json, written by
|
||||
// design/tai-chi/tools/export-app.mjs from the same course.bin.
|
||||
// The Tai Chi course loads, and the app's motion and figure match the course
|
||||
// studio's: sampled poses, solved joints and the flat figure's paint
|
||||
// operations are compared with tests/fixtures/tai-chi-reference.json,
|
||||
// written by design/tai-chi/tools/export-app.mjs from the same course.bin.
|
||||
// A filled shape is compared by its area, centroid and bounds, a line by its
|
||||
// ends and number of points.
|
||||
#import "file"
|
||||
#import "json_scan"
|
||||
#import, file "../src/practices/tai_chi/tai_chi_math.zi";
|
||||
#import, file "../src/practices/tai_chi/tai_chi_course.zi";
|
||||
#import, file "../src/practices/tai_chi/tai_chi_timeline.zi";
|
||||
#import, file "../src/practices/tai_chi/tai_chi_solve.zi";
|
||||
#import, file "../src/practices/tai_chi/tai_chi_layout.zi";
|
||||
|
||||
TAI_CHI_TEST_GRID_COLUMNS :: 2
|
||||
TAI_CHI_TEST_GRID_ROWS :: 6
|
||||
#import, file "../src/practices/tai_chi/tai_chi_view.zi";
|
||||
#import, file "../src/practices/tai_chi/tai_chi_flat.zi";
|
||||
|
||||
test_timeline: TaiChiTimeline;
|
||||
test_worst: float64;
|
||||
test_frame: TaiChiFlatFrame;
|
||||
|
||||
TestNumber :: (text: string, at: s32) -> float64 {
|
||||
return ReadNumber(text, at).value
|
||||
@@ -60,22 +61,82 @@ TestJoint :: (solved: *TaiChiSolved, index: s32) -> TaiChiVector3 {
|
||||
return solved.com
|
||||
}
|
||||
|
||||
TestPieceIndex :: (text: string, at: s32) -> s32 {
|
||||
names: [TAI_CHI_PIECE_COUNT]string = .["shadowL", "shadowR", "shadowBody", "torso", "head", "armL", "armR",
|
||||
"handL", "handR", "legL", "legR", "shoeL", "shoeR"]
|
||||
for index: cast(s32)0..TAI_CHI_PIECE_COUNT - 1 {
|
||||
if TestStringIs(text, at, names[index]) {
|
||||
return index
|
||||
}
|
||||
// A "#rrggbb" colour as 0xRRGGBB.
|
||||
TestColor :: (text: string, at: s32) -> u32 {
|
||||
span := ReadString(text, at)
|
||||
color: u32 = 0
|
||||
if !span.valid || span.end - span.start != 7 {
|
||||
return 0xffffffff
|
||||
}
|
||||
return -1
|
||||
for index: span.start + 1..span.end - 1 {
|
||||
digit := cast(u32)text[index]
|
||||
value: u32 = 0
|
||||
if digit >= cast(u32)48 && digit <= cast(u32)57 {
|
||||
value = digit - cast(u32)48
|
||||
} else if digit >= cast(u32)97 && digit <= cast(u32)102 {
|
||||
value = digit - cast(u32)87
|
||||
} else {
|
||||
return 0xffffffff
|
||||
}
|
||||
color = (color << cast(u32)4) | value
|
||||
}
|
||||
return color
|
||||
}
|
||||
|
||||
// Area, centroid and bounds of a filled shape against the reference.
|
||||
TestFill :: (text: string, entry: s32, points: []TaiChiVector2) -> bool {
|
||||
area: float64 = 0.0
|
||||
cx: float64 = 0.0
|
||||
cy: float64 = 0.0
|
||||
low := points[0]
|
||||
high := points[0]
|
||||
count := cast(s32)points.count
|
||||
for index: cast(s32)0..count - 1 {
|
||||
a := points[index]
|
||||
b := points[(index + 1) % count]
|
||||
cross := a.x * b.y - b.x * a.y
|
||||
area += cross
|
||||
cx += (a.x + b.x) * cross
|
||||
cy += (a.y + b.y) * cross
|
||||
low = TaiChiV2(TaiChiMin(low.x, a.x), TaiChiMin(low.y, a.y))
|
||||
high = TaiChiV2(TaiChiMax(high.x, a.x), TaiChiMax(high.y, a.y))
|
||||
}
|
||||
area = area / 2.0
|
||||
if TaiChiAbs(area) > 0.000000000001 {
|
||||
cx = cx / (6.0 * area)
|
||||
cy = cy / (6.0 * area)
|
||||
} else {
|
||||
cx = points[0].x
|
||||
cy = points[0].y
|
||||
}
|
||||
center := FieldAt(text, entry, "center")
|
||||
box := FieldAt(text, entry, "box")
|
||||
return TestClose(area, TestNumber(text, FieldAt(text, entry, "area")), 0.00002) &&
|
||||
TestClose(cx, TestElementNumber(text, center, 0), 0.0005) &&
|
||||
TestClose(cy, TestElementNumber(text, center, 1), 0.0005) &&
|
||||
TestClose(low.x, TestElementNumber(text, box, 0), 0.0005) &&
|
||||
TestClose(low.y, TestElementNumber(text, box, 1), 0.0005) &&
|
||||
TestClose(high.x, TestElementNumber(text, box, 2), 0.0005) &&
|
||||
TestClose(high.y, TestElementNumber(text, box, 3), 0.0005)
|
||||
}
|
||||
|
||||
// The ends and number of points of a line against the reference.
|
||||
TestLine :: (text: string, entry: s32, op: TaiChiFlatOp, points: []TaiChiVector2) -> bool {
|
||||
ends := FieldAt(text, entry, "ends")
|
||||
last := points[points.count - 1]
|
||||
return cast(s32)TestNumber(text, FieldAt(text, entry, "count")) == op.count &&
|
||||
TestClose(op.width, TestNumber(text, FieldAt(text, entry, "width")), 0.000002) &&
|
||||
TestClose(points[0].x, TestElementNumber(text, ends, 0), 0.0005) &&
|
||||
TestClose(points[0].y, TestElementNumber(text, ends, 1), 0.0005) &&
|
||||
TestClose(last.x, TestElementNumber(text, ends, 2), 0.0005) &&
|
||||
TestClose(last.y, TestElementNumber(text, ends, 3), 0.0005)
|
||||
}
|
||||
|
||||
// One reference sample: 0 when it matches, otherwise a code for what
|
||||
// differs.
|
||||
TestSample :: (text: string, sample: s32) -> s32 {
|
||||
character: s32 = 0
|
||||
if TestStringIs(text, FieldAt(text, sample, "character"), "tibetanWoman") {
|
||||
if TestStringIs(text, FieldAt(text, sample, "character"), "indigoMan") {
|
||||
character = 1
|
||||
}
|
||||
item := cast(s32)TestNumber(text, FieldAt(text, sample, "item"))
|
||||
@@ -107,44 +168,27 @@ TestSample :: (text: string, sample: s32) -> s32 {
|
||||
camera.yaw = TestNumber(text, FieldAt(text, camera_at, "yaw"))
|
||||
camera.tilt = TestNumber(text, FieldAt(text, camera_at, "tilt"))
|
||||
camera.center = TaiChiV3(TestElementNumber(text, center, 0), 0.0, TestElementNumber(text, center, 1))
|
||||
images := TaiChiFigureImagesFor(character)
|
||||
if !images.valid {
|
||||
TaiChiFlatPaint(*test_frame, *solved, *rig, character, camera)
|
||||
ops := FieldAt(text, sample, "ops")
|
||||
if ArrayCount(text, ops) != test_frame.op_count {
|
||||
return 12
|
||||
}
|
||||
memory: TaiChiLayoutMemory
|
||||
frame := TaiChiLayout(*solved, *rig, *images, camera, *memory)
|
||||
order := FieldAt(text, sample, "order")
|
||||
for index: cast(s32)0..TAI_CHI_PIECE_COUNT - 1 {
|
||||
if TestPieceIndex(text, ElementAt(text, order, index)) != frame.order[index] {
|
||||
for index: cast(s32)0..test_frame.op_count - 1 {
|
||||
entry := ElementAt(text, ops, index)
|
||||
op := test_frame.ops[index]
|
||||
points := test_frame.points[op.first:op.first + op.count]
|
||||
fill_at := FieldAt(text, entry, "fill")
|
||||
is_fill := fill_at >= 0
|
||||
if is_fill != (op.kind == TAI_CHI_FLAT_FILL) {
|
||||
return 300 + index
|
||||
}
|
||||
}
|
||||
pieces := FieldAt(text, sample, "pieces")
|
||||
count := ArrayCount(text, pieces)
|
||||
points: [TAI_CHI_TEST_GRID_COLUMNS * TAI_CHI_TEST_GRID_ROWS]TaiChiVector2
|
||||
for index: cast(s32)0..count - 1 {
|
||||
entry := ElementAt(text, pieces, index)
|
||||
piece_index := TestPieceIndex(text, FieldAt(text, entry, "name"))
|
||||
if piece_index < 0 {
|
||||
return 13
|
||||
color_at := ifx is_fill then fill_at else FieldAt(text, entry, "line")
|
||||
if TestColor(text, color_at) != op.color || !TestClose(op.alpha, TestNumber(text, FieldAt(text, entry, "alpha")), 0.000002) {
|
||||
return 400 + index
|
||||
}
|
||||
piece := frame.pieces[piece_index]
|
||||
image_at := FieldAt(text, entry, "image")
|
||||
same_image := TestStringIs(text, image_at, "shadow")
|
||||
if piece.image >= 0 {
|
||||
same_image = TestStringIs(text, image_at, TaiChiCourseString(tai_chi_course.images[piece.image].role))
|
||||
}
|
||||
if !same_image {
|
||||
return 400 + piece_index
|
||||
}
|
||||
TaiChiPieceVertices(*piece, TAI_CHI_TEST_GRID_COLUMNS, TAI_CHI_TEST_GRID_ROWS, points[:])
|
||||
expected := FieldAt(text, entry, "points")
|
||||
for point: cast(s32)0..TAI_CHI_TEST_GRID_COLUMNS * TAI_CHI_TEST_GRID_ROWS - 1 {
|
||||
pair := ElementAt(text, expected, point)
|
||||
if !TestClose(points[point].x, TestElementNumber(text, pair, 0), 0.0005) ||
|
||||
!TestClose(points[point].y, TestElementNumber(text, pair, 1), 0.0005) {
|
||||
return 500 + piece_index
|
||||
}
|
||||
matches := ifx is_fill then TestFill(text, entry, points) else TestLine(text, entry, op, points)
|
||||
if !matches {
|
||||
return 500 + index
|
||||
}
|
||||
}
|
||||
return 0
|
||||
@@ -203,7 +247,8 @@ Check :: () -> s32 {
|
||||
if tai_chi_course.key_set_count < 2 || tai_chi_course.character_count != 2 || tai_chi_course.module_count != 3 {
|
||||
return 3
|
||||
}
|
||||
if TaiChiCourseItemIndex("full/normal") < 0 || TaiChiCourseImage(0, "torso.front") < 0 {
|
||||
if TaiChiCourseItemIndex("full/normal") < 0 || TaiChiCourseString(tai_chi_course.characters[0].id) != "jadeWoman" ||
|
||||
TaiChiCourseString(tai_chi_course.characters[1].id) != "indigoMan" {
|
||||
return 4
|
||||
}
|
||||
// Every item builds a timeline that fits and lasts as long as in the
|
||||
|
||||
@@ -119,7 +119,7 @@ with tempfile.TemporaryDirectory(prefix='profile-', dir=OUTPUT) as profile, cont
|
||||
|
||||
with application('tai_chi_customize') as window:
|
||||
text = capture(window, 'characters')
|
||||
assert 'monk' in text.lower() and 'woman' in text.lower(), text
|
||||
assert 'jade woman' in text.lower() and 'indigo man' in text.lower(), text
|
||||
assert 'Background music' in text and 'Music volume' in text and 'Cue volume' in text, text
|
||||
assert 'Voice narration' in text, text
|
||||
hint_path = OUTPUT / 'narration-hint.png'
|
||||
@@ -155,7 +155,7 @@ with tempfile.TemporaryDirectory(prefix='profile-', dir=OUTPUT) as profile, cont
|
||||
picture.crop((0, 0, 88, 900)).resize((352, 3600)).save(sidebar)
|
||||
navigation = command('tesseract', str(sidebar), 'stdout', '--psm', '11')
|
||||
assert 'Habits' in navigation and 'Diary' in navigation, navigation
|
||||
assert 'monk' not in text.lower(), text
|
||||
assert 'indigo man' not in text.lower(), text
|
||||
click(window, 500, 855)
|
||||
text = capture(window, 'start-opens-course')
|
||||
assert 'Course' in text and 'Lesson 1' in text, text
|
||||
@@ -164,7 +164,7 @@ with tempfile.TemporaryDirectory(prefix='profile-', dir=OUTPUT) as profile, cont
|
||||
assert 'Start' in text and 'Course' not in text, text
|
||||
click(window, 850, 855)
|
||||
text = capture(window, 'customize-reopens')
|
||||
assert 'monk' in text.lower() and 'woman' in text.lower(), text
|
||||
assert 'jade woman' in text.lower() and 'indigo man' in text.lower(), text
|
||||
|
||||
# Use an existing custom-track slot with a disposable WAV. Previewing it
|
||||
# exercises the real music player without a download or desktop audio.
|
||||
@@ -223,7 +223,7 @@ with tempfile.TemporaryDirectory(prefix='profile-', dir=OUTPUT) as profile, cont
|
||||
command('xdotool', 'click', '--repeat', '6', '--delay', '100', '5')
|
||||
time.sleep(.5)
|
||||
text = capture(window, 'narrow-characters')
|
||||
assert 'monk' in text.lower() and 'woman' in text.lower(), text
|
||||
assert 'jade woman' in text.lower() and 'indigo man' in text.lower(), text
|
||||
|
||||
with application('tai_chi_choose') as window:
|
||||
text = capture(window, 'course')
|
||||
|
||||