mirror of
https://github.com/Relintai/broken_seals_2d.git
synced 2024-11-11 20:35:10 +01:00
Added in my old 3d spritesheet generator. This can generate isometric spritesheets from 3d models.
This commit is contained in:
parent
64c38ac3a3
commit
aa914f6733
11
game/spritesheet_generator_3d/SSGen.tres
Normal file
11
game/spritesheet_generator_3d/SSGen.tres
Normal file
File diff suppressed because one or more lines are too long
170
game/spritesheet_generator_3d/SSGen.tscn
Normal file
170
game/spritesheet_generator_3d/SSGen.tscn
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
[gd_scene load_steps=14 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://spritesheet_generator_3d/Spatial.tscn" type="PackedScene" id=1]
|
||||||
|
[ext_resource path="res://spritesheet_generator_3d/Spatial.tscn" type="PackedScene" id=2]
|
||||||
|
[ext_resource path="res://spritesheet_generator/SheetGen.gd" type="Script" id=3]
|
||||||
|
[ext_resource path="res://spritesheet_generator_3d/Spatial.tscn" type="PackedScene" id=4]
|
||||||
|
[ext_resource path="res://spritesheet_generator/SpriteMover.gd" type="Script" id=5]
|
||||||
|
[ext_resource path="res://spritesheet_generator/Sprite3Ds.tscn" type="PackedScene" id=6]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[sub_resource type="ProceduralSky" id=1]
|
||||||
|
|
||||||
|
[sub_resource type="Environment" id=2]
|
||||||
|
background_mode = 2
|
||||||
|
background_sky = SubResource( 1 )
|
||||||
|
background_color = Color( 0.364706, 0.364706, 0.364706, 1 )
|
||||||
|
background_energy = 0.69
|
||||||
|
ambient_light_color = Color( 1, 1, 1, 1 )
|
||||||
|
ambient_light_energy = 0.68
|
||||||
|
ambient_light_sky_contribution = 0.0
|
||||||
|
|
||||||
|
[sub_resource type="Environment" id=3]
|
||||||
|
background_mode = 1
|
||||||
|
background_energy = 0.57
|
||||||
|
ambient_light_color = Color( 0.113725, 0.113725, 0.113725, 1 )
|
||||||
|
ambient_light_energy = 0.68
|
||||||
|
ssao_enabled = true
|
||||||
|
|
||||||
|
[sub_resource type="World" id=4]
|
||||||
|
environment = SubResource( 3 )
|
||||||
|
|
||||||
|
[sub_resource type="Environment" id=5]
|
||||||
|
background_mode = 1
|
||||||
|
background_energy = 0.26
|
||||||
|
ambient_light_color = Color( 0.113725, 0.113725, 0.113725, 1 )
|
||||||
|
ambient_light_energy = 0.58
|
||||||
|
ambient_light_sky_contribution = 0.1
|
||||||
|
tonemap_exposure = 0.36
|
||||||
|
tonemap_white = 0.47
|
||||||
|
|
||||||
|
[sub_resource type="ViewportTexture" id=6]
|
||||||
|
viewport_path = NodePath("Viewport")
|
||||||
|
|
||||||
|
[sub_resource type="SpatialMaterial" id=7]
|
||||||
|
flags_transparent = true
|
||||||
|
params_billboard_mode = 1
|
||||||
|
|
||||||
|
[node name="Node" type="Node"]
|
||||||
|
|
||||||
|
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||||
|
environment = SubResource( 2 )
|
||||||
|
|
||||||
|
[node name="player2" parent="." instance=ExtResource( 1 )]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -34.2601 )
|
||||||
|
visible = false
|
||||||
|
input_ray_pickable = false
|
||||||
|
|
||||||
|
[node name="player" parent="." instance=ExtResource( 1 )]
|
||||||
|
visible = false
|
||||||
|
input_ray_pickable = false
|
||||||
|
|
||||||
|
[node name="MicamoChar" parent="." instance=ExtResource( 2 )]
|
||||||
|
editor/display_folded = true
|
||||||
|
|
||||||
|
[node name="Viewport" type="Viewport" parent="."]
|
||||||
|
size = Vector2( 32, 32 )
|
||||||
|
own_world = true
|
||||||
|
world = SubResource( 4 )
|
||||||
|
transparent_bg = true
|
||||||
|
handle_input_locally = false
|
||||||
|
hdr = false
|
||||||
|
render_target_v_flip = true
|
||||||
|
render_target_update_mode = 3
|
||||||
|
script = ExtResource( 3 )
|
||||||
|
_sprite_size = 32
|
||||||
|
_sprite_num = 16
|
||||||
|
_directions = 16
|
||||||
|
save_texture = true
|
||||||
|
_atlas_show_sprite_path = NodePath("../Sprite3")
|
||||||
|
_sprite_path = NodePath("../Sprite3D")
|
||||||
|
_animation_player_path = NodePath("MicamoChar/AnimationPlayer")
|
||||||
|
_player_path = NodePath("MicamoChar")
|
||||||
|
|
||||||
|
[node name="MicamoChar" parent="Viewport" instance=ExtResource( 4 )]
|
||||||
|
editor/display_folded = true
|
||||||
|
|
||||||
|
[node name="Skeleton" parent="Viewport/MicamoChar" index="0"]
|
||||||
|
bones/0/bound_children = [ ]
|
||||||
|
bones/1/bound_children = [ ]
|
||||||
|
bones/3/bound_children = [ ]
|
||||||
|
bones/4/bound_children = [ ]
|
||||||
|
bones/5/bound_children = [ ]
|
||||||
|
bones/8/bound_children = [ ]
|
||||||
|
bones/9/bound_children = [ ]
|
||||||
|
bones/10/bound_children = [ ]
|
||||||
|
bones/32/bound_children = [ ]
|
||||||
|
bones/33/bound_children = [ ]
|
||||||
|
bones/34/bound_children = [ ]
|
||||||
|
bones/55/bound_children = [ ]
|
||||||
|
bones/56/bound_children = [ ]
|
||||||
|
bones/57/bound_children = [ ]
|
||||||
|
bones/60/bound_children = [ ]
|
||||||
|
bones/61/bound_children = [ ]
|
||||||
|
bones/62/bound_children = [ ]
|
||||||
|
|
||||||
|
[node name="Camera" type="Camera" parent="Viewport"]
|
||||||
|
transform = Transform( 0.707107, -0.353553, 0.612372, 0, 0.866025, 0.5, -0.707107, -0.353553, 0.612372, 2.95796, 3.39896, 2.92486 )
|
||||||
|
environment = SubResource( 5 )
|
||||||
|
projection = 1
|
||||||
|
current = true
|
||||||
|
size = 2.2
|
||||||
|
near = 0.01
|
||||||
|
far = 240.8
|
||||||
|
|
||||||
|
[node name="OmniLight" type="OmniLight" parent="Viewport"]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 3.05496, 1.55159, 3.33238 )
|
||||||
|
layers = 3
|
||||||
|
light_color = Color( 0.952941, 0.929412, 0.807843, 1 )
|
||||||
|
light_energy = 0.74
|
||||||
|
light_indirect_energy = 1.27
|
||||||
|
light_specular = 0.15
|
||||||
|
omni_range = 6.4
|
||||||
|
omni_attenuation = 1.1487
|
||||||
|
|
||||||
|
[node name="OmniLight2" type="OmniLight" parent="Viewport"]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -1.4893, 3.88558, -2.30035 )
|
||||||
|
light_color = Color( 0.898039, 0.898039, 0.729412, 1 )
|
||||||
|
light_energy = 0.58
|
||||||
|
light_indirect_energy = 2.95
|
||||||
|
omni_range = 4.3
|
||||||
|
|
||||||
|
[node name="Sprite" type="Sprite" parent="."]
|
||||||
|
position = Vector2( 837.448, 475.588 )
|
||||||
|
centered = false
|
||||||
|
flip_v = true
|
||||||
|
vframes = 16
|
||||||
|
hframes = 16
|
||||||
|
script = ExtResource( 5 )
|
||||||
|
|
||||||
|
[node name="Camera" type="Camera" parent="."]
|
||||||
|
transform = Transform( 0.707107, -0.353553, 0.612372, 0, 0.866026, 0.5, -0.707107, -0.353553, 0.612372, 13.5879, 9.78323, 18.7533 )
|
||||||
|
projection = 1
|
||||||
|
current = true
|
||||||
|
size = 10.0
|
||||||
|
|
||||||
|
[node name="Sprite2" type="Sprite" parent="."]
|
||||||
|
position = Vector2( 179.55, 160.55 )
|
||||||
|
texture = SubResource( 6 )
|
||||||
|
flip_v = true
|
||||||
|
|
||||||
|
[node name="Sprite3" type="Sprite" parent="."]
|
||||||
|
position = Vector2( 603.531, 254.594 )
|
||||||
|
flip_v = true
|
||||||
|
|
||||||
|
[node name="Sprite3D" type="Sprite3D" parent="."]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 8.18889, 0, 14.9987 )
|
||||||
|
material_override = SubResource( 7 )
|
||||||
|
cast_shadow = 0
|
||||||
|
flip_v = true
|
||||||
|
pixel_size = 0.0156
|
||||||
|
vframes = 16
|
||||||
|
hframes = 16
|
||||||
|
script = ExtResource( 5 )
|
||||||
|
|
||||||
|
[node name="Sprite3D2" parent="." instance=ExtResource( 6 )]
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
|
||||||
|
[editable path="Viewport/MicamoChar"]
|
129
game/spritesheet_generator_3d/SheetGen.gd
Normal file
129
game/spritesheet_generator_3d/SheetGen.gd
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
extends Node
|
||||||
|
|
||||||
|
# Declare member variables here. Examples:
|
||||||
|
# var a = 2
|
||||||
|
# var b = "text"
|
||||||
|
export (int) var _sprite_size
|
||||||
|
export (int) var _sprite_num
|
||||||
|
export (int) var _directions
|
||||||
|
|
||||||
|
export (bool) var _show_atlas = false
|
||||||
|
|
||||||
|
export (bool) var save_texture = false
|
||||||
|
|
||||||
|
export (NodePath) var _atlas_show_sprite_path
|
||||||
|
export (NodePath) var _sprite_path
|
||||||
|
export (NodePath) var _animation_player_path
|
||||||
|
export (NodePath) var _player_path
|
||||||
|
export (NodePath) var _animation_tree_player_path
|
||||||
|
|
||||||
|
var _viewport
|
||||||
|
var _viewport_texture
|
||||||
|
var _sprite
|
||||||
|
var _animation_player
|
||||||
|
var _time = 0
|
||||||
|
var _animation_tree_player
|
||||||
|
var _frame = 0
|
||||||
|
var _rotcount = 0
|
||||||
|
var _rotation = 0
|
||||||
|
var _atlas
|
||||||
|
var _image_texture
|
||||||
|
var _running = false
|
||||||
|
var _atlas_sprite_show_node
|
||||||
|
var _atlas_texture
|
||||||
|
var _player
|
||||||
|
|
||||||
|
var _texture
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready():
|
||||||
|
_viewport = get_node(".")
|
||||||
|
#_viewport.set
|
||||||
|
_sprite = get_node(_sprite_path)
|
||||||
|
_atlas_sprite_show_node = get_node(_atlas_show_sprite_path)
|
||||||
|
_animation_player = get_node(_animation_player_path)
|
||||||
|
_player = get_node(_player_path)
|
||||||
|
_animation_tree_player = get_node(_animation_tree_player_path)
|
||||||
|
_viewport_texture = _viewport.get_texture()
|
||||||
|
|
||||||
|
_texture = Image.new()
|
||||||
|
var frame = _viewport.get_texture().get_data()
|
||||||
|
_texture.create(_sprite_size * _sprite_num, _sprite_size * _directions, false, frame.get_format())
|
||||||
|
|
||||||
|
yield(get_tree(), "idle_frame")
|
||||||
|
yield(get_tree(), "idle_frame")
|
||||||
|
|
||||||
|
_running = true
|
||||||
|
|
||||||
|
#_generated_image = Image.new()
|
||||||
|
#_generated_image.
|
||||||
|
#_sprite.set_texture(_viewport_texture)
|
||||||
|
|
||||||
|
|
||||||
|
#_frame_data.clear()
|
||||||
|
|
||||||
|
#_generated_image.create_from_data(64, 64, false, Image.FORMAT_RGBA4444, texture.get_data().get_data())
|
||||||
|
#texture = _viewport.get_texture()
|
||||||
|
#_sprite.set_texture(texture)
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta):
|
||||||
|
|
||||||
|
#if not _running and Input.is_key_pressed(KEY_K):
|
||||||
|
# _running = true
|
||||||
|
|
||||||
|
if not _running:
|
||||||
|
return
|
||||||
|
|
||||||
|
#_viewport.update_worlds()
|
||||||
|
|
||||||
|
var frame = _viewport.get_texture().get_data()
|
||||||
|
|
||||||
|
|
||||||
|
#if _frame == 0 and _rotcount == 0:
|
||||||
|
|
||||||
|
_texture.blend_rect(frame, frame.get_used_rect(), Vector2((_frame * _sprite_size), (_rotcount * _sprite_size)))
|
||||||
|
|
||||||
|
#_time += 0.3
|
||||||
|
#_animation_player.seek (_time , true )
|
||||||
|
_frame += 1
|
||||||
|
|
||||||
|
if _frame > _sprite_num - 1:
|
||||||
|
_frame = 0
|
||||||
|
|
||||||
|
_rotcount += 1
|
||||||
|
|
||||||
|
if (_rotcount > _sprite_num - 1):
|
||||||
|
_running = false
|
||||||
|
create_atlas()
|
||||||
|
return
|
||||||
|
|
||||||
|
#var m3 = Basis()
|
||||||
|
#m3 = m3.rotated( Vector3(0,1,0), 0.19625 )
|
||||||
|
_player.rotate_y((PI*2)/float(_directions))
|
||||||
|
|
||||||
|
_animation_player.play("default")
|
||||||
|
#_rotation = _rotcount * 22.5
|
||||||
|
#_player.tra
|
||||||
|
|
||||||
|
|
||||||
|
#return
|
||||||
|
|
||||||
|
#0.83
|
||||||
|
_animation_player.seek(_frame * (_animation_player.current_animation_length / (_sprite_num - 1)), true)
|
||||||
|
#_animation_tree_player.advance(0.05)
|
||||||
|
|
||||||
|
|
||||||
|
func create_atlas():
|
||||||
|
_image_texture = ImageTexture.new()
|
||||||
|
_image_texture.create_from_image(_texture, 0)
|
||||||
|
|
||||||
|
_image_texture.get_data().save_png("res://testsave.png")
|
||||||
|
|
||||||
|
if save_texture:
|
||||||
|
_sprite.set_texture(_image_texture)
|
||||||
|
|
||||||
|
if _show_atlas:
|
||||||
|
_atlas_sprite_show_node.set_texture(_image_texture)
|
||||||
|
|
||||||
|
pass
|
3
game/spritesheet_generator_3d/Spatial.tscn
Normal file
3
game/spritesheet_generator_3d/Spatial.tscn
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[gd_scene format=2]
|
||||||
|
|
||||||
|
[node name="Spatial" type="Spatial"]
|
22
game/spritesheet_generator_3d/Sprite3Ds.tscn
Normal file
22
game/spritesheet_generator_3d/Sprite3Ds.tscn
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://testsave.png" type="Texture" id=1]
|
||||||
|
[ext_resource path="res://spritesheet_generator/SpriteMover.gd" type="Script" id=2]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[sub_resource type="SpatialMaterial" id=1]
|
||||||
|
flags_transparent = true
|
||||||
|
params_billboard_mode = 1
|
||||||
|
|
||||||
|
[node name="Sprite3D" type="Sprite3D"]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.39352, 0 )
|
||||||
|
material_override = SubResource( 1 )
|
||||||
|
cast_shadow = 0
|
||||||
|
flip_v = true
|
||||||
|
pixel_size = 0.064
|
||||||
|
texture = ExtResource( 1 )
|
||||||
|
vframes = 16
|
||||||
|
hframes = 16
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
|
82
game/spritesheet_generator_3d/SpriteMover.gd
Normal file
82
game/spritesheet_generator_3d/SpriteMover.gd
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
extends Node
|
||||||
|
|
||||||
|
# Declare member variables here. Examples:
|
||||||
|
# var a = 2
|
||||||
|
# var b = "text"
|
||||||
|
|
||||||
|
var _sprite
|
||||||
|
|
||||||
|
export (bool) var enabled = true
|
||||||
|
export(int) var _animset = 0
|
||||||
|
export(int) var _animset_size = 16
|
||||||
|
export(int) var _animset_count = 16
|
||||||
|
var _min_frame = 0
|
||||||
|
var _max_frame = 16 * 16
|
||||||
|
|
||||||
|
var x = 0
|
||||||
|
var y = 0
|
||||||
|
var timer = 0
|
||||||
|
var _frame = 1
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready():
|
||||||
|
_sprite = get_node(".")
|
||||||
|
_sprite.set_frame(_min_frame)
|
||||||
|
#_sprite.set_position(Vector2(x, y))
|
||||||
|
|
||||||
|
func set_movement_vector(vector):
|
||||||
|
var a = Vector2(vector.x, vector.z)
|
||||||
|
a = a.normalized()
|
||||||
|
|
||||||
|
var base = Vector2(0, -1)
|
||||||
|
|
||||||
|
var angle = a.angle_to(base) + PI
|
||||||
|
|
||||||
|
var slice = (2*PI) / _animset_count
|
||||||
|
|
||||||
|
var num_slice = int(angle / slice)
|
||||||
|
|
||||||
|
set_animset(num_slice)
|
||||||
|
|
||||||
|
func set_animset(animest_id):
|
||||||
|
if (animest_id >= _animset_count):
|
||||||
|
_animset = _animset_count - 1
|
||||||
|
|
||||||
|
if (animest_id < 0):
|
||||||
|
_animset = 0
|
||||||
|
|
||||||
|
_animset = animest_id
|
||||||
|
|
||||||
|
|
||||||
|
#_min_frame = _animset * _animset_size
|
||||||
|
#_max_frame = _animset * _animset_size + _animset_size
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
#set_animset(_animset)
|
||||||
|
|
||||||
|
if not enabled:
|
||||||
|
set_process(false)
|
||||||
|
return
|
||||||
|
|
||||||
|
timer += delta
|
||||||
|
|
||||||
|
if (timer > 0.05):
|
||||||
|
timer -= 0.05
|
||||||
|
_frame += 1
|
||||||
|
|
||||||
|
if _frame > _animset_size - 1:
|
||||||
|
_frame = 0
|
||||||
|
|
||||||
|
_sprite.set_frame(_frame + (_animset * _animset_size))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func a_process(delta):
|
||||||
|
#x += int(delta * 300)
|
||||||
|
y += int(delta * 200)
|
||||||
|
|
||||||
|
if y > 700:
|
||||||
|
y = -50
|
||||||
|
|
||||||
|
_sprite.set_position(Vector2(x, y))
|
Loading…
Reference in New Issue
Block a user