43 lines
1.7 KiB
GDScript
43 lines
1.7 KiB
GDScript
extends SceneTree
|
|
## WEGWERF-Probe: Prüft, ob ImageTexture.get_image() im Headless-Modus
|
|
## funktioniert (fuer Inhaltsvergleich GLTF-Textur vs. Cache-Textur)
|
|
## und ob die GLTF-Textur wirklich identischen Inhalt hat wie die Datei.
|
|
|
|
const PFAD := "/opt/data/scopedvr/work/sync_c8748efc/scopedvr-client/assets/objekte/military_desert/walls/wall_001.glb"
|
|
const TEX := "/opt/data/scopedvr/work/sync_c8748efc/scopedvr-client/assets/objekte/military_desert/textures/desert_multicam_1.png"
|
|
|
|
|
|
func _initialize() -> void:
|
|
_run.call_deferred()
|
|
|
|
|
|
func _run() -> void:
|
|
var gltf_mod := load("res://core/viewport/glb_mesh_store.gd")
|
|
var res = gltf_mod.call("_glb_mesh", PFAD)
|
|
if res == null:
|
|
print("FEHLER: _glb_mesh null")
|
|
quit(1)
|
|
return
|
|
var mesh: Mesh = res
|
|
for si in mesh.get_surface_count():
|
|
var mat = mesh.surface_get_material(si)
|
|
if mat is BaseMaterial3D:
|
|
var tex: Texture2D = (mat as BaseMaterial3D).albedo_texture
|
|
print("surface %d: tex=%s iid=%d" % [si, tex.get_class(), tex.get_instance_id()])
|
|
if tex is ImageTexture:
|
|
var img: Image = (tex as ImageTexture).get_image()
|
|
if img == null:
|
|
print(" get_image() -> NULL (Headless kann nicht lesen)")
|
|
else:
|
|
print(" get_image() -> %dx%d format=%d" % [img.get_width(), img.get_height(), img.get_format()])
|
|
var p: Color = img.get_pixel(0, 0)
|
|
print(" pixel00=%s" % str(p))
|
|
var p2: Color = img.get_pixel(1023, 1023)
|
|
print(" pixel1023_1023=%s" % str(p2))
|
|
# Unsere Version direkt von der Platte zum Vergleich
|
|
var ours: Image = Image.load_from_file(TEX)
|
|
if ours != null:
|
|
print("unsere Datei: %dx%d format=%d pixel00=%s pixel1023=%s" % [
|
|
ours.get_width(), ours.get_height(), ours.get_format(),
|
|
str(ours.get_pixel(0, 0)), str(ours.get_pixel(1023, 1023))])
|
|
quit(0)
|