Ejemplo n.º 1
0
            public SkinnedMeshCapturer(AlembicExporter exp, ComponentCapturer parent, SkinnedMeshRenderer target)
                : base(exp, parent, target)
            {
                m_target = target;
                var mesh = target.sharedMesh;

                if (mesh == null)
                {
                    return;
                }

                m_abc  = parent.abc.NewPolyMesh(target.name);
                m_mbuf = new MeshBuffer();
                m_mbuf.SetupSubmeshes(m_abc, mesh, m_target.sharedMaterials);

                m_meshSrc = target.sharedMesh;
                m_cloth   = m_target.GetComponent <Cloth>();
                if (m_cloth != null)
                {
                    m_cbuf          = new ClothBuffer();
                    m_cbuf.rootBone = m_target.rootBone != null ? m_target.rootBone : m_target.GetComponent <Transform>();

                    var tc = m_parent as TransformCapturer;
                    if (tc != null)
                    {
                        tc.capturePosition = false;
                        tc.captureRotation = false;
                        tc.captureScale    = false;
                    }
                }
            }
Ejemplo n.º 2
0
 public CameraCapturer(AlembicExporter exp, ComponentCapturer parent, Camera target)
     : base(exp, parent, target)
 {
     m_abc    = parent.abc.NewCamera(target.name);
     m_target = target;
     m_params = target.GetComponent <AlembicCameraParams>();
 }
        void CreateCapturers()
        {
            m_root         = new RootCapturer(this, m_ctx.topObject);
            m_capture_node = new Dictionary <Transform, CaptureNode>();
            m_top_nodes    = new List <CaptureNode>();

            // construct tree
            // (bottom-up)
            if (m_settings.captureCamera)
            {
                foreach (var t in GetTargets <Camera>())
                {
                    var node = ConstructTree(t.GetComponent <Transform>());
                    node.componentType = t.GetType();
                }
            }
            if (m_settings.captureMeshRenderer)
            {
                foreach (var t in GetTargets <MeshRenderer>())
                {
                    var node = ConstructTree(t.GetComponent <Transform>());
                    node.componentType = t.GetType();
                }
            }
            if (m_settings.captureSkinnedMeshRenderer)
            {
                foreach (var t in GetTargets <SkinnedMeshRenderer>())
                {
                    var node = ConstructTree(t.GetComponent <Transform>());
                    node.componentType = t.GetType();
                }
            }
            if (m_settings.captureParticleSystem)
            {
                foreach (var t in GetTargets <ParticleSystem>())
                {
                    var node = ConstructTree(t.GetComponent <Transform>());
                    node.componentType = t.GetType();
                }
            }
            if (m_settings.customCapturer)
            {
                foreach (var t in GetTargets <AlembicCustomComponentCapturer>())
                {
                    var node = ConstructTree(t.GetComponent <Transform>());
                    node.componentType = typeof(AlembicCustomComponentCapturer);
                }
            }

            // make component capturers (top-down)
            foreach (var c in m_top_nodes)
            {
                SetupComponentCapturer(null, c);
            }


            m_top_nodes    = null;
            m_capture_node = null;
        }
Ejemplo n.º 4
0
 public TransformCapturer(ComponentCapturer parent, Transform target)
     : base(parent)
 {
     m_obj      = target.gameObject;
     m_abc      = AbcAPI.aeNewXForm(parent.abc, target.name + " (" + target.GetInstanceID().ToString("X8") + ")");
     m_target   = target;
     m_inherits = inherits;
 }
Ejemplo n.º 5
0
 public CameraCapturer(ComponentCapturer parent, Camera target)
     : base(parent)
 {
     m_obj    = target.gameObject;
     m_abc    = AbcAPI.aeNewCamera(parent.abc, target.name);
     m_target = target;
     m_params = target.GetComponent <AlembicCameraParams>();
 }
Ejemplo n.º 6
0
            public ParticleCapturer(AlembicExporter exp, ComponentCapturer parent, ParticleSystem target)
                : base(exp, parent, target)
            {
                m_abc    = parent.abc.NewPoints(target.name);
                m_target = target;

                m_prop_rotatrions = m_abc.NewProperty("rotation", aePropertyType.Float4Array);
            }
Ejemplo n.º 7
0
 public MeshCapturer(ComponentCapturer parent, MeshRenderer target)
     : base(parent)
 {
     m_obj         = target.gameObject;
     m_abc         = AbcAPI.aeNewPolyMesh(parent.abc, target.name);
     m_target      = target;
     m_mesh_buffer = new MeshBuffer();
 }
Ejemplo n.º 8
0
            public ParticleCapturer(ComponentCapturer parent, ParticleSystem target)
                : base(parent)
            {
                m_obj    = target.gameObject;
                m_abc    = AbcAPI.aeNewPoints(parent.abc, target.name);
                m_target = target;

                m_prop_rotatrions = AbcAPI.aeNewProperty(m_abc, "rotation", AbcAPI.aePropertyType.Float4Array);
            }
