Properly move an entity model's expected texture size to the models
Allows high res entity textures and also isn't completely disgusting.
This commit is contained in:
parent
32a09b555e
commit
2310a24468
@ -8,6 +8,9 @@ from mcedit2.rendering.chunkmeshes.entity.modelrenderer import ModelRenderer
|
|||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class ModelBiped(object):
|
class ModelBiped(object):
|
||||||
|
textureWidth = 64
|
||||||
|
textureHeight = 32
|
||||||
|
|
||||||
def __init__(self, expandOffset=0.0, headOffset=0.0):
|
def __init__(self, expandOffset=0.0, headOffset=0.0):
|
||||||
self.bipedHead = ModelRenderer(self, 0, 0)
|
self.bipedHead = ModelRenderer(self, 0, 0)
|
||||||
self.bipedHead.addBox(-4.0, -8.0, -4.0, 8, 8, 8, expandOffset)
|
self.bipedHead.addBox(-4.0, -8.0, -4.0, 8, 8, 8, expandOffset)
|
||||||
@ -48,11 +51,17 @@ class ModelBiped(object):
|
|||||||
|
|
||||||
|
|
||||||
class ModelZombie(ModelBiped):
|
class ModelZombie(ModelBiped):
|
||||||
|
textureWidth = 64
|
||||||
|
textureHeight = 64
|
||||||
|
|
||||||
modelTexture = "assets/minecraft/textures/entity/zombie/zombie.png"
|
modelTexture = "assets/minecraft/textures/entity/zombie/zombie.png"
|
||||||
id = "Zombie"
|
id = "Zombie"
|
||||||
|
|
||||||
|
|
||||||
class ModelPigZombie(ModelBiped):
|
class ModelPigZombie(ModelBiped):
|
||||||
|
textureWidth = 64
|
||||||
|
textureHeight = 64
|
||||||
|
|
||||||
modelTexture = "assets/minecraft/textures/entity/zombie_pigman.png"
|
modelTexture = "assets/minecraft/textures/entity/zombie_pigman.png"
|
||||||
id = "PigZombie"
|
id = "PigZombie"
|
||||||
|
|
||||||
|
@ -9,6 +9,9 @@ log = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class ModelCreeper(object):
|
class ModelCreeper(object):
|
||||||
|
textureWidth = 64
|
||||||
|
textureHeight = 32
|
||||||
|
|
||||||
modelTexture = "assets/minecraft/textures/entity/creeper/creeper.png"
|
modelTexture = "assets/minecraft/textures/entity/creeper/creeper.png"
|
||||||
id = "Creeper"
|
id = "Creeper"
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
models
|
models
|
||||||
"""
|
"""
|
||||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
import collections
|
||||||
import logging
|
import logging
|
||||||
import math
|
import math
|
||||||
import numpy
|
import numpy
|
||||||
@ -107,6 +108,8 @@ def npRotate(axis, angle, rescale=False):
|
|||||||
# xxx rescale
|
# xxx rescale
|
||||||
return rotate
|
return rotate
|
||||||
|
|
||||||
|
CookedModel = collections.namedtuple('CookedModel', 'vertices texWidth texHeight')
|
||||||
|
|
||||||
def cookEntityModel(model):
|
def cookEntityModel(model):
|
||||||
allVerts = []
|
allVerts = []
|
||||||
for part in model.parts:
|
for part in model.parts:
|
||||||
@ -130,12 +133,11 @@ def cookEntityModel(model):
|
|||||||
|
|
||||||
allVerts.append((x+cx, y+cy, z+cz, u, v))
|
allVerts.append((x+cx, y+cy, z+cz, u, v))
|
||||||
|
|
||||||
return allVerts
|
return CookedModel(allVerts, model.textureWidth, model.textureHeight)
|
||||||
|
|
||||||
cookedModels = {}
|
cookedModels = {}
|
||||||
textures = {}
|
textures = {}
|
||||||
|
|
||||||
|
|
||||||
def addModel(model):
|
def addModel(model):
|
||||||
cookedModels[model.id] = cookEntityModel(model)
|
cookedModels[model.id] = cookEntityModel(model)
|
||||||
textures[model.id] = model.modelTexture
|
textures[model.id] = model.modelTexture
|
||||||
|
@ -9,6 +9,9 @@ from mcedit2.rendering.chunkmeshes.entity.modelrenderer import ModelRenderer
|
|||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class ModelQuadruped(object):
|
class ModelQuadruped(object):
|
||||||
|
textureWidth = 64
|
||||||
|
textureHeight = 32
|
||||||
|
|
||||||
def __init__(self, height, expandOffset=0.0):
|
def __init__(self, height, expandOffset=0.0):
|
||||||
self.head = ModelRenderer(self, 0, 0)
|
self.head = ModelRenderer(self, 0, 0)
|
||||||
|
|
||||||
|
@ -9,6 +9,9 @@ from mcedit2.rendering.chunkmeshes.entity.modelrenderer import ModelRenderer
|
|||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class ModelSpider(object):
|
class ModelSpider(object):
|
||||||
|
textureWidth = 64
|
||||||
|
textureHeight = 32
|
||||||
|
|
||||||
id = "Spider"
|
id = "Spider"
|
||||||
modelTexture = "assets/minecraft/textures/entity/spider/spider.png"
|
modelTexture = "assets/minecraft/textures/entity/spider/spider.png"
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ class MonsterModelRenderer(ChunkMeshBase):
|
|||||||
|
|
||||||
model = models.cookedModels[ID]
|
model = models.cookedModels[ID]
|
||||||
|
|
||||||
modelVerts = numpy.array(model)
|
modelVerts = numpy.array(model.vertices)
|
||||||
modelVerts.shape = modelVerts.shape[0]/4, 4, modelVerts.shape[1]
|
modelVerts.shape = modelVerts.shape[0]/4, 4, modelVerts.shape[1]
|
||||||
# scale down
|
# scale down
|
||||||
modelVerts[..., :3] *= 1/16.
|
modelVerts[..., :3] *= 1/16.
|
||||||
@ -165,7 +165,7 @@ class MonsterModelRenderer(ChunkMeshBase):
|
|||||||
|
|
||||||
modelTex = self.chunkUpdate.updateTask.getModelTexture(models.textures[ID])
|
modelTex = self.chunkUpdate.updateTask.getModelTexture(models.textures[ID])
|
||||||
|
|
||||||
textureNode = BindTextureNode(modelTex, (1./modelTex.w, 1./modelTex.h, 1))
|
textureNode = BindTextureNode(modelTex, (1./model.texWidth, 1./model.texHeight, 1))
|
||||||
textureNode.addChild(translateNode)
|
textureNode.addChild(translateNode)
|
||||||
sceneNode.addChild(textureNode)
|
sceneNode.addChild(textureNode)
|
||||||
|
|
||||||
|
@ -195,8 +195,6 @@ class SceneUpdateTask(object):
|
|||||||
GL.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA, w, h, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, rgba[::-1])
|
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 = Texture(_load)
|
||||||
modelTex.w = w # ewwwww
|
|
||||||
modelTex.h = h
|
|
||||||
self.modelTextures[texturePath] = modelTex
|
self.modelTextures[texturePath] = modelTex
|
||||||
return modelTex
|
return modelTex
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user