void OnEnable() { #if UNITY_STANDALONE_WIN AlembicImporter.AddLibraryPath(); #endif m_abc = AlembicImporter.aiCreateContext(); m_loaded = AlembicImporter.aiLoad(m_abc, m_path_to_abc); }
void Update() { if (!m_loaded) { m_loaded = AlembicImporter.aiLoad(m_abc, Application.streamingAssetsPath + "/" + m_path_to_abc); } if (m_loaded) { m_time += Time.deltaTime; if (Math.Abs(m_time - m_time_prev) > m_time_eps) { AlembicImporter.UpdateAbcTree(m_abc, GetComponent <Transform>(), m_reverse_x, m_reverse_faces, AdjustTime(m_time)); m_time_prev = m_time; } } }
static void ImportImpl(string path, bool reverse_x, bool reverse_faces) { if (path == "") { return; } #if UNITY_STANDALONE_WIN AlembicImporter.AddLibraryPath(); #endif aiContext ctx = aiCreateContext(); if (!aiLoad(ctx, Application.streamingAssetsPath + "/" + path)) { Debug.Log("aiLoad(\"" + path + "\") failed"); } else { GameObject root = new GameObject(); root.name = System.IO.Path.GetFileNameWithoutExtension(path); var abcstream = root.AddComponent <AlembicStream>(); abcstream.m_path_to_abc = path; abcstream.m_start_time = aiGetStartTime(ctx); abcstream.m_end_time = aiGetEndTime(ctx); abcstream.m_time_offset = -abcstream.m_start_time; abcstream.m_time_scale = 1.0f; abcstream.m_preserve_start_time = true; abcstream.m_reverse_x = reverse_x; abcstream.m_reverse_faces = reverse_faces; var ic = new ImportContext(); ic.parent = root.GetComponent <Transform>(); ic.reverse_x = reverse_x; ic.reverse_faces = reverse_faces; GCHandle gch = GCHandle.Alloc(ic); aiEnumerateChild(aiGetTopObject(ctx), ImportEnumerator, GCHandle.ToIntPtr(gch)); } aiDestroyContext(ctx); }
void OnDisable() { AlembicImporter.aiDestroyContext(m_abc); }