Unity Vive VR with nCloth

curtain
smallarrows.GIF

Tutorial animated curtain from Maya imported  into Unity

In Unity:

Start Unity (You may need to set up an account)
Select NEW

Give your project a name such as Maya_Tutorial. This will create a folder with folders inside.
Save to the Desktop.
Select 3D.
Select Create Project.

(Close the Services tab, right mouse over the tab, select Close Tab if Services is there.)


Import a VR Camera and Sensors for Vive
     Choose Window->Asset Store

     Type Steam VR Plugin in the search bar, also select FREE ONLY button
unity_VR_steam_plugin
Select the
Steam VR Plugin (the free one by Valve Corporation) and Download

Choose Import
Choose Accept All and OK a few times

Put the main view window back to Scene instead of Asset Store

     Click the Scene tab on the left

Open the arrow on the SteamVR folder from the Project tab
Select Prefabs
Drag the CameraRig into the Hierarchy tab
In the Inspector tab under Steam VR_Play Area
change Size to Calibrated, this uses the calibrated area from the headset


Main Camera Settings
Select the Main Camera from the Hierarchy tab
In the Inspector tab
     Change Target Display
to Display 2.

     Change the Target Eye to None



In Maya:  Make a curtain

Create a snakey curve in the top view.
    
Create->Curve Tools->CV Curve Tool->
boxicon.gif   Curve degree 3 Cubic

Select the curve.

Select Surfaces->Extrude->option.jpg
Choose Style: Distance
Input your  Extrude Length:  8
Choose Direction: Specify
Choose the Y Axis
Choose Output geometry: Polygons
     Choose Quads
     Choose Tessellation method: General
     Change U type to: Per span # of iso params
     Change V type to: Per span # of iso params
     Input Number U: 3   (If this is too jaggy, increase)
     Input Number V: 3
Click Extrude

Poly Extrude a thickness
You need to do this because Unity used single sided geometry display.

Right mouse to select all the faces

Select Edit Mesh->Extrude.
     Select Keep Faces Together.
Move the blue (z axis) extrude arrow to the desired thickness, not too thick.

Select Edit Delete by type->History

Add nCloth dynamics
Switch over to the FX section, choose from upper left, status line.

Select the curtain
Choose nCloth->Create nCloth

Constrain the curtain to an imaginary curtain rod
Select the top row of vertices
Select nConstraint->Transform Constraint

Add wind
Select the curtain
Bring up the Attribute Editor
Arrow over to the nucleus1 tab
     Under Gravity and Wind

          Change Wind Speed to 4
          Change Wind Direction to 1, 0, 1


Use the simulation to model
Make at least 3 copies from various frames of the animation:
Play the animation.
Hit the play arrow on the time slider to play and stop when you like a model. timesliderplay.jpg
Select the curtain
Choose Edit->Duplicate
The copy will not have any dynamics. Do this 3 times

Delete the original nCloth and curves
Keep the 3 duplicated curtain meshes

1 will be the base shape
Name the other 2 curtains curtain1 and curtain2

Surgically remove invisible nodes that mess you up in Unity:
Select one shape at a time
Select Windows->General Editors->Hypergraph: Connections
     Select the light grey node
     Hit delete
     Close the Connection window
Repeat for each shape


Blend Shape
Switch over to the Animation section, choose from upper left, status line.
Select the first curtain (base)
Choose Deform -> Blend Shape
(This adds blend shapes options in the channel editor)

Select curtain1 (target), use shift to select the first curtain(base) too.
(The order is important)

Choose Deform-> Blend Shape -> Add
Do this again for curtain2

Delete the target curtains.

Look at the channel editor, you now have 2 new channels to animate.

Set some keyframes

Choose File->Save As select  Desktop->Maya_Tutorial->Assets
(Or the name of your Unity Project folder.)  Maya scene files will transfer straight into your Unity file.


Any animated items should be separate Maya files. It will be easier to manage


**IMPORTANT Save a spare copy of your Maya model and Textures in another folder away from your Unity project.




In Unity:
Select the Assets folder in the Project tab
Select each Maya file, select the Model section, change the Scale Factor in the Inspector tab to .3.
Drag each Maya file from the Assets list in the Projects tab into the Hierarchy tab.



Set up your animation to loop constantly

From the top menu, select Assets->Create->Animation Controller, name it

Select Assets in the Project tab

Click the small arrow unity_asset_arrow  to reveal the contents of your animated object

Double click the New Animation Controller you just made.
unity_animation_controller

Drag the Take 001 icon into the Animation Controller window. (It is located under the small arrow you opened in the Assets tab.)
unity_take001

Select the object that has the animation from the Hierarchy window

In the Inspector, Animator should be checked

Click the small round circle to the right of Controller, select the controller you just added.
unity_link_anim_controller



Loop
If you would like to loop your animation:
Select the object that has the animation from the Assets window
Change to the Animations section of the Inspector
     Check Loop Time
     Hit Apply




Testing without the Vive
Hit the Play button   unity_play_arrow
Change to Display 2 in the Game window.

If the camera view does not look right, Make sure Scale is 1x in the Game window.