WENIE RAHARDJA
Effects + CGI
  • work
  • Reel

Alembic Option Documentation

8/23/2016

 
AbcExport -h;
​
// AbcExport [options]
Options:
-h / -help  Print this message.
-prs / -preRollStartFrame double
-duf / -dontSkipUnwrittenFrames
-v / -verbose
-j / -jobArg string REQUIRED
-jobArg flags:
-a / -attr string
-df / -dataFormat string
-atp / -attrPrefix string (default ABC_)
-ef / -eulerFilter
-f / -file string REQUIRED
-fr / -frameRange double double
-frs / -frameRelativeSample double
-nn / -noNormals
-pr / -preRoll
-ro / -renderableOnly
-rt / -root
-s / -step double (default 1.0)
-sl / -selection
-sn / -stripNamespaces (optional int)
-u / -userAttr string
-uatp / -userAttrPrefix string
-uv / -uvWrite
-wcs / -writeColorSets
-wfs / -writeFaceSets
-wfg / -wholeFrameGeo
-ws / -worldSpace
-wv / -writeVisibility
-wc / -writeCreases
-mfc / -melPerFrameCallback string
-mpc / -melPostJobCallback string
-pfc / -pythonPerFrameCallback string
-ppc / -pythonPostJobCallback string

Complete description here
AbcImport -h;
//                                                                            
AbcImport  [options] File                                                 

Options:                                                                    
-rpr/ reparent      DagPath                                                                           -ftr/ fitTimeRange                                                          
-rcs / recreateAllColorSets                                                                     
-ct / connect       string node1 node2 ...                                                    -crt/ createIfNotFound                                                                      
-rm / removeIfNoUpdate                                                                
-sts/ setToStartFrame                                                       
-m  / mode          string ("open"|"import"|"replace")                
-ft / filterObjects "regex1 regex2 ..."                                   
-eft / excludeFilterObjects "regex1 regex2 ..."                                         -h  / help          Print this message                                      
-d  / debug         Turn on debug message printout                        

Complete description here

Alembic Cache Script Via Python

8/22/2016

 
Recently I found that there is no equivalent python command for alembic export import. I can't find the documentation on it either.
To read on the documentation, you have to call it in script editor using AbcExport -h and it only comes in mel.

So after further research, I found a way to do it the python way. Basically, you have to wrap the mel version in a string and use it on the jobArg (j) flag. 

For the alembic export

import maya.cmds as cmd

start = 0
end = 120
root = "-root pSphere1 -root pCube1"
save_name = "c:\documents\maya\project\default\cache\alembicTest.abc"

command = "-frameRange " + start + " " + end +" -uvWrite -worldSpace " + root + " -file " + save_name
cmd.AbcExport ( j = command )


 If you do print command you'll get the following result

-frameRange 0 120 -uvWrite -worldSpace -root pSphere1 -root pCube1 -file c:\documents\maya\project\default\cache\alembicTest.abc



The alembic import command doesn't have the jobArg flag so I figured that I can import maya.mel to my python script and use the eval command.

import maya.cmds as cmd
import maya.mel as mel
 command = "AbcImport -mode import -fitTimeRange -connect " + '"' + root + '"' + " " + '"' + save_name + '"' 

 mel.eval(command)

Notice that you need to include the double quote encasing the root and save_name  in the string. ' " '
 If you do print command you'll get the following result

AbcImport -mode import -fitTimeRange -connect "pSphere1 -root pCube1"  "c:\documents\maya\project\default\cache\alembicTest.abc"

Reference:
About alembic export, click  here

About wrapping melscript inside python, click here

Aligning Object Along the Curve with Translation Matrix

8/14/2016

 
I found this to be the easiest way to align object orientation along a curve. Using pointOnCurve command, you can query the position, tangent, and normal information. Using normal and tangent vector, find the bi normal / cross product and arrange all the numbers in a translation matrix with xform command. Normalized everything except position.
Picture
Finding the cross product
Mel or python has the "cross product" command, but to do it manually, you can do this:

Given the normal { Nx, Ny, Nz }   and tangent {Tx, Ty, Tz}

binormal = Ny*Tz - Nz*Ty , Nz*Tx - Nx*Tz, Nx*Ty - Ny*TX


​Prevent the normal from "roll" around the curve
Specify the "up vector" for the curve. For example, Y can be up vector. Using this information, find the normal by calculating the cross product between tangent and the up vector. 

Given the up vector { Ux, Uy, Uz }   and tangent {Tx, Ty, Tz}

normal = Uy*Tz - Uz*Ty , Uz*Tx - Ux*Tz, Ux*Ty - Uy*TX

Reference

https://ilmvfx.wordpress.com/2014/01/28/how-do-i-align-an-object-to-a-curve-without-using-a-constraint/

http://tutorial.math.lamar.edu/Classes/CalcII/CrossProduct.aspx


XGen Basic & Troubleshooting

8/13/2016

 
What happen when you create Xgen
  • It will create external xgen files specific to your scene file name and each collection in the scene. Every time you increment the scene, new xgen files will also be created.
  • It will create folders and files inside the “[project name] -> xgen -> collections” folder where it stores descriptions, maps, and other data.

​Export Xgen 
Xgen won’t do regular export / import process. Currently it also doesn’t export any materials attached to it. So when the Xgen is ready, export the following items:
  • Export the Xgen Collection
  • Export any shading network that are assigned to the description
​
Import Xgen
  • Import or reference the asset
  • Import Collection. It will ask if you want to increment the collection name or override existing one. In most cases, you can choose override.
  • Import the shading network
  • Assign the shader to xgen.

How to reference the same asset multiple times in the same scene with Xgen
  • Reference the asset using namespace
  • Select the grow geometry and import xgen colllection using the same namespace with your reference.
  • Currently, this error show up every time I import “Error: XGen:  Could not return bound geometry” but it seems to work fine, so just ignore it for now.
  • It will automatically create a new collection folder inside the xgen folder with the namespace.

Preparing Xgen for batch render
  • Before submitting to render farm, do the “Export patches for batch render”. It will create an alembic file for the grow geometry.
​

Troubleshooting

Namespace problem
In Maya the xgen name look like this nameSpace:collectionName, but the folder name is actually look like this ​​nameSpace__ns__collectionName because you can't have colon in the folder name. So in Maya, the Xgen file path should be automatically corrected to look for the later name.  Well, sometimes it doesn't do that and give you an error. You have to correct the file path. Go to xgen window, collection -> edit file path.

Save incremental issue
Sometimes when you do the “Increment & Save” for your scene, Xgen “freaks out”. It is saver if you “Save Scene As” and increment the scene manually.

Error on map painting and ptex baking:
Most likely caused by your shader. Try change the geometry shader to default / lambert.

Renderfarm settings
When submitting to Royal Render please confirm that “Allow Local Scene Copy” is disabled. When this option is enabled, Royal Render will copy your scene file to the local directory of the render machine but not the xgen files. Thus, Xgen won’t show up on your render.

Pymel / Python Quick Reference

8/13/2016

 
Query time slider value - use playbackOptions. 
link to documentation here
​

Importing pymel -> import pymel.core as pm

Convert to pynode -> pm.PyNode("[name]")

    Categories

    All
    Hair / Fur
    Scripting