This project aims to creat a VR-based tilt brush app that allows people to draw strokes in 3D on a HTC Vive Focus Plus. Check out our project on Youtube!
HTC Vive Focus Plus runs an Android system, if you want it to run PC VR, use VRidge
Before we start, there is actually a tutorial talks about how to port an app from Vive(Using Steam VR) to Wave VR.
And there is a excellent tutorial teaches how to build tilt brush from scratch.
While the porting process is complicated and leads to many bugs, I decide to continue using Wave VR directly.
Direct Preview won't work on Mac (as those scripts are for Windows)
Need to manually download NDK in Unity-Preference-External Tools
-
Follow this to set up the android environment for Focus Plus(This doc works for Windows, little different in mac os.)
-
Download Wave unity sdk
-
Connect Vive Focus Plus to Computer (Install Android File Transfer on Mac)
4. Enable DirectPreview.
This is a sample Scene build from Hello VR
Simply Build and Run after connecting Focus to Mac
Be able to draw continuous strokes in 3D using a handheld controller
Wired "Gradle build failed" happens sometimes, just try saving all and restart Unity.
See this for more details
WaveVR_Controller.EDeviceType curFocusControllerType = WaveVR_Controller.EDeviceType.Head;
WaveVR_Controller.EDeviceType DomFocusControllerType = WaveVR_Controller.EDeviceType.Dominant;
WaveVR_Controller.EDeviceType NonFocusControllerType = WaveVR_Controller.EDeviceType.NonDominant;
if (WaveVR_Controller.Input(DomFocusControllerType).GetPressDown(WVR_InputId.WVR_InputId_Alias1_Trigger)){}
- Press down: Create new object and add LineRender
LineRenderer currLine;
GameObject go = new GameObject();
currLine = go.AddComponent<LineRenderer>();
currLine.SetWidth(.05f, .01f);
currLine.material = lMat;
- Pressing: Add points of the LineRender
currLine.SetVertexCount(numClicks + 1);
currLine.SetPosition(numClicks, WaveVR_Controller.Input(DomFocusControllerType).transform.pos);
3, Press up: Reset
numClicks = 0;
currLine = null;
Follow this blog to use a "better" line renderer that generate lines which won't "rotate" when camera moving
LineRenderer also works well~
Change stroke's color
Using Package Simple Color Picker
- Rewrite Draggable.cs in Color Picker-Script for the VR controller instead of mouse
- Implement ColorManager.cs to colorpicker
- Rewrite DrawLineManager.cs to receive color
currLine.lmat = new Material(lMat); //create new material every time
currLine.lmat.color = ColorManager.Instance.GetCurrentColor();
Follow this doc to use Swipe Event on both controller to change stroke size.
void OnEvent(params object[] args){}
...
case WVR_EventType.WVR_EventType_LeftToRightSwipe:
width += 0.02f;
...
void OnEnable(){}
Ability to select and erase both individual brush strokes or the entire scene.
Using same logic in Go_event.cs(from helloVR). Attach Reset Scene to test sphere.
Use Nondominant controller to point the test sphere and Press Touchpad will reset the whole Scene.
SceneManager.LoadScene(SceneName);
You can undo the last brush stroke by swiping from Right to Left on the controller
- Scale, rotate, and move your sketch (or your position within the sketch).
- Teleport to different locations within the sketch.