Ejemplo n.º 9
0
        public CameraCapturer CreateComponentCapturer(ComponentCapturer parent, Camera target)
        {
            if (m_debugLog)
            {
                Debug.Log("AlembicExporter: new CameraCapturer(\"" + target.name + "\")");
            }

            var cap = new CameraCapturer(this, parent, target);

            m_capturers.Add(cap);
            return(cap);
        }
Ejemplo n.º 10
0
        public MeshCapturer CreateComponentCapturer(ComponentCapturer parent, MeshRenderer target)
        {
            if (m_detailedLog)
            {
                Debug.Log("AlembicExporter: new MeshCapturer(\"" + target.name + "\"");
            }

            var cap = new MeshCapturer(parent, target);

            m_capturers.Add(cap);
            return(cap);
        }
Ejemplo n.º 11
0
        public SkinnedMeshCapturer CreateComponentCapturer(ComponentCapturer parent, SkinnedMeshRenderer target)
        {
            if (m_debugLog)
            {
                Debug.Log("AlembicExporter: new SkinnedMeshCapturer(\"" + target.name + "\")");
            }

            var cap = new SkinnedMeshCapturer(this, parent, target);

            m_capturers.Add(cap);
            return(cap);
        }
Ejemplo n.º 12
0
        public ParticleCapturer CreateComponentCapturer(ComponentCapturer parent, ParticleSystem target)
        {
            if (m_detailedLog)
            {
                Debug.Log("AlembicExporter: new ParticleCapturer(\"" + target.name + "\"");
            }

            var cap = new ParticleCapturer(parent, target);

            m_capturers.Add(cap);
            return(cap);
        }
        ParticleCapturer CreateComponentCapturer(ComponentCapturer parent, ParticleSystem target)
        {
            if (m_settings.debugLog)
            {
                Debug.Log("AlembicRecorder: new ParticleCapturer(\"" + target.name + "\")");
            }

            var cap = new ParticleCapturer(this, parent, target);

            m_capturers.Add(cap);
            return(cap);
        }
Ejemplo n.º 14
0
        public TransformCapturer CreateComponentCapturer(ComponentCapturer parent, Transform target)
        {
            if (m_detailedLog)
            {
                Debug.Log("AlembicExporter: new TransformCapturer(\"" + target.name + "\"");
            }

            var cap = new TransformCapturer(parent, target);

            m_capturers.Add(cap);
            return(cap);
        }
Ejemplo n.º 15
0
        public CustomCapturerHandler CreateComponentCapturer(ComponentCapturer parent, AlembicCustomComponentCapturer target)
        {
            if (m_debugLog)
            {
                Debug.Log("AlembicExporter: new CustomCapturerHandler(\"" + target.name + "\")");
            }

            target.CreateAbcObject(parent.abc);
            var cap = new CustomCapturerHandler(this, parent, target);

            m_capturers.Add(cap);
            return(cap);
        }
Ejemplo n.º 16
0
            public MeshCapturer(AlembicExporter exp, ComponentCapturer parent, MeshRenderer target)
                : base(exp, parent, target)
            {
                m_target = target;
                var mesh = m_target.GetComponent <MeshFilter>().sharedMesh;

                if (mesh == null)
                {
                    return;
                }

                m_abc  = parent.abc.NewPolyMesh(target.name);
                m_mbuf = new MeshBuffer();
                m_mbuf.SetupSubmeshes(m_abc, mesh, m_target.sharedMaterials);
            }
        public void EndRecording()
        {
            if (!m_recording)
            {
                return;
            }

            m_iidToRemove = null;
            m_newNodes    = null;
            m_nodes       = null;
            m_root        = null;
            m_ctx.Destroy(); // flush archive
            m_recording = false;

            Debug.Log("AlembicRecorder: end: " + m_settings.outputPath);
        }
