feat(editor): add bundled 3D prop models and sample picker in Creator Studio
checkpoint / checkpoint (push) Failing after 3h14m9s
checkpoint / checkpoint (push) Failing after 3h14m9s
This commit is contained in:
@@ -0,0 +1,152 @@
|
||||
extends SceneTree
|
||||
|
||||
func _initialize() -> void:
|
||||
_generate()
|
||||
|
||||
func _save_model(root_node: Node3D, out_path: String) -> void:
|
||||
var gltf := GLTFDocument.new()
|
||||
var state := GLTFState.new()
|
||||
var err := gltf.append_from_scene(root_node, state)
|
||||
if err == OK:
|
||||
var dir := out_path.get_base_dir()
|
||||
DirAccess.make_dir_recursive_absolute(ProjectSettings.globalize_path(dir))
|
||||
var w_err := gltf.write_to_filesystem(state, out_path)
|
||||
print("Saved %s: error=%d" % [out_path, w_err])
|
||||
else:
|
||||
printerr("Failed append_from_scene for %s: %d" % [out_path, err])
|
||||
|
||||
func _generate() -> void:
|
||||
print("Generating prop models...")
|
||||
|
||||
# 1. Crate Small
|
||||
var crate_root := Node3D.new()
|
||||
var crate_mesh := MeshInstance3D.new()
|
||||
var box := BoxMesh.new()
|
||||
box.size = Vector3(1.0, 1.0, 1.0)
|
||||
var mat_wood := StandardMaterial3D.new()
|
||||
mat_wood.albedo_color = Color(0.6, 0.4, 0.2)
|
||||
mat_wood.roughness = 0.8
|
||||
box.material = mat_wood
|
||||
crate_mesh.mesh = box
|
||||
crate_mesh.position.y = 0.5
|
||||
crate_root.add_child(crate_mesh)
|
||||
_save_model(crate_root, "res://assets/props/crate_small.glb")
|
||||
|
||||
# 2. Rock
|
||||
var rock_root := Node3D.new()
|
||||
var rock_mesh := MeshInstance3D.new()
|
||||
var sphere := SphereMesh.new()
|
||||
sphere.radius = 0.6
|
||||
sphere.height = 0.9
|
||||
sphere.radial_segments = 8
|
||||
sphere.rings = 6
|
||||
var mat_rock := StandardMaterial3D.new()
|
||||
mat_rock.albedo_color = Color(0.45, 0.45, 0.48)
|
||||
mat_rock.roughness = 0.9
|
||||
sphere.material = mat_rock
|
||||
rock_mesh.mesh = sphere
|
||||
rock_mesh.position.y = 0.45
|
||||
rock_root.add_child(rock_mesh)
|
||||
_save_model(rock_root, "res://assets/props/rock_01.glb")
|
||||
|
||||
# 3. Pine Tree
|
||||
var tree_root := Node3D.new()
|
||||
var trunk := MeshInstance3D.new()
|
||||
var trunk_mesh := CylinderMesh.new()
|
||||
trunk_mesh.top_radius = 0.15
|
||||
trunk_mesh.bottom_radius = 0.2
|
||||
trunk_mesh.height = 1.0
|
||||
var mat_trunk := StandardMaterial3D.new()
|
||||
mat_trunk.albedo_color = Color(0.38, 0.25, 0.12)
|
||||
mat_trunk.roughness = 0.9
|
||||
trunk_mesh.material = mat_trunk
|
||||
trunk.mesh = trunk_mesh
|
||||
trunk.position.y = 0.5
|
||||
tree_root.add_child(trunk)
|
||||
|
||||
var foliage := MeshInstance3D.new()
|
||||
var cone_mesh := CylinderMesh.new()
|
||||
cone_mesh.top_radius = 0.0
|
||||
cone_mesh.bottom_radius = 0.9
|
||||
cone_mesh.height = 1.8
|
||||
var mat_leaf := StandardMaterial3D.new()
|
||||
mat_leaf.albedo_color = Color(0.15, 0.45, 0.2)
|
||||
mat_leaf.roughness = 0.7
|
||||
cone_mesh.material = mat_leaf
|
||||
foliage.mesh = cone_mesh
|
||||
foliage.position.y = 1.8
|
||||
tree_root.add_child(foliage)
|
||||
_save_model(tree_root, "res://assets/props/tree_pine_01.glb")
|
||||
|
||||
# 4. Lamp Post
|
||||
var lamp_root := Node3D.new()
|
||||
var pole := MeshInstance3D.new()
|
||||
var pole_mesh := CylinderMesh.new()
|
||||
pole_mesh.top_radius = 0.05
|
||||
pole_mesh.bottom_radius = 0.08
|
||||
pole_mesh.height = 2.4
|
||||
var mat_metal := StandardMaterial3D.new()
|
||||
mat_metal.albedo_color = Color(0.2, 0.22, 0.25)
|
||||
mat_metal.metallic = 0.8
|
||||
mat_metal.roughness = 0.3
|
||||
pole_mesh.material = mat_metal
|
||||
pole.mesh = pole_mesh
|
||||
pole.position.y = 1.2
|
||||
lamp_root.add_child(pole)
|
||||
|
||||
var light_mesh := MeshInstance3D.new()
|
||||
var light_box := BoxMesh.new()
|
||||
light_box.size = Vector3(0.3, 0.35, 0.3)
|
||||
var mat_glow := StandardMaterial3D.new()
|
||||
mat_glow.albedo_color = Color(1.0, 0.9, 0.4)
|
||||
mat_glow.emission_enabled = true
|
||||
mat_glow.emission = Color(1.0, 0.85, 0.3)
|
||||
mat_glow.emission_energy_multiplier = 2.0
|
||||
light_box.material = mat_glow
|
||||
light_mesh.mesh = light_box
|
||||
light_mesh.position.y = 2.4
|
||||
lamp_root.add_child(light_mesh)
|
||||
_save_model(lamp_root, "res://assets/props/lamp_post_01.glb")
|
||||
|
||||
# 5. Treasure Chest
|
||||
var chest_root := Node3D.new()
|
||||
var chest_body := MeshInstance3D.new()
|
||||
var cbox := BoxMesh.new()
|
||||
cbox.size = Vector3(0.9, 0.6, 0.6)
|
||||
var mat_chest := StandardMaterial3D.new()
|
||||
mat_chest.albedo_color = Color(0.45, 0.26, 0.12)
|
||||
mat_chest.roughness = 0.6
|
||||
cbox.material = mat_chest
|
||||
chest_body.mesh = cbox
|
||||
chest_body.position.y = 0.3
|
||||
chest_root.add_child(chest_body)
|
||||
|
||||
var latch := MeshInstance3D.new()
|
||||
var latch_box := BoxMesh.new()
|
||||
latch_box.size = Vector3(0.12, 0.15, 0.06)
|
||||
var mat_gold := StandardMaterial3D.new()
|
||||
mat_gold.albedo_color = Color(0.95, 0.8, 0.2)
|
||||
mat_gold.metallic = 0.9
|
||||
mat_gold.roughness = 0.2
|
||||
latch_box.material = mat_gold
|
||||
latch.mesh = latch_box
|
||||
latch.position = Vector3(0, 0.35, 0.31)
|
||||
chest_root.add_child(latch)
|
||||
_save_model(chest_root, "res://assets/props/chest.glb")
|
||||
|
||||
# 6. Buffalo Chip Coin
|
||||
var coin_root := Node3D.new()
|
||||
var coin_mesh := MeshInstance3D.new()
|
||||
var cyl := CylinderMesh.new()
|
||||
cyl.top_radius = 0.35
|
||||
cyl.bottom_radius = 0.35
|
||||
cyl.height = 0.08
|
||||
cyl.material = mat_gold
|
||||
coin_mesh.mesh = cyl
|
||||
coin_mesh.rotation_degrees = Vector3(90, 0, 0)
|
||||
coin_mesh.position.y = 0.4
|
||||
coin_root.add_child(coin_mesh)
|
||||
_save_model(coin_root, "res://assets/props/buffalo_chip_coin.glb")
|
||||
|
||||
print("All prop models generated!")
|
||||
quit(0)
|
||||
Reference in New Issue
Block a user