You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#### TL;DR: Basic 3D world playground with animations and [camera](#camera-keys-example) completely from scratch(only 2D pixels).
8
9
This implementation / API only for demonstration and *playground* purposes based on [Perspective projection](https://en.wikipedia.org/wiki/3D_projection#Perspective_projection).
9
10
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:
18
19
Also you can plot any function on 3D scene.
19
20
20
21
21
-
*[Install](#intall)
22
+
*[Install](#install)
22
23
*[How to use](#how-to-use)
23
24
*[Model View Projection](#model-view-projection)
24
25
*[Projection](#projection)
@@ -34,13 +35,20 @@ Also you can plot any function on 3D scene.
34
35
35
36
## Install
36
37
37
-
`pip install play3d`
38
+
```
39
+
pip install play3d
40
+
```
38
41
39
42
## How to use
40
43
41
44
There is only one requirement - to provide 2D pixel and line renderer(drawer)
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))\
63
71
To create model you can simply pass 3D world vertices as 2-d list `Model(data=data)`
64
72
65
73
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
94
102
Here we use perspective projection matrix\
95
103
Z axis of clipped cube(from frustum) mapped to [-1, 1] and our camera directed to -z axis (OpenGL convention)\
96
104
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
+
101
112
102
113
### World camera
103
114
@@ -227,6 +238,11 @@ model.matrix = Matrix([
227
238
228
239
```
229
240
241
+
### Methods
242
+
*`model_obj @ translate(x, y, z)`
243
+
244
+
translates object's model matrix (in world space)
245
+
230
246
## Trajectory API
231
247
232
248
`Models.Trajectory`
@@ -239,14 +255,15 @@ To move our object through defined path we can build Trajectory for our object.
239
255
You can provide any parametric equation with args.\
240
256
World coordinates defined by `func(*args)` tuple output.
0 commit comments