Discovery, Inspirations, Thoughts.

Tuesday, 9 December 2014

Busy December

01:04 Posted by Unknown No comments
Kingdom Youth 2014 Christmas Play rehearsal

December's always a busy month for me every year. This year, Kingdom Youth is directing a play about the birth of Jesus Christ for our Christmas Service. On top of that, we had to perform a medley Christmas song too.

Then there's some design work to do for the performance, a wedding, some promotional materials for darling, and some branding work.

And I still have some props that I haven't completed for the Christmas play @.@

But all is well in God's spell (super forceful rhyme intended, I had always imagined God to be a superstar magician who can do anything by just saying it out). Looking at our younger batch of youths in KY befriending each other and willing to stay back for practice gives me the comfort I never imagined I would have. I do hope these new blood can do great things for the glory of God in many years to come!

Friday, 28 November 2014

Preparing 3D rig and animation files for Unity

17:30 Posted by Unknown , , No comments

After fumbling for a few days, we found out the best way (yet) to prepare 3D rig and animation FBX files for our Unity game. This is just a guide on how we prepare our files. The way we prepare the assets might or might not be suitable for you.

Getting the Rig/T-Pose file

1. Open up your animation .ma file. Import all references.
2. Select all Controllers (you can do it easily by muting mesh, joints and ik handle selection so that when you drag across your model, only NURB controllers are selected).
3. Zero out the translation and rotations.
4. File > Export All. Select FBX file type to export, and make sure the Animation checkbox is off before you export. Now you'll have your Rig/T-pose file.


Exporting Animations

