Add method to SceneUpdateTask to get a model texture.
Uses the ResourceLoader from the texture atlas. Puts the texture size on the texture where the entity model renderer can find it. Which is wrong. Kinda gross.
This commit is contained in:
parent
eee4b5bf77
commit
514b3155d1
@ -83,7 +83,7 @@ class TextureAtlas(object):
|
||||
self.blockModels = blockModels
|
||||
self.blocktypes = world.blocktypes
|
||||
self._filename = world.filename
|
||||
self._resourceLoader = resourceLoader
|
||||
self.resourceLoader = resourceLoader
|
||||
self._lightTexture = None
|
||||
self._terrainTexture = None
|
||||
self._maxLOD = maxLOD
|
||||
@ -212,7 +212,7 @@ class TextureAtlas(object):
|
||||
if name == "MCEDIT_UNKNOWN":
|
||||
block_unknown = resourcePath("mcedit2/assets/mcedit2/block_unknown.png")
|
||||
return file(block_unknown, "rb")
|
||||
return self._resourceLoader.openStream(name)
|
||||
return self.resourceLoader.openStream(name)
|
||||
|
||||
def bindTerrain(self):
|
||||
self._terrainTexture.bind()
|
||||
|
@ -17,6 +17,7 @@ from mcedit2.rendering.chunkupdate import ChunkRenderInfo
|
||||
from mcedit2.rendering.depths import DepthOffset
|
||||
from mcedit2.rendering.geometrycache import GeometryCache
|
||||
from mcedit2.util.glutils import Texture
|
||||
from mcedit2.util.load_png import loadPNGData
|
||||
from mceditlib.anvil.biome_types import BiomeTypes
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -38,6 +39,7 @@ def layerProperty(layer, default=True):
|
||||
|
||||
DEBUG_WORLDMESH_LISTS = "-debuglists" in sys.argv
|
||||
|
||||
|
||||
class SceneUpdateTask(object):
|
||||
showRedraw = True
|
||||
showHiddenOres = False
|
||||
@ -62,6 +64,7 @@ class SceneUpdateTask(object):
|
||||
|
||||
self.textureAtlas = textureAtlas
|
||||
self.mapTextures = {}
|
||||
self.modelTextures = {}
|
||||
|
||||
self.renderType = numpy.zeros((256*256,), 'uint8')
|
||||
self.renderType[:] = 3
|
||||
@ -175,6 +178,26 @@ class SceneUpdateTask(object):
|
||||
self.mapTextures[mapID] = mapTex
|
||||
return mapTex
|
||||
|
||||
def getModelTexture(self, texturePath):
|
||||
if texturePath in self.modelTextures:
|
||||
return self.modelTextures[texturePath]
|
||||
|
||||
try:
|
||||
w, h, rgba = loadPNGData(self.textureAtlas.resourceLoader.openStream(texturePath).read())
|
||||
except Exception as e:
|
||||
log.exception("Model texture %s could not be loaded", texturePath)
|
||||
else:
|
||||
def _load():
|
||||
GL.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA, w, h, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, rgba[::-1])
|
||||
|
||||
modelTex = Texture(_load)
|
||||
modelTex.w = w # ewwwww
|
||||
modelTex.h = h
|
||||
self.modelTextures[texturePath] = modelTex
|
||||
return modelTex
|
||||
|
||||
|
||||
|
||||
|
||||
class WorldScene(scenegraph.Node):
|
||||
def __init__(self, dimension, textureAtlas=None, geometryCache=None, bounds=None):
|
||||
|
Reference in New Issue
Block a user