示例#1
0
        private void Render(Wire wire)
        {
            if (wire.Native == null)
            {
                if (m_segmentSpawner != null)
                {
                    m_segmentSpawner.Destroy();
                    m_segmentSpawner = null;
                }
                return;
            }

            if (m_positions == null)
            {
                m_positions          = new List <Vector3>();
                m_positions.Capacity = 256;
            }

            m_positions.Clear();

            agxWire.RenderIterator it    = wire.Native.getRenderBeginIterator();
            agxWire.RenderIterator endIt = wire.Native.getRenderEndIterator();
            while (!it.EqualWith(endIt))
            {
                m_positions.Add(it.getWorldPosition().ToHandedVector3());
                it.inc();
            }

            m_segmentSpawner.Begin();

            try
            {
                for (int i = 0; i < m_positions.Count - 1; ++i)
                {
                    Vector3 curr       = m_positions[i];
                    Vector3 next       = m_positions[i + 1];
                    Vector3 currToNext = next - curr;
                    float   distance   = currToNext.magnitude;
                    currToNext /= distance;
                    int   numSegments = Convert.ToInt32(distance * NumberOfSegmentsPerMeter + 0.5f);
                    float dl          = distance / numSegments;
                    for (int j = 0; j < numSegments; ++j)
                    {
                        next = curr + dl * currToNext;

                        m_segmentSpawner.CreateSegment(curr, next, wire.Radius);
                        curr = next;
                    }
                }
            }
            catch (System.Exception e)
            {
                Debug.LogException(e);
            }

            m_segmentSpawner.End();

            it.ReturnToPool();
            endIt.ReturnToPool();
        }
示例#2
0
        private void Render()
        {
            if (m_segmentSpawner == null)
            {
                return;
            }

            agxCable.Cable native = Cable.Native;
            if (native == null)
            {
                if (m_segmentSpawner != null)
                {
                    m_segmentSpawner.Destroy();
                    m_segmentSpawner = null;
                }
                return;
            }

            m_segmentSpawner.Begin();
            try {
                agxCable.CableIterator it    = native.begin();
                agxCable.CableIterator endIt = native.end();
                float radius = Cable.Radius;
                while (!it.EqualWith(endIt))
                {
                    m_segmentSpawner.CreateSegment(it.getBeginPosition().ToHandedVector3(), it.getEndPosition().ToHandedVector3(), radius);
                    it.inc();
                }
            }
            catch (System.Exception e) {
                Debug.LogException(e, this);
            }
            m_segmentSpawner.End();
        }
示例#3
0
        protected override void OnDestroy()
        {
            if (m_segmentSpawner != null)
            {
                m_segmentSpawner.Destroy();
            }
            m_segmentSpawner = null;

            base.OnDestroy();
        }
示例#4
0
        public void InitializeRenderer(bool destructLast = false)
        {
            if (destructLast && m_segmentSpawner != null)
            {
                m_segmentSpawner.Destroy();
                m_segmentSpawner = null;
            }

            m_segmentSpawner = new SegmentSpawner(GetComponent <Wire>(), @"Wire/WireSegment", @"Wire/WireSegmentBegin");
            m_segmentSpawner.Initialize(gameObject);
        }
示例#5
0
        public void InitializeRenderer(bool destructLast = false)
        {
            if (m_segmentSpawner != null)
            {
                m_segmentSpawner.Destroy();
                m_segmentSpawner = null;
            }

            m_segmentSpawner = new SegmentSpawner(Cable,
                                                  @"Cable/CableSegment",
                                                  @"Cable/CableSegmentBegin");
            m_segmentSpawner.Initialize(gameObject);
        }
示例#6
0
        protected override void OnDestroy()
        {
            if (m_segmentSpawner != null)
            {
                m_segmentSpawner.Destroy();
            }
            m_segmentSpawner = null;

            if (Simulation.HasInstance)
            {
                Simulation.Instance.StepCallbacks.PostStepForward -= Render;
            }

            base.OnDestroy();
        }
示例#7
0
        private void Render()
        {
            if (m_segmentSpawner == null)
            {
                return;
            }

            var native = Cable.Native;

            if (native == null)
            {
                if (m_segmentSpawner != null)
                {
                    m_segmentSpawner.Destroy();
                    m_segmentSpawner = null;
                }
                return;
            }

            var it    = native.begin();
            var endIt = native.end();

            m_segmentSpawner.Begin();
            try {
                float radius          = Cable.Radius;
                var   prevEndPosition = it.EqualWith(endIt) ?
                                        Vector3.zero :
                                        it.getBeginPosition().ToHandedVector3();
                while (!it.EqualWith(endIt))
                {
                    var endPosition = it.getEndPosition().ToHandedVector3();
                    m_segmentSpawner.CreateSegment(prevEndPosition, endPosition, radius);
                    prevEndPosition = endPosition;
                    it.inc();
                }
            }
            catch (System.Exception e) {
                Debug.LogException(e, this);
            }
            m_segmentSpawner.End();

            it.ReturnToPool();
            endIt.ReturnToPool();
        }