mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-11-13 20:47:19 +01:00
Created a uv debugger tool.
This commit is contained in:
parent
3b0c2d3d23
commit
96ff1b6d5d
37
game/tools/uv_debugger/UVDebugger.gd
Normal file
37
game/tools/uv_debugger/UVDebugger.gd
Normal file
@ -0,0 +1,37 @@
|
||||
tool
|
||||
extends Control
|
||||
|
||||
var _texture : Texture
|
||||
var _indices : PoolIntArray = PoolIntArray()
|
||||
var _uvs : PoolVector2Array = PoolVector2Array()
|
||||
|
||||
func _draw():
|
||||
if _texture:
|
||||
draw_texture_rect_region(_texture, Rect2(Vector2(), get_size()), Rect2(Vector2(), _texture.get_size()))
|
||||
|
||||
if _uvs.size() > 0:
|
||||
var c : Color = Color(1, 1, 1, 1)
|
||||
|
||||
for i in range(0, len(_indices), 3):
|
||||
draw_line(_uvs[_indices[i]] * get_size(), _uvs[_indices[i + 1]] * get_size(), c, 1, false)
|
||||
draw_line(_uvs[_indices[i + 1]] * get_size(), _uvs[_indices[i + 2]] * get_size(), c, 1, false)
|
||||
draw_line(_uvs[_indices[i + 2]] * get_size(), _uvs[_indices[i]] * get_size(), c, 1, false)
|
||||
|
||||
func set_texture(texture : Texture) -> void:
|
||||
_texture = texture
|
||||
update()
|
||||
|
||||
func setup_from_mdr(mdr : MeshDataResource):
|
||||
setup_from_arrays(mdr.array)
|
||||
|
||||
func setup_from_arrays(arrays : Array):
|
||||
if arrays.size() != ArrayMesh.ARRAY_MAX:
|
||||
return
|
||||
|
||||
if arrays[ArrayMesh.ARRAY_TEX_UV] == null:
|
||||
return
|
||||
|
||||
_uvs = arrays[ArrayMesh.ARRAY_TEX_UV]
|
||||
_indices = arrays[ArrayMesh.ARRAY_INDEX]
|
||||
|
||||
update()
|
8
game/tools/uv_debugger/UVDebugger.tscn
Normal file
8
game/tools/uv_debugger/UVDebugger.tscn
Normal file
@ -0,0 +1,8 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://tools/uv_debugger/UVDebugger.gd" type="Script" id=1]
|
||||
|
||||
[node name="UVDebugger" type="PanelContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = ExtResource( 1 )
|
Loading…
Reference in New Issue
Block a user