Skip to content
/ TiBox2d Public

Game oriented 2d physics engine made by taichi

License

Notifications You must be signed in to change notification settings

Wimacs/TiBox2d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TiBox2d

A Taichi Hackthon project
Yet another game-oriented GPU Physics Engine

Motivation:

  1. Fulfill a wish from 2 years ago when I first learned Taichi and GAMES201 完成一个鸽了许久的承诺
  2. Most developers who want to write a physics simulation game with Taichi can't help but use "MPM99" as a template and modify it, so it's time to bring some diversity. 写游戏竟然不用PBD?
  3. for fun 确实很好玩

API与使用方法

故事开始

import TiBox2d
import taichi as ti

创建Tibox2d物理收集器

tibox_collector = TiBox2d.Collector()

使用收集器收集你想模拟的物理材料,输入它AABB左下和右上的位置坐标

tibox_collector.add_water_box(5.0, 5.0, 15.0, 15.0)
tibox_collector.add_plastic_box(16.0, 20.0, 26.0, 30.0)
tibox_collector.add_rigid_box(27.0, 35.0, 37.0, 45.0)
tibox_collector.add_elastic_box(38.0, 50.0, 48.0, 60.0)
tibox_collector.add_rope(50.0, 0.0, 30.0)

创建求解器并编译

tibox_solver = TiBox2d.Solver(...)
tibox_solver.Compile(tibox_collector)

在主循环中调用step进行模拟

tibox_solver = TiBox2d.Solver(...)
tibox_solver.step(tibox_collector)

这时位置就会在tibox_solver.positions中得到更新

Demo1: Frozen19 (中文:19行代码的《冰雪奇缘》)

cd src
python3 frozen19.py

Demo2(Incomplete): AngryTi中文:愤怒的小鸟太极版)

cd src
python3 AngryTi.py

Todo List (Priority from highest to lowest):

  • rigid Body (shape matching)
  • elastic body (region based shape matching)
  • plastic body fake (shape matching with some trick)
  • plastic body real (shape matching with yield&creep)
  • Neighborhood Search for collision handling
  • ropes (Follow the leader & shape matching)
  • fluid (PBF)
  • cloth

About

Game oriented 2d physics engine made by taichi

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages