Skip to content

Commit

Permalink
Updated lighting demos with animation example
Browse files Browse the repository at this point in the history
  • Loading branch information
Timo Friedrich committed Apr 2, 2020
1 parent 2012bd9 commit fd1c121
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 18 deletions.
117 changes: 99 additions & 18 deletions notebooks/lighting_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,13 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 23,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ee958a7eb4de486dbfc1a4a13b0ef0af",
"model_id": "53876d4ecc6e4f38890459f619d6b8fe",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -260,7 +260,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -276,7 +276,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -286,7 +286,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -295,7 +295,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -312,7 +312,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -331,7 +331,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -348,7 +348,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -372,7 +372,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -390,7 +390,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -615,13 +615,13 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 27,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "8704c06726ca4234b216c5f3b9323c01",
"model_id": "94b122b532cd41529f9cf9d03bbf94fa",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -654,7 +654,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 28,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -695,7 +695,7 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 29,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -845,12 +845,93 @@
"spot1.shadow_bias=-0.0005"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Animated Light"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 47,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "c993ddb4d5ac496ca269b14532c3aa0b",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(Figure(camera=PerspectiveCamera(fov=45.0, position=(0.0, 0.0, 2.0), quaternion=(0.0, 0.0, 0.0, …"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"[b1, p1, s1] = plot_all_no_change(kb=True, wp=True, ts=False)\n",
"point1=p3.point_light()\n"
]
},
{
"cell_type": "code",
"execution_count": 48,
"metadata": {},
"outputs": [],
"source": []
"source": [
"# Light and shadow Setup\n",
"point1.position_x=20\n",
"point1.position_y=10\n",
"point1.position_z=0\n",
"point1.cast_shadow = True\n",
"b1.cast_shadow = True\n",
"b1.receive_shadow = True\n",
"p1.receive_shadow = True\n",
"point1.shadow_map_type='PCF_SOFT'\n",
"point1.shadow_map_size=1024\n",
"# point1.shadow_radius=20 \n",
"point1.decay = 2"
]
},
{
"cell_type": "code",
"execution_count": 49,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "4a6e362235ab4017ac86e9b85dea240c",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output()"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Generating gif with animated light position\n",
"def set_pos(fig, i, fraction):\n",
" point1.position_x = np.sin(2*np.pi*fraction) * 20\n",
" point1.position_z = np.cos(2*np.pi*fraction) * 20\n",
" \n",
"# a = p3.movie('rotatelight.gif', set_pos, fps=20, frames=40, endpoint=False, cmd_template_gif)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<img src=\"./rotatelight.gif\" width=\"400\" align=\"center\">"
]
}
],
"metadata": {
Expand All @@ -869,7 +950,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
"version": "3.6.10"
}
},
"nbformat": 4,
Expand Down
Binary file added notebooks/rotatelight.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fd1c121

Please sign in to comment.