Skip to content

Commit

Permalink
Merge pull request #52 from jspahrsummers/asteroids
Browse files Browse the repository at this point in the history
Asteroids!
  • Loading branch information
jspahrsummers authored Jul 25, 2024
2 parents 5759d61 + 113285d commit 416eb9e
Show file tree
Hide file tree
Showing 45 changed files with 863 additions and 11 deletions.
20 changes: 20 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,26 @@ As mentioned before, the one stipulation is that these images aren’t to be use
- target_overlay
- selected_galaxy_node

[Asteroids](https://gargore.itch.io/asteroids) created by [Gargore](https://www.gargore.com/), purchased for use in this project:
- asteroids
- asteroid1_lod0
- asteroid1_lod1
- asteroid2_lod1
- asteroid4_lod1
- asteroid6_lod1
- Asteroid1_d
- Asteroid1_n
- Asteroid2_d
- Asteroid2_n
- Asteroid3_d
- Asteroid3_n
- Asteroid4_d
- Asteroid4_n
- Asteroid5_d
- Asteroid5_n
- Asteroid6_d
- Asteroid6_n

Graphics created by [Justin Spahr-Summers](https://github.com/jspahrsummers) for this project, using [Midjourney](https://www.midjourney.com/):
- icon
- planet landing images
Expand Down
38 changes: 38 additions & 0 deletions fx/asteroids/asteroid_field.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
extends MultiMeshInstance3D

var _physics_bodies: Array[RID] = []

const MAX_LINEAR_VELOCITY = 1.5
const MAX_ANGULAR_VELOCITY = 1.5

const SPHERE_SHAPE_RADIUS = 0.4

func _ready() -> void:
for i in range(self.multimesh.instance_count):
var mesh_transform := self.multimesh.get_instance_transform(i)
var linear_velocity := Vector3(randf_range( - MAX_LINEAR_VELOCITY, MAX_LINEAR_VELOCITY), 0.0, randf_range( - MAX_LINEAR_VELOCITY, MAX_LINEAR_VELOCITY))
var angular_velocity := Vector3(randf_range( - MAX_ANGULAR_VELOCITY, MAX_ANGULAR_VELOCITY), randf_range( - MAX_ANGULAR_VELOCITY, MAX_ANGULAR_VELOCITY), randf_range( - MAX_ANGULAR_VELOCITY, MAX_ANGULAR_VELOCITY))

var physics_body := PhysicsServer3D.body_create()
PhysicsServer3D.body_set_mode(physics_body, PhysicsServer3D.BODY_MODE_RIGID)
PhysicsServer3D.body_set_state(physics_body, PhysicsServer3D.BODY_STATE_TRANSFORM, mesh_transform)
PhysicsServer3D.body_set_state(physics_body, PhysicsServer3D.BODY_STATE_ANGULAR_VELOCITY, angular_velocity)
PhysicsServer3D.body_set_state(physics_body, PhysicsServer3D.BODY_STATE_LINEAR_VELOCITY, linear_velocity)
PhysicsServer3D.body_set_space(physics_body, self.get_world_3d().space)
PhysicsServer3D.body_set_force_integration_callback(physics_body, _body_moved, i)
PhysicsServer3D.body_set_collision_layer(physics_body, 0)
PhysicsServer3D.body_set_collision_mask(physics_body, 0)
PhysicsServer3D.body_set_axis_lock(physics_body, PhysicsServer3D.BODY_AXIS_LINEAR_Y, true)
_physics_bodies.append(physics_body)

var shape := PhysicsServer3D.sphere_shape_create()
PhysicsServer3D.shape_set_data(shape, SPHERE_SHAPE_RADIUS)
PhysicsServer3D.body_add_shape(physics_body, shape, Transform3D.IDENTITY)

func _body_moved(state: PhysicsDirectBodyState3D, index: int) -> void:
var mesh_transform := state.transform

# Overwrite the physics scale from the multimesh, because it gets lost for some reason otherwise.
mesh_transform.basis = mesh_transform.basis.scaled(multimesh.get_instance_transform(index).basis.get_scale())

multimesh.set_instance_transform(index, mesh_transform)
Binary file added fx/asteroids/asteroids.glb
Binary file not shown.
138 changes: 138 additions & 0 deletions fx/asteroids/asteroids.glb.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
[remap]

importer="scene"
importer_version=1
type="PackedScene"
uid="uid://dwdbyvepc3f70"
path="res://.godot/imported/asteroids.glb-1a46b919ea1a762f671e57135a1d9f77.scn"

[deps]

source_file="res://fx/asteroids/asteroids.glb"
dest_files=["res://.godot/imported/asteroids.glb-1a46b919ea1a762f671e57135a1d9f77.scn"]

[params]

nodes/root_type=""
nodes/root_name=""
nodes/apply_root_scale=true
nodes/root_scale=1.0
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={
"meshes": {
"asteroids_Asteroid1_LOD0": {
"generate/lightmap_uv": 0,
"generate/lods": 0,
"generate/shadow_meshes": 0,
"lods/normal_merge_angle": 60.0,
"lods/normal_split_angle": 25.0,
"save_to_file/enabled": true,
"save_to_file/make_streamable": "",
"save_to_file/path": "res://fx/asteroids/asteroid1_lod0.res"
},
"asteroids_Asteroid1_LOD1": {
"generate/lightmap_uv": 0,
"generate/lods": 0,
"generate/shadow_meshes": 0,
"lods/normal_merge_angle": 60.0,
"lods/normal_split_angle": 25.0,
"save_to_file/enabled": true,
"save_to_file/make_streamable": "",
"save_to_file/path": "res://fx/asteroids/asteroid1_lod1.res"
},
"asteroids_Asteroid2_LOD0": {
"save_to_file/enabled": true,
"save_to_file/path": "res://fx/asteroids/asteroid2_lod0.res"
},
"asteroids_Asteroid2_LOD1": {
"generate/lightmap_uv": 0,
"generate/lods": 0,
"generate/shadow_meshes": 0,
"lods/normal_merge_angle": 60.0,
"lods/normal_split_angle": 25.0,
"save_to_file/enabled": true,
"save_to_file/make_streamable": "",
"save_to_file/path": "res://fx/asteroids/asteroid2_lod1.res"
},
"asteroids_Asteroid3_LOD0": {
"save_to_file/enabled": true,
"save_to_file/path": "res://fx/asteroids/asteroid3_lod0.res"
},
"asteroids_Asteroid3_LOD1": {
"save_to_file/enabled": true,
"save_to_file/path": "res://fx/asteroids/asteroid3_lod1.res"
},
"asteroids_Asteroid4_LOD0": {
"save_to_file/enabled": true,
"save_to_file/path": "res://fx/asteroids/asteroid4_lod0.res"
},
"asteroids_Asteroid4_LOD1": {
"generate/lightmap_uv": 0,
"generate/lods": 0,
"generate/shadow_meshes": 0,
"lods/normal_merge_angle": 60.0,
"lods/normal_split_angle": 25.0,
"save_to_file/enabled": true,
"save_to_file/make_streamable": "",
"save_to_file/path": "res://fx/asteroids/asteroid4_lod1.res"
},
"asteroids_Asteroid5_LOD0": {
"save_to_file/enabled": true,
"save_to_file/path": "res://fx/asteroids/asteroid5_lod0.res"
},
"asteroids_Asteroid5_LOD1": {
"save_to_file/enabled": true,
"save_to_file/path": "res://fx/asteroids/asteroid5_lod1.res"
},
"asteroids_Asteroid6_LOD0": {
"save_to_file/enabled": true,
"save_to_file/path": "res://fx/asteroids/asteroid6_lod0.res"
},
"asteroids_Asteroid6_LOD1": {
"generate/lightmap_uv": 0,
"generate/lods": 0,
"generate/shadow_meshes": 0,
"lods/normal_merge_angle": 60.0,
"lods/normal_split_angle": 25.0,
"save_to_file/enabled": true,
"save_to_file/make_streamable": "",
"save_to_file/path": "res://fx/asteroids/asteroid6_lod1.res"
}
},
"nodes": {
"PATH:Asteroid2_LOD0": {
"import/skip_import": true
},
"PATH:Asteroid3_LOD0": {
"import/skip_import": true
},
"PATH:Asteroid3_LOD1": {
"import/skip_import": true
},
"PATH:Asteroid4_LOD0": {
"import/skip_import": true
},
"PATH:Asteroid5_LOD0": {
"import/skip_import": true
},
"PATH:Asteroid5_LOD1": {
"import/skip_import": true
},
"PATH:Asteroid6_LOD0": {
"import/skip_import": true
}
}
}
gltf/naming_version=1
gltf/embedded_image_handling=1
88 changes: 88 additions & 0 deletions fx/asteroids/asteroids.mtl
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Blender MTL File: 'asteroids.blend'
# Material Count: 7

newmtl A1
Ns 98.039216
Ka 1.000000 1.000000 1.000000
Kd 1.000000 1.000000 1.000000
Ks 0.000000 0.000000 0.000000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 1
map_Kd Asteroid1_d.png
map_Bump Asteroid1_n.png
map_d Asteroid1_d.png

newmtl A2
Ns 98.039216
Ka 1.000000 1.000000 1.000000
Kd 1.000000 1.000000 1.000000
Ks 0.000000 0.000000 0.000000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 1
map_Kd Asteroid2_d.png
map_Bump Asteroid2_n.png
map_d Asteroid2_d.png

newmtl A3
Ns 98.039216
Ka 1.000000 1.000000 1.000000
Kd 1.000000 1.000000 1.000000
Ks 0.000000 0.000000 0.000000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 1
map_Kd Asteroid3_d.png
map_Bump Asteroid3_n.png
map_d Asteroid3_d.png

newmtl A4
Ns 98.039216
Ka 1.000000 1.000000 1.000000
Kd 1.000000 1.000000 1.000000
Ks 0.000000 0.000000 0.000000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 1
map_Kd Asteroid4_d.png
map_Bump Asteroid4_n.png
map_d Asteroid4_d.png

newmtl A5
Ns 98.039216
Ka 1.000000 1.000000 1.000000
Kd 1.000000 1.000000 1.000000
Ks 0.000000 0.000000 0.000000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 1
map_Kd Asteroid5_d.png
map_Bump Asteroid5_n.png
map_d Asteroid5_d.png

newmtl A6
Ns 98.039216
Ka 1.000000 1.000000 1.000000
Kd 1.000000 1.000000 1.000000
Ks 0.000000 0.000000 0.000000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 1
map_Kd Asteroid6_d.png
map_Bump Asteroid6_n.png
map_d Asteroid6_d.png

newmtl None
Ns 0
Ka 0.000000 0.000000 0.000000
Kd 0.8 0.8 0.8
Ks 0.8 0.8 0.8
d 1
illum 2
10 changes: 10 additions & 0 deletions fx/asteroids/materials/asteroid1.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[gd_resource type="StandardMaterial3D" load_steps=3 format=3 uid="uid://xuvjc1bnuf5c"]

[ext_resource type="Texture2D" uid="uid://b1jlnlktkmr8m" path="res://fx/asteroids/textures/Asteroid1_d.png" id="1_8xplf"]
[ext_resource type="Texture2D" uid="uid://daxfsktoiqu68" path="res://fx/asteroids/textures/Asteroid1_n.png" id="2_b8vbt"]

[resource]
albedo_color = Color(0.587751, 0.587751, 0.587751, 1)
albedo_texture = ExtResource("1_8xplf")
normal_enabled = true
normal_texture = ExtResource("2_b8vbt")
10 changes: 10 additions & 0 deletions fx/asteroids/materials/asteroid2.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[gd_resource type="StandardMaterial3D" load_steps=3 format=3 uid="uid://cp4s11ekdehf8"]

[ext_resource type="Texture2D" uid="uid://c6albkvfk0wv6" path="res://fx/asteroids/textures/Asteroid2_d.png" id="1_7de2u"]
[ext_resource type="Texture2D" uid="uid://chge0sdo4rmxv" path="res://fx/asteroids/textures/Asteroid2_n.png" id="2_0rdk7"]

[resource]
albedo_color = Color(0.587751, 0.587751, 0.587751, 1)
albedo_texture = ExtResource("1_7de2u")
normal_enabled = true
normal_texture = ExtResource("2_0rdk7")
10 changes: 10 additions & 0 deletions fx/asteroids/materials/asteroid3.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[gd_resource type="StandardMaterial3D" load_steps=3 format=3 uid="uid://bufkffkho1smg"]

[ext_resource type="Texture2D" uid="uid://dj1cl33rjglbp" path="res://fx/asteroids/textures/Asteroid3_d.png" id="1_xhmvw"]
[ext_resource type="Texture2D" uid="uid://cmxyllk1cnbyx" path="res://fx/asteroids/textures/Asteroid3_n.png" id="2_xm2qx"]

[resource]
albedo_color = Color(0.587751, 0.587751, 0.587751, 1)
albedo_texture = ExtResource("1_xhmvw")
normal_enabled = true
normal_texture = ExtResource("2_xm2qx")
10 changes: 10 additions & 0 deletions fx/asteroids/materials/asteroid4.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[gd_resource type="StandardMaterial3D" load_steps=3 format=3 uid="uid://beh0uiho3iyc0"]

[ext_resource type="Texture2D" uid="uid://ba8rex6410eu2" path="res://fx/asteroids/textures/Asteroid4_d.png" id="1_1e47d"]
[ext_resource type="Texture2D" uid="uid://bnymlq6n4kjow" path="res://fx/asteroids/textures/Asteroid4_n.png" id="2_ficw4"]

[resource]
albedo_color = Color(0.587751, 0.587751, 0.587751, 1)
albedo_texture = ExtResource("1_1e47d")
normal_enabled = true
normal_texture = ExtResource("2_ficw4")
10 changes: 10 additions & 0 deletions fx/asteroids/materials/asteroid5.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[gd_resource type="StandardMaterial3D" load_steps=3 format=3 uid="uid://bmwo2lvolrpia"]

[ext_resource type="Texture2D" uid="uid://bqmwgalnxswue" path="res://fx/asteroids/textures/Asteroid5_d.png" id="1_ad8iv"]
[ext_resource type="Texture2D" uid="uid://6keqysucp0v3" path="res://fx/asteroids/textures/Asteroid5_n.png" id="2_s3wkw"]

[resource]
albedo_color = Color(0.587751, 0.587751, 0.587751, 1)
albedo_texture = ExtResource("1_ad8iv")
normal_enabled = true
normal_texture = ExtResource("2_s3wkw")
10 changes: 10 additions & 0 deletions fx/asteroids/materials/asteroid6.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[gd_resource type="StandardMaterial3D" load_steps=3 format=3 uid="uid://dap1t36sdcpq0"]

[ext_resource type="Texture2D" uid="uid://0f4h1bsqam3l" path="res://fx/asteroids/textures/Asteroid6_d.png" id="1_ribjn"]
[ext_resource type="Texture2D" uid="uid://dr2jkxlq6ffm4" path="res://fx/asteroids/textures/Asteroid6_n.png" id="2_yn7ci"]

[resource]
albedo_color = Color(0.587751, 0.587751, 0.587751, 1)
albedo_texture = ExtResource("1_ribjn")
normal_enabled = true
normal_texture = ExtResource("2_yn7ci")
Binary file added fx/asteroids/meshes/asteroid1_lod0.res
Binary file not shown.
Binary file added fx/asteroids/meshes/asteroid1_lod1.res
Binary file not shown.
Binary file added fx/asteroids/meshes/asteroid2_lod1.res
Binary file not shown.
Binary file added fx/asteroids/meshes/asteroid4_lod1.res
Binary file not shown.
Binary file added fx/asteroids/meshes/asteroid6_lod1.res
Binary file not shown.
Loading

0 comments on commit 416eb9e

Please sign in to comment.