Skip to content
Snippets Groups Projects
Commit 2712413e authored by Olivier Bertrand's avatar Olivier Bertrand
Browse files

Update doc rendering

parent 571a15af
No related branches found
No related tags found
No related merge requests found
...@@ -4,8 +4,8 @@ Run several blender instances if blender is installed ...@@ -4,8 +4,8 @@ Run several blender instances if blender is installed
import pkg_resources import pkg_resources
import glob import glob
import os import os
import shutil
import sys import sys
import shutil
import inspect import inspect
import tempfile import tempfile
...@@ -18,8 +18,8 @@ def activate_virtualenv(venv_path): ...@@ -18,8 +18,8 @@ def activate_virtualenv(venv_path):
exec(f.read(), dict(__file__=filepath)) exec(f.read(), dict(__file__=filepath))
venv = sys.base_prefix venv_path = sys.base_prefix
print(venv)
blendercomand = shutil.which('blender') blendercomand = shutil.which('blender')
worldfile = pkg_resources.resource_filename( worldfile = pkg_resources.resource_filename(
'navipy', 'resources/forest_world.blend') 'navipy', 'resources/forest_world.blend')
...@@ -29,7 +29,7 @@ for demofile in glob.iglob('**/blenddemo*.py', recursive=True): ...@@ -29,7 +29,7 @@ for demofile in glob.iglob('**/blenddemo*.py', recursive=True):
tfile.write('import os \n'.encode(encoding)) tfile.write('import os \n'.encode(encoding))
for line in inspect.getsourcelines(activate_virtualenv)[0]: for line in inspect.getsourcelines(activate_virtualenv)[0]:
tfile.write(line.encode(encoding)) tfile.write(line.encode(encoding))
line = 'activate_virtualenv(\"{}\")\n'.format(venv) line = 'activate_virtualenv(\"{}\")\n'.format(venv_path)
tfile.write(line.encode(encoding)) tfile.write(line.encode(encoding))
with open(demofile) as infile: with open(demofile) as infile:
for line in infile: for line in infile:
......
...@@ -15,13 +15,16 @@ Blender comes with its own python installation. Thus, we need to \ ...@@ -15,13 +15,16 @@ Blender comes with its own python installation. Thus, we need to \
tell blender to use our virtualenv where the navigation toolbox \ tell blender to use our virtualenv where the navigation toolbox \
is installed. To do we need to import the os module is installed. To do we need to import the os module
.. literalinclude:: example/rendering/blenddemo_beesampling.py .. literalinclude:: blender_run.py
:lines: 5 - 6 :lines: 6 - 7
then activate the environment: then activate the environment by using the following function:
.. literalinclude:: example/rendering/blenddemo_beesampling.py .. literalinclude:: blender_run.py
:lines: 12 - 26 :lines: 13 - 18
here venv_path is the path to the virtual environment within which \
navipy has been installed.
Now, blender can import all modules used by the navigation toolbox. Now, blender can import all modules used by the navigation toolbox.
...@@ -39,13 +42,9 @@ Custom sampling ...@@ -39,13 +42,9 @@ Custom sampling
Rendering classes Rendering classes
----------------- -----------------
BeeSampling
~~~~~~~~~~~
.. autoclass:: navipy.rendering.bee_sampling.BeeSampling .. autoclass:: navipy.rendering.bee_sampling.BeeSampling
:members: :members:
Cyberbee
~~~~~~~~
.. autoclass:: navipy.rendering.cyber_bee.Cyberbee .. autoclass:: navipy.rendering.cyber_bee.Cyberbee
:members: :members:
""" """
...@@ -6,10 +6,10 @@ With the toolbox at disposition we just need to configure the \ ...@@ -6,10 +6,10 @@ With the toolbox at disposition we just need to configure the \
BeeSampling to render images on a regular 3D grid. BeeSampling to render images on a regular 3D grid.
.. literalinclude:: example/rendering/blenddemo_beesampling.py .. literalinclude:: example/rendering/blenddemo_beesampling.py
:lines: 34 :lines: 9
.. literalinclude:: example/rendering/blenddemo_beesampling.py .. literalinclude:: example/rendering/blenddemo_beesampling.py
:lines: 37-44 :lines: 12-19
If we want to use the distance to objects, we need to tell the \ If we want to use the distance to objects, we need to tell the \
BeeSampling what is the maximum distance to objects in the environment.\ BeeSampling what is the maximum distance to objects in the environment.\
...@@ -18,13 +18,12 @@ compressed in the database, all distance to object will be equal to \ ...@@ -18,13 +18,12 @@ compressed in the database, all distance to object will be equal to \
zero: zero:
.. literalinclude:: example/rendering/blenddemo_beesampling.py .. literalinclude:: example/rendering/blenddemo_beesampling.py
:lines: 48-49 :lines: 23-24
Finally we can generate the database. Finally we can generate the database.
.. literalinclude:: example/rendering/blenddemo_beesampling.py .. literalinclude:: example/rendering/blenddemo_beesampling.py
:lines: 53-54 :lines: 28-29
""" """
import warnings import warnings
try: try:
...@@ -42,13 +41,7 @@ from navipy.database import DataBaseSave ...@@ -42,13 +41,7 @@ from navipy.database import DataBaseSave
class BeeSampling(Cyberbee): class BeeSampling(Cyberbee):
""" """
BeeSampling is a class deriving from Cyberbee. BeeSampling allows to create a DataBase using Cyberbee as the renderer.
The BeeSampling can be used to generate a database of
images taken on a rectangular regular grid. For the database,
the BeeSampling rely on DataBase
It worth noting that the generated database can take a large
harddrive space, as each image is composed of 4 channels of 180x360 pixels.
""" """
def __init__(self): def __init__(self):
......
""" """
BLA .. literalinclude:: example/rendering/blenddemo_cyberbee.py
:lines: 1-2
With the toolbox at disposition we just need to configure the \
Cyberbee to render images at desired positions.
.. literalinclude:: example/rendering/blenddemo_cyberbee.py
:lines: 7-8
To render a scene at a given positions we just have to do:
.. literalinclude:: example/rendering/blenddemo_cyberbee.py
:lines: 9-10
""" """
import warnings import warnings
...@@ -93,25 +105,11 @@ class Cyberbee(): ...@@ -93,25 +105,11 @@ class Cyberbee():
return bpy.data.scenes["Scene"].camera.rotation_mode return bpy.data.scenes["Scene"].camera.rotation_mode
@camera_rotation_mode.setter @camera_rotation_mode.setter
def camera_rotation_mode(self, mode='XYZ'): def camera_rotation_mode(self, mode):
"""change the camera rotation mode """change the camera rotation mode
:param mode: the mode of rotation for the camera see blender do
:param mode: the mode of rotation for the camera see blender doc
(default: 'XYZ').
:type mode: a string :type mode: a string
.. seealso: blender bpy.data.scenes["Scene"].camera.rotation_mode .. seealso: blender bpy.data.scenes["Scene"].camera.rotation_mode
..todo: Use @property.setter
def camera_rotation_mode(self, mode='XYZ')
""" """
if not isinstance(mode, str): if not isinstance(mode, str):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment