Commit ef701ad3 authored by Houkime's avatar Houkime

initial commit

parents
*.import
*~
[submodule "godot_headers"]
path = godot_headers
url = https://github.com/GodotNativeTools/godot_headers
CC := gcc
CCFLAGS := -std=c11 -fPIC -Isrc -I./godot_headers/
LDFLAGS := -rdynamic -shared -pthread -lmodbus
OBJ := src/simple.o
TARGETS := simple/bin/libsimple.so
LIBS :=
.PHONY: all
all: $(TARGETS)
$(OBJ): %.o : %.c
$(CC) -c -o $@ $< $(CCFLAGS)
$(TARGETS): % : $(OBJ)
$(CC) -o $@ $(LIBS) $^ $(CCFLAGS) $(LDFLAGS)
Subproject commit 98ee82599dfe07e17983ad831f5e9ac41068667f
*.import
bin/*.so
\ No newline at end of file
extends Spatial
export var speed = 1.0
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
var mat = $belt/graphics.get_surface_material(0)
mat.set_shader_param("speed",speed)
$StaticBody.constant_linear_velocity.x = speed
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
[gd_scene load_steps=13 format=2]
[ext_resource path="res://outline.tres" type="Material" id=1]
[ext_resource path="res://belt.shader" type="Shader" id=2]
[ext_resource path="res://Conveyor.gd" type="Script" id=3]
[ext_resource path="res://test_bevel.obj" type="ArrayMesh" id=4]
[sub_resource type="CubeMesh" id=1]
[sub_resource type="SpatialMaterial" id=2]
flags_unshaded = true
albedo_color = Color( 0.564706, 0.564706, 0.564706, 1 )
[sub_resource type="ArrayMesh" id=3]
surfaces/0 = {
"aabb": AABB( -1.02887, -1.02887, -1.02887, 2.05773, 2.05774, 2.05774 ),
"array_data": PoolByteArray( 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 63, 0, 0, 127, 0, 127, 0, 0, 127, 0, 0, 0, 0, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 191, 0, 0, 129, 0, 129, 0, 0, 127, 85, 57, 0, 0, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 63, 0, 0, 127, 0, 127, 0, 0, 127, 85, 53, 0, 0, 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 191, 0, 0, 129, 0, 129, 0, 0, 127, 0, 60, 0, 0, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 63, 0, 0, 127, 0, 127, 0, 0, 127, 0, 0, 0, 56, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 191, 0, 0, 129, 0, 129, 0, 0, 127, 85, 57, 0, 56, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 63, 0, 0, 127, 0, 127, 0, 0, 127, 85, 53, 0, 56, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 191, 0, 0, 129, 0, 129, 0, 0, 127, 0, 60, 0, 56, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 63, 127, 0, 0, 0, 0, 0, 129, 127, 85, 53, 0, 0, 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 191, 129, 0, 0, 0, 0, 0, 127, 127, 0, 0, 0, 56, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 191, 127, 0, 0, 0, 0, 0, 129, 127, 85, 57, 0, 0, 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 63, 129, 0, 0, 0, 0, 0, 127, 127, 85, 53, 0, 56, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 63, 127, 0, 0, 0, 0, 0, 129, 127, 85, 53, 0, 56, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 191, 129, 0, 0, 0, 0, 0, 127, 127, 0, 0, 0, 60, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 191, 127, 0, 0, 0, 0, 0, 129, 127, 85, 57, 0, 56, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 63, 129, 0, 0, 0, 0, 0, 127, 127, 85, 53, 0, 60, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 63, 0, 127, 0, 0, 129, 0, 0, 127, 85, 53, 0, 56, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 63, 0, 129, 0, 0, 127, 0, 0, 127, 85, 57, 0, 56, 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 63, 0, 127, 0, 0, 129, 0, 0, 127, 85, 57, 0, 56, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 63, 0, 129, 0, 0, 127, 0, 0, 127, 0, 60, 0, 56, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 191, 0, 127, 0, 0, 129, 0, 0, 127, 85, 53, 0, 60, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 191, 0, 129, 0, 0, 127, 0, 0, 127, 85, 57, 0, 60, 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 191, 0, 127, 0, 0, 129, 0, 0, 127, 85, 57, 0, 60, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 191, 0, 129, 0, 0, 127, 0, 0, 127, 0, 60, 0, 60 ),
"array_index_data": PoolByteArray( 0, 0, 4, 0, 2, 0, 2, 0, 4, 0, 6, 0, 1, 0, 5, 0, 3, 0, 3, 0, 5, 0, 7, 0, 8, 0, 12, 0, 10, 0, 10, 0, 12, 0, 14, 0, 9, 0, 13, 0, 11, 0, 11, 0, 13, 0, 15, 0, 16, 0, 20, 0, 18, 0, 18, 0, 20, 0, 22, 0, 17, 0, 21, 0, 19, 0, 19, 0, 21, 0, 23, 0 ),
"blend_shape_data": [ ],
"format": 97559,
"index_count": 36,
"primitive": 4,
"skeleton_aabb": [ ],
"vertex_count": 24
}
[sub_resource type="CubeMesh" id=4]
[sub_resource type="ArrayMesh" id=5]
surfaces/0 = {
"aabb": AABB( -1.02887, -1.02887, -1.02887, 2.05773, 2.05774, 2.05774 ),
"array_data": PoolByteArray( 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 63, 0, 0, 127, 0, 127, 0, 0, 127, 0, 0, 0, 0, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 191, 0, 0, 129, 0, 129, 0, 0, 127, 85, 57, 0, 0, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 63, 0, 0, 127, 0, 127, 0, 0, 127, 85, 53, 0, 0, 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 191, 0, 0, 129, 0, 129, 0, 0, 127, 0, 60, 0, 0, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 63, 0, 0, 127, 0, 127, 0, 0, 127, 0, 0, 0, 56, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 191, 0, 0, 129, 0, 129, 0, 0, 127, 85, 57, 0, 56, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 63, 0, 0, 127, 0, 127, 0, 0, 127, 85, 53, 0, 56, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 191, 0, 0, 129, 0, 129, 0, 0, 127, 0, 60, 0, 56, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 63, 127, 0, 0, 0, 0, 0, 129, 127, 85, 53, 0, 0, 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 191, 129, 0, 0, 0, 0, 0, 127, 127, 0, 0, 0, 56, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 191, 127, 0, 0, 0, 0, 0, 129, 127, 85, 57, 0, 0, 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 63, 129, 0, 0, 0, 0, 0, 127, 127, 85, 53, 0, 56, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 63, 127, 0, 0, 0, 0, 0, 129, 127, 85, 53, 0, 56, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 191, 129, 0, 0, 0, 0, 0, 127, 127, 0, 0, 0, 60, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 191, 127, 0, 0, 0, 0, 0, 129, 127, 85, 57, 0, 56, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 63, 129, 0, 0, 0, 0, 0, 127, 127, 85, 53, 0, 60, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 63, 0, 127, 0, 0, 129, 0, 0, 127, 85, 53, 0, 56, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 63, 0, 129, 0, 0, 127, 0, 0, 127, 85, 57, 0, 56, 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 63, 0, 127, 0, 0, 129, 0, 0, 127, 85, 57, 0, 56, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 63, 0, 129, 0, 0, 127, 0, 0, 127, 0, 60, 0, 56, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 191, 0, 127, 0, 0, 129, 0, 0, 127, 85, 53, 0, 60, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 191, 0, 129, 0, 0, 127, 0, 0, 127, 85, 57, 0, 60, 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 191, 0, 127, 0, 0, 129, 0, 0, 127, 85, 57, 0, 60, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 191, 0, 129, 0, 0, 127, 0, 0, 127, 0, 60, 0, 60 ),
"array_index_data": PoolByteArray( 0, 0, 4, 0, 2, 0, 2, 0, 4, 0, 6, 0, 1, 0, 5, 0, 3, 0, 3, 0, 5, 0, 7, 0, 8, 0, 12, 0, 10, 0, 10, 0, 12, 0, 14, 0, 9, 0, 13, 0, 11, 0, 11, 0, 13, 0, 15, 0, 16, 0, 20, 0, 18, 0, 18, 0, 20, 0, 22, 0, 17, 0, 21, 0, 19, 0, 19, 0, 21, 0, 23, 0 ),
"blend_shape_data": [ ],
"format": 97559,
"index_count": 36,
"primitive": 4,
"skeleton_aabb": [ ],
"vertex_count": 24
}
[sub_resource type="PlaneMesh" id=6]
[sub_resource type="ShaderMaterial" id=7]
shader = ExtResource( 2 )
shader_param/bg_color = null
shader_param/fg_color = Color( 0.976471, 0.917647, 0.0196078, 1 )
shader_param/scale = null
shader_param/speed = 0.1
[sub_resource type="ConvexPolygonShape" id=8]
points = PoolVector3Array( -0.986604, -0.9557, -0.832278, -0.986604, -0.9557, 0.832278, -0.986604, -0.832278, -0.9557, -0.986604, -0.832278, 0.9557, -0.986604, 0.832278, -0.9557, -0.986604, 0.832278, 0.9557, -0.986604, 0.9557, -0.832278, -0.986604, 0.9557, 0.832278, -0.985938, -0.924172, -0.893482, -0.9557, -0.986604, -0.832278, -0.9557, -0.986604, 0.832278, -0.9557, -0.832278, -0.986604, -0.9557, -0.832278, 0.986604, -0.9557, 0.832278, -0.986604, -0.9557, 0.832278, 0.986604, -0.9557, 0.986604, -0.832278, -0.9557, 0.986604, 0.832278, -0.9537, -0.9537, -0.9537, -0.9537, -0.9537, 0.9537, -0.9537, 0.9537, -0.9537, -0.9537, 0.9537, 0.9537, -0.832278, -0.986604, -0.9557, -0.832278, -0.986604, 0.9557, -0.832278, -0.9557, -0.986604, -0.832278, -0.9557, 0.986604, -0.832278, 0.9557, -0.986604, -0.832278, 0.9557, 0.986604, -0.832278, 0.986604, -0.9557, -0.832278, 0.986604, 0.9557, 0.832278, -0.986604, -0.9557, 0.832278, -0.986604, 0.9557, 0.832278, -0.9557, -0.986604, 0.832278, -0.9557, 0.986604, 0.832278, 0.9557, -0.986604, 0.832278, 0.9557, 0.986604, 0.832278, 0.986604, -0.9557, 0.832278, 0.986604, 0.9557, 0.893315, 0.924199, 0.985967, 0.9537, -0.9537, -0.9537, 0.9537, -0.9537, 0.9537, 0.9537, 0.9537, -0.9537, 0.9537, 0.9537, 0.9537, 0.9557, -0.986604, -0.832278, 0.9557, -0.986604, 0.832278, 0.9557, -0.832278, -0.986604, 0.9557, -0.832278, 0.986604, 0.9557, 0.832278, -0.986604, 0.9557, 0.832278, 0.986604, 0.9557, 0.986604, -0.832278, 0.9557, 0.986604, 0.832278, 0.986604, -0.9557, -0.832278, 0.986604, -0.9557, 0.832278, 0.986604, -0.832278, -0.9557, 0.986604, -0.832278, 0.9557, 0.986604, 0.832278, -0.9557, 0.986604, 0.832278, 0.9557, 0.986604, 0.9557, -0.832278, 0.986604, 0.9557, 0.832278 )
[node name="Conveyor" type="Spatial"]
transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0 )
script = ExtResource( 3 )
[node name="base" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 0.8, 0, 0, 0, 1, 0, -0.2, 0 )
mesh = SubResource( 1 )
material/0 = SubResource( 2 )
[node name="MeshInstance" type="MeshInstance" parent="base"]
material_override = ExtResource( 1 )
mesh = SubResource( 3 )
material/0 = null
[node name="belt" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 0.2, 0, 0, 0, 1, 0, 0.8, 0 )
mesh = SubResource( 4 )
material/0 = null
[node name="MeshInstance" type="MeshInstance" parent="belt"]
mesh = SubResource( 5 )
material/0 = ExtResource( 1 )
[node name="graphics" type="MeshInstance" parent="belt"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.02021, 0 )
mesh = SubResource( 6 )
material/0 = SubResource( 7 )
[node name="StaticBody" type="StaticBody" parent="."]
constant_linear_velocity = Vector3( 0.1, 0, 0 )
[node name="test_bevel" type="MeshInstance" parent="StaticBody"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 6, 0 )
visible = false
mesh = ExtResource( 4 )
material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="StaticBody"]
transform = Transform( 1.2, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
shape = SubResource( 8 )
extends KinematicBody
var phase = 0.0
var freq = 1.0
var rot_freq = 2.0
var amplitude = 1.0
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
func _process(delta):
phase = wrapf(phase + freq*delta,0,2*PI)
translation = Vector3(0,amplitude*sin(phase),0)
rotate_x(freq*delta)
rotate_y(freq*delta)
rotate_z(freq*delta/2.0)
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
extends Node
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
extends Node
class_name ModbusServer
var c_backend = load('res://simple.gdns').new()
var hold_register = 17 setget set_holding_register, get_holding_register #single for now
#var coils = [0,0,0,0]
func _init(address, port):
c_backend.start_server(address, port)
func set_holding_register(value):
c_backend.set_holding_register(value)
func get_holding_register():
return c_backend.get_holding_register()
func get_coil():
return c_backend.get_coil()
extends Spatial
class_name ModbusSpatial
export var address = "192.168.56.1"
export var port = 5020
var ms
func _ready():
print("creating sth with " + address + " " + str(port))
ms = ModbusServer.new(address, port)
[gd_scene load_steps=14 format=2]
[ext_resource path="res://SimplePusher.gd" type="Script" id=1]
[ext_resource path="res://Spawner.gd" type="Script" id=2]
[ext_resource path="res://pushermat.tres" type="Material" id=3]
[ext_resource path="res://Sensor.tscn" type="PackedScene" id=4]
[ext_resource path="res://Conveyor.tscn" type="PackedScene" id=5]
[ext_resource path="res://blockshader_ghost.shader" type="Shader" id=6]
[sub_resource type="CubeMesh" id=1]
[sub_resource type="ShaderMaterial" id=2]
shader = ExtResource( 6 )
shader_param/color = Color( 0.227451, 0.521569, 0.521569, 1 )
shader_param/scale = 113.0
[sub_resource type="CubeMesh" id=3]
[sub_resource type="CubeMesh" id=4]
[sub_resource type="SpatialMaterial" id=5]
flags_unshaded = true
albedo_color = Color( 0.207843, 0.207843, 0.207843, 1 )
[sub_resource type="ConvexPolygonShape" id=6]
points = PoolVector3Array( -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1 )
[sub_resource type="CylinderMesh" id=7]
[node name="Pushertest" type="Spatial"]
[node name="Spawner" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0 )
script = ExtResource( 2 )
[node name="MeshInstance" type="MeshInstance" parent="Spawner"]
transform = Transform( 0.48, 0, 0, 0, 0.48, 0, 0, 0, 0.48, 0, 0, 0 )
mesh = SubResource( 1 )
material/0 = SubResource( 2 )
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 2.01221, 6.90506 )
far = 8192.0
[node name="Pusher" type="Spatial" parent="."]
transform = Transform( -8.14603e-08, 0, -0.5, 0, 0.5, 0, 0.5, 0, -8.14603e-08, 5, 1, -1 )
script = ExtResource( 1 )
port = 5040
[node name="MeshInstance" type="MeshInstance" parent="Pusher"]
transform = Transform( 0.8, 0, 0, 0, 1, 0, 0, 0, 1, -0.2, 0, 0 )
mesh = SubResource( 3 )
material/0 = ExtResource( 3 )
[node name="PusherHandle" type="Spatial" parent="Pusher"]
[node name="MeshInstance2" type="MeshInstance" parent="Pusher/PusherHandle"]
transform = Transform( 0.2, 0, 0, 0, 1, 0, 0, 0, 1, 0.8, 0, 0 )
mesh = SubResource( 4 )
material/0 = SubResource( 5 )
[node name="KinematicBody" type="KinematicBody" parent="Pusher/PusherHandle"]
[node name="CollisionShape" type="CollisionShape" parent="Pusher/PusherHandle/KinematicBody"]
transform = Transform( 0.2, 0, 0, 0, 1, 0, 0, 0, 1, 0.8, 0, 0 )
shape = SubResource( 6 )
[node name="shaft_handle" type="Spatial" parent="Pusher"]
transform = Transform( -1.31134e-08, -0.1, 0, 0.3, -4.37114e-09, 0, 0, 0, 0.3, 0.6, 0, 0 )
[node name="MeshInstance2" type="MeshInstance" parent="Pusher/shaft_handle"]
transform = Transform( 1, 7.10543e-15, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0 )
mesh = SubResource( 7 )
material/0 = null
[node name="Conveyor" parent="." instance=ExtResource( 5 )]
[node name="Conveyor2" parent="." instance=ExtResource( 5 )]
transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 1, 0, 0 )
[node name="Conveyor3" parent="." instance=ExtResource( 5 )]
transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 2, 0, 0 )
[node name="Conveyor4" parent="." instance=ExtResource( 5 )]
transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 3, 0, 0 )
[node name="Conveyor5" parent="." instance=ExtResource( 5 )]
transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 4, 0, 0 )
[node name="Conveyor6" parent="." instance=ExtResource( 5 )]
transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 5, 0, 0 )
[node name="Conveyor7" parent="." instance=ExtResource( 5 )]
transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 6, 0, 0 )
[node name="Sensor" parent="." instance=ExtResource( 4 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 5, 4, 0 )
extends ModbusSpatial
func _physics_process(delta):
ms.hold_register = floor($RayCast.distance*100.0)
This source diff could not be displayed because it is too large. You can view the blob instead.
[gd_scene load_steps=10 format=2]
[ext_resource path="res://Kinematic_Cube.gd" type="Script" id=1]
[ext_resource path="res://distance_readout.gd" type="Script" id=2]
[ext_resource path="res://Sensor.gd" type="Script" id=3]
[ext_resource path="res://Sensor.tscn" type="PackedScene" id=4]
[sub_resource type="CubeMesh" id=2]
[sub_resource type="SpatialMaterial" id=3]
flags_unshaded = true
albedo_color = Color( 0.87451, 1, 0, 1 )
[sub_resource type="ArrayMesh" id=4]
surfaces/0 = {
"aabb": AABB( -1.02887, -1.02887, -1.02887, 2.05773, 2.05774, 2.05774 ),
"array_data": PoolByteArray( 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 63, 0, 0, 127, 0, 127, 0, 0, 127, 0, 0, 0, 0, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 191, 0, 0, 129, 0, 129, 0, 0, 127, 85, 57, 0, 0, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 63, 0, 0, 127, 0, 127, 0, 0, 127, 85, 53, 0, 0, 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 191, 0, 0, 129, 0, 129, 0, 0, 127, 0, 60, 0, 0, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 63, 0, 0, 127, 0, 127, 0, 0, 127, 0, 0, 0, 56, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 191, 0, 0, 129, 0, 129, 0, 0, 127, 85, 57, 0, 56, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 63, 0, 0, 127, 0, 127, 0, 0, 127, 85, 53, 0, 56, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 191, 0, 0, 129, 0, 129, 0, 0, 127, 0, 60, 0, 56, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 63, 127, 0, 0, 0, 0, 0, 129, 127, 85, 53, 0, 0, 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 191, 129, 0, 0, 0, 0, 0, 127, 127, 0, 0, 0, 56, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 191, 127, 0, 0, 0, 0, 0, 129, 127, 85, 57, 0, 0, 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 63, 129, 0, 0, 0, 0, 0, 127, 127, 85, 53, 0, 56, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 63, 127, 0, 0, 0, 0, 0, 129, 127, 85, 53, 0, 56, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 191, 129, 0, 0, 0, 0, 0, 127, 127, 0, 0, 0, 60, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 191, 127, 0, 0, 0, 0, 0, 129, 127, 85, 57, 0, 56, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 63, 129, 0, 0, 0, 0, 0, 127, 127, 85, 53, 0, 60, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 63, 0, 127, 0, 0, 129, 0, 0, 127, 85, 53, 0, 56, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 63, 0, 129, 0, 0, 127, 0, 0, 127, 85, 57, 0, 56, 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 63, 0, 127, 0, 0, 129, 0, 0, 127, 85, 57, 0, 56, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 63, 0, 129, 0, 0, 127, 0, 0, 127, 0, 60, 0, 56, 238, 177, 131, 63, 238, 177, 131, 63, 238, 177, 131, 191, 0, 127, 0, 0, 129, 0, 0, 127, 85, 53, 0, 60, 238, 177, 131, 191, 238, 177, 131, 191, 238, 177, 131, 191, 0, 129, 0, 0, 127, 0, 0, 127, 85, 57, 0, 60, 238, 177, 131, 191, 238, 177, 131, 63, 238, 177, 131, 191, 0, 127, 0, 0, 129, 0, 0, 127, 85, 57, 0, 60, 238, 177, 131, 63, 238, 177, 131, 191, 238, 177, 131, 191, 0, 129, 0, 0, 127, 0, 0, 127, 0, 60, 0, 60 ),
"array_index_data": PoolByteArray( 0, 0, 4, 0, 2, 0, 2, 0, 4, 0, 6, 0, 1, 0, 5, 0, 3, 0, 3, 0, 5, 0, 7, 0, 8, 0, 12, 0, 10, 0, 10, 0, 12, 0, 14, 0, 9, 0, 13, 0, 11, 0, 11, 0, 13, 0, 15, 0, 16, 0, 20, 0, 18, 0, 18, 0, 20, 0, 22, 0, 17, 0, 21, 0, 19, 0, 19, 0, 21, 0, 23, 0 ),
"blend_shape_data": [ ],
"format": 97559,
"index_count": 36,
"primitive": 4,
"skeleton_aabb": [ ],
"vertex_count": 24
}
[sub_resource type="SpatialMaterial" id=5]
flags_unshaded = true
[sub_resource type="BoxShape" id=6]
[node name="SensorTest" type="Spatial"]
[node name="Sensor" type="Spatial" parent="." instance=ExtResource( 4 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0 )
script = ExtResource( 3 )
[node name="test_equilibrium" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0 )
[node name="Kinematic_Cube" type="KinematicBody" parent="test_equilibrium"]
transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, -4.76837e-07, -4.76837e-07 )
script = ExtResource( 1 )
[node name="test_cube" type="MeshInstance" parent="test_equilibrium/Kinematic_Cube"]
mesh = SubResource( 2 )
material/0 = SubResource( 3 )
[node name="MeshInstance" type="MeshInstance" parent="test_equilibrium/Kinematic_Cube/test_cube"]
mesh = SubResource( 4 )
material/0 = SubResource( 5 )
[node name="CollisionShape" type="CollisionShape" parent="test_equilibrium/Kinematic_Cube"]
shape = SubResource( 6 )
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 0.88643, 0.462863, 0, -0.462863, 0.88643, 0, 4.71983, 6.1721 )
far = 8192.0
[node name="Label" type="Label" parent="."]
margin_right = 40.0
margin_bottom = 14.0
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
extends ModbusSpatial
var speed = 1;
var max_extension = 1.0;
var extension = 0;
var min_shaft_len = 0.1; # godot does not like zero-lenth things
func _physics_process(delta):
var needs_to_extend = ms.get_coil()
#var needs_to_extend = false
#var just_to_read = ms.get_coil()
#print(needs_to_extend)
if needs_to_extend and extension < max_extension:
extension = clamp($PusherHandle.translation.x/2.0 + speed * delta, 0, max_extension)
$PusherHandle.translation.x = extension * 2
$shaft_handle.scale.y = max(extension, min_shaft_len)
if !needs_to_extend and extension > 0:
extension = clamp($PusherHandle.translation.x/2.0 - speed * delta, 0, max_extension)
$PusherHandle.translation.x = extension * 2
$shaft_handle.scale.y = max(extension, min_shaft_len)
extends Spatial
[gd_scene load_steps=7 format=2]
[ext_resource path="res://Spatial.gd" type="Script" id=1]
[ext_resource path="res://skyshader.tres" type="Material" id=2]
[ext_resource path="res://Pushertest.tscn" type="PackedScene" id=3]
[ext_resource path="res://firewall.gd" type="Script" id=7]
[sub_resource type="BoxShape" id=1]
extents = Vector3( 13.3624, 1, 18.5475 )
[sub_resource type="SphereMesh" id=2]
flip_faces = true
[node name="MAIN" type="Spatial"]
script = ExtResource( 1 )
[node name="Pushertest" parent="." instance=ExtResource( 3 )]
[node name="Area" type="Area" parent="."]
script = ExtResource( 7 )
__meta__ = {
"_edit_lock_": true
}
[node name="CollisionShape" type="CollisionShape" parent="Area"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -6.34348, 0 )
shape = SubResource( 1 )
[node name="Sky" type="MeshInstance" parent="."]
transform = Transform( 100, 0, 0, 0, 100, 0, 0, 0, 100, 0, 0, 0 )
mesh = SubResource( 2 )
material/0 = ExtResource( 2 )
__meta__ = {
"_edit_lock_": true
}
extends Spatial
export var frequency = 0.3
onready var timer = Timer.new()
var boxscene = preload("res://TestBox.tscn")
func _ready():
timer.wait_time = 1.0/float(frequency)
timer.connect("timeout",self,"spawn")
add_child(timer)
timer.start()
spawn()
func spawn():
var box = boxscene.instance()
add_child(box)
[gd_scene load_steps=4 format=2]
[ext_resource path="res://basic_cube.tscn" type="PackedScene" id=1]
[sub_resource type="PhysicsMaterial" id=1]
rough = true
[sub_resource type="BoxShape" id=2]
[node name="TestCube" type="RigidBody"]
physics_material_override = SubResource( 1 )
can_sleep = false
[node name="CollisionShape" type="CollisionShape" parent="."]
transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0 )
shape = SubResource( 2 )
[node name="test_cube" parent="." instance=ExtResource( 1 )]
transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0 )
[gd_scene load_steps=4 format=2]
[ext_resource path="res://blockshader.shader" type="Shader" id=1]
[sub_resource type="CubeMesh" id=1]
[sub_resource type="ShaderMaterial" id=2]
shader = ExtResource( 1 )
shader_param/color = Color( 0.686275, 0.65098, 0.0784314, 1 )
shader_param/scale = 113.0
[node name="test_cube" type="MeshInstance"]
mesh = SubResource( 1 )
material/0 = SubResource( 2 )
shader_type spatial;
render_mode unshaded;
uniform vec4 bg_color: hint_color;
uniform vec4 fg_color: hint_color;
uniform float scale;
uniform float speed;
bool triangle(float x,float y){
// if (x < 0.3) {
// return false;
// }
if (abs(y-0.5)+x-0.5 > 0.5) {
return false;
}
if (abs(y-0.5)+x-0.5 < 0.3) {
return false;
}
return true;
}
void fragment(){
float x = UV.x;
float y = UV.y;
float unity = 1.0;
x -= TIME*speed;
x = x - floor(x);
if (triangle(x,y)){
ALBEDO = fg_color.xyz;
} else{
ALBEDO = bg_color.xyz;
}
}
shader_type spatial;
render_mode unshaded;
uniform vec4 color: hint_color;
uniform float scale;
void fragment()
{
ALBEDO=color.xyz;
if (cos(UV.x*scale/6.)>=0.9||cos(UV.y*scale/9.)>=0.9){
ALBEDO=vec3(1,1,1);
}
}
\ No newline at end of file
shader_type spatial;
render_mode unshaded;
render_mode blend_add;
uniform vec4 color: hint_color;
uniform float scale;
void fragment()
{
float screen_y = mod(SCREEN_UV.y + TIME/30.0, 1.0);
if (mod(screen_y, 1.0/100.0) <= 0.005){
discard;
}
ALBEDO=color.xyz;
if (cos(UV.x*scale/6.)>=0.9||cos(UV.y*scale/9.)>=0.9){
ALBEDO=vec3(1,1,1);
}
}
\ No newline at end of file
extends Label
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
func _process(delta):
text = "Distance: " + str($"../Sensor/RayCast".distance)
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
extends Area
func _ready():
connect("body_entered",self,"destroy_intruders")
func destroy_intruders(body):
body.queue_free()
[entry]
X11.64="res://bin/libsimple.so"
[dependencies]
X11.64=[ ]
[general]
singleton=false
load_once=false
symbol_prefix="godot_"
reloadable=true
[gd_resource type="Environment" load_steps=2 format=2]
[sub_resource type="ProceduralSky" id=1]
[resource]
background_sky = SubResource( 1 )
[gd_resource type="SpatialMaterial" format=2]
[resource]
flags_unshaded = true
; 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=[ {
"base": "Node",
"class": "ModbusServer",
"language": "GDScript",
"path": "res://Modbus_Server.gd"
}, {
"base": "Reference",
"class": "ModbusServerNative",
"language": "NativeScript",
"path": "res://simple.gdns"
}, {
"base": "Spatial",
"class": "ModbusSpatial",
"language": "GDScript",
"path": "res://Modbus_Spatial.gd"
} ]
_global_script_class_icons={
"ModbusServer": "",
"ModbusServerNative": "",
"ModbusSpatial": ""
}
[application]
run/main_scene="res://Spatial.tscn"
[physics]
3d/physics_engine="GodotPhysics"
[rendering]
environment/default_environment="res://new_environment.tres"
[gd_resource type="SpatialMaterial" format=2]
[resource]
flags_unshaded = true
albedo_color = Color( 0.988235, 0.694118, 0.0745098, 1 )
extends RayCast
export var maxlength = 10.0
var distance = 0
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
cast_to = Vector3(0,-maxlength,0)
func _physics_process(delta):
if !is_colliding():
$intersection.visible = false
$ray_handle.scale = Vector3(0,distance,0)
return
var collision_p = to_local(get_collision_point())
distance = collision_p.length()
$ray_handle.scale = Vector3(1,distance,1)
$intersection.visible = true
$intersection.translation = collision_p
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
[gd_resource type="NativeScript" load_steps=2 format=2]
[ext_resource path="res://libsimple.gdnlib" type="GDNativeLibrary" id=1]
[resource]
class_name = "ModbusServerNative"
library = ExtResource( 1 )
script_class_name = "ModbusServerNative"
[gd_resource type="ShaderMaterial" load_steps=2 format=2]
[sub_resource type="Shader" id=1]
code = "shader_type spatial;
render_mode unshaded;
uniform float thickness;
uniform float step_theta;
uniform float step_phi;
void fragment(){
if (mod(UV.y,step_theta*abs(1.0+sin(TIME/10.0)/2.0)) < thickness) {
ALBEDO=vec3(255,0,255);
} else{
ALBEDO=vec3(0,0,0);
}
}"
[resource]
shader = SubResource( 1 )
shader_param/thickness = 0.01
shader_param/step_theta = 0.056
shader_param/step_phi = null
# Blender MTL File: 'None'
# Material Count: 1
newmtl Material
Ns 323.999994
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
# Blender v2.82 (sub 7) OBJ File: ''
# www.blender.org
mtllib test_bevel.mtl
o Cube
v 0.929289 0.829289 -1.000000
v 0.829289 0.929289 -1.000000
v 0.829289 1.000000 -0.929289
v 0.929289 1.000000 -0.829289
v 1.000000 0.929289 -0.829289
v 1.000000 0.829289 -0.929289
v 0.897102 0.897102 -1.000000
v 0.953650 0.953650 -0.953650
v 0.829289 0.977240 -0.977240
v 0.897102 1.000000 -0.897102
v 0.977240 0.977240 -0.829289
v 1.000000 0.897102 -0.897102
v 0.977240 0.829289 -0.977240
v 0.929289 -1.000000 -0.829289
v 0.829289 -1.000000 -0.929289
v 0.829289 -0.929289 -1.000000
v 0.929289 -0.829289 -1.000000
v 1.000000 -0.829289 -0.929289
v 1.000000 -0.929289 -0.829289
v 0.897102 -1.000000 -0.897102
v 0.953650 -0.953651 -0.953650
v 0.829289 -0.977240 -0.977240
v 0.897102 -0.897102 -1.000000
v 0.977240 -0.829289 -0.977240
v 1.000000 -0.897102 -0.897102
v 0.977240 -0.977240 -0.829289
v 1.000000 0.829289 0.929289
v 1.000000 0.929289 0.829289
v 0.929289 1.000000 0.829289
v 0.829289 1.000000 0.929289
v 0.829289 0.929289 1.000000
v 0.929289 0.829289 1.000000
v 1.000000 0.897102 0.897102
v 0.953650 0.953650 0.953650
v 0.977240 0.977240 0.829289
v 0.897102 1.000000 0.897102
v 0.829289 0.977240 0.977240
v 0.897102 0.897102 1.000000
v 0.977240 0.829289 0.977240
v 1.000000 -0.929289 0.829289
v 1.000000 -0.829289 0.929289
v 0.929289 -0.829289 1.000000
v 0.829289 -0.929289 1.000000
v 0.829289 -1.000000 0.929289
v 0.929289 -1.000000 0.829289
v 1.000000 -0.897102 0.897102
v 0.953651 -0.953650 0.953650
v 0.977240 -0.829289 0.977240
v 0.897102 -0.897102 1.000000
v 0.829289 -0.977240 0.977240
v 0.897102 -1.000000 0.897102
v 0.977240 -0.977240 0.829289
v -0.829289 0.929289 -1.000000
v -0.929289 0.829289 -1.000000
v -1.000000 0.829289 -0.929289
v -1.000000 0.929289 -0.829289
v -0.929289 1.000000 -0.829289
v -0.829289 1.000000 -0.929289
v -0.897102 0.897102 -1.000000
v -0.953650 0.953650 -0.953651
v -0.977240 0.829289 -0.977240
v -1.000000 0.897102 -0.897102
v -0.977240 0.977240 -0.829289
v -0.897102 1.000000 -0.897102
v -0.829289 0.977240 -0.977240
v -1.000000 -0.929289 -0.829289
v -1.000000 -0.829289 -0.929289
v -0.929289 -0.829289 -1.000000
v -0.829289 -0.929289 -1.000000
v -0.829289 -1.000000 -0.929289
v -0.929289 -1.000000 -0.829289
v -1.000000 -0.897102 -0.897102
v -0.953651 -0.953650 -0.953650
v -0.977240 -0.829289 -0.977240
v -0.897102 -0.897102 -1.000000
v -0.829289 -0.977240 -0.977240
v -0.897102 -1.000000 -0.897102
v -0.977240 -0.977240 -0.829289
v -1.000000 0.929289 0.829289
v -1.000000 0.829289 0.929289
v -0.929289 0.829289 1.000000
v -0.829289 0.929289 1.000000
v -0.829289 1.000000 0.929289
v -0.929289 1.000000 0.829289
v -1.000000 0.897102 0.897102
v -0.953651 0.953650 0.953650
v -0.977240 0.829289 0.977240
v -0.897102 0.897102 1.000000
v -0.829289 0.977240 0.977240
v -0.897102 1.000000 0.897102
v -0.977240 0.977240 0.829289
v -0.929289 -1.000000 0.829289
v -0.829289 -1.000000 0.929289
v -0.829289 -0.929289 1.000000
v -0.929289 -0.829289 1.000000
v -1.000000 -0.829289 0.929289
v -1.000000 -0.929289 0.829289
v -0.897102 -1.000000 0.897102
v -0.953650 -0.953650 0.953650
v -0.829289 -0.977240 0.977240
v -0.897102 -0.897102 1.000000
v -0.977240 -0.829289 0.977240
v -1.000000 -0.897102 0.897102
v -0.977240 -0.977240 0.829289
vt 0.133839 0.521339
vt 0.137862 0.512862
vt 0.146339 0.508839
vt 0.353661 0.508839
vt 0.362138 0.512862
vt 0.366161 0.521339
vt 0.366161 0.728661
vt 0.362138 0.737138
vt 0.353661 0.741161
vt 0.146339 0.741161
vt 0.137862 0.737138
vt 0.133839 0.728661
vt 0.383839 0.021339
vt 0.387862 0.012862
vt 0.396339 0.008839
vt 0.603661 0.008839
vt 0.612138 0.012862
vt 0.616161 0.021339
vt 0.616161 0.228661
vt 0.612138 0.237138
vt 0.603661 0.241161
vt 0.396339 0.241161
vt 0.387862 0.237138
vt 0.383839 0.228661
vt 0.383839 0.771339
vt 0.387862 0.762862
vt 0.396339 0.758839
vt 0.603661 0.758839
vt 0.612138 0.762862
vt 0.616161 0.771339
vt 0.616161 0.978661
vt 0.612138 0.987138
vt 0.603661 0.991161
vt 0.396339 0.991161
vt 0.387862 0.987138
vt 0.383839 0.978661
vt 0.633839 0.521339
vt 0.637862 0.512862
vt 0.646339 0.508839
vt 0.853661 0.508839
vt 0.862138 0.512862
vt 0.866161 0.521339
vt 0.866161 0.728661
vt 0.862138 0.737138
vt 0.853661 0.741161
vt 0.646339 0.741161
vt 0.637862 0.737138
vt 0.633839 0.728661
vt 0.383839 0.521339
vt 0.387862 0.512862
vt 0.396339 0.508839
vt 0.603661 0.508839
vt 0.612138 0.512862
vt 0.616161 0.521339
vt 0.616161 0.728661
vt 0.612138 0.737138
vt 0.603661 0.741161
vt 0.396339 0.741161
vt 0.387862 0.737138
vt 0.383839 0.728661
vt 0.603661 0.500000
vt 0.612138 0.500000
vt 0.623069 0.500000
vt 0.603661 0.500000
vt 0.616161 0.478661
vt 0.625000 0.478661
vt 0.612138 0.487138
vt 0.625000 0.478661
vt 0.625000 0.487138
vt 0.625000 0.521339
vt 0.625000 0.521339
vt 0.625000 0.512862
vt 0.375000 0.521339
vt 0.375000 0.512862
vt 0.375000 0.501931
vt 0.375000 0.521339
vt 0.353661 0.500000
vt 0.353661 0.500000
vt 0.362138 0.500000
vt 0.396339 0.491161
vt 0.396339 0.500000
vt 0.387862 0.487138
vt 0.396339 0.500000
vt 0.387862 0.500000
vt 0.603661 0.750000
vt 0.612138 0.750000
vt 0.625000 0.748069
vt 0.603661 0.750000
vt 0.625000 0.728661
vt 0.625000 0.728661
vt 0.625000 0.737138
vt 0.646339 0.750000
vt 0.646339 0.750000
vt 0.637862 0.750000
vt 0.375000 0.728661
vt 0.375000 0.737138
vt 0.376931 0.750000
vt 0.375000 0.728661
vt 0.396339 0.750000
vt 0.396339 0.750000
vt 0.387862 0.750000
vt 0.375000 0.771339
vt 0.375000 0.771339
vt 0.375000 0.762862
vt 0.853661 0.500000
vt 0.862138 0.500000
vt 0.869206 0.500000
vt 0.853661 0.500000
vt 0.603661 0.258839
vt 0.603661 0.250000
vt 0.619206 0.250000
vt 0.612138 0.262862
vt 0.603661 0.250000
vt 0.612138 0.250000
vt 0.625000 0.228661
vt 0.625000 0.244206
vt 0.625000 0.228661
vt 0.625000 0.237138
vt 0.125000 0.521339
vt 0.125000 0.512862
vt 0.125000 0.505794
vt 0.125000 0.521339
vt 0.396339 0.250000
vt 0.380794 0.250000
vt 0.396339 0.250000
vt 0.387862 0.250000
vt 0.383839 0.271339
vt 0.375000 0.271339
vt 0.375000 0.255794
vt 0.387862 0.262862
vt 0.375000 0.271339
vt 0.375000 0.262862
vt 0.875000 0.728661
vt 0.875000 0.737138
vt 0.875000 0.744206
vt 0.875000 0.728661
vt 0.603661 0.000000
vt 0.619206 0.000000
vt 0.603661 0.000000
vt 0.612138 0.000000
vt 0.625000 0.978661
vt 0.625000 0.994206
vt 0.625000 0.978661
vt 0.625000 0.987138
vt 0.375000 0.021339
vt 0.375000 0.012862
vt 0.375000 0.005794
vt 0.375000 0.021339
vt 0.146339 0.750000
vt 0.130794 0.750000
vt 0.146339 0.750000
vt 0.137862 0.750000
vt 0.396339 1.000000
vt 0.380794 1.000000
vt 0.396339 1.000000
vt 0.387862 1.000000
vt 0.125000 0.728661
vt 0.375000 0.228661
vt 0.146339 0.500000
vt 0.375000 0.478661
vt 0.383839 0.478661
vt 0.603661 0.491161
vt 0.603661 1.000000
vt 0.396339 0.000000
vt 0.396339 0.258839
vt 0.853661 0.750000
vt 0.625000 0.771339
vt 0.353661 0.750000
vt 0.375000 0.978661
vt 0.875000 0.521339
vt 0.625000 0.021339
vt 0.646339 0.500000
vt 0.625000 0.271339
vt 0.616161 0.271339
vn 0.0000 -1.0000 0.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 1.0000
vn 0.0000 1.0000 0.0000
vn 1.0000 0.0000 0.0000
vn 0.4444 0.2351 -0.8644
vn 0.2351 0.4444 -0.8644
vn 0.2351 0.8644 -0.4444
vn 0.4444 0.8644 -0.2351
vn 0.8644 0.4444 -0.2351
vn 0.8644 0.2351 -0.4444
vn 0.4444 -0.8644 -0.2351
vn 0.2351 -0.8644 -0.4444
vn 0.2351 -0.4444 -0.8644
vn 0.4444 -0.2351 -0.8644
vn 0.8644 -0.2351 -0.4444
vn 0.8644 -0.4444 -0.2351
vn 0.8644 0.2351 0.4444
vn 0.8644 0.4444 0.2351
vn 0.4444 0.8644 0.2351
vn 0.2351 0.8644 0.4444
vn 0.2351 0.4444 0.8644
vn 0.4444 0.2351 0.8644
vn 0.8644 -0.4444 0.2351
vn 0.8644 -0.2351 0.4444
vn 0.4444 -0.2351 0.8644
vn 0.2351 -0.4444 0.8644
vn 0.2351 -0.8644 0.4444
vn 0.4444 -0.8644 0.2351
vn -0.2351 0.4444 -0.8644
vn -0.4444 0.2351 -0.8644
vn -0.8644 0.2351 -0.4444
vn -0.8644 0.4444 -0.2351
vn -0.4444 0.8644 -0.2351
vn -0.2351 0.8644 -0.4444
vn -0.8644 -0.4444 -0.2351
vn -0.8644 -0.2351 -0.4444
vn -0.4444 -0.2351 -0.8644
vn -0.2351 -0.4444 -0.8644
vn -0.2351 -0.8644 -0.4444
vn -0.4444 -0.8644 -0.2351
vn -0.8644 0.4444 0.2351
vn -0.8644 0.2351 0.4444
vn -0.4444 0.2351 0.8644
vn -0.2351 0.4444 0.8644
vn -0.2351 0.8644 0.4444
vn -0.4444 0.8644 0.2351
vn -0.4444 -0.8644 0.2351
vn -0.2351 -0.8644 0.4444
vn -0.2351 -0.4444 0.8644
vn -0.4444 -0.2351 0.8644
vn -0.8644 -0.2351 0.4444
vn -0.8644 -0.4444 0.2351
vn -0.4288 -0.9034 0.0000
vn -0.9034 -0.4288 0.0000
vn 0.0000 -0.9034 -0.4288
vn 0.0000 -0.4288 -0.9034
vn 0.9034 0.0000 -0.4288
vn 0.4288 0.0000 -0.9034
vn -0.4288 0.0000 0.9034
vn -0.9034 0.0000 0.4288
vn 0.4288 0.0000 0.9034
vn 0.9034 0.0000 0.4288
vn -0.4288 0.0000 -0.9034
vn -0.9034 0.0000 -0.4288
vn 0.0000 0.9034 0.4288
vn 0.0000 0.4288 0.9034
vn 0.4288 0.9034 0.0000
vn 0.9034 0.4288 0.0000
vn 0.0000 -0.9034 0.4288
vn 0.0000 -0.4288 0.9034
vn -0.4288 0.9034 0.0000
vn -0.9034 0.4288 0.0000
vn 0.0000 0.9034 -0.4288
vn 0.0000 0.4288 -0.9034
vn 0.4288 -0.9034 0.0000
vn 0.9034 -0.4288 0.0000
vn 0.0000 0.0000 -1.0000
usemtl Material
s off
f 71/1/1 77/2/1 70/3/1 15/4/1 20/5/1 14/6/1 45/7/1 51/8/1 44/9/1 93/10/1 98/11/1 92/12/1
f 97/13/2 103/14/2 96/15/2 80/16/2 85/17/2 79/18/2 56/19/2 62/20/2 55/21/2 67/22/2 72/23/2 66/24/2
f 43/25/3 49/26/3 42/27/3 32/28/3 38/29/3 31/30/3 82/31/3 88/32/3 81/33/3 95/34/3 101/35/3 94/36/3
f 4/37/4 10/38/4 3/39/4 58/40/4 64/41/4 57/42/4 84/43/4 90/44/4 83/45/4 30/46/4 36/47/4 29/48/4
f 19/49/5 25/50/5 18/51/5 6/52/5 12/53/5 5/54/5 28/55/5 33/56/5 27/57/5 41/58/5 46/59/5 40/60/5
f 1/61/6 7/62/6 8/63/6 13/64/6
f 2/65/7 9/66/7 8/63/7 7/67/7
f 3/68/8 10/69/8 8/63/8 9/66/8
f 4/37/9 11/70/9 8/63/9 10/38/9
f 5/71/10 12/72/10 8/63/10 11/70/10
f 6/52/11 13/64/11 8/63/11 12/53/11
f 14/73/12 20/74/12 21/75/12 26/76/12
f 15/4/13 22/77/13 21/75/13 20/5/13
f 16/78/14 23/79/14 21/75/14 22/77/14
f 17/80/15 24/81/15 21/75/15 23/82/15
f 18/83/16 25/84/16 21/75/16 24/81/16
f 19/49/17 26/76/17 21/75/17 25/50/17
f 27/85/18 33/86/18 34/87/18 39/88/18
f 28/55/19 35/89/19 34/87/19 33/56/19
f 29/90/20 36/91/20 34/87/20 35/89/20
f 30/46/21 37/92/21 34/87/21 36/47/21
f 31/93/22 38/94/22 34/87/22 37/92/22
f 32/28/23 39/88/23 34/87/23 38/29/23
f 40/95/24 46/96/24 47/97/24 52/98/24
f 41/58/25 48/99/25 47/97/25 46/59/25
f 42/100/26 49/101/26 47/97/26 48/99/26
f 43/25/27 50/102/27 47/97/27 49/26/27
f 44/103/28 51/104/28 47/97/28 50/102/28
f 45/7/29 52/98/29 47/97/29 51/8/29
f 53/105/30 59/106/30 60/107/30 65/108/30
f 54/109/31 61/110/31 60/111/31 59/112/31
f 55/113/32 62/114/32 60/111/32 61/110/32
f 56/19/33 63/115/33 60/116/33 62/20/33
f 57/117/34 64/118/34 60/116/34 63/115/34
f 58/40/35 65/108/35 60/107/35 64/41/35
f 66/119/36 72/120/36 73/121/36 78/122/36
f 67/22/37 74/123/37 73/124/37 72/23/37
f 68/125/38 75/126/38 73/124/38 74/123/38
f 69/127/39 76/128/39 73/129/39 75/130/39
f 70/131/40 77/132/40 73/129/40 76/128/40
f 71/1/41 78/122/41 73/121/41 77/2/41
f 79/133/42 85/134/42 86/135/42 91/136/42
f 80/16/43 87/137/43 86/138/43 85/17/43
f 81/139/44 88/140/44 86/138/44 87/137/44
f 82/31/45 89/141/45 86/142/45 88/32/45
f 83/143/46 90/144/46 86/142/46 89/141/46
f 84/43/47 91/136/47 86/135/47 90/44/47
f 92/145/48 98/146/48 99/147/48 104/148/48
f 93/10/49 100/149/49 99/150/49 98/11/49
f 94/151/50 101/152/50 99/150/50 100/149/50
f 95/34/51 102/153/51 99/154/51 101/35/51
f 96/155/52 103/156/52 99/154/52 102/153/52
f 97/13/53 104/148/53 99/147/53 103/14/53
f 71/1/54 92/12/54 104/157/54 78/122/54
f 78/158/55 104/148/55 97/13/55 66/24/55
f 15/4/56 70/3/56 76/159/56 22/77/56
f 22/160/57 76/128/57 69/127/57 16/161/57
f 6/52/58 18/51/58 24/81/58 13/64/58
f 13/64/59 24/81/59 17/80/59 1/162/59
f 95/34/60 81/33/60 87/163/60 102/153/60
f 102/164/61 87/137/61 80/16/61 96/15/61
f 32/28/62 42/27/62 48/99/62 39/88/62
f 39/88/63 48/99/63 41/58/63 27/57/63
f 54/109/64 68/165/64 74/123/64 61/110/64
f 61/110/65 74/123/65 67/22/65 55/21/65
f 30/46/66 83/45/66 89/166/66 37/92/66
f 37/167/67 89/141/67 82/31/67 31/30/67
f 4/37/68 29/48/68 35/89/68 11/70/68
f 11/70/69 35/89/69 28/55/69 5/54/69
f 93/10/70 44/9/70 50/168/70 100/149/70
f 100/169/71 50/102/71 43/25/71 94/36/71
f 84/43/72 57/42/72 63/170/72 91/136/72
f 91/171/73 63/115/73 56/19/73 79/18/73
f 58/40/74 3/39/74 9/172/74 65/108/74
f 65/173/75 9/66/75 2/65/75 53/174/75
f 45/7/76 14/6/76 26/76/76 52/98/76
f 52/98/77 26/76/77 19/49/77 40/60/77
f 69/127/78 75/130/78 68/165/78 54/109/78 59/112/78 53/174/78 2/65/78 7/67/78 1/162/78 17/80/78 23/82/78 16/161/78
#include "../godot_headers/gdnative_api_struct.gen.h"
#include <unistd.h>
#include <asm/unistd.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <modbus/modbus.h>
#include <pthread.h>
#include <sys/types.h>
#include <sys/syscall.h>
const godot_gdnative_core_api_struct *api = NULL;
const godot_gdnative_ext_nativescript_api_struct *nativescript_api = NULL;
void *modbus_constructor(godot_object *p_instance, void *p_method_data);
void modbus_destructor(godot_object *p_instance, void *p_method_data, void *p_user_data);
godot_variant modbus_get_data(godot_object *p_instance, void *p_method_data,
void *p_user_data, int p_num_args, godot_variant **p_args);
typedef struct user_data_struct {
modbus_t *ctx;
modbus_mapping_t *mb_mapping;
} user_data_struct;
user_data_struct ud;
//typedef struct server_parameters {
// int port;
// char *address;
//} server_parameters;
void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *p_options)
{
api = p_options->api_struct;
// Now find our extensions.
for (int i = 0; i < api->num_extensions; i++) {
switch (api->extensions[i]->type) {
case GDNATIVE_EXT_NATIVESCRIPT: {
nativescript_api = (godot_gdnative_ext_nativescript_api_struct *)api->extensions[i];
}; break;
default: break;
}
}
}
void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *p_options)
{
api = NULL;
nativescript_api = NULL;
}
void *server_routine(void *user_data_void_p)
{
user_data_struct *user_data = (user_data_struct *) user_data_void_p;
//printf("in server_routine address is %s and port is %d\n", user_data->ctx->address, user_data->ctx->port);
int s = -1;
for (;;) {
s = modbus_tcp_listen(user_data->ctx, 1);
printf("before accept\n");
printf("[%d]: outer loop \n", syscall(__NR_gettid));
modbus_tcp_accept(user_data->ctx, &s);
for (;;) {
uint8_t query[MODBUS_TCP_MAX_ADU_LENGTH];
int rc;
printf("[%d]: inner loop entry\n", syscall(__NR_gettid));
rc = modbus_receive(user_data->ctx, query);
if (rc > 0) {
/* rc is the query size */
modbus_reply(user_data->ctx, query, rc, user_data->mb_mapping);
} else if (rc == -1) {
/* Connection closed by the client or error */
break;
}
}
printf("Quit the loop: %s\n", modbus_strerror(errno));
if (s != -1) {
close(s);
}
}
modbus_mapping_free(user_data->mb_mapping);
modbus_close(user_data->ctx);
modbus_free(user_data->ctx);
}
void *modbus_constructor(godot_object *p_instance, void *p_method_data)
{
user_data_struct *user_data = api->godot_alloc(sizeof(user_data_struct));
// init is delayed so that we can pass arguments normally
return user_data;
}
void modbus_destructor(godot_object *p_instance, void *p_method_data, void *p_user_data)
{
api->godot_free(p_user_data);
}
godot_variant modbus_get_holding_register(godot_object *p_instance, void *p_method_data,
void *p_user_data, int p_num_args, godot_variant **p_args)
{
godot_variant ret;
user_data_struct *user_data = (user_data_struct *)p_user_data;
int reg_num = 0;
int value = user_data->mb_mapping->tab_registers[reg_num];
api->godot_variant_new_int(&ret, value);
return ret;
}
godot_variant modbus_set_holding_register(godot_object *p_instance, void *p_method_data,
void *p_user_data, int p_num_args, godot_variant **p_args)
{
godot_variant ret;
user_data_struct *user_data = (user_data_struct *)p_user_data;
int reg_num = 0;
godot_variant *gd_value = p_args[0];
int value = api->godot_variant_as_int(gd_value);
user_data->mb_mapping->tab_registers[reg_num]=value;
return ret;
}
godot_variant modbus_set_coil(godot_object *p_instance, void *p_method_data,
void *p_user_data, int p_num_args, godot_variant **p_args)
{
godot_variant ret;
user_data_struct *user_data = (user_data_struct *)p_user_data;
int reg_num = 0;
godot_variant *gd_value = p_args[0];
bool value = api->godot_variant_as_bool(gd_value);
modbus_set_bits_from_byte(&user_data->mb_mapping->tab_bits[0], reg_num, (uint8_t) value);
return ret;
}
godot_variant modbus_get_coil(godot_object *p_instance, void *p_method_data,
void *p_user_data, int p_num_args, godot_variant **p_args)
{
godot_variant ret;
user_data_struct *user_data = (user_data_struct *)p_user_data;
int reg_num = 0;
int bit_idx = 0;
uint8_t value = user_data->mb_mapping->tab_bits[reg_num];
printf("get coil native: %d\n", value);
value = ((value >> bit_idx) & 0x01);
api -> godot_variant_new_bool(&ret, (godot_bool) value); //godot_bool is just a typedefed bool
return ret;
}
godot_variant modbus_start_server(godot_object *p_instance, void *p_method_data,
void *p_user_data, int p_num_args, godot_variant **p_args)
{
//server_parameters srv_parameters;
pthread_t server_thread;
//pthread_attr_t attr;
int port;
const char* address;
godot_variant ret;
user_data_struct *user_data = (user_data_struct *)p_user_data;
//pthread_attr_init(&attr);
// start_server(address,port)
godot_variant *gd_variant_address = p_args[0];
godot_variant *gd_variant_port = p_args[1];
port = api->godot_variant_as_int(gd_variant_port);
godot_string gd_string_address = api->godot_variant_as_string(gd_variant_address);
godot_char_string gd_string_ascii_address = api->godot_string_ascii(&gd_string_address);
address = api->godot_char_string_get_data(&gd_string_ascii_address);
user_data->ctx = modbus_new_tcp(address, port);
printf("created new context with address %s and port %d\n", address, port);
user_data->mb_mapping = modbus_mapping_new(500, 500, 500, 500);
if (user_data->mb_mapping == NULL) {
fprintf(stderr, "Failed to allocate the mapping: %s\n",
modbus_strerror(errno));
modbus_free(user_data->ctx);
return ret;
}
pthread_create(&server_thread, NULL, &server_routine, user_data);
return ret;
}
void GDN_EXPORT godot_nativescript_init(void *p_handle)
{
godot_instance_create_func create = { NULL, NULL, NULL };
create.create_func = &modbus_constructor;
godot_instance_destroy_func destroy = { NULL, NULL, NULL };
destroy.destroy_func = &modbus_destructor;
nativescript_api->godot_nativescript_register_class(p_handle, "ModbusServerNative", "Reference",
create, destroy);
godot_method_attributes attributes = { GODOT_METHOD_RPC_MODE_DISABLED };
godot_instance_method get_holding_register = { NULL, NULL, NULL };
get_holding_register.method = &modbus_get_holding_register;
nativescript_api->godot_nativescript_register_method(p_handle, "ModbusServerNative", "get_holding_register",
attributes, get_holding_register);
godot_instance_method set_holding_register = { NULL, NULL, NULL };
set_holding_register.method = &modbus_set_holding_register;
nativescript_api->godot_nativescript_register_method(p_handle, "ModbusServerNative", "set_holding_register",
attributes, set_holding_register);
godot_instance_method start_server = { NULL, NULL, NULL };
start_server.method = &modbus_start_server;
nativescript_api->godot_nativescript_register_method(p_handle, "ModbusServerNative", "start_server",
attributes, start_server);
godot_instance_method set_coil = { NULL, NULL, NULL };
set_coil.method = &modbus_set_coil;
nativescript_api->godot_nativescript_register_method(p_handle, "ModbusServerNative", "set_coil",
attributes, set_coil);
godot_instance_method get_coil = { NULL, NULL, NULL };
get_coil.method = &modbus_get_coil;
nativescript_api->godot_nativescript_register_method(p_handle, "ModbusServerNative", "get_coil",
attributes, get_coil);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment