some corrections to bge.texture docs

This commit is contained in:
2011-07-07 19:23:51 +00:00
parent 99736f373c
commit af27622a87
2 changed files with 379 additions and 377 deletions

View File

@@ -3,8 +3,8 @@ Game Engine bge.texture Module
============================== ==============================
.. note:: .. note::
This documentation is still very weak, and needs some help! Right now they are mostly a collection This documentation is still very weak, and needs some help! Right now they are mostly a collection
of the docstrings found in the bge.texture source code + some random places filled with text. of the docstrings found in the bge.texture source code + some random places filled with text.
***** *****
Intro Intro
@@ -20,14 +20,14 @@ In addition, you can apply filters on the images before sending them to the GPU,
bge.texture uses FFmpeg to load images and videos. All the formats and codecs that FFmpeg supports are supported by this module, including but not limited to:: bge.texture uses FFmpeg to load images and videos. All the formats and codecs that FFmpeg supports are supported by this module, including but not limited to::
* AVI * AVI
* Ogg * Ogg
* Xvid * Xvid
* Theora * Theora
* dv1394 camera * dv1394 camera
* video4linux capture card (this includes many webcams) * video4linux capture card (this includes many webcams)
* videoForWindows capture card (this includes many webcams) * videoForWindows capture card (this includes many webcams)
* JPG * JPG
The principle is simple: first you identify a texture on an existing object using The principle is simple: first you identify a texture on an existing object using
the :materialID: function, then you create a new texture with dynamic content the :materialID: function, then you create a new texture with dynamic content
@@ -42,410 +42,410 @@ When the texture object is deleted, the new texture is deleted and the old textu
.. class:: VideoFFmpeg(file [, capture=-1, rate=25.0, width=0, height=0]) .. class:: VideoFFmpeg(file [, capture=-1, rate=25.0, width=0, height=0])
FFmpeg video source FFmpeg video source
.. attribute:: status .. attribute:: status
video status video status
.. attribute:: range .. attribute:: range
replay range replay range
.. attribute:: repeat .. attribute:: repeat
repeat count, -1 for infinite repeat repeat count, -1 for infinite repeat
:type: int :type: int
.. attribute:: framerate
frame rate
:type: float
.. attribute:: valid
Tells if an image is available
:type: bool
.. attribute:: image
image data
.. attribute:: size
image size
.. attribute:: scale
fast scale of image (near neighbour)
.. attribute:: flip
flip image vertically
.. attribute:: filter
pixel filter
.. attribute:: preseek
number of frames of preseek
:type: int
.. attribute:: deinterlace
deinterlace image
:type: bool
.. method:: play() .. attribute:: framerate
Play (restart) video frame rate
.. method:: pause() :type: float
pause video
.. attribute:: valid
.. method:: stop() Tells if an image is available
stop video (play will replay it from start)
:type: bool
.. method:: refresh()
Refresh video - get its status .. attribute:: image
image data
.. attribute:: size
image size
.. attribute:: scale
fast scale of image (near neighbour)
.. attribute:: flip
flip image vertically
.. attribute:: filter
pixel filter
.. attribute:: preseek
number of frames of preseek
:type: int
.. attribute:: deinterlace
deinterlace image
:type: bool
.. method:: play()
Play (restart) video
.. method:: pause()
pause video
.. method:: stop()
stop video (play will replay it from start)
.. method:: refresh()
Refresh video - get its status
.. class:: ImageFFmpeg(file) .. class:: ImageFFmpeg(file)
FFmpeg image source FFmpeg image source
.. attribute:: status .. attribute:: status
video status video status
.. attribute:: valid .. attribute:: valid
Tells if an image is available Tells if an image is available
:type: bool :type: bool
.. attribute:: image .. attribute:: image
image data image data
.. attribute:: size .. attribute:: size
image size image size
.. attribute:: scale .. attribute:: scale
fast scale of image (near neighbour) fast scale of image (near neighbour)
.. attribute:: flip .. attribute:: flip
flip image vertically flip image vertically
.. attribute:: filter .. attribute:: filter
pixel filter pixel filter
.. method:: refresh() .. method:: refresh()
Refresh image, i.e. load it Refresh image, i.e. load it
.. method:: reload([newname]) .. method:: reload([newname])
Reload image, i.e. reopen it Reload image, i.e. reopen it
.. class:: ImageBuff() .. class:: ImageBuff()
Image source from image buffer Image source from image buffer
.. attribute:: filter .. attribute:: filter
pixel filter pixel filter
.. attribute:: flip .. attribute:: flip
flip image vertically flip image vertically
.. attribute:: image .. attribute:: image
image data image data
.. method:: load(imageBuffer, width, height) .. method:: load(imageBuffer, width, height)
Load image from buffer Load image from buffer
.. method:: plot(imageBuffer, width, height, positionX, positionY) .. method:: plot(imageBuffer, width, height, positionX, positionY)
update image buffer update image buffer
.. attribute:: scale .. attribute:: scale
fast scale of image (near neighbour) fast scale of image (near neighbour)
.. attribute:: size .. attribute:: size
image size image size
.. attribute:: valid .. attribute:: valid
bool to tell if an image is available bool to tell if an image is available
.. class:: ImageMirror(scene) .. class:: ImageMirror(scene)
Image source from mirror Image source from mirror
.. attribute:: alpha .. attribute:: alpha
use alpha in texture use alpha in texture
.. attribute:: background .. attribute:: background
background color background color
.. attribute:: capsize .. attribute:: capsize
size of render area size of render area
.. attribute:: clip .. attribute:: clip
clipping distance clipping distance
.. attribute:: filter .. attribute:: filter
pixel filter pixel filter
.. attribute:: flip .. attribute:: flip
flip image vertically flip image vertically
.. attribute:: image .. attribute:: image
image data image data
.. method:: refresh(imageMirror) .. method:: refresh(imageMirror)
Refresh image - invalidate its current content Refresh image - invalidate its current content
.. attribute:: scale .. attribute:: scale
fast scale of image (near neighbour) fast scale of image (near neighbour)
.. attribute:: size .. attribute:: size
image size image size
.. attribute:: valid .. attribute:: valid
bool to tell if an image is available bool to tell if an image is available
.. attribute:: whole .. attribute:: whole
use whole viewport to render use whole viewport to render
.. class:: ImageMix() .. class:: ImageMix()
Image mixer Image mixer
.. attribute:: filter .. attribute:: filter
pixel filter pixel filter
.. attribute:: flip .. attribute:: flip
flip image vertically flip image vertically
.. method:: getSource(imageMix) .. method:: getSource(imageMix)
get image source get image source
.. method:: getWeight(imageMix) .. method:: getWeight(imageMix)
get image source weight get image source weight
.. attribute:: image .. attribute:: image
image data image data
.. method:: refresh(imageMix) .. method:: refresh(imageMix)
Refresh image - invalidate its current content Refresh image - invalidate its current content
.. attribute:: scale .. attribute:: scale
fast scale of image (near neighbour) fast scale of image (near neighbour)
.. method:: setSource(imageMix) .. method:: setSource(imageMix)
set image source set image source
.. method:: setWeight(imageMix) .. method:: setWeight(imageMix)
set image source weight set image source weight
.. attribute:: valid .. attribute:: valid
bool to tell if an image is available bool to tell if an image is available
.. class:: ImageRender(scene, camera) .. class:: ImageRender(scene, camera)
Image source from render Image source from render
.. attribute:: alpha .. attribute:: alpha
use alpha in texture use alpha in texture
.. attribute:: background .. attribute:: background
background color background color
.. attribute:: capsize .. attribute:: capsize
size of render area size of render area
.. attribute:: filter .. attribute:: filter
pixel filter pixel filter
.. attribute:: flip .. attribute:: flip
flip image vertically flip image vertically
.. attribute:: image .. attribute:: image
image data image data
.. method:: refresh(imageRender) .. method:: refresh(imageRender)
Refresh image - invalidate its current content Refresh image - invalidate its current content
.. attribute:: scale .. attribute:: scale
fast scale of image (near neighbour) fast scale of image (near neighbour)
.. attribute:: size .. attribute:: size
image size image size
.. attribute:: valid .. attribute:: valid
bool to tell if an image is available bool to tell if an image is available
.. attribute:: whole .. attribute:: whole
use whole viewport to render use whole viewport to render
.. class:: ImageViewport() .. class:: ImageViewport()
Image source from viewport Image source from viewport
.. attribute:: alpha .. attribute:: alpha
use alpha in texture use alpha in texture
.. attribute:: capsize .. attribute:: capsize
size of viewport area being captured size of viewport area being captured
.. attribute:: filter .. attribute:: filter
pixel filter pixel filter
.. attribute:: flip .. attribute:: flip
flip image vertically flip image vertically
.. attribute:: image .. attribute:: image
image data image data
.. attribute:: position .. attribute:: position
upper left corner of captured area upper left corner of captured area
.. method:: refresh(imageViewport) .. method:: refresh(imageViewport)
Refresh image - invalidate its current content Refresh image - invalidate its current content
.. attribute:: scale .. attribute:: scale
fast scale of image (near neighbour) fast scale of image (near neighbour)
.. attribute:: size .. attribute:: size
image size image size
.. attribute:: valid .. attribute:: valid
bool to tell if an image is available bool to tell if an image is available
.. attribute:: whole .. attribute:: whole
use whole viewport to capture use whole viewport to capture
.. class:: Texture(gameObj) .. class:: Texture(gameObj)
Texture objects Texture objects
.. attribute:: bindId .. attribute:: bindId
OpenGL Bind Name OpenGL Bind Name
.. method:: close(texture) .. method:: close(texture)
Close dynamic texture and restore original Close dynamic texture and restore original
.. attribute:: mipmap .. attribute:: mipmap
mipmap texture mipmap texture
.. method:: refresh(texture) .. method:: refresh(texture)
Refresh texture from source Refresh texture from source
.. attribute:: source .. attribute:: source
source of texture source of texture
.. class:: FilterBGR24() .. class:: FilterBGR24()
Source filter BGR24 objects Source filter BGR24 objects
.. class:: FilterBlueScreen() .. class:: FilterBlueScreen()
Filter for Blue Screen objects Filter for Blue Screen objects
.. attribute:: color .. attribute:: color
blue screen color blue screen color
.. attribute:: limits .. attribute:: limits
blue screen color limits blue screen color limits
.. attribute:: previous .. attribute:: previous
previous pixel filter previous pixel filter
.. class:: FilterColor() .. class:: FilterColor()
Filter for color calculations Filter for color calculations
.. attribute:: matrix .. attribute:: matrix
matrix [4][5] for color calculation matrix [4][5] for color calculation
.. attribute:: previous .. attribute:: previous
previous pixel filter previous pixel filter
.. class:: FilterGray() .. class:: FilterGray()
Filter for gray scale effect Filter for gray scale effect
.. attribute:: previous .. attribute:: previous
previous pixel filter previous pixel filter
.. class:: FilterLevel() .. class:: FilterLevel()
Filter for levels calculations Filter for levels calculations
.. attribute:: levels .. attribute:: levels
levels matrix [4] (min, max) levels matrix [4] (min, max)
.. attribute:: previous .. attribute:: previous
previous pixel filter previous pixel filter
.. class:: FilterNormal() .. class:: FilterNormal()
Filter for Blue Screen objects Filter for Blue Screen objects
.. attribute:: colorIdx .. attribute:: colorIdx
index of color used to calculate normal (0 - red, 1 - green, 2 - blue) index of color used to calculate normal (0 - red, 1 - green, 2 - blue)
.. attribute:: depth .. attribute:: depth
depth of relief depth of relief
.. attribute:: previous .. attribute:: previous
previous pixel filter previous pixel filter
.. class:: FilterRGB24() .. class:: FilterRGB24()
Returns a new input filter object to be used with :class:'ImageBuff' object when the image passed Returns a new input filter object to be used with :class:`ImageBuff` object when the image passed
to the ImageBuff.load() function has the 3-bytes pixel format BGR. to the ImageBuff.load() function has the 3-bytes pixel format BGR.
.. class:: FilterRGBA32() .. class:: FilterRGBA32()
Source filter RGBA32 objects Source filter RGBA32 objects
.. function:: getLastError() .. function:: getLastError()
Last error that occurred in a bge.texture function. Last error that occurred in a bge.texture function.
:return: the description of the last error occurred in a bge.texture function. :return: the description of the last error occurred in a bge.texture function.
:rtype: string :rtype: string
.. function:: imageToArray(image,mode) .. function:: imageToArray(image,mode)
Returns a :class:`~bgl.buffer` corresponding to the current image stored in a texture source object. Returns a :class:`~bgl.buffer` corresponding to the current image stored in a texture source object.
:arg image: Image source object. :arg image: Image source object.
:type image: object of type :class:'VideoFFmpeg', :class:'ImageFFmpeg', :class:'ImageBuff', :class:'ImageMix', :class:'ImageRender', :class:'ImageMirror' or :class:'ImageViewport' :type image: object of type :class:`VideoFFmpeg`, :class:`ImageFFmpeg`, :class:`ImageBuff`, :class:`ImageMix`, :class:`ImageRender`, :class:`ImageMirror` or :class:`ImageViewport`
:arg mode: optional argument representing the pixel format. :arg mode: optional argument representing the pixel format.
| You can use the characters R, G, B for the 3 color channels, A for the alpha channel, You can use the characters R, G, B for the 3 color channels, A for the alpha channel,
| 0 to force a fixed 0 color channel and 1 to force a fixed 255 color channel. 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. 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. "RGB1" will return 4 bytes per pixel with the Red, Green, Blue channels in that order and the alpha channel forced to 255.
| The default mode is "RGBA". 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.
: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.
.. function materialID(object,name) .. function materialID(object,name)
Returns a numeric value that can be used in :class:'Texture' to create a dynamic texture. Returns a numeric value that can be used in :class:`Texture` to create a dynamic texture.
The value corresponds to an internal material number that uses the texture identified The value corresponds to an internal material number that uses the texture identified
by name. name is a string representing a texture name with IM prefix if you want to by name. name is a string representing a texture name with IM prefix if you want to
identify the texture directly. This method works for basic tex face and for material, identify the texture directly. This method works for basic tex face and for material,
provided the material has a texture channel using that particular texture in first provided the material has a texture channel using that particular texture in first
position of the texture stack. name can also have MA prefix if you want to identify position of the texture stack. name can also have MA prefix if you want to identify
the texture by material. In that case the material must have a texture channel in first the texture by material. In that case the material must have a texture channel in first
position. position.
If the object has no material that matches name, it generates a runtime error. Use try/except to catch the exception. If the object has no material that matches name, it generates a runtime error. Use try/except to catch the exception.
Ex: bge.texture.materialID(obj, 'IMvideo.png') Ex: bge.texture.materialID(obj, 'IMvideo.png')
:arg object: the game object that uses the texture you want to make dynamic :arg object: the game object that uses the texture you want to make dynamic
:type object: game object :type object: game object
:arg name: name of the texture/material you want to make dynamic. :arg name: name of the texture/material you want to make dynamic.
:type name: string :type name: string
:rtype: integer :rtype: integer
.. function setLogFile(filename) .. function setLogFile(filename)
Sets the name of a text file in which runtime error messages will be written, in addition to the printing Sets the name of a text file in which runtime error messages will be written, in addition to the printing
of the messages on the Python console. Only the runtime errors specific to the VideoTexture module of the messages on the Python console. Only the runtime errors specific to the VideoTexture module
are written in that file, ordinary runtime time errors are not written. are written in that file, ordinary runtime time errors are not written.
:arg filename: name of error log file :arg filename: name of error log file
:type filename: string :type filename: string
:rtype: integer :rtype: integer

