Skip to content

Commit 28a0432

Browse files
author
Tamerlan Abilov
committed
README.md update badges typo, remove pygame dep from library
1 parent eeac22a commit 28a0432

File tree

3 files changed

+33
-17
lines changed

3 files changed

+33
-17
lines changed

README.md

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
![Pygame integration example](example/sm-example.gif)
55

66
[![Tests](https://github.com/timabilov/python-play3d/actions/workflows/python-package.yml/badge.svg?event=push)](https://github.com/timabilov/python-play3d/actions/workflows/python-package.yml)
7+
[![Latest PyPI version](https://img.shields.io/pypi/v/play3d)](https://pypi.python.org/pypi/play3d/)
78
#### TL;DR: Basic 3D world playground with animations and [camera](#camera-keys-example) completely from scratch(only 2D pixels).
89
This implementation / API only for demonstration and *playground* purposes based on [Perspective projection](https://en.wikipedia.org/wiki/3D_projection#Perspective_projection).
910
Can be used on top of **any** 2d graphics engine/lib(frame buffers, sdl and etc.)
@@ -18,7 +19,7 @@ Not implemented features due to low performance:
1819
Also you can plot any function on 3D scene.
1920

2021

21-
* [Install](#intall)
22+
* [Install](#install)
2223
* [How to use](#how-to-use)
2324
* [Model View Projection](#model-view-projection)
2425
* [Projection](#projection)
@@ -34,13 +35,20 @@ Also you can plot any function on 3D scene.
3435

3536
## Install
3637

37-
`pip install play3d`
38+
```
39+
pip install play3d
40+
```
3841

3942
## How to use
4043

4144
There is only one requirement - to provide 2D pixel and line renderer(drawer)
4245

43-
As current example uses `pygame`:
46+
As current example uses `pygame`,
47+
48+
```
49+
pip install pygame==2.0.1 # recommended version
50+
```
51+
4452
```python
4553
from play3d.three_d import Device
4654
import pygame
@@ -59,7 +67,7 @@ screen = pygame.display.set_mode(Device.get_resolution())
5967
```
6068

6169
That's all we need for setting up environment.
62-
Now we can create and render model objects by calling `Model.draw()` at each frame update (See example)\
70+
Now we can create and render model objects by calling `Model.draw()` at each frame update (See [Example](#pygame-example))\
6371
To create model you can simply pass 3D world vertices as 2-d list `Model(data=data)`
6472

6573
It is possible to provide faces as 2d array `Model(data=data, faces=faces)`. Face index starts from 1. Only triangles supported. For more information see below.
@@ -94,10 +102,13 @@ while True: # your render lib/method
94102
Here we use perspective projection matrix\
95103
Z axis of clipped cube(from frustum) mapped to [-1, 1] and our camera directed to -z axis (OpenGL convention)\
96104
Projection Matrix can be tuned there (aspect ratio, FOV and etc.) \
97-
`Camera.near = 1`\
98-
`Camera.far = 10`\
99-
`Camera.fov = 60`\
100-
`Camera.aspect_ratio = 3/4`
105+
```python
106+
Camera.near = 1
107+
Camera.far = 10
108+
Camera.fov = 60
109+
Camera.aspect_ratio = 3/4
110+
```
111+
101112

102113
### World camera
103114

@@ -227,6 +238,11 @@ model.matrix = Matrix([
227238

228239
```
229240

241+
### Methods
242+
* `model_obj @ translate(x, y, z)`
243+
244+
translates object's model matrix (in world space)
245+
230246
## Trajectory API
231247

232248
`Models.Trajectory`
@@ -239,14 +255,15 @@ To move our object through defined path we can build Trajectory for our object.
239255
You can provide any parametric equation with args.\
240256
World coordinates defined by `func(*args)` tuple output.
241257

242-
#### `model_obj @ translate(x, y, z)`
243-
translates object's model matrix (in world space)
244258

245-
#### `rotate(self, angle_x, angle_y=0, angle_z=0)`
246-
Rotates object relative to particular axis plane. First object translated from the world space back to local origin, then we rotate the object
259+
### Methods
260+
* `rotate(self, angle_x, angle_y=0, angle_z=0)`
261+
262+
Rotates object relative to particular axis plane. First object translated from the world space back to local origin, then we rotate the object
247263

248-
#### `route(self, trajectory: 'Trajectory', enable_trace=False)`
249-
Set the function-based trajectory routing for the object.
264+
* `route(self, trajectory: 'Trajectory', enable_trace=False)`
265+
266+
Set the function-based trajectory routing for the object.
250267

251268
- trajectory `Trajectory` - trajectory state
252269
- enable_trace `bool` - Keep track of i.e. draw trajectory path (breadcrumbs)

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
-r requirements.txt
2-
pytest
2+
pytest

requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
numpy
2-
pygame==2.0.1
1+
numpy

0 commit comments

Comments
 (0)