Skip to content

Commit

Permalink
Added a proper README file and the license
Browse files Browse the repository at this point in the history
This should help people understand how to use this plugin,
and also understand the script format understood by the plugin,
just in case someone wants to code another editor.

Signed-off-by: VR Voyage <[email protected]>
  • Loading branch information
VR Voyage committed Jun 25, 2021
1 parent b4f4d82 commit 833656d
Show file tree
Hide file tree
Showing 6 changed files with 267 additions and 10 deletions.
9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The MIT License (MIT)

Copyright © 2021 Voyage (vr-voyage)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
7 changes: 7 additions & 0 deletions Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"profiles": {
"VoyageNeosVRPlugin": {
"commandName": "Project"
}
}
}
230 changes: 230 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
# THE PLUGIN IS IN ALPHA STATE, EXPECT HEAVY CHANGES

# About

This NeosVR plugin is used to provide remote Logix programming
support, through external scripts sent through Websocket.

# Compilation and installation

You'll most likely need to change the DLL Dependencies of the project, and
set them to appropriate paths on your system.
I'll try to put in place a way to automate this process (CMake maybe ?).
Meanwhile, be sure to reference the following DLL, from `Neos_Data\Managed\`
inside NeosVR installation directory :

* BaseX.dll
* CloudX.Shared.dll
* CodeX.dll
* FrooxEngine.dll

Then **Generate the solution** and copy the generated DLL files, located
in the source folder `bin/Debug/netstandard2.0` or `bin/Release/netstandard2.0`
to NeosVR `Libraries` directory located in the installation folder.

So, if NeosVR is installed in :
`C:\Program Files (x86)\Steam\steamapps\common\NeosVR`

And the source folder is located in `%HOMEPATH%\sources\voyage-neosvr-plugin`

You'll have to be sure that the following dependencies are referenced :
* `C:\Program Files (x86)\Steam\steamapps\common\NeosVR\Neos_Data\Managed\BaseX.dll`
* `C:\Program Files (x86)\Steam\steamapps\common\NeosVR\Neos_Data\Managed\CloudX.Shared.dll`
* `C:\Program Files (x86)\Steam\steamapps\common\NeosVR\Neos_Data\Managed\CodeX.dll`
* `C:\Program Files (x86)\Steam\steamapps\common\NeosVR\Neos_Data\Managed\ FrooxEngine.dll`

The generate the solution (we'll use the Debug configuration in this example) and then :

```powershell
copy %HOMEPATH%\sources\voyage-neosvr-plugin\bin\Debug\netstandard2.0\VoyageNeosVRPlugin.* C:\Program Files (x86)\Steam\steamapps\common\NeosVR\Libraries
```

# Usage

## Start NeosVR with the plugin

Once the plugin copied in the `Libraries` directory inside NeosVR installation
folder, launch the game using the **Neos Launcher**, then be sure to check
`NeosSampleLibrary.dll` in the list before clicking `Launch`.

## Add the component

Inside the game, open the inspector and `Add a component`, then select :
**Voyage** > **RemoteLogix**

Once the component added, setup the websocket URI to which the
component should receive scripts from, then click on `Connect`.

> The default URI targets the Websocket server started by the desktop
> version of the [RemoteLogix editor](https://github.com/vr-voyage/remote-logix)
Once the component, you can start streaming LogiX script to NeosVR.
Each program will be added as a child of the slot which host the component.

> If you send the same program twice, it will create two children with the
> same name.
> There is no updating or overwriting mechanism at the moment.
Once the program uploaded, you can remove the component and restart
the game, to share the generated programs with your friends.

# Limitations

## Multiplayer will most likely be broken

On NeosVR, when you use a custom plugin, you can only join people using
the same custom plugin. So you're most likely going to be alone when
using this plugin, at the moment.

## No overwriting or updating mechanism

Uploading the same program multiple times just generate multiple copies
of the program.

## Remaining Websocket clients are useless

When you click on 'Connect', a WebsocketClient component is added, with
specific handlers setup internally to receive the data and parse it through the
plugin.
If you disconnect and the reconnect to the game, the added WebsocketClient
component will still be there, but the custom handlers won't be restored,
making the client useless.
I'll see how to fix that in the future. Meanwhile, remove remaining websocket
generated by the plugin when reconnecting.

> During a continuoussession, unchecking 'Connect' after checking it
> will remove the WebsocketClient without issues.
# Script syntax

## Basics

* Each line begins with an instruction mnemonic.
* Instruction arguments are separated by spaces.
* Single quoted arguments contain C# class names and input/output slots names.
They're expected to not contain spaces.
If any single-quote character present in these identifiers are doubled.
* Double quoted arguments contain user-input encoded in Base64.
* Numeric arguments are printed as-is.


## Documentation syntax

In this documentation :

* `"NAME"` means a double quoted Base64 encoded user input, referenced
as NAME in the docs.
To decode it, you're expected to remove the double quotes and decode
the content, using standard Base64 decoding algorithm.

* `'FullClassName'`, `'Input'`, `'Output'` mean single-quoted C# full class names
and nodes input/output names as printed inside NeosVR.
To parse these strings, remove the surrounding single quotes and every two
occurences of single-quote characters by one single-quote character within
the remaining string.
For the C# class names, you'll need to check the **FrooxEngine.dll** assembly.
Visual Studio can do that, by default.
For example, the full class name of `StringInput` is
`FrooxEngine.LogiX.Input.StringInput`.

> This single quote handling might be removed in the future, since no identifier
> use single quotes.
* Non quoted strings are either mnemonics or numeric arguments names.
These names should be replaced by actual numbers in the script.


## Mnemonics

### PROGRAM "[BASE64_INPUT]" VERSION

Define the program name.

Arguments :
* The program name encoded in base64.
* The script version used. Should always be 1 at the moment.

> The script version is used by the interpreter to understand how
> to interpret the following script.
Example :

`PROGRAM "RXhhbXBsZQ==" 1`

### NODE ID 'NodeFullClassName' "NODE_NAME"

Define a new node.

Arguments :
* The node ID. Used as reference in the following instructions. MUST be unique.
* The node full C# class name. Example : 'FrooxEngine.LogiX.Input.StringInput' for **StringInput**.
* The node name, encoded in Base64.

> The best way to get class names is to add `FrooxEngine.dll` in a DLL project,
> through Visual Studio, and explore the `FrooxEngine.LogiX` assemblies.
> To do that, on the right-pane of Visual Studio, right-click `FrooxEngine` in
> **Dependencies** > **Assemblys**.
Example :

`NODE 17 'FrooxEngine.LogiX.Input.StringInput' "U3RyaW5nSW5wdXQ="`

### SETCONST NODE_ID "CONTENT"

Defines the content of a constant node.

Arguments :
* The node ID representing a constant value node. The node ID MUST be defined through a `NODE` instruction before.
* The base64 encoded content.

Example :

`SETCONST 17 "QmxlbmRzaGFwZXM="`

### POS NODE_ID X Y

Defines the position of a node.

> Note that RemoteLogix encode Y positions with Y pointing downward.
> This is why the plugin actually negate the value.
Arguments :
* The node ID. The node ID MUST be defined through a `NODE` instruction before.
* The X position of the node.
* The Y position of the node.

Example :

`POS 17 1280 280`

### INPUT TO_NODE_ID 'InputName' FROM_NODE_ID 'OutputName'

Defines a connection between two nodes.

Arguments :
* The node ID receiving the connection. The node ID MUST be defined through a `NODE` instruction before.
* The name of the input slot receiving the connection.
* The node ID from where the connection starts. The node ID MUST be defined through a `NODE` instruction before.
* The name of the output slot from where the connection starts.

> `'*'` output name is used for default outputs on various nodes with only
> one output slot.
Example :

`INPUT 15 'Name' 17 '*'`

Connects node 17 "*" OUTPUT to INPUT "Name" on node 15 .

### IMPULSE TO_NODE_ID 'ImpulseTarget' FROM_NODE_ID 'Impulse'

Connects Impulse slots between two nodes.

* The node ID receiving the connection. The node ID MUST be defined through a `NODE` instruction before.
* The name of the Impulse input receving the connection.
* The node ID from where the connection starts. The node ID MUST be defined through a `NODE` instruction before.
* The name of the Impulse output from where the connection start.

`IMPULSE 46 'Run' 10 'True'`

Connects node 10 "True" Impulse OUTPUT to the "True" Impulse INPUT on node 46 .
20 changes: 11 additions & 9 deletions RemoteLogix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using FrooxEngine.LogiX;
using System.Reflection;

namespace NeosQuickSetupTools
namespace VoyageNeosVRPlugin
{
[Category("Voyage")]
public class RemoteLogix : Component
Expand Down Expand Up @@ -682,14 +682,6 @@ Type ScriptGetActualNodeType(string providedNodeTypeFullName)
* FrooxEngine.Logix.Data.ReadDynamicVariable<System-Single>
*/
string genericTypeName = providedNodeTypeFullName.Substring(0, bracketPosition);
/* It seems that all generics type names are suffixed with '`1' */
genericTypeName += "`1";
Type genericType = LogixGetType(genericTypeName);
if (genericType == null)
{
UniLog.Log("Could not find generic type " + genericTypeName);
return null;
}

