Skip to content

Commit

Permalink
[greenscreen_camera] initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
MrEliptik committed Feb 12, 2021
1 parent 85d333b commit 50fcf2a
Show file tree
Hide file tree
Showing 12 changed files with 327 additions and 0 deletions.
Binary file added 3D/greenscreen_camera/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletions 3D/greenscreen_camera/project.godot
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters

config_version=4

_global_script_classes=[ ]
_global_script_class_icons={

}

[application]

config/name="greenscreen_camera"
run/main_scene="res://scenes/world.tscn"
config/icon="res://icon.png"

[display]

window/size/width=1920
window/size/height=1080
window/size/borderless=true
window/stretch/mode="2d"
window/stretch/aspect="keep"

[input]

move_forward={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":90,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"unicode":0,"echo":false,"script":null)
]
}
move_back={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":83,"unicode":0,"echo":false,"script":null)
]
}
strafe_left={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":81,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"unicode":0,"echo":false,"script":null)
]
}
strafe_right={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":68,"unicode":0,"echo":false,"script":null)
]
}

[rendering]

quality/filters/anisotropic_filter_level=8
quality/filters/msaa=3
environment/default_environment="res://default_env.tres"
8 changes: 8 additions & 0 deletions 3D/greenscreen_camera/scenes/pawn.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[gd_scene load_steps=2 format=2]

[ext_resource path="res://visuals/models/pawn/pawn.glb" type="PackedScene" id=1]

[node name="pawn" instance=ExtResource( 1 )]

[node name="Pawn" parent="." index="0"]
layers = 2
61 changes: 61 additions & 0 deletions 3D/greenscreen_camera/scenes/player.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
extends KinematicBody

onready var camera = $Pivot/Camera

var gravity: float = -30
var max_speed: float = 8
var mouse_sensitivity: float = 0.0015 # radians/pixel

var velocity: Vector3 = Vector3()

# OBJECT
var collider = null
var previous_collider = null
var picked_up = null

var initial_distance: float = 0.0

func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)

func get_input():
var input_dir = Vector3()
# desired move in camera direction

if Input.is_action_pressed("move_forward"):
input_dir += -camera.global_transform.basis.z
if Input.is_action_pressed("move_back"):
input_dir += camera.global_transform.basis.z
if Input.is_action_pressed("strafe_left"):
input_dir += -camera.global_transform.basis.x
if Input.is_action_pressed("strafe_right"):
input_dir += camera.global_transform.basis.x
input_dir = input_dir.normalized()
return input_dir

func _unhandled_input(event):
if event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
rotate_y(-event.relative.x * mouse_sensitivity)
$Pivot.rotate_x(-event.relative.y * mouse_sensitivity)
$Pivot.rotation.x = clamp($Pivot.rotation.x, -1.2, 1.2)

func _process(delta):
if Input.is_action_just_pressed("ui_cancel"):
if Input.get_mouse_mode() == Input.MOUSE_MODE_VISIBLE:
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
else:
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)

func _physics_process(delta):
if picked_up:
var new_distance = picked_up.global_transform.origin.distance_to(global_transform.origin)
# print("New dist: ", new_distance)
# print("Scale diff: ", new_distance/initial_distance)

velocity.y += gravity * delta
var desired_velocity = get_input() * max_speed

velocity.x = desired_velocity.x
velocity.z = desired_velocity.z
velocity = move_and_slide(velocity, Vector3.UP, true)

36 changes: 36 additions & 0 deletions 3D/greenscreen_camera/scenes/player.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[gd_scene load_steps=5 format=2]

[ext_resource path="res://scenes/player.gd" type="Script" id=1]
[ext_resource path="res://scenes/pawn.tscn" type="PackedScene" id=2]

[sub_resource type="CapsuleShape" id=1]
radius = 0.5

[sub_resource type="BoxShape" id=2]
extents = Vector3( 0.4, 0.1, 0.4 )

[node name="Player" type="KinematicBody"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.055, 0 )
script = ExtResource( 1 )

[node name="Body" type="CollisionShape" parent="."]
transform = Transform( 1, 0, 0, 0, -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0, 0 )
shape = SubResource( 1 )

[node name="Feet" type="CollisionShape" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.956, 0 )
shape = SubResource( 2 )

[node name="Pivot" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.737966, 0 )

[node name="Camera" type="Camera" parent="Pivot"]
cull_mask = 1048573
current = true
fov = 80.0

[node name="CameraTarget" type="Position3D" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.0118878, 0 )

