Skip to content

Commit f20953b

Browse files
committed
prepare release info
1 parent bc5ff93 commit f20953b

File tree

7 files changed

+334
-7
lines changed

7 files changed

+334
-7
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
Release history
22
===============
33

4-
v0.7.2 - unreleased
5-
-------------------
4+
`v0.7.2`_ - 2020-05-13
5+
----------------------
66

77
Added
88
~~~~~
99

10+
- raw mesh geometry (defined explicitly with vertices, faces, normals, and uv mapping)
1011
- selection of devices
1112

1213
Fixed
@@ -310,6 +311,7 @@ v0.1.2.5 - 2019-04-16
310311

311312
Two weeks and some steps from the initial release. Starting changelog relative to this point.
312313

314+
.. _`v0.7.2`: https://github.com/rnd-team-dev/plotoptix/releases/tag/v0.7.2
313315
.. _`v0.7.1`: https://github.com/rnd-team-dev/plotoptix/releases/tag/v0.7.1
314316
.. _`v0.7.0`: https://github.com/rnd-team-dev/plotoptix/releases/tag/v0.7.0
315317
.. _`v0.5.2`: https://github.com/rnd-team-dev/plotoptix/releases/tag/v0.5.2

README.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ PlotOptiX
1313

1414
**Data visualisation in Python based on NVIDIA OptiX ray tracing framework.**
1515

16-
**Now you can support development** on `PATREON <https://www.patreon.com/rndteam>`__. :)
17-
1816
3D `ray tracing <https://en.wikipedia.org/wiki/Ray_tracing_(graphics)>`__ package for Python, aimed at easy and aesthetic visualization
1917
of large datasets (and small as well). Data features can be represented on plots as a position, size/thickness and color of markers
2018
of several basic shapes, or projected onto the surfaces of objects in form of a color textures and displacement maps. All finished with
@@ -53,7 +51,7 @@ Features
5351

5452
- progressive path tracing with explicit light sampling
5553
- pinhole cameras and thin-lens cameras with depth of field simulation
56-
- geometries: particle (sphere), parallelepiped, parallelogram, tetrahedron, bezier line, surface mesh
54+
- geometries: particle (sphere), parallelepiped, parallelogram, tetrahedron, bezier line, various mesh options
5755
- parameterized materials shading: flat, diffuse, reflective, refractive; including: light dispersion, surface roughness, and nested volumes
5856
- spherical and parallelogram light sources
5957
- environmental light and ambient occlusion
@@ -62,7 +60,7 @@ Features
6260
- callbacks at the scene initialization, start and end of each frame raytracing, end of progressive accumulation
6361
- image output to `numpy <http://www.numpy.org>`__ array, or save to popular image file formats
6462
- hardware accelerated video output to MP4 file format using `NVENC 9.0 <https://developer.nvidia.com/nvidia-video-codec-sdk>`__
65-
- multi-GPU support
63+
- configurable multi-GPU support
6664
- Tkinter based UI or headless raytracer
6765

