tutorial - wyrmtale · pdf filein this tutorial we will create an endless looping waving flag....

14
TUTORIAL & object reference Bake and Blend 3D Animation Loops (c) copyright 2013 – WyrmTale Games http://www.wyrmtale.com

Upload: dinhtruc

Post on 14-Mar-2018

214 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: TUTORIAL - WyrmTale · PDF fileIn this tutorial we will create an endless looping waving flag. ( Check the tutorial DEMO online ) ... We will create our flag model in blender3D, set

TUTORIAL & object reference

Bake and Blend3D Animation Loops

(c) copyright 2013 – WyrmTale Games http://www.wyrmtale.com

Page 2: TUTORIAL - WyrmTale · PDF fileIn this tutorial we will create an endless looping waving flag. ( Check the tutorial DEMO online ) ... We will create our flag model in blender3D, set

INTRODUCTIONB-loop is a tool for Unity that lets you convert a serie of exported 3d model frames into raw vertex data. This data is stored into an xml file and loaded and played back in your game.

By manipulating this raw vertex data (offsetting and blending end-ponts) B-loop can create endless animating loops that are less cpu costly than the regular Unity cloth/wind physics techniques

B-loop uses a simple workflow : Create your 3d model and bake modifiers like cloth and forces like wind, export the baked animation to a sequence of seperate wavefront .obj files, import these files in Unity and build the bloop file with the click of a button. Load the bloop file in your scene and play it on your object mesh.

Our worldflags product was created with an early version of the b-loop tool.( check the demo )

Page 3: TUTORIAL - WyrmTale · PDF fileIn this tutorial we will create an endless looping waving flag. ( Check the tutorial DEMO online ) ... We will create our flag model in blender3D, set

TUTORIALIn this tutorial we will create an endless looping waving flag.

( Check the tutorial DEMO online )

The steps to create a bloop file that can be played on your exported model are :

1. Create a 3D modelWe will create our flag model in blender3D, set it to be cloth and apply a wind force to it.

2. Export the backed frames as objectsWe will export the model so that all frames will be saved as single wavefront (.obj) files and can be imported into Unity.

3. Generate the bloop-file in UnityWe will use bloop in the Unity editor to create an endless looping animation by generating a file with vertex data.

4. Create your sceneWe will setup a new scene by adding the model and include a bloop manager to load the animation data. A bloop player script that we put on our mesh will play our animation when the model is in view.

Page 4: TUTORIAL - WyrmTale · PDF fileIn this tutorial we will create an endless looping waving flag. ( Check the tutorial DEMO online ) ... We will create our flag model in blender3D, set

CREATE 3D MODEL1. Start blender3D

2. Remove the default cube by selecting it (right mousebutton) and pressing [x][ENTER] and Add a grid object. Rotate it 90 degrees around the Y-axis. [r][y][90][ENTER] This will be our flag.

Page 5: TUTORIAL - WyrmTale · PDF fileIn this tutorial we will create an endless looping waving flag. ( Check the tutorial DEMO online ) ... We will create our flag model in blender3D, set

3. Prepare the flag by selecting and assigning the vertices , that will used to 'pin' the flag, to a vertex group

4. Check using weight paint if the selected vertices have been painted red. Set our object to be cloth in the physics panel, check the 'pinned' checkbox and select the vertex group.

Page 6: TUTORIAL - WyrmTale · PDF fileIn this tutorial we will create an endless looping waving flag. ( Check the tutorial DEMO online ) ... We will create our flag model in blender3D, set

5. Add a wind force and rotate 90 on the y-axis [r][y][90][ENTER] and 20 on the x-axis [r][z][20][ENTER]. Set the strength of the wind to 100, the flow to 10 and the noise to 5.

6. Bake the cloth animation using the cloth cache and look at the result [Alt-A]

UV mapping has not been done yet. If you want to texture your flag in Unity . You need to do that as well.

Page 7: TUTORIAL - WyrmTale · PDF fileIn this tutorial we will create an endless looping waving flag. ( Check the tutorial DEMO online ) ... We will create our flag model in blender3D, set

EXPORT BAKED FRAMESAfter you are happy with the result, you need to export the baked frames.

Because the flag starts from hanging postion and we need it to be looping we change the start frame to 30 and the end frame to 230 so we got a sequence of 200 frames.

To export each frame to a seperate mesh model that Unity can read, we export to wavefront (.obj).

Make sure you have only your model to export selected!

Selection Only - on, Animation - on, Write Materials - off, select the folder, give a filename .... and press [Export OBJ].