[node name="pawn" parent="." instance=ExtResource( 2 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.04221, 0 )
9 changes: 9 additions & 0 deletions 3D/greenscreen_camera/scenes/world.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
extends Spatial

# Called when the node enters the scene tree for the first time.
func _ready():
pass

func _process(delta):
$Viewport/Camera.look_at($Player.get_node("CameraTarget").global_transform.origin, Vector3.UP)
$Viewport2/Camera.look_at($Player.get_node("CameraTarget").global_transform.origin, Vector3.UP)
153 changes: 153 additions & 0 deletions 3D/greenscreen_camera/scenes/world.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
[gd_scene load_steps=17 format=2]

[ext_resource path="res://visuals/textures/texture_08.png" type="Texture" id=1]
[ext_resource path="res://scenes/player.tscn" type="PackedScene" id=2]
[ext_resource path="res://visuals/textures/texture_11.png" type="Texture" id=3]
[ext_resource path="res://scenes/world.gd" type="Script" id=4]

[sub_resource type="SpatialMaterial" id=4]
albedo_color = Color( 0.701961, 0.701961, 0.701961, 1 )
albedo_texture = ExtResource( 1 )
uv1_triplanar = true

[sub_resource type="SpatialMaterial" id=9]
albedo_color = Color( 0.0196078, 0.0196078, 0.0196078, 1 )

[sub_resource type="ViewportTexture" id=11]
viewport_path = NodePath("Viewport")

[sub_resource type="SpatialMaterial" id=12]
resource_local_to_scene = true
albedo_texture = SubResource( 11 )

[sub_resource type="PlaneMesh" id=13]
resource_local_to_scene = true
material = SubResource( 12 )
size = Vector2( 8, 4 )

[sub_resource type="ViewportTexture" id=10]
viewport_path = NodePath("Viewport2")

[sub_resource type="SpatialMaterial" id=8]
resource_local_to_scene = true
flags_unshaded = true
albedo_texture = SubResource( 10 )

[sub_resource type="PlaneMesh" id=1]
resource_local_to_scene = true
material = SubResource( 8 )
size = Vector2( 8, 4 )

[sub_resource type="ProceduralSky" id=5]

[sub_resource type="Environment" id=6]
background_mode = 2
background_sky = SubResource( 5 )
ambient_light_color = Color( 1, 1, 1, 1 )
ambient_light_sky_contribution = 0.0
tonemap_mode = 1
adjustment_enabled = true

[sub_resource type="SpatialMaterial" id=15]
albedo_color = Color( 1, 0.917647, 0.0509804, 1 )
albedo_texture = ExtResource( 3 )
uv1_triplanar = true

[sub_resource type="CubeMesh" id=14]
material = SubResource( 15 )

[node name="World" type="Spatial"]
script = ExtResource( 4 )

[node name="Player" parent="." instance=ExtResource( 2 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.81354, 0 )

[node name="CSGBox" type="CSGBox" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5, 0 )
use_collision = true
invert_faces = true
width = 25.0
height = 10.0
depth = 25.0
material = SubResource( 4 )

[node name="Viewport" type="Viewport" parent="."]
size = Vector2( 1920, 1080 )
transparent_bg = true
render_target_v_flip = true
render_target_update_mode = 3

[node name="Camera" type="Camera" parent="Viewport"]
transform = Transform( 0.00675424, 0, -0.999977, 0, 1, 0, 0.999977, 0, 0.00675424, 1.96952, 6.83915, -11.3751 )
cull_mask = 2
current = true
fov = 40.0

[node name="Camera2" type="CSGBox" parent="Viewport/Camera"]
transform = Transform( -1.62921e-07, 0, 1, 0, 1, 0, -1, 0, -1.62921e-07, -0.000247955, -0.00028944, -0.000444412 )
material_override = SubResource( 9 )
width = 1.0
height = 0.4
depth = 0.4

[node name="Lens" type="CSGCylinder" parent="Viewport/Camera/Camera2"]
transform = Transform( -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0, 0, 1, 0.570034, 0, 0 )
radius = 0.15
height = 0.2
sides = 16

[node name="Screen" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, -0.171413, -0.985199, 0, 0.985199, -0.171413, -4.33926, 4.02376, -11.6551 )
mesh = SubResource( 13 )
material/0 = null

[node name="Viewport2" type="Viewport" parent="."]
size = Vector2( 1920, 1080 )
transparent_bg = true
render_target_v_flip = true
render_target_update_mode = 3

[node name="Camera" type="Camera" parent="Viewport2"]
transform = Transform( 0.00675424, 0, -0.999977, 0, 1, 0, 0.999977, 0, 0.00675424, -1.94913, 6.83915, -11.3487 )
current = true
fov = 40.0

[node name="Camera2" type="CSGBox" parent="Viewport2/Camera"]
transform = Transform( -1.62921e-07, 0, 1, 0, 1, 0, -1, 0, -1.62921e-07, -0.000247955, -0.00028944, -0.000444412 )
material_override = SubResource( 9 )
width = 1.0
height = 0.4
depth = 0.4

[node name="Lens" type="CSGCylinder" parent="Viewport2/Camera/Camera2"]
transform = Transform( -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0, 0, 1, 0.570034, 0, 0 )
radius = 0.15
height = 0.2
sides = 16

[node name="Screen2" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, -0.171413, -0.985199, 0, 0.985199, -0.171413, 4.15281, 4.02376, -11.6551 )
mesh = SubResource( 1 )
material/0 = null

[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource( 6 )

[node name="DirectionalLight" type="DirectionalLight" parent="WorldEnvironment"]
transform = Transform( 0.896965, 0.253231, -0.362391, 0, 0.819702, 0.57279, 0.442101, -0.513773, 0.735245, 0, 8.55322, 0 )
shadow_enabled = true

[node name="CSGMesh" type="CSGMesh" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 4.2244 )
use_collision = true
mesh = SubResource( 14 )

[node name="CSGMesh2" type="CSGMesh" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 4.81883, 1, 4.2244 )
use_collision = true
mesh = SubResource( 14 )

[node name="CSGMesh3" type="CSGMesh" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -4.55169, 1, 4.2244 )
use_collision = true
mesh = SubResource( 14 )
1 change: 1 addition & 0 deletions 3D/greenscreen_camera/visuals/models/pawn/licence.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"Pawn [Chess]" (https://skfb.ly/6WTXH) by cengizkurtoglu1 is licensed under Creative Commons Attribution (http://creativecommons.org/licenses/by/4.0/).
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 50fcf2a

Please sign in to comment.