1. Undo back few steps till the translations and rotations were not zero-ed out.
2. Open up your Axtended GUI window from your shelf. (If you haven't had Axtended installed yet, do refer to my post here to see how to do it)
3. Add your animations. Right-click on the Animation List area and click Add/Edit Animation.
4. Type in your animation name and its start and end frames, then click on Add to add the animation to your Animation List.
5. After you had finished adding in the animations, right-click on the Animation List area again and click Export List to File to export your animation list to a text file as a backup, just in case.
6. Before you start exporting, you need to Bake your animation. Go to Window > Hypergraph: Hierarchy and select everything inside the Hierarchy window. Then go to Edit > Keys > Bake Simulation.
7. After the baking is done, delete the mesh. Now you only have the bones and controllers in the scne.
8. Go to File > TOGGLE FBX in your Axtended window and make sure TOGGLE FBX is ON.
9. Start batch exporting your animation. Right-click on the Animation List area and click on Export All Animations
10. Wait for the process to be done! Now you'll have your Animation data files.

Importing Rig and Animation FBX into Unity

1. Drag the Rig and Animation FBX files into your Unity Project window to import them into Unity.
2. Go to the Rig tab of the files and select Generic from Animation Type, and Create From This Model for Avatar Definition. Hit Apply.
3. Select any animation FBX file and go to its Animation tab. You'll see the window below that says "No model is available for preview". Drag your rig FBX file to this window and click on the Play button at the window to see your animation.

Axtended: FBX Split Animation Batch Exporter Plugin

14:22 Posted by Unknown , No comments
Few days ago, I've been searching around for an FBX split animation batch exporter plugin for Maya so that we can reduce the time and effort taken to manually export each animation out of our characters. I've seen Axtended before during my hunt for plugins, but skipped it because it only exports the bone animations, which didn't work with our characters when only the bone animation data is imported into Unity. :(

After few hours of trying out different plugins, I came back to Axtended and decided to try and modify the script so that I can enable the Export All function instead of Export Selected function.

Thanks to Eva, my trusty sister/colleague working as a Python Developer, we managed to modify the script so that we can bypass the step of selecting the root_jnt, and straightaway Export All the assets into individual FBX files.

Here's the script that we modified, shown in red (basically just comment out the pre-requisite step of selecting a joint). Start from line 2355:
// Check if exporting as FBX
if(`optionVar -q axAnim_ExportAsFBX` == 1){
//if(size(`getAttr "AxtendedData.Selection"`) == 0){
//string $message  = "No joints has been defined for export!\n\n";
  //$message += "Either select the root joint (to automate selection) or all specific joints and then in File menu click [Set joints for export]. This is a one time setup.";

//confirmDialog -title "No joints defined" -message $message
//-button "OK"
//-defaultButton "OK";
//}
//else{
// Remember current values
//string $selection[] = `ls -sl`;

int $startFrame = `playbackOptions -q -minTime`;
int $endFrame   = `playbackOptions -q -maxTime`;
// Setup exporter and store current values
FBXExportBakeComplexAnimation -v true;
FBXExportBakeComplexStep -v 1;
FBXProperty "Export|IncludeGrp|Animation" -v true;
string $file;
if ($folder != " ")
$file = $defaultDirectory[0] + $parentFolder + $folder + "/" + $sequenceName + ".fbx";
else
$file = $defaultDirectory[0] + $parentFolder + "/" + $sequenceName + ".fbx";
// Set start time
playbackOptions -e -minTime  $startTime;
FBXExportBakeComplexStart -v $startTime;
// Set end time
if(`checkBox -q -v axAnim_FrameCheckbox` == 1) $endTime = $endTime - 1;
playbackOptions -e -maxTime $endTime;
FBXExportBakeComplexEnd  -v $endTime;
// Start exporting
axtendedLog(("[FBX] Exporting animation [" + $sequenceName + "] to [" + $file + "]"));
select -r `getAttr "AxtendedData.Selection"`;
FBXExport -f $file;
// Reset timeline and selection to previous values
playbackOptions -e -minTime $startFrame;
playbackOptions -e -maxTime $endFrame;
//select -r $selection;
//}
}

What's good about Axtended is that you can create a list of animations with its start/end frames and export this list into a text file, which you can import it back to your working file anytime you want. So no more hassle of manually keying in the start and end frames in your time slider and export each animation out whenever a rig is changed! And this makes your Animators happy :D

Axtended is very easy to use, and you'll only need to do a few steps to get your plugin up and running and start batch exporting your animations.
1. Download Axtended mel script from http://www.creativecrash.com/maya/script/axtended-animation-manager-fbx-psa
2. Open the script using any text editor, then edit the script like above, starting from line 2355.
3. Save the script, then place the script in your Maya scripts folder.
4. Open up your animation file in Maya, then Window > General Editor > Script Editor.
5. Load the axtended.mel script from the Script Editor and then click Execute.
6. Copy and paste this script below in the MEL tab of your Script Editor and Save Script to Shelf.
axtended();
7.  Click on the new Shelf Item you just created and the Axtended GUI window will pop up.
8. Right-click on the Animation List area and click Add/Edit Animation.
9. Type in your animation name and its start and end frames, then click on Add to add the animation to your Animation List.
10. After you had finished adding in the animations, right-click on the Animation List area again and click Export List to File to export your animation list to a text file as a backup, just in case.
11. Before you start exporting, you need to Bake your animation. Go to Window > Hypergraph: Hierarchy and select everything inside the Hierarchy window. Then go to Edit > Keys > Bake Simulation.
12. After the baking is done, you can start batch exporting your animation. To export FBX files, make sure you TOGGLE FBX to ON by going to File > TOGGLE FBX in your Axtended window. To start batch exporting, right-click on the Animation List area and click on Export All Animations. 
* Depending on your game asset preparation pipeline, you might want to delete the mesh before you start batch exporting. For our game, we only want the bones and controllers, so we delete the mesh for exporting animations.*
13. And you're done! Import all the animation files and your rig/t-pose file into Unity and you should be able to see it move :)


Thanks to Denny Lindberg for the Axtended script! It really helps our studio to save a lot of time and effort when we are preparing the animation FBX files, especially for characters that have A LOT of animations.

Thanks to Dustin Nelson for the Rapid Rig: Character Kit 0.0.2 too for the example rig shown in my screenshot above!

Links:
Axtended Animation Manager: http://www.creativecrash.com/maya/script/axtended-animation-manager-fbx-psa
Rapid Rig: Character Kit 0.0.2: http://www.creativecrash.com/maya/downloads/character-rigs/c/rapid-rig-character-kit

Thursday, 27 November 2014

Start blogging again

22:49 Posted by Unknown No comments

It's been a looooooooonnnnnnngggggg while since I've blogged. But recently, I feel that I should start blogging again, just to record down some tids and bits of inspirations and discoveries.

Well, let's see how long can I keep this habit up! :)