{
"cells": [
{
"cell_type": "markdown",
"id": "a3fab8cc-90d1-4ffd-9c2e-fe3b9815e5da",
"metadata": {},
"source": [
"\n",
"\n",
"# 3 Concept of animation within the simulator"
]
},
{
"cell_type": "markdown",
"id": "d7fa66af-b58a-4b4c-9be3-991b30533798",
"metadata": {},
"source": [
"## Imports"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "ca6fca39-cd5b-444c-9c12-0da51fbf538e",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"os.chdir(\"../demo\")"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "b2d077ff-88cc-46da-9859-c3084b632172",
"metadata": {},
"outputs": [],
"source": [
"from pathlib import Path\n",
"from IPython.display import Code\n",
"from scripts.nb_utils import read_pc, read_from_output_folder, display_xml, download_from_url\n",
"import pyhelios\n",
"from pyhelios.util.xmldisplayer import find_playback_dir\n",
"import numpy as np\n",
"import pyvista as pv\n",
"pv.set_jupyter_backend('trame')"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "12c0a179-3441-4b43-89be-a299f3df0194",
"metadata": {},
"outputs": [],
"source": [
"# url for getting the data\n",
"url = 'https://heibox.uni-heidelberg.de/f/2b264f8b55a94b749d51/?dl=1'\n",
"target_path = 'data/sceneparts'"
]
},
{
"cell_type": "markdown",
"id": "842fc6d2-8add-4169-bad6-16a3dbee7f2b",
"metadata": {},
"source": [
"## Example 3.1: Tree moving in the wind during a single terrestrial laser scan\n",
"\n",
"In terrestrial laser scanning (TLS) acquisitions, vegetation can appear as distorted if it is moving during the scan. These effects can be reproduced in the simulation. While vegetation actually deforms non-rigidly, we can assume that a single branch moves almost rigidly. We will therefore use a HELIOS++ [dynamic scene](https://github.com/3dgeo-heidelberg/helios/wiki/Dynamic-scenes) with rigid motions to recreate the distortion effects. We create two dynamic scenes. In both cases, the branch rotates about its base, creating a way motion, but in opposite directions. With the scanner always rotating counter-clockwise, this will lead to a compressed branch (where scanner head and branch move in opposite directions) and an elongated branch (where scanner head and branch move in the same direction)."
]
},
{
"cell_type": "markdown",
"id": "76583356-7372-4bce-ab9a-fa562fcce7e7",
"metadata": {},
"source": [
"### Getting the data\n",
"\n",
"We first need to download the scene parts that we need for this example. Execute the code below!"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "0bc46ff2-e7ec-4756-acaa-2f1d68c19ed6",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Successfully downloaded and unpacked data to \"data/sceneparts\"\n"
]
}
],
"source": [
"download_from_url(url, target_path, subdir_path='Example_3-1')"
]
},
{
"cell_type": "markdown",
"id": "f12d902d-af2e-44e4-ad50-5542aab7f6ca",
"metadata": {},
"source": [
"### The scene\n",
"\n",
"[Dynamic scenes](https://github.com/3dgeo-heidelberg/helios/wiki/Dynamic-scenes) in HELIOS++ are defined in the XML files using `motion`s (e.g., rotation and translation), which can be combined into one `dmotion` and chained together to motion sequences. We display just the first part of the scene XML below."
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "0424b1e0-2116-4f87-b166-0dc25265f888",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
<document>\n",
" <scene id="dyn_scene" name="Dynamic scene" dynTimeStep="0.020833333333333332">\n",
" <part>\n",
" <filter type="objloader">\n",
" <param type="string" key="filepath" value="data/sceneparts/box/box_unit_test.obj" />\n",
" <param type="string" key="up" value="z" />\n",
" </filter>\n",
" <filter type="scale">\n",
" <param type="double" key="scale" value="0.15" />\n",
" </filter>\n",
" </part>\n",
" <!--Dynamic scenepart-->\n",
" <part>\n",
" <filter type="objloader">\n",
" <param type="string" key="filepath" value="data\\sceneparts\\animated_branch_1\\leaves.obj" />\n",
" <param type="string" key="up" value="z" />\n",
" </filter>\n",
" \n",
" \n",
" <dmotion id="leaves_0" loop="1" next="leaves_1">\n",
" <motion type="rotation" axis="0.000;1.000;0.000" angle="0.00000000" center="0.00000000;0.00000000;0.00000000" autoCRS="1" />\n",
" <motion type="translation" vec="0.00000000;0.00000000;0.00000000" />\n",
" </dmotion>\n",
" \n",
" <dmotion id="leaves_1" loop="1" next="leaves_2">\n",
" <motion type="rotation" axis="0.000;1.000;0.000" angle="0.00000000" center="0.00000000;0.00000000;0.00000000" autoCRS="1" />\n",
" <motion type="translation" vec="0.00000000;0.00000000;0.00000000" />\n",
" </dmotion>\n",
" \n",
" <dmotion id="leaves_2" loop="1" next="leaves_3">\n",
" <motion type="rotation" axis="0.000;1.000;0.000" angle="0.00000000" center="0.00000000;0.00000000;0.00000000" autoCRS="1" />\n",
" <motion type="translation" vec="0.00000000;0.00000000;0.00000000" />\n",
" </dmotion>\n",
" \n",
"