"""
The sample code demonstrates how to construction a camera sequencer shot with cached ICE simulations
"""
# 1) Create a basic emission from grid and cache the ICE simulation to file
Application.NewScene( "", False )
Application.CreatePrim("Grid", "MeshSurface", "", "")
Application.ICEFlow_CreateParticles("", "", "")
Application.CacheObjectsIntoFile( "pointcloud", 5, 1, 100, 1, True, True,
"Color,Force,Mass,NbSubSamples,Orientation,PointPosition,PointVelocity,Scale,Shape,SimulatedFrameFraction,Size,State_ID",
"ICECache1",
XSIUtils.BuildPath( "[project path]", "Simulation", "[model]", "[object]", "[object]_ICECache1_#.icecache" ),
False )
# 2) Create a new point cloud and apply the cached simulation
Application.NewScene( "", False )
Application.GetPrim( "pointcloud", "ice_cached_cloud" )
Application.AddFileCacheSource( "ice_cached_cloud",
XSIUtils.BuildPath( "[project path]", "Simulation", "scene_root", "pointcloud", "pointcloud_ICECache1_[1..100].icecache" ),
"", "" )
# 3) Create Camera Sequencer Shot Clips
Application.AddShotClip( "", "Shot1", "", 1, 80, 99 )
Application.AddShotClip( "", "Shot2", "", 25, 1, 31 )
Application.AddShotClip( "", "Shot3", "", 60, 80, 99 )
Application.SceneRefresh()
# 4) Plot the cached ICE simulation in the Camera Sequencer
RetVal = Application.PlotCamSeqForCachedObjects( XSIUtils.BuildPath( "[project path]", "Simulation", "CamSeq", "ice_cached_cloud_CamSeqCache_#.icecache" ),
1, 100, "", "", False )
Application.LogMessage( "Name of cached cloud: " + RetVal[0] )
Application.LogMessage( "Location of cache files: " + RetVal[1] )
Application.LogMessage( "Collection of clips to be deleted: " + RetVal[2].GetAsText() )
# 5) Re-apply plotted cache simulation back to the pointcloud
Application.ApplyCamSeqFileCacheSources( RetVal[0], RetVal[1], RetVal[2] ) |