Ejemplo n.º 18
0
            public SkinnedMeshCapturer(ComponentCapturer parent, SkinnedMeshRenderer target)
                : base(parent)
            {
                m_obj         = target.gameObject;
                m_abc         = AbcAPI.aeNewPolyMesh(parent.abc, target.name);
                m_target      = target;
                m_mesh_buffer = new MeshBuffer();

                if (m_target.GetComponent <Cloth>() != null)
                {
                    var t = m_parent as TransformCapturer;
                    if (t != null)
                    {
                        t.scale = false;
                    }
                }
            }
        public bool BeginRecording()
        {
            if (m_recording)
            {
                Debug.LogWarning("AlembicRecorder: already recording");
                return(false);
            }
            if (m_settings.scope == ExportScope.TargetBranch && targetBranch == null)
            {
                Debug.LogWarning("AlembicRecorder: target object is not set");
                return(false);
            }


            {
                var dir = Path.GetDirectoryName(m_settings.outputPath);
                if (!Directory.Exists(dir))
                {
                    try
                    {
                        Directory.CreateDirectory(dir);
                    }
                    catch (Exception)
                    {
                        Debug.LogWarning("AlembicRecorder: Failed to create directory " + dir);
                        return(false);
                    }
                }
            }

            // create context and open archive
            m_ctx = aeContext.Create();
            if (m_ctx.self == IntPtr.Zero)
            {
                Debug.LogWarning("AlembicRecorder: failed to create context");
                return(false);
            }

            m_ctx.SetConfig(ref m_settings.conf);
            if (!m_ctx.OpenArchive(m_settings.outputPath))
            {
                Debug.LogWarning("AlembicRecorder: failed to open file " + m_settings.outputPath);
                m_ctx.Destroy();
                return(false);
            }

            m_root                         = new RootCapturer(this, m_ctx.topObject);
            m_nodes                        = new Dictionary <int, CaptureNode>();
            m_newNodes                     = new List <CaptureNode>();
            m_iidToRemove                  = new List <int>();
            m_lastTimeSamplingIndex        = 1;
            m_startFrameOfLastTimeSampling = 0;

            // create capturers
            SetupCapturerTable();

            m_recording  = true;
            m_time       = m_timePrev = 0.0f;
            m_frameCount = 0;

            if (m_settings.conf.timeSamplingType == aeTimeSamplingType.Uniform && m_settings.fixDeltaTime)
            {
                Time.maximumDeltaTime = (1.0f / m_settings.conf.frameRate);
            }

            Debug.Log("AlembicRecorder: start " + m_settings.outputPath);
            return(true);
        }
Ejemplo n.º 20
0
        void CreateCapturers_Flat()
        {
            m_root = new RootCapturer(AbcAPI.aeGetTopObject(m_ctx));

            // Camera
            if (m_captureCamera)
            {
                foreach (var target in GetTargets <Camera>())
                {
                    if (ShouldBeIgnored(target))
                    {
                        continue;
                    }
                    var trans = CreateComponentCapturer(m_root, target.GetComponent <Transform>());
                    trans.inherits      = false;
                    trans.invertForward = true;
                    CreateComponentCapturer(trans, target);
                }
            }

            // MeshRenderer
            if (m_captureMeshRenderer)
            {
                foreach (var target in GetTargets <MeshRenderer>())
                {
                    if (ShouldBeIgnored(target))
                    {
                        continue;
                    }
                    var trans = CreateComponentCapturer(m_root, target.GetComponent <Transform>());
                    trans.inherits = false;
                    CreateComponentCapturer(trans, target);
                }
            }

            // SkinnedMeshRenderer
            if (m_captureSkinnedMeshRenderer)
            {
                foreach (var target in GetTargets <SkinnedMeshRenderer>())
                {
                    if (ShouldBeIgnored(target))
                    {
                        continue;
                    }
                    var trans = CreateComponentCapturer(m_root, target.GetComponent <Transform>());
                    trans.inherits = false;
                    CreateComponentCapturer(trans, target);
                }
            }

            // ParticleSystem
            if (m_captureParticleSystem)
            {
                foreach (var target in GetTargets <ParticleSystem>())
                {
                    if (ShouldBeIgnored(target))
                    {
                        continue;
                    }
                    var trans = CreateComponentCapturer(m_root, target.GetComponent <Transform>());
                    trans.inherits = false;
                    CreateComponentCapturer(trans, target);
                }
            }

            // handle custom capturers (AlembicCustomComponentCapturer)
            if (m_customCapturer)
            {
                foreach (var target in GetTargets <AlembicCustomComponentCapturer>())
                {
                    if (ShouldBeIgnored(target))
                    {
                        continue;
                    }
                    var trans = CreateComponentCapturer(m_root, target.GetComponent <Transform>());
                    trans.inherits = false;
                    CreateComponentCapturer(trans, target);
                }
            }
        }
Ejemplo n.º 21
0
 protected ComponentCapturer(ComponentCapturer p)
 {
     m_parent = p;
 }
Ejemplo n.º 22
0
 public CustomCapturerHandler(ComponentCapturer parent, AlembicCustomComponentCapturer target)
     : base(parent)
 {
     m_obj    = target.gameObject;
     m_target = target;
 }
Ejemplo n.º 23
0
 protected ComponentCapturer(AlembicExporter exp, ComponentCapturer p, Component c)
 {
     m_exporter = exp;
     m_parent   = p;
     m_obj      = c != null ? c.gameObject : null;
 }
Ejemplo n.º 24
0
 public TransformCapturer(AlembicExporter exp, ComponentCapturer parent, Transform target)
     : base(exp, parent, target)
 {
     m_abc    = parent.abc.NewXform(target.name + " (" + target.GetInstanceID().ToString("X8") + ")");
     m_target = target;
 }
 public ParticleCapturer(AlembicRecorder exp, ComponentCapturer parent, ParticleSystem target)
     : base(exp, parent, target)
 {
     m_abc    = parent.abcObject.NewPoints(target.name);
     m_target = target;
 }
Ejemplo n.º 26
0
 public CustomCapturerHandler(AlembicExporter exp, ComponentCapturer parent, AlembicCustomComponentCapturer target)
     : base(exp, parent, target)
 {
     m_target = target;
 }