From 4213eca5fc3b5f2c2b23945e9462b38e13f843c4 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 20 Oct 2012 22:28:44 +0000 Subject: BGE VideoTexture: add depth buffer access to ImageViewport and ImageRender. 2 new attributes to ImageViewport and ImageRender object: depth: set to True to retrieve the depth buffer as an array of float (not suitable for texture source). zbuff: set to True to retrieve the depth buffer as a grey scale pixel array (suitable for texture source). A new mode 'F' is added to VideoTexture.imageToArray() to allow returning the image buffer as a one dimensional array of float. This mode should only be used to retrieve the depth buffer of ImageViewport and ImageRender objects. Example: viewport = VideoTexture.ImageViewport() viewport.depth = True depth = VideoTexture.imageToArray(viewport,'F') # show depth of bottom left pixel # 1.0 = infinite, 0.0 = on near clip plane. print(depth[0]) --- doc/python_api/rst/bge.texture.rst | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/python_api/rst/bge.texture.rst b/doc/python_api/rst/bge.texture.rst index 07d83f66bd4..0c9e9da0661 100644 --- a/doc/python_api/rst/bge.texture.rst +++ b/doc/python_api/rst/bge.texture.rst @@ -351,6 +351,15 @@ When the texture object is deleted, the new texture is deleted and the old textu use whole viewport to render + .. attribute:: depth + + use depth component of render as array of float - not suitable for texture source, + should only be used with bge.texture.imageToArray(mode='F') + + .. attribute:: zbuff + + use depth component of render as grey scale color - suitable for texture source + .. class:: ImageViewport() Image source from viewport @@ -399,6 +408,15 @@ When the texture object is deleted, the new texture is deleted and the old textu use whole viewport to capture + .. attribute:: depth + + use depth component of viewport as array of float - not suitable for texture source, + should only be used with bge.texture.imageToArray(mode='F') + + .. attribute:: zbuff + + use depth component of viewport as grey scale color - suitable for texture source + .. class:: Texture(gameObj) Texture objects @@ -518,13 +536,16 @@ When the texture object is deleted, the new texture is deleted and the old textu 0 to force a fixed 0 color channel and 1 to force a fixed 255 color channel. Example: "BGR" will return 3 bytes per pixel with the Blue, Green and Red channels in that order. "RGB1" will return 4 bytes per pixel with the Red, Green, Blue channels in that order and the alpha channel forced to 255. + A special mode "F" allows to return the image as an array of float. This mode should only be used to retrieve + the depth buffer of the ImageViewport and ImageRender object. The default mode is "RGBA". + :type mode: string :rtype: :class:`~bgl.buffer` :return: A object representing the image as one dimensional array of bytes of size (pixel_size*width*height), line by line starting from the bottom of the image. The pixel size and format is determined by the mode - parameter. + parameter. For mode 'F', the array is a one dimensional array of float of size (width*height). .. function:: materialID(object,name) -- cgit v1.2.3 From 7c846bbe75af2be9124596d2c2ab26dad2023391 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 24 Oct 2012 16:55:06 +0000 Subject: add section on how to run scripts in blender for the API intro, found there were no simple docs like this in the wiki. also set the window type to normal on start when -p argument is given, since the view could be maximized/fullscreen. --- doc/python_api/rst/info_quickstart.rst | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'doc') diff --git a/doc/python_api/rst/info_quickstart.rst b/doc/python_api/rst/info_quickstart.rst index 19ec8059aca..62ad4e9c4d8 100644 --- a/doc/python_api/rst/info_quickstart.rst +++ b/doc/python_api/rst/info_quickstart.rst @@ -2,8 +2,8 @@ Quickstart Introduction *********************** -Intro -===== +Preface +======= This API is generally stable but some areas are still being added and improved. @@ -58,6 +58,22 @@ A quick list of helpful things to know before starting: * To examine further scripts distributed with Blender, see ``~/.blender/scripts/startup/bl_ui`` for the user interface and ``~/.blender/scripts/startup/bl_op`` for operators. +Running Scripts +--------------- + +The two most common ways to execute python scripts are using the built-in text editor or entering commands in the python console. + +Both the **Text Editor** and **Python Console** are space types you can select from the view header. + +Rather then manually configuring your spaces for Python development, you may prefer to use the **Scripting** screen, included default with Blender, accessible from the top headers screen selector. + +From the text editor you can open ``.py`` files or paste then from the clipboard, then test using **Run Script**. + +The Python Console is typically used for typing in snippets and for testing to get immediate feedback, but can also have entire scripts pasted into it. + +Scripts can also run from the command line with Blender but to learn Blender/Python this isn't essential. + + Key Concepts ============ -- cgit v1.2.3 From aeba4950c38ed7a93ddacca5a294bcc8bd6d291a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 27 Oct 2012 10:42:28 +0000 Subject: style cleanup --- doc/python_api/rst/info_overview.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/python_api/rst/info_overview.rst b/doc/python_api/rst/info_overview.rst index 30c45213570..818eb692be9 100644 --- a/doc/python_api/rst/info_overview.rst +++ b/doc/python_api/rst/info_overview.rst @@ -71,7 +71,7 @@ The only difference between addons and built-in python modules is that addons mu The user preferences addon listing uses **bl_info** to display information about each addon. -`See Addons `_ for details on the **bl_info** dictionary. +`See Addons `_ for details on the **bl_info** dictionary. Integration through Classes -- cgit v1.2.3