mirror of https://github.com/teverse/teverse
Compare commits
No commits in common. "57fdb64a08a16348826d2a68ffd885de3014a8e1" and "279552d399e2ea9259d4ce990d147ab816cc4268" have entirely different histories.
57fdb64a08
...
279552d399
|
@ -18,7 +18,7 @@ For those that have contributed, we thank you for your time and service to make
|
|||
|
||||
# Copyright
|
||||
|
||||
Copyright (c) 2020 [teverse.com](https://teverse.com/)
|
||||
Copyright (c) 2020 teverse.com
|
||||
|
||||
# Acknowledgements
|
||||
- sound/click.ogg sourced from http://soundbible.com/1705-Click2.html
|
||||
|
|
|
@ -1,130 +0,0 @@
|
|||
-- Copyright 2020- Teverse
|
||||
-- This script constructs (or builds) the default in-game chat system on the client
|
||||
|
||||
local globals = require("tevgit:workshop/library/globals.lua") -- globals; variables or instances that can be shared between files
|
||||
|
||||
-- Load the networking debug UI from the teverse/teverse github
|
||||
--local debugContainer = require("tevgit:utilities/networkDebug.lua")()
|
||||
--debugContainer.parent = teverse.interface
|
||||
|
||||
local clientLocal = teverse.networking.localClient
|
||||
|
||||
local chatContainer = teverse.construct("guiFrame", {
|
||||
parent = teverse.interface,
|
||||
size = guiCoord(0, 300, 0, 200),
|
||||
position = guiCoord(0, 0, 0, 0),
|
||||
backgroundColour = globals.defaultColours.white,
|
||||
backgroundAlpha = 0.3,
|
||||
clip = true,
|
||||
visible = false
|
||||
})
|
||||
|
||||
local chatInputField = teverse.construct("guiTextBox", {
|
||||
parent = teverse.interface,
|
||||
size = guiCoord(1, 0, 0, 20),
|
||||
position = guiCoord(0, 0, 0.9, 0),
|
||||
textAlign = "middleLeft",
|
||||
textSize = 16,
|
||||
text = " Click to chat",
|
||||
textColour = globals.defaultColours.black,
|
||||
backgroundColour = globals.defaultColours.white,
|
||||
backgroundAlpha = 0.3,
|
||||
textEditable = true,
|
||||
textMultiline = false,
|
||||
visible = false
|
||||
})
|
||||
|
||||
|
||||
function chatShift()
|
||||
if #chatContainer.children == 0 then return end
|
||||
for _, message in pairs(chatContainer.children) do
|
||||
message.position = message.position + guiCoord(0, 0, 0, -15)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function message(client, text)
|
||||
|
||||
-- Should add a pcall here to determine if the message was sent successfully
|
||||
-- If not, display that the message was never sent
|
||||
teverse.networking:sendToServer("chat", text)
|
||||
|
||||
local Message = teverse.construct("guiFrame", {
|
||||
parent = chatContainer,
|
||||
size = guiCoord(1, 0, 0, 15),
|
||||
position = guiCoord(0, 0, 0, 185),
|
||||
backgroundColour = globals.defaultColours.white,
|
||||
backgroundAlpha = 0
|
||||
})
|
||||
|
||||
teverse.construct("guiTextBox", {
|
||||
parent = Message,
|
||||
size = guiCoord(1, 0, 1, 0),
|
||||
position = guiCoord(0, 0, 0, 0),
|
||||
textSize = 16,
|
||||
text = "["..client.name.."] "..text,
|
||||
backgroundColour = globals.defaultColours.white,
|
||||
backgroundAlpha = 0,
|
||||
textColour = globals.defaultColours.black,
|
||||
textAlign = enums.align.middleLeft
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
function serverMessage(client, message, color)
|
||||
local joinMessage = teverse.construct("guiFrame", {
|
||||
parent = chatContainer,
|
||||
size = guiCoord(1, 0, 0, 15),
|
||||
position = guiCoord(0, 0, 0, 185),
|
||||
backgroundColour = globals.defaultColours.white,
|
||||
backgroundAlpha = 0
|
||||
})
|
||||
|
||||
teverse.construct("guiTextBox", {
|
||||
parent = joinMessage,
|
||||
size = guiCoord(1, 0, 1, 0),
|
||||
position = guiCoord(0, 0, 0, 0),
|
||||
textSize = 16,
|
||||
text = "[SERVER] "..client.name..message,
|
||||
backgroundColour = globals.defaultColours.white,
|
||||
backgroundAlpha = 0,
|
||||
textColour = color,
|
||||
textAlign = enums.align.middleLeft
|
||||
})
|
||||
end
|
||||
|
||||
function clientAddMessage(client, text)
|
||||
chatShift()
|
||||
message(client, text)
|
||||
end
|
||||
|
||||
-- On the fence about this, will reconsider.
|
||||
--function clientRemoveMessage() end
|
||||
|
||||
chatInputField:on("keyDown", function(key)
|
||||
if key == "KEY_RETURN" then
|
||||
chatContainer.visible = true
|
||||
clientAddMessage(clientLocal, chatInputField.text)
|
||||
chatInputField.text = " "
|
||||
sleep(10)
|
||||
chatContainer.visible = false
|
||||
chatInputField.visible = false
|
||||
end
|
||||
end)
|
||||
|
||||
chatInputField:on("mouseLeftDown", function(position)
|
||||
chatInputField.text = " "
|
||||
end)
|
||||
|
||||
teverse.input:on("keyDown", function(key)
|
||||
if key == "KEY_SLASH" then
|
||||
chatInputField.visible = true
|
||||
end
|
||||
end)
|
||||
|
||||
-- Networking Events
|
||||
teverse.networking:on("ChatMessage", message)
|
||||
teverse.networking:on("_clientConnected", function(client) serverMessage(client, " has joined the server.", globals.defaultColours.green) end)
|
||||
teverse.networking:on("_clientDisconnected", function(client) serverMessage(client, " has left the server.", globals.defaultColours.red) end)
|
||||
teverse.networking:on("_disconnected", function(client) serverMessage(client, " has disconnected from the server.", globals.defaultColours.yellow) end)
|
||||
teverse.networking:on("_connected", function(client) serverMessage(client, " has connected to the server.", globals.defaultColours.yellow) end)
|
|
@ -1,17 +0,0 @@
|
|||
{
|
||||
"schema": 1,
|
||||
"id": "ChatSystem",
|
||||
"networked": true,
|
||||
"version": "0.0.1",
|
||||
"permissions": {
|
||||
"client": {
|
||||
"networking": true,
|
||||
"interface": true,
|
||||
"construct": true,
|
||||
"input": true
|
||||
},
|
||||
"server": {
|
||||
"networking": true
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
-- Copyright 2020- Teverse
|
||||
-- This script constructs (or builds) the default in-game chat system on the server
|
||||
|
||||
teverse.networking:on("ChatMessage", function(client, message)
|
||||
teverse.networking:broadcast("ChatMessage", client, message)
|
||||
end)
|
||||
|
||||
--[[
|
||||
teverse.networking:on("_clientConnected", function(client)
|
||||
teverse.networking:broadcast("ChatClientAdd", "Server", client.name .. " joined the chat")
|
||||
end)
|
||||
|
||||
teverse.networking:on("_clientDisconnected", function(client)
|
||||
teverse.networking:broadcast("ChatClientRemoved", "Server", client.name .. " left the chat")
|
||||
end)
|
||||
]]--
|
|
@ -1,12 +0,0 @@
|
|||
$input v_normal, v_colour, v_position, v_pbr
|
||||
|
||||
#include <teverse.sh>
|
||||
|
||||
uniform vec4 uniformCameraPosition;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragData[0] = vec4(v_colour.xyz, v_pbr.x);
|
||||
gl_FragData[1] = vec4(v_normal, v_pbr.y);
|
||||
//gl_FragData[2] = vec4(v_position, 0.0);
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
vec3 v_view : TEXCOORD1 = vec3(0.0, 0.0, 0.0);
|
||||
vec3 v_position : TEXCOORD2 = vec3(0.0, 0.0, 0.0);
|
||||
vec4 v_colour : TEXCOORD3 = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
vec4 v_pbr : TEXCOORD4 = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
vec3 v_normal : NORMAL = vec3(0.0, 0.0, 1.0);
|
||||
|
||||
vec3 a_position : POSITION;
|
||||
vec4 a_normal : NORMAL;
|
||||
vec4 a_weight : BLENDWEIGHT;
|
||||
vec4 a_indices : BLENDINDICES;
|
|
@ -1,34 +0,0 @@
|
|||
$input a_position, a_normal, a_weight, a_indices
|
||||
$output v_normal, v_colour, v_position, v_pbr
|
||||
|
||||
#include <teverse.sh>
|
||||
#include <teverse_compute.sh>
|
||||
|
||||
uniform mat3 normalMatrix;
|
||||
uniform vec4 colour;
|
||||
uniform vec4 pbr;
|
||||
uniform mat4 jointMatrix[90];
|
||||
|
||||
void main()
|
||||
{
|
||||
// metalness, roughness, 0, 0
|
||||
v_pbr = pbr;
|
||||
|
||||
mat4 model = (
|
||||
a_weight.x * jointMatrix[int(a_indices.x)] +
|
||||
a_weight.y * jointMatrix[int(a_indices.y)] +
|
||||
a_weight.z * jointMatrix[int(a_indices.z)] +
|
||||
a_weight.w * jointMatrix[int(a_indices.w)]
|
||||
);
|
||||
|
||||
vec4 wpos = mul(model, vec4(a_position, 1.0));
|
||||
gl_Position = mul(u_modelViewProj, wpos);
|
||||
|
||||
//gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0));
|
||||
|
||||
vec3 normal = a_normal.xyz * 2.0 - 1.0;
|
||||
vec3 wnormal = instMul(normalMatrix, normal.xyz);
|
||||
v_normal = encodeNormalUint(normalize(wnormal.xyz));
|
||||
v_colour = colour;
|
||||
v_position = gl_Position.xyz;
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
-- Copyright 2020- Teverse
|
||||
-- This script constructs (or builds) the baseline (or default) environment
|
||||
|
||||
return {
|
||||
default = function()
|
||||
teverse.scene.simulate = true
|
||||
|
@ -16,7 +17,5 @@ return {
|
|||
scale = vector3(30, 1, 30),
|
||||
colour = colour(1, 1, 1)
|
||||
})
|
||||
|
||||
-- Load Default PlayerScripts
|
||||
end
|
||||
}
|
Loading…
Reference in New Issue