Page 8: TUTORIAL - WyrmTale · PDF fileIn this tutorial we will create an endless looping waving flag. ( Check the tutorial DEMO online ) ... We will create our flag model in blender3D, set

After this action you have your list of .obj frame files that can be imported into Unity and contain the mesh state of each baked frame.

Page 9: TUTORIAL - WyrmTale · PDF fileIn this tutorial we will create an endless looping waving flag. ( Check the tutorial DEMO online ) ... We will create our flag model in blender3D, set

GENERATE BLOOP FILEAfter the frame objects have been exported, just create a folder in your project and put them all in.

Assuming that you have already imported the bloop package into your project, you select the first frame object file in your Unity property inpector, right-click and select the 'Bloop' action in the context menu.

Next you will be presented the following editor window

Page 10: TUTORIAL - WyrmTale · PDF fileIn this tutorial we will create an endless looping waving flag. ( Check the tutorial DEMO online ) ... We will create our flag model in blender3D, set

Basicly, when you just set the name, check 'create loop' and import you will get a good amimation in most of the cases.

After you have clicked [Import], you will find the animation data xml file with the chosen name in the objects parent folder.

You can move this file if you want. To play it on one of your objects' meshes you just link it to an bloop manager object and to a bloop player script. We will see how that is done next...

REFERENCE | Generate bloop fileImport pathDisplays the path to the folder that contains your object filesShapeKeysSummery of the objects foundKeyset NameThis will be the name of your bloop fileCreate LoopIf true, it will blend the animation into an endless loopFrom ShapeFrame number to start blendingTo ShapeFrame number to end blendingDuplicate offsetQuickly change blending start offset to find a good blend spotImport (button)Generate the bloop file

Page 11: TUTORIAL - WyrmTale · PDF fileIn this tutorial we will create an endless looping waving flag. ( Check the tutorial DEMO online ) ... We will create our flag model in blender3D, set

CREATE YOUR SCENENow lets get something waving in your scene...

Lets create a new scene in Unity and drag in the BloopManager object. This prefab object can be found in the root folder of your imported Bloop package : /Assets/Bloop.

When you select this BloopManager in your scene hierarchy, you will find some settings in the property inspector :

REFERENCE | BloopManagerBloopsArray with your bloop TextAsset files ( loaded in that order )Frames Load Per CycleHow many keyframes are loaded each update cycle ( default = 10 )Display GUIDisplays debug information about the loading (and our logo)

Page 12: TUTORIAL - WyrmTale · PDF fileIn this tutorial we will create an endless looping waving flag. ( Check the tutorial DEMO online ) ... We will create our flag model in blender3D, set

By setting the bloops array size to 1 and dragging in the generated bloop file we instruct the bloopmanager to start loading our animation when the application starts.

Next is adding a model instance. You can use any of your imported frame objects for that , or make a copy and store that in a safe folder. Maybe you will be deleting the sequence as you do not really need it anymore when satisfied with the animation result.

You can add the object itself or the mesh that is located within the object.

To playback our animation we need to put the BloopPlayer.cs script from /Assets/Bloop/Scripts on the mesh object. It is the object that has the Mesh Renderer component attached.

In my tutorial , I have also setup UV, so I can also hook up a texture using a material.

Page 13: TUTORIAL - WyrmTale · PDF fileIn this tutorial we will create an endless looping waving flag. ( Check the tutorial DEMO online ) ... We will create our flag model in blender3D, set

To instruct the added BloopPlayer script to play the bloop file on this mesh we drag in the same generated bloop file onto the Bloop File inspector property.

REFERENCE | BloopPlayerBloop FileBloop file that has to be playedOffsetFrame number offset on animation startStart At Random FrameIf true, will start the animation at a random frameFpsAnimation playback speed in frames per secondPauze when out of viewIf true, the players is paused when the mesh is not in viewDisplay GUIIf true, will display the frame play sliderDisplay GUIY position of the GUI frame play slider

Page 14: TUTORIAL - WyrmTale · PDF fileIn this tutorial we will create an endless looping waving flag. ( Check the tutorial DEMO online ) ... We will create our flag model in blender3D, set

THATS IT! (JUST PLAY...)

The files for this tutorial are provided with the project. The scene is just a little different because I also generated and display the original sequence bloop file to show the difference.

You can check out a life demo of this tutorial on:http://www.wyrmtale.com/demo/products/bloop

Our website's product page :http://www.wyrmtale.com/products/unity3d-components/bloop