broken cube spin

This commit is contained in:
Leon Palluch 2020-01-31 23:02:24 +01:00
parent 0b15a91484
commit f34690ce2b
4 changed files with 146 additions and 0 deletions

View File

@ -0,0 +1,14 @@
[gd_scene load_steps=3 format=2]
[sub_resource type="CubeMesh" id=1]
[sub_resource type="BoxShape" id=2]
[node name="Torso" type="RigidBody"]
[node name="MeshInstance" type="MeshInstance" parent="."]
mesh = SubResource( 1 )
material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="."]
shape = SubResource( 2 )

View File

@ -0,0 +1,69 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://BodyConfig/BodyParts/Tesso.tscn" type="PackedScene" id=1]
[ext_resource path="res://BodyConfig/bodyBuildingScript.gd" type="Script" id=2]
[node name="Body Builder Menu" type="Spatial"]
script = ExtResource( 2 )
[node name="GUI" type="MarginContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="HBoxC" type="HBoxContainer" parent="GUI"]
margin_right = 1024.0
margin_bottom = 600.0
rect_min_size = Vector2( 550, 500 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VBoxC" type="VBoxContainer" parent="GUI/HBoxC"]
margin_right = 300.0
margin_bottom = 600.0
rect_min_size = Vector2( 300, 500 )
[node name="Button" type="Button" parent="GUI/HBoxC/VBoxC"]
margin_right = 300.0
margin_bottom = 20.0
text = "Button 1"
[node name="Button2" type="Button" parent="GUI/HBoxC/VBoxC"]
margin_top = 24.0
margin_right = 300.0
margin_bottom = 44.0
text = "Button 2"
[node name="Button3" type="Button" parent="GUI/HBoxC/VBoxC"]
margin_top = 48.0
margin_right = 300.0
margin_bottom = 68.0
text = "Button 3"
[node name="Button4" type="Button" parent="GUI/HBoxC/VBoxC"]
margin_top = 72.0
margin_right = 300.0
margin_bottom = 92.0
text = "Button 4"
[node name="ViewportContainer" type="ViewportContainer" parent="GUI/HBoxC"]
margin_left = 304.0
margin_right = 1024.0
margin_bottom = 600.0
rect_min_size = Vector2( 500, 500 )
size_flags_horizontal = 3
size_flags_vertical = 3
stretch = true
[node name="Viewport" type="Viewport" parent="GUI/HBoxC/ViewportContainer"]
size = Vector2( 720, 600 )
handle_input_locally = false
render_target_update_mode = 3
[node name="Camera" type="Camera" parent="GUI/HBoxC/ViewportContainer/Viewport"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 3 )
[node name="Torso" parent="." instance=ExtResource( 1 )]

View File

@ -0,0 +1,61 @@
extends Spatial
const ROT_MOD = 10
var _viewRot = false
var _prev_mouse_pos
# Called when the node enters the scene tree for the first time.
func _ready():
PhysicsServer.area_set_param(get_viewport().find_world().get_space(), PhysicsServer.AREA_PARAM_GRAVITY, 0)
func _physics_process(delta):
if _viewRot:
var mouse_pos = get_viewport().get_mouse_position()
var x_dif = mouse_pos.x - _prev_mouse_pos.x
var y_dif = mouse_pos.y - _prev_mouse_pos.y
print (x_dif)
print (y_dif)
rotate_x(x_dif * ROT_MOD * delta * PI/180 - global_transform.basis.get_euler().y)
rotate_y(y_dif * ROT_MOD * delta * PI/180 - global_transform.basis.get_euler().y)
_prev_mouse_pos = mouse_pos
# Get the camera
#var camera = get_node("GUI/HBoxC/ViewportContainer/Viewport/Camera")
#var mouse_pos = get_viewport().get_mouse_position()
# Project mouse into a 3D ray
#var ray_origin = camera.project_ray_origin(mouse_pos)
#var ray_direction = camera.project_ray_normal(mouse_pos)
# Cast a ray
#var from = ray_origin
#var to = ray_origin + ray_direction * 1000.0
#var space_state = get_world().get_direct_space_state()
#var hit = space_state.intersect_ray(from, to)
#print("test")
#if hit.size() != 0:
# collider will be the node you hit
#print(hit.collider)
#pass
func _input(event):
if event is InputEventMouseButton:
if event.pressed:
print("Mouse Click at: ", event.position)
_prev_mouse_pos = event.position
_viewRot = true
else:
print("mouse unpressed at: ", event.position)
_viewRot = false

View File

@ -1,5 +1,7 @@
[gd_resource type="Environment" load_steps=2 format=2] [gd_resource type="Environment" load_steps=2 format=2]
[sub_resource type="ProceduralSky" id=1] [sub_resource type="ProceduralSky" id=1]
[resource] [resource]
background_mode = 2 background_mode = 2
background_sky = SubResource( 1 ) background_sky = SubResource( 1 )