10 KiB
Sphinx Warnings
411: WARNING: Explicit markup ends without a blank line; unexpected unindent. 420: WARNING: Field list ends without a blank line; unexpected unindent.
Note the preview is not accurate and warnings may not indicate real issues.
Game Engine bge.texture Module
Note
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.
Intro
The bge.texture module allows you to manipulate textures during the game.
Several sources for texture are possible: video files, image files, video capture, memory buffer, camera render or a mix of that.
The video and image files can be loaded from the internet using an URL instead of a file name.
In addition, you can apply filters on the images before sending them to the GPU, allowing video effect: blue screen, color band, gray, normal map.
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 * Ogg * Xvid * Theora * dv1394 camera * video4linux capture card (this includes many webcams) * videoForWindows capture card (this includes many webcams) * JPG
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 and swap the two textures in the GPU.
The GE is not aware of the substitution and continues to display the object as always, except that you are now in control of the texture.
When the texture object is deleted, the new texture is deleted and the old texture restored.
- class bge.texture.VideoFFmpeg(file[, capture=-1, rate=25.0, width=0, height=0])
FFmpeg video source
- status
- video status
- range
- replay range
- repeat
- repeat count, -1 for infinite repeat
- Type:
int
- framerate
- frame rate
- Type:
float
- valid
- Tells if an image is available
- Type:
bool
- image
- image data
- size
- image size
- scale
- fast scale of image (near neighbour)
- flip
- flip image vertically
- filter
- pixel filter
- preseek
- number of frames of preseek
- Type:
int
- deinterlace
- deinterlace image
- Type:
bool
- play()
- Play (restart) video
- pause()
- pause video
- stop()
- stop video (play will replay it from start)
- refresh()
- Refresh video - get its status
- class bge.texture.ImageFFmpeg(file)
FFmpeg image source
- status
- video status
- valid
- Tells if an image is available
- Type:
bool
- image
- image data
- size
- image size
- scale
- fast scale of image (near neighbour)
- flip
- flip image vertically
- filter
- pixel filter
- refresh()
- Refresh image, i.e. load it
- reload([newname])
- Reload image, i.e. reopen it
- class bge.texture.ImageBuff
Image source from image buffer
- filter
- pixel filter
- flip
- flip image vertically
- image
- image data
- load(imageBuffer, width, height)
- Load image from buffer
- plot(imageBuffer, width, height, positionX, positionY)
- update image buffer
- scale
- fast scale of image (near neighbour)
- size
- image size
- valid
- bool to tell if an image is available
- class bge.texture.ImageMirror(scene)
Image source from mirror
- alpha
- use alpha in texture
- background
- background color
- capsize
- size of render area
- clip
- clipping distance
- filter
- pixel filter
- flip
- flip image vertically
- image
- image data
- refresh(imageMirror)
- Refresh image - invalidate its current content
- scale
- fast scale of image (near neighbour)
- size
- image size
- valid
- bool to tell if an image is available
- whole
- use whole viewport to render
- class bge.texture.ImageMix
Image mixer
- filter
- pixel filter
- flip
- flip image vertically
- getSource(imageMix)
- get image source
- getWeight(imageMix)
- get image source weight
- image
- image data
- refresh(imageMix)
- Refresh image - invalidate its current content
- scale
- fast scale of image (near neighbour)
- setSource(imageMix)
- set image source
- setWeight(imageMix)
- set image source weight
- valid
- bool to tell if an image is available
- class bge.texture.ImageRender(scene, camera)
Image source from render
- alpha
- use alpha in texture
- background
- background color
- capsize
- size of render area
- filter
- pixel filter
- flip
- flip image vertically
- image
- image data
- refresh(imageRender)
- Refresh image - invalidate its current content
- scale
- fast scale of image (near neighbour)
- size
- image size
- valid
- bool to tell if an image is available
- whole
- use whole viewport to render
- class bge.texture.ImageViewport
Image source from viewport
- alpha
- use alpha in texture
- capsize
- size of viewport area being captured
- filter
- pixel filter
- flip
- flip image vertically
- image
- image data
- position
- upper left corner of captured area
- refresh(imageViewport)
- Refresh image - invalidate its current content
- scale
- fast scale of image (near neighbour)
- size
- image size
- valid
- bool to tell if an image is available
- whole
- use whole viewport to capture
- class bge.texture.Texture(gameObj)
Texture objects
- bindId
- OpenGL Bind Name
- close(texture)
- Close dynamic texture and restore original
- mipmap
- mipmap texture
- refresh(texture)
- Refresh texture from source
- source
- source of texture
- class bge.texture.FilterBGR24
Source filter BGR24 objects
- class bge.texture.FilterBlueScreen
Filter for Blue Screen objects
- color
- blue screen color
- limits
- blue screen color limits
- previous
- previous pixel filter
- class bge.texture.FilterColor
Filter for color calculations
- matrix
- matrix [4][5] for color calculation
- previous
- previous pixel filter
- class bge.texture.FilterGray
Filter for gray scale effect
- previous
- previous pixel filter
- class bge.texture.FilterLevel
Filter for levels calculations
- levels
- levels matrix [4] (min, max)
- previous
- previous pixel filter
- class bge.texture.FilterNormal
Filter for Blue Screen objects
- colorIdx
- index of color used to calculate normal (0 - red, 1 - green, 2 - blue)
- depth
- depth of relief
- previous
- previous pixel filter
- class bge.texture.FilterRGB24
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.
- class bge.texture.FilterRGBA32
Source filter RGBA32 objects
- bge.texture.getLastError()
- Last error that occurred in a bge.texture function.
- Returns:
the description of the last error occurred in a bge.texture function.
- Return type:
string
- bge.texture.imageToArray(image, mode)
- Returns a :class:`~bgl.buffer` corresponding to the current image stored in a texture source object.
- Parameters:
image (object of type :class:'VideoFFmpeg', :class:'ImageFFmpeg', :class:'ImageBuff', :class:'ImageMix', :class:'ImageRender', :class:'ImageMirror' or :class:'ImageViewport') – Image source object.
mode – optional argument representing the pixel format.
- type mode:
string
- rtype:
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.