6866
System Requirements
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
"""
2+
Create simple mesh in code.
3+
"""
4+
5+
import numpy as np
6+
from plotoptix import TkOptiX
7+
8+
9+
def main():
10+
11+
# tetrahedron vertices and faces:
12+
pt = 1/np.sqrt(2)
13+
14+
points = [
15+
[1, 0, -pt],
16+
[-1, 0, -pt],
17+
[0, 1, pt],
18+
[0, -1, pt]
19+
]
20+
21+
faces = [
22+
[0, 1, 2],
23+
[0, 1, 3],
24+
[1, 2, 3],
25+
[0, 2, 3]
26+
]
27+
28+
# colors assigned to vertices
29+
colors = [
30+
[0.7, 0, 0],
31+
[0, 0.7, 0],
32+
[0, 0, 0.7],
33+
[1, 1, 1],
34+
]
35+
36+
rt = TkOptiX() # create and configure, show the window later
37+
38+
rt.set_param(min_accumulation_step=2, max_accumulation_frames=100)
39+
rt.setup_camera("cam1", cam_type="DoF", eye=[1, -6, 4], focal_scale=0.9, fov=25)
40+
rt.setup_light("light1", pos=[10, -9, -8], color=[14, 13, 12], radius=4)
41+
rt.set_ambient([0.2, 0.3, 0.4])
42+
43+
# add mesh geometry to the scene
44+
rt.set_mesh("m", points, faces, c=colors)
45+
46+
rt.start()
47+
print("done")
48+
49+
50+
if __name__ == '__main__':
51+
main()
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
"""
2+
Generate mesh with pygmsh.
3+
See https://github.com/nschloe/pygmsh for installation.
4+
Note: any package with meshio (https://github.com/nschloe/meshio) interface is fine.
5+
6+
Hint: double-click an object to select it, then drag with mouse to rotate it. Double-click
7+
again in the empty area to select camera. Drag with mouse to rotate camera. ;)
8+
"""
9+
10+
import pygmsh
11+
import numpy as np
12+
from plotoptix import TkOptiX
13+
14+
def main():
15+
16+
# a mesh from pygmsh example:
17+
geom = pygmsh.built_in.Geometry()
18+
19+
# Draw a cross.
20+
poly = geom.add_polygon([
21+
[ 0.0, 0.5, 0.0],
22+
[-0.1, 0.1, 0.0],
23+
[-0.5, 0.0, 0.0],
24+
[-0.1, -0.1, 0.0],
25+
[ 0.0, -0.5, 0.0],
26+
[ 0.1, -0.1, 0.0],
27+
[ 0.5, 0.0, 0.0],
28+
[ 0.1, 0.1, 0.0]
29+
],
30+
lcar=0.05
31+
)
32+
33+
axis = [0, 0, 1]
34+
35+
geom.extrude(
36+
poly,
37+
translation_axis=axis,
38+
rotation_axis=axis,
39+
point_on_axis=[0, 0, 0],
40+
angle=2.0 / 6.0 * np.pi
41+
)
42+
43+
mesh = pygmsh.generate_mesh(geom)
44+
45+
rt = TkOptiX() # create and configure, show the window later
46+
47+
rt.set_param(min_accumulation_step=2, max_accumulation_frames=100)
48+
rt.setup_camera("cam1", cam_type="DoF",
49+
eye=[0.5, -3, 2], target=[0, 0, 0.5],
50+
focal_scale=0.9, fov=25)
51+
rt.setup_light("light1", pos=[15, 0, 10], color=[14, 13, 12], radius=4)
52+
rt.set_ambient([0.1, 0.15, 0.2])
53+
54+
# add mesh geometry to the scene
55+
rt.set_mesh("m", mesh.points, mesh.cells_dict['triangle'])
56+
57+
rt.start()
58+
print("done")
59+
60+
61+
if __name__ == '__main__':
62+
main()
Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"## Create and modify mesh in code\n",
8+
"\n",
9+
"This example shows how to create a mesh programmatically, and then update mesh data: shading normals and texture mapping."
10+
]
11+
},
12+
{
13+
"cell_type": "code",
14+
"execution_count": 1,
15+
"metadata": {},
16+
"outputs": [],
17+
"source": [
18+
"import numpy as np\n",
19+
"from plotoptix import TkOptiX\n",
20+
"from plotoptix.materials import m_diffuse"
21+
]
22+
},
23+
{
24+
"cell_type": "markdown",
25+
"metadata": {},
26+
"source": [
27+
"Setup the scene:"
28+
]
29+
},
30+
{
31+
"cell_type": "code",
32+
"execution_count": 2,
33+
"metadata": {},
34+
"outputs": [],
35+
"source": [
36+
"rt = TkOptiX()\n",
37+
"rt.set_param(min_accumulation_step=2, max_accumulation_frames=100)\n",
38+
"rt.setup_camera(\"cam1\", cam_type=\"DoF\", eye=[7, 1, 2], focal_scale=0.8, fov=35)\n",
39+
"rt.setup_light(\"light1\", pos=[10, -9, -8], color=[9, 8, 7], radius=4)\n",
40+
"rt.set_ambient([0.2, 0.3, 0.4])"
41+
]
42+
},
43+
{
44+
"cell_type": "markdown",
45+
"metadata": {},
46+
"source": [
47+
"Icosahedron vertices and faces:"
48+
]
49+
},
50+
{
51+
"cell_type": "code",
52+
"execution_count": 3,
53+
"metadata": {},
54+
"outputs": [],
55+
"source": [
56+
"pt = (1 + np.sqrt(5)) / 2\n",
57+
"\n",
58+
"points = [\n",
59+
" [-1, pt, 0], [1, pt, 0], [-1, -pt, 0], [1, -pt, 0],\n",
60+
" [0, -1, pt], [0, 1, pt], [0, -1, -pt], [0, 1, -pt],\n",
61+
" [pt, 0, -1], [pt, 0, 1], [-pt, 0, -1], [-pt, 0, 1]\n",
62+
"]\n",
63+
"\n",
64+
"faces = [\n",
65+
" [0, 11, 5], [0, 5, 1], [0, 1, 7], [0, 7, 10], [0, 10, 11],\n",
66+
" [1, 5, 9], [5, 11, 4], [11, 10, 2], [10, 7, 6], [7, 1, 8],\n",
67+
" [3, 9, 4], [3, 4, 2], [3, 2, 6], [3, 6, 8], [3, 8, 9],\n",
68+
" [4, 9, 5], [2, 4, 11], [6, 2, 10], [8, 6, 7], [9, 8, 1]\n",
69+
"]"
70+
]
71+
},
72+
{
73+
"cell_type": "markdown",
74+
"metadata": {},
75+
"source": [
76+
"Try also the other line, so smooth normals are pre-calculated by the package."
77+
]
78+
},
79+
{
80+
"cell_type": "code",
81+
"execution_count": 4,
82+
"metadata": {},
83+
"outputs": [],
84+
"source": [
85+
"rt.set_mesh(\"m\", points, faces, c=[0.9, 0.8, 0.5])\n",
86+
"#rt.set_mesh(\"m\", points, faces, make_normals=True)"
87+
]
88+
},
89+
{
90+
"cell_type": "markdown",
91+
"metadata": {},
92+
"source": [
93+
"Open GUI."
94+
]
95+
},
96+
{
97+
"cell_type": "code",
98+
"execution_count": 5,
99+
"metadata": {},
100+
"outputs": [],
101+
"source": [
102+
"rt.start()"
103+
]
104+
},
105+
{
106+
"cell_type": "markdown",
107+
"metadata": {},
108+
"source": [
109+
"Change the color:"
110+
]
111+
},
112+
{
113+
"cell_type": "code",
114+
"execution_count": 6,
115+
"metadata": {},
116+
"outputs": [],
117+
"source": [
118+
"rt.update_mesh(\"m\", c=0.99)"
119+
]
120+
},
121+
{
122+
"cell_type": "markdown",
123+
"metadata": {},
124+
"source": [
125+
"Prepare UV mapping so each face will use the same area of textures."
126+
]
127+
},
128+
{
129+
"cell_type": "code",
130+
"execution_count": 7,
131+
"metadata": {},
132+
"outputs": [],
133+
"source": [
134+
"uv_map = [[0.01, 0.99], [0.99, 0.99], [0.5, 0.01]]\n",
135+
"uv_idx = 20 * [[0, 1, 2]]\n",
136+
"\n",
137+
"rt.update_mesh(\"m\", uvmap=uv_map, uvidx=uv_idx)"
138+
]
139+
},
140+
{
141+
"cell_type": "markdown",
142+
"metadata": {},
143+
"source": [
144+
"Load texture, add it to the default material:"
145+
]
146+
},
147+
{
148+
"cell_type": "code",
149+
"execution_count": 8,
150+
"metadata": {},
151+
"outputs": [],
152+
"source": [
153+
"rt.load_texture(\"tri\", \"tri.png\")\n",
154+
"m_diffuse[\"ColorTextures\"] = [ \"tri\" ]\n",
155+
"\n",
156+
"rt.update_material(\"diffuse\", m_diffuse)"
157+
]
158+
},
159+
{
160+
"cell_type": "markdown",
161+
"metadata": {},
162+
"source": [
163+
"Calculate normals at each vertex, add normals to the mesh. Actually, result is the same if you use automatic pre-calculation of smooth normals (``make_normals=True`` variant). "
164+
]
165+
},
166+
{
167+
"cell_type": "code",
168+
"execution_count": 9,
169+
"metadata": {},
170+
"outputs": [],
171+
"source": [
172+
"normals = [x / np.linalg.norm(x) for x in points]\n",
173+
"rt.update_mesh(\"m\", normals=normals)"
174+
]
175+
},
176+
{
177+
"cell_type": "markdown",
178+
"metadata": {},
179+
"source": [
180+
"Close the session:"
181+
]
182+
},
183+
{
184+
"cell_type": "code",
185+
"execution_count": 10,
186+
"metadata": {},
187+
"outputs": [],
188+
"source": [
189+
"rt.close()"
190+
]
191+
}
192+
],
193+
"metadata": {
194+
"kernelspec": {
195+
"display_name": "Python 3",
196+
"language": "python",
197+
"name": "python3"
198+
},
199+
"language_info": {
200+
"codemirror_mode": {
201+
"name": "ipython",
202+
"version": 3
203+
},
204+
"file_extension": ".py",
205+
"mimetype": "text/x-python",
206+
"name": "python",
207+
"nbconvert_exporter": "python",
208+
"pygments_lexer": "ipython3",
209+
"version": "3.7.4"
210+
}
211+
},
212+
"nbformat": 4,
213+
"nbformat_minor": 2
214+
}
32.4 KB
Loading

plotoptix/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
__author__ = "Robert Sulej, R&D Team <dev@rnd.team>"
1414
__status__ = "beta"
1515
__version__ = "0.7.2"
16-
__date__ = "8 May 2020"
16+
__date__ = "13 May 2020"
1717

1818
import logging
1919

0 commit comments

Comments
 (0)