mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
loader: Added loading of 2D texture array
Signed-off-by: deflected <deflected@users.noreply.github.com>
This commit is contained in:
parent
70f10a70d1
commit
234e7eefee
@ -687,6 +687,63 @@ class Loader(DirectObject):
|
|||||||
|
|
||||||
return texture
|
return texture
|
||||||
|
|
||||||
|
def load2DTextureArray(self, texturePattern, readMipmaps = False, okMissing = False,
|
||||||
|
minfilter = None, magfilter = None, anisotropicDegree = None,
|
||||||
|
loaderOptions = None, multiview = None, numViews = 2):
|
||||||
|
"""
|
||||||
|
texturePattern is a string that contains a sequence of one or
|
||||||
|
more hash characters ('#'), which will be filled in with the
|
||||||
|
z-height number. Returns a 2-D Texture array object, suitable
|
||||||
|
for rendering array of textures.
|
||||||
|
|
||||||
|
okMissing should be True to indicate the method should return
|
||||||
|
None if the texture file is not found. If it is False, the
|
||||||
|
method will raise an exception if the texture file is not
|
||||||
|
found or cannot be loaded.
|
||||||
|
|
||||||
|
If readMipmaps is True, then the filename string must contain
|
||||||
|
two sequences of hash characters; the first group is filled in
|
||||||
|
with the z-height number, and the second group with the mipmap
|
||||||
|
index number.
|
||||||
|
|
||||||
|
If multiview is true, it indicates to load a multiview or
|
||||||
|
stereo texture. In this case, numViews should also be
|
||||||
|
specified (the default is 2), and the sequence of texture
|
||||||
|
images will be divided into numViews views. The total
|
||||||
|
z-height will be (numImages / numViews). For instance, if you
|
||||||
|
read 16 images with numViews = 2, then you have created a
|
||||||
|
stereo multiview image, with z = 8. In this example, images
|
||||||
|
numbered 0 - 7 will be part of the left eye view, and images
|
||||||
|
numbered 8 - 15 will be part of the right eye view.
|
||||||
|
"""
|
||||||
|
assert Loader.notify.debug("Loading 2-D texture array: %s" % (texturePattern))
|
||||||
|
if loaderOptions is None:
|
||||||
|
loaderOptions = LoaderOptions()
|
||||||
|
else:
|
||||||
|
loaderOptions = LoaderOptions(loaderOptions)
|
||||||
|
if multiview is not None:
|
||||||
|
flags = loaderOptions.getTextureFlags()
|
||||||
|
if multiview:
|
||||||
|
flags |= LoaderOptions.TFMultiview
|
||||||
|
else:
|
||||||
|
flags &= ~LoaderOptions.TFMultiview
|
||||||
|
loaderOptions.setTextureFlags(flags)
|
||||||
|
loaderOptions.setTextureNumViews(numViews)
|
||||||
|
|
||||||
|
texture = TexturePool.load2dTextureArray(texturePattern, readMipmaps, loaderOptions)
|
||||||
|
if not texture and not okMissing:
|
||||||
|
message = 'Could not load 2-D texture array: %s' % (texturePattern)
|
||||||
|
raise IOError(message)
|
||||||
|
|
||||||
|
if minfilter is not None:
|
||||||
|
texture.setMinfilter(minfilter)
|
||||||
|
if magfilter is not None:
|
||||||
|
texture.setMagfilter(magfilter)
|
||||||
|
if anisotropicDegree is not None:
|
||||||
|
texture.setAnisotropicDegree(anisotropicDegree)
|
||||||
|
|
||||||
|
return texture
|
||||||
|
|
||||||
def loadCubeMap(self, texturePattern, readMipmaps = False, okMissing = False,
|
def loadCubeMap(self, texturePattern, readMipmaps = False, okMissing = False,
|
||||||
minfilter = None, magfilter = None, anisotropicDegree = None,
|
minfilter = None, magfilter = None, anisotropicDegree = None,
|
||||||
loaderOptions = None, multiview = None):
|
loaderOptions = None, multiview = None):
|
||||||
|
@ -81,10 +81,10 @@ get_texture_flags() const {
|
|||||||
/**
|
/**
|
||||||
* Specifies the expected number of views to load for the texture. This is
|
* Specifies the expected number of views to load for the texture. This is
|
||||||
* ignored unless TF_multiview is included in texture_flags. This must be
|
* ignored unless TF_multiview is included in texture_flags. This must be
|
||||||
* specified when loading a 3-d multiview texture, in which case it is used to
|
* specified when loading a 3-d multiview texture or 2-d texture array, in
|
||||||
* differentiate z levels from separate views; it may be zero in the case of
|
* which case it is used to differentiate z levels from separate views; it
|
||||||
* 2-d textures or cube maps, in which case the number of views can be
|
* may be zero in the case of 2-d textures or cube maps, in which case the
|
||||||
* inferred from the number of images found on disk.
|
* number of views can be inferred from the number of images found on disk.
|
||||||
*/
|
*/
|
||||||
INLINE void LoaderOptions::
|
INLINE void LoaderOptions::
|
||||||
set_texture_num_views(int texture_num_views) {
|
set_texture_num_views(int texture_num_views) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user