Skip to content

Commit

Permalink
Addressing #11 and reorganize the book
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKangs committed May 24, 2023
1 parent adebb4d commit d78fbd7
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 122 deletions.
60 changes: 7 additions & 53 deletions src/Beginner_Tutorial/setting_up_plugin_development_environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugins are typically developed in their own repositories or folders.

## Before plugin development
Before we start doing any plugin development, we need to set up the engine into your machine. Please refer to the [Development Environment](../Product_Page/dev_env.md) before we start setting up the plugin development environment.
Before we start doing any plugin development, we need to set up the engine into your machine. Please refer to the [Installation](../installation.md) as beginning installation and [Development Environment](../installation.md#most-advanced-version-development-environment-version) to set up the development environment.

## Using the template
The easiest way to get started is to fork the
Expand All @@ -17,25 +17,11 @@ git clone [email protected]:ChatImproVR/template.git
cd template
git remote remove origin
```

## Setting up the helper script
The helper script is intended to make it easy to run the client, server, or both from a single command. The script requires Python 3.
## Modifying the helper script
We need to update the helpder script to locate where the plugin path is located. For the next section, we will help you out how to modify the helper script based on each terminal.
> Note that all the additional change is inserting line(s) outside of the `cimvr` function call.
### On Linux/Unix/MacOS (Bash)

If your MacOS system is using `bash` instead of `zsh`, then please follow this procedure. Otherwise, please follow the MacOS (Zsh) section.

Assuming you have a copy of `iteration0` somewhere (in this case, `$HOME/Projects/chatimprovr`), you can put the following in your `~/.bashrc`:

```bash
function cimvr() {
$HOME/Projects/chatimprovr/cimvr.py $@
}
```
This will allow you to access the script as `cimvr` anywhere.

> *NOTE: If you do not have the .bashrc file, you need to create on in the $HOME directory.*
let's say we want to develop a plugin called `foo`, that we're developing at `$HOME/Projects/foo`. Then we could add this to our `~/.bashrc`:
```bash
export CIMVR_PLUGINS="$HOME/Projects/foo"
Expand All @@ -47,18 +33,6 @@ export CIMVR_PLUGINS="$HOME/Projects/foo;$HOME/Desktop/poo"
```

### On MacOS (Zsh)

Assuming you have a copy of `iteration0` somewhere (in this case, `$HOME/Desktop/Rust/chatimprovr`), you can put the following in your `~/.zshrc`:

```zsh
function cimvr() {
$HOME/Desktop/Rust/chatimprovr/cimvr.py $@
}
```
This will allow you to access the script as `cimvr` anywhere.

> *NOTE: If you do not have the .zshrc file, you need to create on in the $HOME directory.*
let's say we want to develop a plugin called `foo`, that we're developing at `$HOME/Desktop/Rust/foo`. Then we could add this to our `~/.bashrc`

```zsh
Expand All @@ -71,20 +45,6 @@ export CIMVR_PLUGINS="$HOME/Desktop/Rust/foo;$HOME/Desktop/poo"
```

### On Windows
Assuming you have a copy of `iteration0` somewhere (in this case, `C:\Users\dunca\Documents\iteration0`), you can put the following in your `Microsoft.PowerShell_profile.ps1`.

```ps1
function cimvr() {
$cimvr_path="C:\Users\dunca\Documents\iteration0"
python $cimvr_path\cimvr.py $args
}
```
This will allow you to access the script as `cimvr` anywhere.

> *NOTE: If you cannot find the `Microsoft.PowerShell_profile.ps1`, you can find the file by typing `$profile` in Windows PowerShell. There is a chance that `Microsoft.PowerShell_profile.ps1` might not exist yet. In that case, you need to create a new file and the directory to match that path. In the image below, the file should be located in `Documents\WindowsPowerShell` under the file name as `Microsoft.PowerShell_profile.ps1`. If running scripts is disabled on your machine, consult the common fixes section.*
![$profile path](./images/profile_path.png)

Let's say we want to develop a plugin called `foo`, that we're developing at `C:\Users\dunca\Documents\Projects\foo`. Then we could add this to our `$profile`:
```ps1
$Env:CIMVR_PLUGINS="C:\Users\dunca\Documents\Projects\foo"
Expand All @@ -94,24 +54,18 @@ If you are developing on several plugins at the same time, for example `foo` and
export CIMVR_PLUGINS="C:\Users\dunca\Documents\Projects\foo;C:\Users\Mr.Kangs\Desktop\galaga"
```


### Using the script to launch plugins
After building both `iteration0`'s client and server as well as the example plugins, we could launch the cube example included with ChatImproVR using:
```bash
cimvr camera cube
```

After building our own plugin we could launch it with:
After building our own plugin and updating the helper script, we could launch it with:

```bash
cimvr foo
```

This will start the client and the server with our plugin as arguments. Note that this name `foo` is determined via package name, the one we set earlier.

The `CIMVR_PLUGINS` environment variable is a semicolon-seperated list of search paths. We've set it to `target/wasm32-unknown-unknown/release` under our own plugin, so that it can find `foo.wasm`.
The `CIMVR_PLUGINS` environment variable is a semicolon-seperated list of search paths. We've set it to the path of the plugin under our own plugin, so that it can find `foo.wasm`.

Note that the `example_plugins` directory will be looked for by default, so you don't need to add an environment variable for these.
> Note that the `example_plugins` directory will be looked for by default, so you don't need to add an environment variable for these.
## Tips and tricks
### Using the cargo-watch crate
Expand Down
2 changes: 0 additions & 2 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

- [Introduction](./introduction.md)
- [Installation](./installation.md)
- [How do you Run](./execuation.md)
- [Development Environment](./dev_env.md)
- [Core Concepts](./Core_Concepts/core_concepts.md)
- [Plugins](./Core_Concepts/plugin.md)
- [Webassembly](./Core_Concepts/wasm.md)
Expand Down
57 changes: 0 additions & 57 deletions src/dev_env.md

This file was deleted.

File renamed without changes.
File renamed without changes
120 changes: 110 additions & 10 deletions src/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ We cannot provide the most accurate requirement; however, the PC must able to ru

## Softwares to Download
There are four softwares to download in order to use the ChatImproVR.
1. [Rust](https://www.rust-lang.org/tools/install)
2. [CMake](https://cmake.org/download/)
1. [Rust](#rust)
2. [CMake](#cmake)
3. VR Supported Headset Software
1. [Oculus VR](https://www.oculus.com/Setup/)
2. [Steam VR](https://store.steampowered.com/app/250820/SteamVR/)
4. [Our Engine](https://github.com/ChatImproVR/chatimprovr)
1. [Oculus VR](#oculus-vr)
2. [Steam VR](#steam-vr)
4. Our Engine
1. [Stable Version Environment](#stable-version)
2. [Development Environment](#most-advanced-version-development-environment-version)

We will guide you how to install for each software to be ready to use our engine. Before you go into the installaion, please open the links that are provided above.

Expand All @@ -30,7 +32,7 @@ When you visit the page for Rust, it will greet you the screen as below.
Please follow the instructions as they stated. The page might look slighlty different based on operating system.

## CMake
When you visit the page for Cmake, it will greet you the screen as below. Please download the latest version of Cmake that has the option of Windows x64 Installer: the file extension is `.msi`.
When you visit the [page for Cmake](https://cmake.org/download/), it will greet you the screen as below. Please download the latest version of Cmake that has the option of Windows x64 Installer: the file extension is `.msi`.
![Cmake Install Page](/images/cmake_install_page.png)
In the image above, the version we are downloading is 3.26.4, but you can download and install a higher version if you want as well.

Expand Down Expand Up @@ -61,20 +63,118 @@ Once the installation is complete, then you will see the following screen.
![Cmake Installer Part 6](/images/cmake_installer_part_6.png)

## Oculus VR
Once you open the page, you will be greet the follow page as below.
Once you [open the page](https://www.oculus.com/Setup/), you will be greet the follow page as below.

![Oculus Download Page](/images/oculus_download_page.png)

Select the `Download Oculus Rift Software` button. By selecting the button will open an `.exe`. Please follow the installer instruction.

## Steam VR
//TODO: someone test this out/write this part. I have no idea what is a major difference when it comes to Steam VR application.
[Download Link](https://store.steampowered.com/app/250820/SteamVR/)

## Our Engine
There are two methods to use our engine: the stable version and most advanced version.

### Stable Version
Use the Release Code Version
If you want to use the stable version, we recommend to download the engine from releases. You can download from [here](https://github.com/ChatImproVR/chatimprovr/releases). If you are a **Windows** user, please download the `.exe`. If you are a **Linux** or **Mac**, please download the file that is stated in the release note (The application that has no extension).From there, you can run the `cimvr_server.exe` to host your own server whereas the `cimvr_client.exe` to connect server based on the address of the server.

### Most Advanced Version
Clone the repository
### Most Advanced Version (Development Environment Version)
If you want to get the most up-to-date version that might have some bugs within the engine but has more features than the stable version and develop new plugins or engine features, then we recommend to clone our repository from [here](https://github.com/ChatImproVR/chatimprovr). There are additional steps that need to finish in order to use this version.

#### WASM target
Make sure you have the `wasm32-unknown-unknown` target installed;
```sh
rustup target add wasm32-unknown-unknown
```

#### Dependencies on Ubuntu:
```sh
sudo apt install build-essential cmake libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libspeechd-dev libxkbcommon-dev libssl-dev
```

#### Compilation
Build the client, server, and example plugins like so:
```sh
pushd server
cargo build --release
popd

pushd client
cargo build --release
cargo build --release --features vr # (For VR/OpenXR support)
popd

pushd example_plugins
./compile_all.sh # (Linux)
# ./compile_all.ps1 # (Windows)
popd
```

You can compile all of the example plugins with the `compile_all.sh` script.
If you're on windows, you can either use `Git Bash` to run the `.sh` files or open a PR; sorry about it!

While most crates _are_ in a workspace, the client crate is unfortunately excluded due to an issue with the `openxr` crate.

#### Setting up the helper script
The helper script is intended to make it easy to run the client, server, or both from a single command. The script requires Python 3.

##### On Linux/Unix/MacOS (Bash)

If your MacOS system is using `bash` instead of `zsh`, then please follow this procedure. Otherwise, please follow the MacOS (Zsh) section.

Assuming you have a copy of `chatimprovr` somewhere (in this case, `$HOME/Projects/chatimprovr`), you can put the following in your `~/.bashrc`:

```bash
function cimvr() {
$HOME/Projects/chatimprovr/cimvr.py $@
}
```
This will allow you to access the script as `cimvr` anywhere.

> *NOTE: If you do not have the .bashrc file, you need to create on in the $HOME directory.*
##### On MacOS (Zsh)

Assuming you have a copy of `chatimprovr` somewhere (in this case, `$HOME/Desktop/Rust/chatimprovr`), you can put the following in your `~/.zshrc`:

```zsh
function cimvr() {
$HOME/Desktop/Rust/chatimprovr/cimvr.py $@
}
```
This will allow you to access the script as `cimvr` anywhere.

> *NOTE: If you do not have the .zshrc file, you need to create on in the $HOME directory.*
##### On Windows
Assuming you have a copy of `chatimprovr` somewhere (in this case, `C:\Users\dunca\Documents\chatimprovr`), you can put the following in your `Microsoft.PowerShell_profile.ps1`.

```ps1
function cimvr() {
$cimvr_path="C:\Users\dunca\Documents\chatimprovr"
python $cimvr_path\cimvr.py $args
}
```
This will allow you to access the script as `cimvr` anywhere.

> *NOTE: If you cannot find the `Microsoft.PowerShell_profile.ps1`, you can find the file by typing `$profile` in Windows PowerShell. There is a chance that `Microsoft.PowerShell_profile.ps1` might not exist yet. In that case, you need to create a new file and the directory to match that path. In the image below, the file should be located in `Documents\WindowsPowerShell` under the file name as `Microsoft.PowerShell_profile.ps1`. If running scripts is disabled on your machine, consult the common fixes section.*
![$profile path](./images/profile_path.png)

##### Using the script to launch the engine
After building both `chatimprovr`'s client and server as well as the example plugins, we could launch the cube example included with ChatImproVR using:
```bash
cimvr camera cube
```
in the terminal where you installed the helper script.

#### Additional Tips and Tricks
##### Sparse registries
Recently, the sparse protocol for cargo registries was stablized. This can help improve initial compile times. See [the rust blog](https://blog.rust-lang.org/2023/03/09/Rust-1.68.0.html#cargos-sparse-protocol).

##### Logging
Wasmtime/Cranelift puts a bunch of junk in the log by default. To disable this, put the following in your RC file:
```sh
export RUST_LOG="debug,cranelift=OFF,wasmtime=OFF"
```

0 comments on commit d78fbd7

Please sign in to comment.