View File

@@ -77,9 +77,9 @@ else:
"bpy.types", # supports filtering "bpy.types", # supports filtering
"bpy.ops", # supports filtering "bpy.ops", # supports filtering
"bpy_extras", "bpy_extras",
"bge", # "bge",
"aud", "aud",
#"bgl", "bgl",
"blf", "blf",
"mathutils", "mathutils",
"mathutils.geometry", "mathutils.geometry",
@@ -1048,6 +1048,7 @@ def rna2sphinx(BASEPATH):
fw(" bge.types.rst\n\n") fw(" bge.types.rst\n\n")
fw(" bge.logic.rst\n\n") fw(" bge.logic.rst\n\n")
fw(" bge.render.rst\n\n") fw(" bge.render.rst\n\n")
fw(" bge.texture.rst\n\n")
fw(" bge.events.rst\n\n") fw(" bge.events.rst\n\n")
# rna generated change log # rna generated change log
@@ -1182,6 +1183,7 @@ def rna2sphinx(BASEPATH):
shutil.copy2(os.path.join(BASEPATH, "..", "rst", "bge.types.rst"), BASEPATH) shutil.copy2(os.path.join(BASEPATH, "..", "rst", "bge.types.rst"), BASEPATH)
shutil.copy2(os.path.join(BASEPATH, "..", "rst", "bge.logic.rst"), BASEPATH) shutil.copy2(os.path.join(BASEPATH, "..", "rst", "bge.logic.rst"), BASEPATH)
shutil.copy2(os.path.join(BASEPATH, "..", "rst", "bge.render.rst"), BASEPATH) shutil.copy2(os.path.join(BASEPATH, "..", "rst", "bge.render.rst"), BASEPATH)
shutil.copy2(os.path.join(BASEPATH, "..", "rst", "bge.texture.rst"), BASEPATH)
shutil.copy2(os.path.join(BASEPATH, "..", "rst", "bge.events.rst"), BASEPATH) shutil.copy2(os.path.join(BASEPATH, "..", "rst", "bge.events.rst"), BASEPATH)
shutil.copy2(os.path.join(BASEPATH, "..", "rst", "change_log.rst"), BASEPATH) shutil.copy2(os.path.join(BASEPATH, "..", "rst", "change_log.rst"), BASEPATH)