A Python library for creating 3D basic shape models and animations with Physics.
Project description
CubicPy
CubicPyは、子供向けのPython学習用3D物理シミュレーションアプリケーションです。Pythonコードを書いて、マインクラフトのようにブロックを組み立て、物理の法則に従って動く世界を作成できます。
概要
CubicPyは、Pythonプログラミングと物理シミュレーションを楽しく学ぶためのツールです。子供たちがコードを書くことで、3D空間に箱や球などの物体を配置し、重力や衝突などの物理法則を体験できます。
特徴
- Pythonコーディング: シンプルなPythonコードで3D構造物を定義
- リアルタイム物理シミュレーション: 重力や衝突を実際に観察できる
- カスタマイズ可能: 位置、サイズ、色、質量などを自由に設定
- インタラクティブな環境: キー操作でカメラや重力を調整可能
- 安全な実行環境: 子供が安全にコードを実験できる制限付き環境
使い方
インストール
- このリポジトリをクローンします:
git clone https://github.com/yourusername/CubicPy.git
cd CubicPy
- 必要なライブラリをインストールします:
pip install panda3d panda3d-bullet
実行方法
- サンプルコードを
codesフォルダに保存します(例:box_tower.py) - 以下のコマンドで実行します:
python main.py
サンプルコード
箱の塔を作る (box_tower.py)
body_data = []
for i in range(10):
body_data.append({
'type': 'box',
'pos': (0, 0, i),
'scale': (1, 1, 1),
'color': (i / 10, 0, 1 - i / 10),
})
このコードは10個の箱を縦に積み重ね、高さによって色が変化する塔を作成します。
オブジェクトの定義方法
CubicPyでは、以下のようなパラメータを設定できます:
type: 物体の種類 ('box', 'sphere', 'cylinder' など)pos: 位置座標 (x, y, z)scale: 大きさ (幅, 奥行き, 高さ)color: 色 (赤, 緑, 青) - 各値は0〜1mass: 質量(省略可、デフォルトは1)hpr: 回転角度(heading, pitch, roll)(省略可)position_mode: 位置基準(省略可)
操作方法
- 矢印キー: カメラ角度の変更
- マウスホイール: ズームイン/アウト
- W/S/A/D: 地面を傾ける
- F/G: 重力の強さを変更
- R: リセット
- ESC: 終了
必要条件
- Python 3.6以上
- Panda3D
- Panda3D-Bullet物理エンジン
ライセンス
MITライセンスの下で公開されています。詳細はLICENSEファイルをご覧ください。
貢献
バグ報告や機能改善の提案は、GitHubのIssueやPull Requestでお願いします。
楽しくPythonと物理を学びましょう!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cubicpy-0.1.2-py3-none-any.whl.
File metadata
- Download URL: cubicpy-0.1.2-py3-none-any.whl
- Upload date:
- Size: 67.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6221a7a02e2c7164fc060a60b34b2d2f5df808d767fac00a62caddbf4114369
|
|
| MD5 |
51aab44c43c4369d74f2e01dd1f5344c
|
|
| BLAKE2b-256 |
6c9b9cd205faf2c7d86952ff91dd55be99b7159fbb0761a2948e41dd9bb4d847
|