Skip to content

Instantly share code, notes, and snippets.

@Einlander
Created September 19, 2018 03:39
Show Gist options
  • Save Einlander/6f932d02112218cdf840dbd15987a406 to your computer and use it in GitHub Desktop.
Save Einlander/6f932d02112218cdf840dbd15987a406 to your computer and use it in GitHub Desktop.
Takes the needed pictures to create a cube map.
extends Camera
# Takes the needed pictures to create a cube map.
# Read this to find where the files are saved. http://docs.godotengine.org/en/3.0/tutorials/io/data_paths.html?highlight=user%3A%2F%2F
# Go here to make it useable in godot. https://nadirpatch.com/cube2sphere/
var _pass = 0
func _ready():
get_viewport().size = Vector2(1024,1024)
self.rotation = Vector3(0,0,0)
pass
func _process(delta):
yield(get_tree(), "idle_frame")
yield(get_tree(), "idle_frame")
var capture = get_viewport().get_texture().get_data()
capture.flip_y()
if _pass == 0 :
capture.save_png("user://front.png")
self.rotation.y = deg2rad(90)
if _pass == 1 :
capture.save_png("user://right.png")
self.rotation.y = deg2rad(180)
if _pass == 2:
capture.save_png("user://back.png")
self.rotation.y = deg2rad(270)
if _pass == 3:
capture.save_png("user://left.png")
self.rotation.y = deg2rad(0)
self.rotation.x = deg2rad(90)
if _pass == 4:
capture.save_png("user://top.png")
self.rotation.x = deg2rad(270)
if _pass == 5:
capture.save_png("user://bottom.png")
_pass += 1
if _pass > 5:
get_tree().quit()
_pass += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment