def __init__(self): self.texture_to_draw = None self.gray_data = None self.texture = ue.create_transient_texture(512, 512, EPixelFormat.PF_G8) self.texture.auto_root() filename = os.path.join(ue.get_content_dir(), 'haarcascade_frontalface_default.xml') self.cascade = cv2.CascadeClassifier(filename)
def __init__(self): self.texture_to_draw = None self.gray_data = None # create a transient texture with a single color channel self.texture = ue.create_transient_texture(512, 512, EPixelFormat.PF_G8) # this automatically destroys the texture when self.texture dies (this is required as UE does not know about this texture object) self.texture.auto_root()
def __init__(self): self.texture_to_draw = None self.gray_data = None # create a transient texture with a single color channel self.texture = ue.create_transient_texture(512, 512, EPixelFormat.PF_G8) # this automatically destroys the texture when self.texture dies (this is required as UE does not know about this texture object) self.texture.auto_root()
def __init__(self): self.texture_to_draw = None self.gray_data = None self.texture = ue.create_transient_texture(512, 512, EPixelFormat.PF_G8) self.texture.auto_root() filename = os.path.join(ue.get_content_dir(), 'haarcascade_frontalface_default.xml') self.cascade = cv2.CascadeClassifier(filename)
def begin_play(self): # open the first video capture device self.capture = cv2.VideoCapture(0) # get its size width = int(self.capture.get(cv2.CAP_PROP_FRAME_WIDTH)) height = int(self.capture.get(cv2.CAP_PROP_FRAME_HEIGHT)) # create a new texture with the desired size self.texture = ue.create_transient_texture(width, height, EPixelFormat.PF_R8G8B8A8) # assign the texture to the material mapped to the cube self.material = self.uobject.create_material_instance_dynamic(ue.load_object(Material, '/Game/DumbMaterial')) self.uobject.get_owner().StaticMeshComponent.set_material(0, self.material) self.material.set_material_texture_parameter('Texture', self.texture)
def LoadTexture(self, texturePath: str, colorKeyR: int, colorKeyG: int, colorKeyB: int, textureAddressMode: int) -> (Texture2D): """Attempts to load the texture at the specified path.""" if texturePath in self.loadedTextures: return self.loadedTextures[texturePath] if os.path.isfile(texturePath) is False: ue.log("Could not find texture to load: " + texturePath) return None image = None # Attempt to load PNG version which will be quicker PNGFilename = texturePath + ImporterSettings.PNG_CACHE_FILE_SUFFIX imageFile = None if os.path.isfile(PNGFilename) and ImporterSettings.bUsePNGCache: image = PILImage.open(PNGFilename) else: imageFile = RSBImageReader.RSBImageFile() imageFile.read_file(texturePath) colokeyMask = (colorKeyR, colorKeyG, colorKeyB) image = imageFile.convert_full_color_image_with_colorkey_mask( colokeyMask) if ImporterSettings.bUsePNGCache: #Save this image as it will be quicker to load in future image.save(PNGFilename, "PNG") imageWidth, imageHeight = image.size #TODO: generate mip maps newTexture = ue.create_transient_texture(imageWidth, imageHeight, EPixelFormat.PF_R8G8B8A8) if image.mode == 'RGB': image.putalpha(255) newTexture.texture_set_data(image.tobytes()) textureAddressModeConstant = TextureAddress.TA_Wrap if textureAddressMode == 1: #WRAP textureAddressModeConstant = TextureAddress.TA_Wrap elif textureAddressMode == 2: #MIRROR textureAddressModeConstant = TextureAddress.TA_Mirror elif textureAddressMode == 3: #CLAMP #this should be CLAMP but many textures break when this is enabled. textureAddressModeConstant = TextureAddress.TA_Wrap else: ue.warn("WARNING: Unknown texture tiling method") newTexture.AddressX = textureAddressModeConstant newTexture.AddressY = textureAddressModeConstant self.loadedTextures[texturePath] = newTexture return newTexture
def LoadTexture(self, texturePath: str, colorKeyR: int, colorKeyG: int, colorKeyB: int, textureAddressMode: int) -> (Texture2D): """Attempts to load the texture at the specified path.""" if texturePath in self.loadedTextures: return self.loadedTextures[texturePath] if os.path.isfile(texturePath) is False: ue.log("Could not find texture to load: " + texturePath) return None image = None # Attempt to load PNG version which will be quicker PNGFilename = texturePath + ImporterSettings.PNG_CACHE_FILE_SUFFIX imageFile = None if os.path.isfile(PNGFilename) and ImporterSettings.bUsePNGCache: image = PIL.Image.open(PNGFilename) else: imageFile = RSBImageReader.RSBImageFile() imageFile.read_file(texturePath) colokeyMask = (colorKeyR, colorKeyG, colorKeyB) image = imageFile.convert_full_color_image_with_colorkey_mask( colokeyMask) if ImporterSettings.bUsePNGCache: #Save this image as it will be quicker to load in future image.save(PNGFilename, "PNG") imageWidth, imageHeight = image.size #TODO: generate mip maps newTexture = ue.create_transient_texture(imageWidth, imageHeight, EPixelFormat.PF_R8G8B8A8) newTexture.texture_set_data(image.tobytes()) # #These don't appear used in Rainbow Six, but probably will be in Rogue Spear if textureAddressMode == 1: #WRAP _ = TextureAddress.TA_Wrap # newTexture.AddressX = TextureAddress.TA_Wrap # newTexture.AddressY = TextureAddress.TA_Wrap # newTexture.AddressX = TextureAddress.TA_Clamp # newTexture.AddressY = TextureAddress.TA_Clamp elif textureAddressMode == 3: #CLAMP _ = TextureAddress.TA_Clamp # newTexture.AddressX = TextureAddress.TA_Clamp # newTexture.AddressY = TextureAddress.TA_Clamp # newTexture.AddressX = TextureAddress.TA_Wrap # newTexture.AddressY = TextureAddress.TA_Wrap else: ue.log("WARNING: Unknown texture tiling method") self.loadedTextures[texturePath] = newTexture return newTexture
def begin_play(self): width = 1024 height = 1024 dpi = 72.0 self.texture = ue.create_transient_texture(width, height, EPixelFormat.PF_R8G8B8A8) self.uobject.get_owner().StaticMeshComponent.OverrideMaterials[0].set_material_texture_parameter('Graph', self.texture) self.fig = plt.figure(1) self.fig.set_dpi(dpi) self.fig.set_figwidth(width/dpi) self.fig.set_figheight(height/dpi) self.uobject.get_owner().bind_event('OnGraphDataUpdated', self.update_graph)
def begin_play(self): # open the first video capture device self.capture = cv2.VideoCapture(0) # get its size width = int(self.capture.get(cv2.CAP_PROP_FRAME_WIDTH)) height = int(self.capture.get(cv2.CAP_PROP_FRAME_HEIGHT)) # create a new texture with the desired size self.texture = ue.create_transient_texture(width, height, EPixelFormat.PF_R8G8B8A8) # assign the texture to the material mapped to the cube self.material = self.uobject.create_material_instance_dynamic( ue.load_object(Material, '/Game/DumbMaterial')) self.uobject.get_owner().StaticMeshComponent.set_material( 0, self.material) self.material.set_material_texture_parameter('Texture', self.texture)
def begin_play(self): width = 1024 height = 1024 dpi = 72.0 self.texture = ue.create_transient_texture(width, height, EPixelFormat.PF_R8G8B8A8) self.uobject.get_owner().StaticMeshComponent.OverrideMaterials[ 0].set_material_texture_parameter('Graph', self.texture) self.fig = plt.figure(1) self.fig.set_dpi(dpi) self.fig.set_figwidth(width / dpi) self.fig.set_figheight(height / dpi) self.uobject.get_owner().bind_event('OnGraphDataUpdated', self.update_graph)
_filter = FARFilter() _filter.class_names = ['StaticMesh'] thumbnails = [] for static_mesh in ue.get_assets_by_filter(_filter): thumbnails.append((static_mesh.get_full_name(), static_mesh.get_thumbnail())) window = SWindow(client_size=(1024, 512), title='StaticMeshes thumbnails') scroll_box = SScrollBox() vertical = SVerticalBox() for name, thumbnail in thumbnails: texture = ue.create_transient_texture(thumbnail.get_image_width(), thumbnail.get_image_height()) texture.texture_set_data(thumbnail.get_uncompressed_image_data()) vertical.add_slot( SHorizontalBox() ( SImage().set_texture(texture), max_width=64 ) ( STextBlock(text=name), padding=4, auto_width=True, ), max_height=64 )
import matplotlib.pyplot as plt # set texture/plot dimensions and dpi, ensure dpi is a float ! width = 1024 height = 1024 dpi = 72.0 # create a new figure with the specified sizes fig = plt.figure(1) fig.set_dpi(dpi) fig.set_figwidth(width/dpi) fig.set_figheight(height/dpi) # plot a simple graph with a label on the y axis plt.plot([1, 2, 3, 4]) plt.ylabel('some numbers') # draw the graph (in memory) fig.canvas.draw() # create a texture in memory (will be saved later) texture = ue.create_transient_texture(width, height, EPixelFormat.PF_R8G8B8A8) # copy pixels from matplotlib canvas to the texture as RGBA texture.texture_set_data(fig.canvas.buffer_rgba()) # save the texture texture.save_package('/Game/FirstGraphTexture') # open its editor ue.open_editor_for_asset(texture)
from unreal_engine.enums import EPixelFormat import matplotlib.pyplot as plt #Use Agg renderer matplotlib.use('Agg') width = 1024 height = 1024 dpi = 72.0 fig = plt.figure(1) fig.set_dpi(dpi) fig.set_figwidth(width / dpi) fig.set_figheight(height / dpi) plt.plot([1, 2, 3, 4]) plt.ylabel('some numbers') #draw the graph in memory fig.canvas.draw() texture = ue.create_transient_texture(width, height, EPixelFormat.PF_R8G8B8A8) #copy pixels from matplotlib canvas to texture as RGBA texture.texture_set_data(fig.canvas.buffer_rgba()) #save the texture texture.save_package('/Game/FirstGraphTexture') #open its editor ue.open_editor_for_asset(texture)