Unity Vive VR with Maya nCloth

curtain
smallarrows.GIF

Tutorial animated Maya Ncloth curtain imported  into Unity


In Unity:
Start Unity

Select NEW
Give your project a name such as Maya_Anim3_Tutorial.
Select 3D.  Select Create Project.



Import SteamVR SDK Assets
Choose Window->Asset Store

Type SteamVR in the search bar
unity_VR_steam_plugin
Select the
SteamVR Plugin by Valve 
Choose Import twice (Ignore errors, select I made a backup go ahead)
Choose
Accept All and OK

Select the SteamVR folder from the Project tab, Select the arrow, select Prefabs
Select the CameraRig
In the Inspector tab
change Size to Calibrated, this uses the calibrated area from the headset



Setup the Main Camera to be used later
Select the Main Camera from the Hierarchy tab
     Change Target Display to Display 2

     Change Target Eye to None in the Inspector tab
(The main camera interferes with the Vive camera if you do not do this.)



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.

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

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 Anim 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 Anim 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 for the 2 channels named curtain 1 and curtain2
The timeline should be the length of your animation.

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


In Unity: Add your Maya File to your scene
Select Assets in the Project tab
Drag your Maya file from the Assets list over to the Hierarchy tab.

If your object is the wrong scale do this:
Select the Maya file in the Assets list, select the Model section in the Inspector tab, change the Scale Factor, hit Apply
Scale: In general the classroom active area is about 15 x 10 x 11.25 units xyz in Maya, this will match the Vive scale is you scale by .3. Of course you can make your model any size and you will be able to teleport around.
VRCollisions_1


Create an Animator Controller:
*The Animator Controller allows you to arrange and maintain a set of animations for a maya scene, as well as transitions between the different animation states.

Top menu bar  Assets-> Create-> Animator Controller re-name it

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_dot
unity_link_anim_controller



Set up an Animation State:
In the Project tab select Assets
Double click on the Animation Controller in Assets, the Animator tab should pop up.

To navigate inside the Animator Tab, Hold middle mouse button and drag on the grid.


VRCollisions_4



Open up the little arrow next to the animated object in the Assets folder  unity_asset_arrow

Drag the Animation Take 001 into the Animator tab onto the grid.

unity_drag_take001_controller2



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 tab
Check Loop Time
Hit Apply


Now your animations are all set up to run continuously.




:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Testing without the Vive
Hit the Play button   unity_play_arrow
Change to Display 2 in the Game window.  (The Vive is using Display 1)

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

You can position this camera using the Scene view when the Game is not running.


:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

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