int afterStartBracketIdx = bracketPosition + 1;
int betweenBracketsLength =
Expand All @@ -701,6 +693,16 @@ Type ScriptGetActualNodeType(string providedNodeTypeFullName)
Type[] specialTypes = new Type[typeTNamesList.Length];
int typesCount = typeTNamesList.Length;

/* It seems that all generics type names are suffixed with '`' followed
* by the amount of generic arguments */
genericTypeName += "`" + typesCount;
Type genericType = LogixGetType(genericTypeName);
if (genericType == null)
{
UniLog.Log("Could not find generic type " + genericTypeName);
return null;
}

for (int i = 0; i < typesCount; i++)
{
string typeTFullName = typeTNamesList[i].Trim();
Expand Down
9 changes: 9 additions & 0 deletions NeosQuickSetupTools.csproj → VoyageNeosVRPlugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>VoyageNeosVRPlugin</AssemblyName>
<PackageProjectUrl>https://github.com/vr-voyage/voyage-neosvr-plugin</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Copyright>Voyage (VRSNS)</Copyright>
<Description>Currently used to provide a remote Logix scripts import mechanisms.
Such scripts can be generated through RemoteLogix : https://github.com/vr-voyage/remote-logix</Description>
<RepositoryUrl>https://github.com/vr-voyage/voyage-neosvr-plugin</RepositoryUrl>
<RepositoryType>Github</RepositoryType>
<RootNamespace>VoyageNeosVRPlugin</RootNamespace>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion NeosQuickSetupTools.sln → VoyageNeosVRPlugin.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31321.278
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NeosQuickSetupTools", "NeosQuickSetupTools.csproj", "{2A6363C2-51D2-47A3-9D3A-877693BF94C6}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VoyageNeosVRPlugin", "VoyageNeosVRPlugin.csproj", "{2A6363C2-51D2-47A3-9D3A-877693BF94C6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down

0 comments on commit 833656d

Please sign in to comment.