diff --git a/doc/source/blender_run.py b/doc/source/blender_run.py index 8b7c1518f802a38096e753cfea526090d17f457c..26849d24aaa72cc51233361d41d44ed2af65a233 100644 --- a/doc/source/blender_run.py +++ b/doc/source/blender_run.py @@ -4,8 +4,8 @@ Run several blender instances if blender is installed import pkg_resources import glob import os -import shutil import sys +import shutil import inspect import tempfile @@ -18,8 +18,8 @@ def activate_virtualenv(venv_path): exec(f.read(), dict(__file__=filepath)) -venv = sys.base_prefix -print(venv) +venv_path = sys.base_prefix + blendercomand = shutil.which('blender') worldfile = pkg_resources.resource_filename( 'navipy', 'resources/forest_world.blend') @@ -29,7 +29,7 @@ for demofile in glob.iglob('**/blenddemo*.py', recursive=True): tfile.write('import os \n'.encode(encoding)) for line in inspect.getsourcelines(activate_virtualenv)[0]: tfile.write(line.encode(encoding)) - line = 'activate_virtualenv(\"{}\")\n'.format(venv) + line = 'activate_virtualenv(\"{}\")\n'.format(venv_path) tfile.write(line.encode(encoding)) with open(demofile) as infile: for line in infile: diff --git a/navipy/rendering/__init__.py b/navipy/rendering/__init__.py index 5c237d757ec0a290b2736d3c9674afb09d42aba1..294345fcc7b702e5f4afefcd0c5264daebfe7dc9 100644 --- a/navipy/rendering/__init__.py +++ b/navipy/rendering/__init__.py @@ -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 \ is installed. To do we need to import the os module -.. literalinclude:: example/rendering/blenddemo_beesampling.py - :lines: 5 - 6 +.. literalinclude:: blender_run.py + :lines: 6 - 7 -then activate the environment: +then activate the environment by using the following function: -.. literalinclude:: example/rendering/blenddemo_beesampling.py - :lines: 12 - 26 +.. literalinclude:: blender_run.py + :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. @@ -39,13 +42,9 @@ Custom sampling Rendering classes ----------------- -BeeSampling -~~~~~~~~~~~ .. autoclass:: navipy.rendering.bee_sampling.BeeSampling :members: -Cyberbee -~~~~~~~~ .. autoclass:: navipy.rendering.cyber_bee.Cyberbee :members: """ diff --git a/navipy/rendering/bee_sampling.py b/navipy/rendering/bee_sampling.py index 5245b5c3aad05ad0242148bc641244e67f4eb539..bdcc0e06a6dc3e427c604e97f733d7097f13a28e 100644 --- a/navipy/rendering/bee_sampling.py +++ b/navipy/rendering/bee_sampling.py @@ -6,10 +6,10 @@ With the toolbox at disposition we just need to configure the \ BeeSampling to render images on a regular 3D grid. .. literalinclude:: example/rendering/blenddemo_beesampling.py - :lines: 34 + :lines: 9 .. 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 \ 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 \ zero: .. literalinclude:: example/rendering/blenddemo_beesampling.py - :lines: 48-49 + :lines: 23-24 Finally we can generate the database. .. literalinclude:: example/rendering/blenddemo_beesampling.py - :lines: 53-54 - + :lines: 28-29 """ import warnings try: @@ -42,13 +41,7 @@ from navipy.database import DataBaseSave class BeeSampling(Cyberbee): """ - BeeSampling is a class deriving from Cyberbee. - 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. - + BeeSampling allows to create a DataBase using Cyberbee as the renderer. """ def __init__(self): diff --git a/navipy/rendering/cyber_bee.py b/navipy/rendering/cyber_bee.py index 1c9ad25303290fb6c4bf12906360b9d96abdbccd..877c99cfc291e45357dbb3f3b9c40f899cc57c36 100644 --- a/navipy/rendering/cyber_bee.py +++ b/navipy/rendering/cyber_bee.py @@ -1,5 +1,17 @@ """ - 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 @@ -93,25 +105,11 @@ class Cyberbee(): return bpy.data.scenes["Scene"].camera.rotation_mode @camera_rotation_mode.setter - def camera_rotation_mode(self, mode='XYZ'): + def camera_rotation_mode(self, mode): """change the camera rotation mode - - - - :param mode: the mode of rotation for the camera see blender doc - - (default: 'XYZ'). - + :param mode: the mode of rotation for the camera see blender do :type mode: a string - .. 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):