예제 #1
0
        protected virtual void Init()
        {
            if (vertices == null)
            {
                vertices = new VertexPositionTexture[originalTrailLength * 2];
                primitiveCount = (originalTrailLength - 1) * 2;
            }

            RecycleQueuedSegments();

            int iIndex = 0;

            for (int i = 0; i < originalTrailLength; i++)
            {
                TrailSegment newSegment = new TrailSegment(radius);
                //newSegment.Position = new Vector3(0, 0, 100);
                segments.AddLast(newSegment);

                VertexPositionTexture vVertex = new VertexPositionTexture();

                vVertex.Position = newSegment.Position;
                vertices[iIndex] = vVertex;

                vVertex.Position = newSegment.Position;
                vertices[iIndex + 1] = vVertex;

                iIndex += 2;
            }
            curHead = segments.First;

            for (int i = 0; i < controlPoints.Length; ++i)
            {
                controlPoints[i] = new TrailSegment(radius);
            }
        }
예제 #2
0
파일: DrawTrail.cs 프로젝트: andi2/LD32-4
 void OnDisable()
 {
     if (currentSegment)
         currentSegment.Complete();
     currentSegment = null;
     lastPoint = Vector3.zero;
     lastQuad = null;
 }
예제 #3
0
파일: DrawTrail.cs 프로젝트: gzuidhof/LD32
 void OnDisable()
 {
     if (currentSegment)
     {
         currentSegment.Complete();
     }
     currentSegment = null;
     lastPoint      = Vector3.zero;
     lastQuad       = null;
 }
예제 #4
0
파일: DrawTrail.cs 프로젝트: gzuidhof/LD32
    void Update()
    {
        bool    keepLastPoint = false;
        Vector3 currentPoint  = GetNewPoint();

        bool canDraw = !NoDraw.isInNoDraw(currentPoint);


        if (Input.GetKeyUp(KeyCode.Mouse0) || !canDraw)
        {
            if (currentSegment)
            {
                currentSegment.Complete();
            }
            currentSegment = null;
            lastPoint      = Vector3.zero;
            lastQuad       = null;
        }

        if (currentPoint == Vector3.zero || !Input.GetKey(KeyCode.Mouse0) || !canDraw)
        {
            lastPoint      = Vector3.zero;
            currentSegment = null;
            lastQuad       = null;
            return;
        }



        if (lastPoint != Vector3.zero)
        {
            if (currentSegment == null) //Create first part of new segment
            {
                lastQuad       = MakeQuad(lastPoint, currentPoint, lineSize);
                currentSegment = CreateNewSegment(lastQuad);
            }

            else if (Vector3.Distance(currentPoint, lastPoint) > minimumSectionLength)  //Continue segment
            {
                lastQuad = MakeQuadWithPrevious(lastPoint, currentPoint, lastQuad, lineSize);
                currentSegment.AddLine(lastQuad, false);
                currentSegment.CreateCollider();
            }
            else //Don't draw section yet, not big enough section
            {
                keepLastPoint = true;
            }
        }

        if (!keepLastPoint)
        {
            lastPoint = currentPoint;
        }
    }
예제 #5
0
 private TrailSegment GetNewQueueSegment()
 {
     TrailSegment retSeg;
     if (recycledSegments.First != null)
     {
         retSeg = recycledSegments.First.Value;
         recycledSegments.RemoveFirst();
     }
     else
     {
         retSeg = new TrailSegment(radius);
     }
     return retSeg;
 }
예제 #6
0
 public void Move(Vector3 pos, Vector3 right, Vector3 normal)
 {
     TrailSegment seg = GetNewQueueSegment();
     seg.UpdateData(pos, right, normal);
     segmentsToAdd.AddLast(seg);
 }
예제 #7
0
    public void CreatePelletsFromSegment(TrailSegment segment, Vector3 startPos)
    {
        //instantiate all the positions
        //get the position list
        List<Vector3> positions = segment.Positions;

        foreach(Vector3 p in positions)
        {
            AddPellet(p + startPos);
        }
    }
예제 #8
0
    TrailSegment CreateSegment(Vector3 direction, float spacing, int pelletCount)
    {
        TrailSegment newSeg = new TrailSegment();

        //work out the start and end points based on the direction and spacing
        newSeg.startPos = new Vector3(0,0,0);

        newSeg.endPos = direction.normalized * (spacing * pelletCount);
        newSeg.numPellets = pelletCount;

        return newSeg;
    }
예제 #9
0
파일: DrawTrail.cs 프로젝트: andi2/LD32-4
    void Update()
    {
        bool keepLastPoint = false;
        Vector3 currentPoint = GetNewPoint();

        bool canDraw = !NoDraw.isInNoDraw(currentPoint);

        if (Input.GetKeyUp(KeyCode.Mouse0) || !canDraw)
        {
            if (currentSegment)
                currentSegment.Complete();
            currentSegment = null;
            lastPoint = Vector3.zero;
            lastQuad = null;
        }

        if (currentPoint == Vector3.zero || !Input.GetKey(KeyCode.Mouse0) || !canDraw)
        {
            lastPoint = Vector3.zero;
            currentSegment = null;
            lastQuad = null;
            return;
        }

        if (lastPoint != Vector3.zero) {

            if (currentSegment == null) //Create first part of new segment
            {
                lastQuad = MakeQuad(lastPoint, currentPoint, lineSize);
                currentSegment = CreateNewSegment(lastQuad);
            }

            else if (Vector3.Distance(currentPoint, lastPoint) > minimumSectionLength)  //Continue segment
            {
                lastQuad = MakeQuadWithPrevious(lastPoint, currentPoint, lastQuad, lineSize);
                currentSegment.AddLine(lastQuad, false);
                currentSegment.CreateCollider();

            }
            else //Don't draw section yet, not big enough section
            {
                keepLastPoint = true;
            }
        }

        if (!keepLastPoint)
        {
            lastPoint = currentPoint;
        }
    }