-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from jspahrsummers/asteroids
Asteroids!
- Loading branch information
Showing
45 changed files
with
863 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.