SetPosition() public method

Set the position of the vertex in the line.

public SetPosition ( int index, Vector3 position ) : void
index int Which position to set.
position Vector3 The new position.
return void
コード例 #1
0
		void Start()
		{
			startTime = Time.time;
			prevPosition = gameObject.transform.position;
			
			sourceOriginalV = sourceVessel.rigidbody.velocity;
			
			Light light = gameObject.AddComponent<Light>();
			light.type = LightType.Point;
			light.color = lightColor;
			light.range = 8;
			light.intensity = 1;
			
			bulletTrail = gameObject.AddComponent<LineRenderer>();
			bulletTrail.SetVertexCount(2);
			bulletTrail.SetPosition(0, transform.position);
			bulletTrail.SetPosition(1, transform.position);
			bulletTrail.SetWidth(tracerStartWidth, tracerEndWidth);
			bulletTrail.material = new Material(Shader.Find("KSP/Particles/Alpha Blended"));
			bulletTrail.material.mainTexture = GameDatabase.Instance.GetTexture("BDArmory/Textures/bullet", false);
			bulletTrail.material.SetColor("_TintColor", projectileColor);
			
			rigidbody.useGravity = false;
			
		}
コード例 #2
0
    // Following method sets border of MagnifyGlass
    private void createBordersForMagniyGlass()
    {
        magnifyBorders = new GameObject ();
        LeftBorder = getLine ();
        LeftBorder.SetVertexCount(2);
        LeftBorder.SetPosition(0,new Vector3(getWorldPosition(new Vector3(MGOX,MG0Y,0)).x,getWorldPosition(new Vector3(MGOX,MG0Y,0)).y-0.1f,-1));
        LeftBorder.SetPosition(1,new Vector3(getWorldPosition(new Vector3(MGOX,MG0Y+MGHeight,0)).x,getWorldPosition(new Vector3(MGOX,MG0Y+MGHeight,0)).y+0.1f,-1));
        LeftBorder.transform.parent = magnifyBorders.transform;

        TopBorder = getLine ();
        TopBorder.SetVertexCount(2);
        TopBorder.SetPosition(0,new Vector3(getWorldPosition(new Vector3(MGOX,MG0Y+MGHeight,0)).x,getWorldPosition(new Vector3(MGOX,MG0Y+MGHeight,0)).y,-1));
        TopBorder.SetPosition(1,new Vector3(getWorldPosition(new Vector3(MGOX+MGWidth,MG0Y+MGHeight,0)).x,getWorldPosition(new Vector3(MGOX+MGWidth,MG0Y+MGHeight,0)).y,-1));
        TopBorder.transform.parent = magnifyBorders.transform;

        RightBorder = getLine ();
        RightBorder.SetVertexCount(2);
        RightBorder.SetPosition(0,new Vector3(getWorldPosition(new Vector3(MGOX+MGWidth,MG0Y+MGWidth,0)).x,getWorldPosition(new Vector3(MGOX+MGWidth,MG0Y+MGWidth,0)).y+0.1f,-1));
        RightBorder.SetPosition(1,new Vector3(getWorldPosition(new Vector3(MGOX+MGWidth,MG0Y,0)).x,getWorldPosition(new Vector3(MGOX+MGWidth,MG0Y,0)).y-0.1f,-1));
        RightBorder.transform.parent = magnifyBorders.transform;

        BottomBorder = getLine ();
        BottomBorder.SetVertexCount(2);
        BottomBorder.SetPosition(0,new Vector3(getWorldPosition(new Vector3(MGOX+MGWidth,MG0Y,0)).x,getWorldPosition(new Vector3(MGOX+MGWidth,MG0Y,0)).y,-1));
        BottomBorder.SetPosition(1,new Vector3(getWorldPosition(new Vector3(MGOX,MG0Y,0)).x,getWorldPosition(new Vector3(MGOX,MG0Y,0)).y,-1));
        BottomBorder.transform.parent = magnifyBorders.transform;
    }
コード例 #3
0
ファイル: CannonShell.cs プロジェクト: kevincoggins/BDArmory
		void Start()
		{
			startTime = Time.time;
			prevPosition = gameObject.transform.position;
			
			Light light = gameObject.AddComponent<Light>();
			light.type = LightType.Point;
			light.range = 15;
			light.intensity = 8;
			
			audioSource = gameObject.AddComponent<AudioSource>();
			audioSource.minDistance = 0.1f;
			audioSource.maxDistance = 75;
			audioSource.clip = GameDatabase.Instance.GetAudioClip("BDArmory/Sounds/shellWhistle");
			audioSource.volume = Mathf.Sqrt(GameSettings.SHIP_VOLUME);// * 0.85f;
			audioSource.dopplerLevel = 0.02f;
			
			explosion = GameDatabase.Instance.GetModel("BDArmory/Models/explosion/explosion");
			explosion.SetActive(true);
			
			bulletTrail = gameObject.AddComponent<LineRenderer>();
			bulletTrail.SetVertexCount(2);
			bulletTrail.SetPosition(0, transform.position);
			bulletTrail.SetPosition(1, transform.position);
			bulletTrail.SetWidth(tracerStartWidth, tracerEndWidth);
			bulletTrail.material = new Material(Shader.Find("KSP/Particles/Additive"));
			bulletTrail.material.mainTexture = GameDatabase.Instance.GetTexture("BDArmory/Textures/bullet", false);
			bulletTrail.material.SetColor("_TintColor", projectileColor);
			
			
			rigidbody.useGravity = false;
			
		}
コード例 #4
0
    void Start()
    {
        //get line renderer of current component
        lineRenderer = GetComponent<LineRenderer> ();

        //every line needs to have at least 2 points to be relevant
        if (segments < 2) {
            segments = 2;
        }

            //we draw an arch by calculating a midpoint relative to the line renderer original position
            lineRenderer.SetVertexCount (segments);
            midpoint = new Vector2 (Random.Range (-radius, radius), Random.Range (-radius, radius));
            //Debug.Log (segments);
            for (int i = 1; i < segments -1; i++) {
                // 16 si 2 unde maxz = 8

                I1 = 1;
                I2 = maxZ;

                float z = ((float)i) * maxZ / (float)(segments - 1);
                float x = -midpoint.x * z * z / I2 + z * midpoint.x / I1;
                float y = -midpoint.y * z * z / I2 + z * midpoint.y / I1;

                //every poin in the line renderer between its endings is manipulated according
                //to the midpoint + certain abberations of movement
                lineRenderer.SetPosition (i, new Vector3 (x + Random.Range (-posRange, posRange), (y + Random.Range (-posRange, posRange)), z));
            }
            //line renderer endings remain at 0-0-0
            lineRenderer.SetPosition (0, new Vector3 (0f, 0f, 0f));
            lineRenderer.SetPosition (segments - 1, new Vector3 (0f, 0f, maxZ));
    }
コード例 #5
0
ファイル: Bullet.cs プロジェクト: Andrewnopoulos/Strain
    // Use this for initialization
    void Start()
    {
        float distance = 500;

        layermask = ((1 << 10) | (1 << 11) | (1 << 12));

        startPos = transform.position;

        lineRenderer = transform.GetComponent<LineRenderer> ();

        ray = new Ray (transform.position, transform.forward);
        RaycastHit hit;
        if (Physics.Raycast (ray, out hit, 1000, layermask))
        {
            collidedObject = hit.collider.gameObject;

            distance = hit.distance;

            if (collidedObject.layer == 10 || collidedObject.layer == 12)
            {
                NPC script = collidedObject.GetComponent<NPC>();
                script.health -= damage;
                GameObject bloodSpray = (GameObject)Instantiate(blood, transform.position + transform.forward * distance, transform.rotation);
                bloodSpray.transform.parent = collidedObject.transform;
                script.GetPushed(transform.forward * 0.5f);
            }
        }

        endPos = startPos + (transform.forward * distance);

        lineRenderer.SetPosition (0, startPos);
        lineRenderer.SetPosition (1, endPos);
    }
コード例 #6
0
ファイル: DrawLine.cs プロジェクト: osROSE/UnityRose
 // Use this for initialization
 void Start()
 {
     lineRenderer = GetComponent<LineRenderer>();
     lineRenderer.SetPosition(0, p0.position);
     lineRenderer.SetPosition(1, p1.position);
     lineRenderer.SetWidth(.02f, 0.02f);
 }
コード例 #7
0
ファイル: LineController.cs プロジェクト: telhurin/Test
 // Use this for initialization
 void Start()
 {
     lineRenderer = GetComponent<LineRenderer>();
     lineRenderer.SetPosition(0, origin.position);
     lineRenderer.SetPosition(1, origin.position + (destination.position - origin.position) * 0);
     distance = Vector3.Distance(origin.position, destination.position);
 }
コード例 #8
0
ファイル: s_RouteControl.cs プロジェクト: Jwho303/Night-Watch
    public void RouteGraphicsPopulate(int patroli)
    {
        //populate stage
        line = new GameObject();
        line.name = "Trail "+(patroli+1);
        linerenderer = line.AddComponent<LineRenderer>();

        for (int ii = 0; ii < patrol[patroli].waypoint.Count; ii++)
        {
        //Waypoint Objects
        Vector3 spawn;
        spawn = new Vector3(patrol[patroli].waypoint[ii].Coord.x, patrol[patroli].waypoint[ii].Coord.y+0.1f, patrol[patroli].waypoint[ii].Coord.z);
        WpObject = (GameObject)Instantiate(WPModel,spawn, Quaternion.identity);
        WpObject.name ="WP "+(patroli+1)+"."+(ii+1);
        WpText = WpObject.GetComponentInChildren<TextMesh>();
        WpText.text = (patroli + 1) + "." + (ii + 1);
        //Trail / LineRenderer
        linerenderer.SetVertexCount(patrol[patroli].waypoint.Count+1);
        linerenderer.SetWidth(0.1f,0.1f);
        //linerenderer.material.color = Color.green;
        line.renderer.enabled = true;
        linerenderer.renderer.material = TrailMaterial;
        linerenderer.SetPosition(ii,patrol[patroli].waypoint[ii].Coord);
        linerenderer.SetPosition(patrol[patroli].waypoint.Count,patrol[patroli].waypoint[0].Coord);

        }
    }
コード例 #9
0
    // Use this for initialization
    void Start()
    {
        lr = GetComponent<LineRenderer>();

        if (!customColor)
        {
            if (hit) col = new Color(0,1,1,0.35f);
            if (!hit) col = new Color(1,0.5f,0,0.35f);
        }

        lr.SetColors(col,col);

        float distance = Vector3.Distance(start,end);
        Vector3 direction = (end-start).normalized;

        int stepCount = Mathf.FloorToInt(distance / 0.5f);

        points = new Vector3[stepCount];
        moves = new Vector3[stepCount];
        for (int i=0; i<stepCount; i++){
            points[i] = start + (direction * i * 0.5f);
            points[i] += new Vector3(Random.Range(-Spread,Spread),Random.Range(-Spread,Spread),Random.Range(-Spread,Spread));
            moves[i] = new Vector3(Random.Range(-Spread,Spread),Random.Range(-Spread,Spread),Random.Range(-Spread,Spread));
        }

        lr.SetVertexCount(points.Length+1);
        for (int i=0; i<stepCount; i++){
            lr.SetPosition(i,points[i]);
        }
        lr.SetPosition(points.Length,end);
        //lr.SetPosition(0,start);
        //lr.SetPosition(1,end);
    }
コード例 #10
0
ファイル: fishingLine.cs プロジェクト: Haserde/Week-5
 // Update is called once per frame
 void Update()
 {
     line = transform.GetComponent<LineRenderer> ();
         line.SetVertexCount (2);
         line.SetPosition (0, gameObject.transform.position);
         line.SetPosition (1, length.transform.position);
 }
コード例 #11
0
ファイル: Lightning.cs プロジェクト: ddoodm/Mowdown
    void Start()
    {
        player = GameObject.FindWithTag("Player");
        enemy = GameObject.FindWithTag("Enemy");
        if (enemy != null && player != null)
        {
            if (Vector3.Distance(player.transform.position, this.transform.position) < 5)
            {
                opponent = GameObject.FindGameObjectWithTag("Enemy").GetComponent<Transform>();
            }
            else
            {
                opponent = GameObject.FindGameObjectWithTag("Player").GetComponent<Transform>();
            }
        }

        lineRenderer = GetComponent<LineRenderer>();
        lineRenderer.SetVertexCount(noSegments);

        for(int i = 1; i < noSegments - 1; i++)
        {
            float z = ((float)i) * (maxZ) / (float)(noSegments - 1);

            lineRenderer.SetPosition(i, new Vector3(opponent.position.x + Random.Range(-posRange, posRange), opponent.position.y + Random.Range(-posRange, posRange), opponent.position.z));
        }

        lineRenderer.useWorldSpace = true;
        lineRenderer.SetPosition(0, this.transform.position);
        lineRenderer.SetPosition(noSegments - 1, opponent.position);
    }
コード例 #12
0
ファイル: DrawingScript.cs プロジェクト: rgerd/TunnelVision
 private void drawRayLine(LineRenderer lr, Vector3 pt1, Vector3 pt2)
 {
     lr.enabled = true;
     lr.SetColors(markerColor, markerColor);
     lr.SetPosition(0, pt1);
     lr.SetPosition(1, pt2);
 }
コード例 #13
0
ファイル: TowerAIClient.cs プロジェクト: Burzok/GodlyCubes
 void Awake()
 {
     towerReloader = transform.parent.GetComponent<TowerReloaderClient>();
     laserPointer = transform.parent.Find("Laser").GetComponent<LineRenderer>();
     laserPointer.SetPosition(0,laserPointer.transform.position);
     laserPointer.SetPosition(1,laserPointer.transform.position);
 }
コード例 #14
0
ファイル: LineDragNDraw.cs プロジェクト: TAPeri/WordsMatter
    public void reset()
    {
        startPos.x = 0;
        startPos.y = 0;
        startPos.z = 0;

        endPos.x = 0;
        endPos.y = 0;
        endPos.z = 0;

        penDown = false;
        sessionStart = false;
        inSession = false;

        localLRend = this.transform.gameObject.GetComponent<LineRenderer>();
        localLRend.material = new Material(Shader.Find("Diffuse"));
        localLRend.material.color = Color.black;
        localLRend.castShadows = false;
        localLRend.receiveShadows = false;
        localLRend.SetVertexCount(2);
        localLRend.SetWidth(lineThickness,lineThickness);
        localLRend.SetColors(Color.black,Color.black);

        localLRend.SetPosition(0,Vector3.zero);
        localLRend.SetPosition(1,Vector3.zero);
        localLRend.enabled = false;
    }
コード例 #15
0
ファイル: Connection.cs プロジェクト: Deus0/Zeltex
	public void CreateLine() {
		MyLine = gameObject.AddComponent<LineRenderer> ();
		MyLine.SetWidth (LineWidth,LineWidth);
		MyLine.SetVertexCount (2);
		MyLine.SetPosition (0, NeuronA.transform.position);
		MyLine.SetPosition (1, NeuronB.transform.position);
		MyLine.material = MyMaterial;
	}
コード例 #16
0
    void Start()
    {
        lr = GetComponent<LineRenderer>();

        resources = GetComponent<IdManager>().res;
        lr.SetPosition(0, transform.position + Vector3.forward);
        lr.SetPosition(1, transform.position + Vector3.forward);
    }
コード例 #17
0
 public void SetLight(float startWidth, float endWidth, Color color, Vector3 startPoint, Vector3 endPoint)
 {
     _lineRenderer = GetComponent<LineRenderer>();
     _lineRenderer.SetPosition(0, startPoint);
     _lineRenderer.SetPosition(1, endPoint);
     _lineRenderer.SetWidth(startWidth, endWidth);
     _lineRenderer.SetColors(color, color);
 }
コード例 #18
0
ファイル: Laser.cs プロジェクト: Jalict/rap
 void Start()
 {
     line = GetComponent<LineRenderer>();
     if (other != null) {
         line.SetPosition(0, transform.position);
         line.SetPosition(1, other.position);
     }
 }
コード例 #19
0
ファイル: Hook.cs プロジェクト: cookie966507/Fire-On-Ice
 void Start()
 {
     anim = owner.GetComponent<Animation> ();
     abilityReady = true;
     lineRender = GetComponent<LineRenderer>();
     lineRender.SetPosition(0, transform.position);
     lineRender.SetPosition(1, transform.position);
 }
コード例 #20
0
ファイル: LineController.cs プロジェクト: MDemaille/GGJ16
	void Start(){
		lineRenderer = GetComponent<LineRenderer> ();

		lineRenderer.SetPosition (0, start.position);
		lineRenderer.SetPosition (1, end.position);

		StartCoroutine (AnimLine ());
	}
コード例 #21
0
ファイル: BallControl.cs プロジェクト: yaokailing/HoloInOne
 private void InitializeAimLine()
 {
     var ray = GetRayCameraToBall();
     this.aimLine = this.gameObject.GetComponent<LineRenderer>();
     aimLine.SetColors(Color.red, Color.red);
     aimLine.SetWidth(0.02f, 0.02f);
     aimLine.SetPosition(0, ray.origin);
     aimLine.SetPosition(1, ray.origin + (ray.direction/2));
 }
コード例 #22
0
ファイル: UnityLink.cs プロジェクト: vs-team/casanova-mk2
 // Use this for initialization
 void Start()
 {
   LineRenderer = this.GetComponent<LineRenderer>();
   LineRenderer.SetVertexCount(2);
   var p1 = GameObject.Find(Beginning);
   var p2 = GameObject.Find(End);
   LineRenderer.SetPosition(0, p1.transform.position);
   LineRenderer.SetPosition(1, p2.transform.position);
 }
コード例 #23
0
 public void drawLine(Color color, Vector3 start, Vector3 end, float loss)
 {
     lineRenderer = gameObject.GetComponent<LineRenderer> ();
     //lineRenderer.material = new Material(Shader.Find("Particles/Additive"));
     lineRenderer.SetWidth (3f, 3f);
     lineRenderer.SetColors(color, color);
     lineRenderer.SetPosition (0, start);
     lineRenderer.SetPosition (1, end);
 }
コード例 #24
0
    // Use this for initialization
    void Start()
    {
        lr = GetComponent<LineRenderer>();

        lr.SetPosition(0,start);
        lr.SetPosition(1,end);
        lr.SetWidth(width,width);
        lr.SetColors(col,col);
    }
コード例 #25
0
ファイル: InputOverlord.cs プロジェクト: hhogwood/orbit
    public void Init()
    {
        //StartCoroutine(Delay());

        lineObject = GameObject.Instantiate(Overlord.instance.LinePrefab) as GameObject;
        line = lineObject.GetComponent<LineRenderer>();
        line.SetPosition(0, Vector3.zero);
        line.SetPosition(1, Vector3.zero);
    }
コード例 #26
0
ファイル: Bullet.cs プロジェクト: GameDesignGroup6/MazeFPS
 // Use this for initialization
 void Start()
 {
     line = GetComponent<LineRenderer>();
     source = GetComponent<AudioSource>();
     line.SetPosition(0,transform.position);
     line.SetPosition(1,transform.position);
     oldPos = transform.position;
     Destroy (gameObject,maxLife);
 }
コード例 #27
0
ファイル: DrawLine.cs プロジェクト: MarsSnow/Fleshiness
    private void Start()
    {
        lineRenderer = LineRenderGameObject.GetComponent<LineRenderer>();
        lineRenderer.SetVertexCount(lineLength);

        lineRenderer.SetPosition(0, v0);
        lineRenderer.SetPosition(1, v1);
        lineRenderer.SetPosition(2, v2);
        lineRenderer.SetPosition(3, v3);
    }
コード例 #28
0
    void MakeIonTrail(Vector3 originPosition, Vector3 endPosition)
    {
        GameObject trail = (GameObject) Instantiate(ionTrail);
        line = trail.GetComponent<LineRenderer>();

        line.SetWidth(0.05f,0.05f);

        line.SetPosition(0,originPosition);
        line.SetPosition(1,endPosition);
    }
コード例 #29
0
ファイル: Laser.cs プロジェクト: redahanb/Spectral
    // Use this for initialization
    void Start()
    {
        alertSystem = GameObject.Find("Alert System").GetComponent<AlertManager>();

        hitPosition = transform.position + new Vector3(0,0,20);

        lRenderer = GetComponent<LineRenderer>();
        lRenderer.SetPosition(0, transform.position);
        lRenderer.SetPosition(1, hitPosition);
    }
コード例 #30
0
 void Start()
 {
     line = transform.GetComponent<LineRenderer> ();
     line.SetVertexCount (5);
     line.SetPosition (0, new Vector3 (-1, 1, 0));
     line.SetPosition (1, new Vector3 (1, 1, 0));
     line.SetPosition (2, new Vector3 (1, -1, 0));
     line.SetPosition (3, new Vector3 (-1, -1, 0));
     line.SetPosition (4, new Vector3 (-1, 1, 0));
 }
コード例 #31
0
 static public int SetPosition(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.LineRenderer self = (UnityEngine.LineRenderer)checkSelf(l);
         System.Int32             a1;
         checkType(l, 2, out a1);
         UnityEngine.Vector3 a2;
         checkType(l, 3, out a2);
         self.SetPosition(a1, a2);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
コード例 #32
0
ファイル: LineLR.cs プロジェクト: roki512/FriendlyLines
        // Update is called once per frame
        void Update()
        {
            while (_lrVerticesCount < _vertices.Count)
            {
                _lineRenderer.SetVertexCount(_lrVerticesCount + 1);
                _lineRenderer.SetPosition(_lrVerticesCount, _vertices[_lrVerticesCount]);

                _lrVerticesCount++;
            }

            if (_size != _lrSize)
            {
                _lrSize = _size;
                _lineRenderer.SetWidth(_lrSize, _lrSize);
            }

            if (_lrColor != _color)
            {
                _lrColor = _color;
                _lineRenderer.SetColors(_color, _color);
            }

            if (_lrSortingLayer != _sortingLayer)
            {
                _lrSortingLayer = _sortingLayer;
                _lineRenderer.sortingLayerName = _lrSortingLayer;
            }
        }
コード例 #33
0
    /// <summary>
    /// 等高線図のXYZ軸の表示長さをセットする
    /// </summary>
    /// <param name="yWidth">表示内容(圧力、計算格子)に応じて変更する</param>
    private void ResizeGraph(float yWidth)
    {
        try
        {
            float Xwidth     = m_RCShader.CalAreaX;
            float Zwidth     = m_RCShader.CalAreaZ;
            float Ywidth     = yWidth;
            float magnitudeX = m_Xwidth / Xwidth;
            float magnitudeZ = m_Zwidth / Zwidth;
            float magnitudeY = m_Ywidth / Ywidth;

            this.m_MeshFilter.transform.localScale = new Vector3(magnitudeX, magnitudeY, magnitudeZ);

            Vector3 originePos = new Vector3(0, 0, 0);
            Vector3 xPos       = new Vector3(m_Xwidth, 0, 0);
            Vector3 zPos       = new Vector3(0, 0, m_Zwidth);
            Vector3 yPos       = new Vector3(0, m_Ywidth, 0);


            UnityEngine.EventSystems.ExecuteEvents.Execute <AxisLabel.IMessageSend>(m_OrigineBillBoard, null, (sender, eventData) => { sender.UpdateLabelPos(originePos); });
            UnityEngine.EventSystems.ExecuteEvents.Execute <AxisLabel.IMessageSend>(m_ZaxisBillBoard, null, (sender, eventData) => { sender.UpdateLabelPos(zPos); });
            UnityEngine.EventSystems.ExecuteEvents.Execute <AxisLabel.IMessageSend>(m_XaxisBillBoard, null, (sender, eventData) => { sender.UpdateLabelPos(xPos); });
            UnityEngine.EventSystems.ExecuteEvents.Execute <AxisLabel.IMessageSend>(m_YaxisBillBoard, null, (sender, eventData) => { sender.UpdateLabelPos(yPos); });

            m_Xaxis.SetPosition(0, new Vector3(0, 0, 0));
            m_Xaxis.SetPosition(1, xPos);

            m_Yaxis.SetPosition(0, new Vector3(0, 0, 0));
            m_Yaxis.SetPosition(1, yPos);

            m_Zaxis.SetPosition(0, new Vector3(0, 0, 0));
            m_Zaxis.SetPosition(1, zPos);

            UnityEngine.EventSystems.ExecuteEvents.Execute <IMessageCreateLabel>(m_AxiLabel.gameObject, null, (sender, eventData) => { sender.UpdateLabelPos(new Vector3(xPos.x, yPos.y, zPos.z)); });

            var MyAxisGridVect = new Vector3(m_Xwidth, m_Ywidth, m_Zwidth);
            UnityEngine.EventSystems.ExecuteEvents.Execute <MyAxisGrid.ISendMessage>(m_Xaxis.gameObject, null, (sender, eventData) => { sender.Update(5, MyAxisGridVect); });
            UnityEngine.EventSystems.ExecuteEvents.Execute <MyAxisGrid.ISendMessage>(m_Yaxis.gameObject, null, (sender, eventData) => { sender.Update(5, MyAxisGridVect); });
            UnityEngine.EventSystems.ExecuteEvents.Execute <MyAxisGrid.ISendMessage>(m_Zaxis.gameObject, null, (sender, eventData) => { sender.Update(5, MyAxisGridVect); });
        }
        catch (System.Exception e)
        {
            Debug.Log(e.Message);
        }
    }
コード例 #34
0
        private void UpdateLineTracer(bool traceResult, float distance)
        {
            if (mLineTracer == null)
            {
                var debugNode = GetDebugTransform();
                if (debugNode != null)
                {
                    mLineTracer = debugNode.GetComponent <LineRenderer>("LineTracer");
                }
            }

            if (mLineTracer != null)
            {
                if (!debug)
                {
                    mLineTracer.gameObject.SetActive(false);
                    return;
                }

                mLineTracer.gameObject.SetActive(true);
                mLineTracer.useWorldSpace = true;

                if (mLineTracer.positionCount != 2 || !Application.isPlaying)
                {
                    Vector3 pos = transform.position;
                    mLineTracer.SetPositions(new Vector3[] { pos, pos + forward * 10.0f });
                }

                if (traceResult)
                {
                    mLineTracer.SetPosition(0, transform.position);
                    mLineTracer.SetPosition(1, transform.position + forward * distance);
                    mLineTracer.startColor = Color.green;
                    mLineTracer.endColor   = Color.green;
                }
                else
                {
                    mLineTracer.SetPosition(0, transform.position);
                    mLineTracer.SetPosition(1, transform.position + forward * expectedRange);
                    mLineTracer.startColor = Color.red;
                    mLineTracer.endColor   = Color.red;
                }
            }
        }
コード例 #35
0
 static public int SetPosition(IntPtr l)
 {
     try {
         UnityEngine.LineRenderer self = (UnityEngine.LineRenderer)checkSelf(l);
         System.Int32             a1;
         checkType(l, 2, out a1);
         UnityEngine.Vector3 a2;
         checkType(l, 3, out a2);
         self.SetPosition(a1, a2);
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #36
0
 static int SetPosition(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         UnityEngine.LineRenderer obj = (UnityEngine.LineRenderer)ToLua.CheckObject(L, 1, typeof(UnityEngine.LineRenderer));
         int arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
         UnityEngine.Vector3 arg1 = ToLua.ToVector3(L, 3);
         obj.SetPosition(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
コード例 #37
0
        /// <summary>
        ///     Function to render the intersection of a plane and a triangle
        /// </summary>
        /// <param name="height"></param>
        /// <param name="vertices"></param>
        /// <param name="crossSectionRenderer"></param>
        public void crossSectTri(Unity.Mathematics.float3 point, Unity.Mathematics.float3 normalDirection,
                                 Unity.Mathematics.float3[] vertices, UnityEngine.LineRenderer crossSectionRenderer)
        {
            //Vertices are organized in clockwise manner starting from top
            //top vertex
            Unity.Mathematics.float3 a = vertices[0];
            //bottom right
            Unity.Mathematics.float3 b = vertices[1];
            //bottom left
            Unity.Mathematics.float3 c = vertices[2];

            //intermediate calculations
            Unity.Mathematics.float3 ac_hat = (c - a) / UnityEngine.Vector3.Magnitude(c - a);
            Unity.Mathematics.float3 ab_hat = (b - a) / UnityEngine.Vector3.Magnitude(b - a);
            Unity.Mathematics.float3 bc_hat = (c - b) / UnityEngine.Vector3.Magnitude(c - b);

            //points of intersection on each line segment
            Unity.Mathematics.float3 ac_star = IMRE.Math.Operations.SegmentPlaneIntersection(a, c, point, normalDirection);
            Unity.Mathematics.float3 ab_star = IMRE.Math.Operations.SegmentPlaneIntersection(a, b, point, normalDirection);
            Unity.Mathematics.float3 bc_star = IMRE.Math.Operations.SegmentPlaneIntersection(b, c, point, normalDirection);

            //boolean values for if intersection hits only a vertex of the triangle
            bool ac_star_isEndpoint;

            ac_star_isEndpoint = ac_star.Equals(a) || ac_star.Equals(c);
            bool ab_star_isEndpoint;

            ab_star_isEndpoint = ab_star.Equals(a) || ab_star.Equals(b);
            bool bc_star_isEndpoint;

            bc_star_isEndpoint = bc_star.Equals(c) || bc_star.Equals(c);

            //booleans for if intersection hits somewhere on the segments
            bool ac_star_onSegment = !ac_star.Equals(new float3(Mathf.Infinity, Mathf.Infinity, Mathf.Infinity));
            bool ab_star_onSegment = !ab_star.Equals(new float3(Mathf.Infinity, Mathf.Infinity, Mathf.Infinity));
            bool bc_star_onSegment = !bc_star.Equals(new float3(Mathf.Infinity, Mathf.Infinity, Mathf.Infinity));

            //track how many vertices the intersection hits
            int endpointCount = 0;

            if (ac_star_isEndpoint)
            {
                endpointCount++;
            }
            if (ab_star_isEndpoint)
            {
                endpointCount++;
            }
            if (bc_star_isEndpoint)
            {
                endpointCount++;
            }

            //If plane does not hit triangle
            if (!(ab_star_onSegment || ac_star_onSegment || bc_star_onSegment))
            {
                crossSectionRenderer.enabled = false;
                UnityEngine.Debug.Log("Line does not intersect with any of triangle sides.");
            }

            //intersection is a segment (edge) of the triangle
            //the concept for choosing the right points of the cross section is the same for each of these subcases
            //two unique endpoint values
            else if (endpointCount >= 2 &&
                     (!ab_star.Equals(ac_star) || !ab_star.Equals(bc_star) || !ac_star.Equals(bc_star)))
            {
                crossSectionRenderer.enabled = true;
                //if there are two unique values, pick two.
                //drop the result for the edge which is within the plane

                //tolerance accounts for rounding errors
                float tolerance = .00001f;
                if (Unity.Mathematics.math.dot(ab_hat, normalDirection) < tolerance)
                {
                    crossSectionRenderer.SetPosition(0, a);
                    crossSectionRenderer.SetPosition(1, b);
                }
                else if (Unity.Mathematics.math.dot(ac_hat, normalDirection) < tolerance)
                {
                    crossSectionRenderer.SetPosition(0, a);
                    crossSectionRenderer.SetPosition(1, c);
                }
                else if (Unity.Mathematics.math.dot(bc_hat, normalDirection) < tolerance)
                {
                    crossSectionRenderer.SetPosition(0, b);
                    crossSectionRenderer.SetPosition(1, c);
                }
                else
                {
                    Debug.LogWarning("Error in calculation of line plane intersection");
                    crossSectionRenderer.enabled = false;
                }
            }

            //intersection hits one vertex on triangle and one of the segments
            else if (endpointCount == 2 && ab_star.Equals(ac_star) || ab_star.Equals(bc_star) ||
                     ac_star.Equals(bc_star))
            {
                crossSectionRenderer.enabled = true;

                //if point of intersection hits a, it must hit bc_star; same logic applies to remaining subcases
                if (ab_star.Equals(ac_star))
                {
                    crossSectionRenderer.SetPosition(0, a);
                    crossSectionRenderer.SetPosition(1, bc_star);
                }
                else if (ab_star.Equals(bc_star))
                {
                    crossSectionRenderer.SetPosition(0, b);
                    crossSectionRenderer.SetPosition(1, ac_star);
                }
                else if (ac_star.Equals(bc_star))
                {
                    crossSectionRenderer.SetPosition(0, c);
                    crossSectionRenderer.SetPosition(1, ab_star);
                }
                else
                {
                    Debug.LogWarning("Error in calculation of line plane intersection");
                    crossSectionRenderer.enabled = false;
                }
            }
            //intersection hits somewhere on two different segments of triangle; last remaining case
            else
            {
                crossSectionRenderer.enabled = true;

                //find out which two segments are intersected and use their calculated intersections
                if (ac_star_onSegment && ab_star_onSegment)
                {
                    crossSectionRenderer.SetPosition(0, ac_star);
                    crossSectionRenderer.SetPosition(1, ab_star);
                }
                else if (ac_star_onSegment && bc_star_onSegment)
                {
                    crossSectionRenderer.SetPosition(0, ac_star);
                    crossSectionRenderer.SetPosition(1, bc_star);
                }
                else if (ab_star_onSegment && bc_star_onSegment)
                {
                    crossSectionRenderer.SetPosition(0, ab_star);
                    crossSectionRenderer.SetPosition(1, bc_star);
                }
                else
                {
                    Debug.LogWarning("Error in calculation of line plane intersection");
                    crossSectionRenderer.enabled = false;
                }
            }
        }
コード例 #38
0
 public void UpdatePositions(Vector3 startPosition, Vector3 endPosition)
 {
     _lineRenderer.SetPosition(0, startPosition);
     _lineRenderer.SetPosition(1, endPosition);
 }
コード例 #39
0
        /// <summary>
        /// Function to render the intersection of a plane and a square
        /// </summary>
        /// <param name="height"></param>
        /// <param name="vertices"></param>
        /// <param name="crossSectionRenderer"></param>
        public void crossSectSquare(Unity.Mathematics.float3 point, Unity.Mathematics.float3 normalDirection,
                                    float3[] vertices,
                                    UnityEngine.LineRenderer crossSectionRenderer)
        {
            //Vertices are organized in clockwise manner starting from top left
            //top left
            Unity.Mathematics.float3 a = vertices[0];
            //top right
            Unity.Mathematics.float3 b = vertices[1];
            //bottom right
            Unity.Mathematics.float3 c = vertices[2];
            //bottom left
            Unity.Mathematics.float3 d = vertices[3];

            //intermediate calculations
            Unity.Mathematics.float3 ab_hat = (b - a) / UnityEngine.Vector3.Magnitude(b - a);
            Unity.Mathematics.float3 bc_hat = (c - b) / UnityEngine.Vector3.Magnitude(c - b);
            Unity.Mathematics.float3 cd_hat = (d - c) / UnityEngine.Vector3.Magnitude(d - c);
            Unity.Mathematics.float3 da_hat = (a - d) / UnityEngine.Vector3.Magnitude(a - d);

            //calculations for point of intersection on different segments
            Unity.Mathematics.float3 ab_star = IMRE.Math.Operations.SegmentPlaneIntersection(a, b, point, normalDirection);
            Unity.Mathematics.float3 bc_star = IMRE.Math.Operations.SegmentPlaneIntersection(b, c, point, normalDirection);
            Unity.Mathematics.float3 cd_star = IMRE.Math.Operations.SegmentPlaneIntersection(c, d, point, normalDirection);
            Unity.Mathematics.float3 da_star = IMRE.Math.Operations.SegmentPlaneIntersection(d, a, point, normalDirection);

            //booleans for if the intersection hits a vertex
            bool ab_star_isEndpoint = ab_star.Equals(a) || ab_star.Equals(b);
            bool bc_star_isEndpoint = bc_star.Equals(b) || bc_star.Equals(c);
            bool cd_star_isEndpoint = cd_star.Equals(c) || cd_star.Equals(d);
            bool da_star_isEndpoint = da_star.Equals(d) || da_star.Equals(a);

            //booleans for if the intersection hits somewhere on the segments besides the vertices
            bool ab_star_onSegment =
                !ab_star.Equals(new float3(Mathf.Infinity, Mathf.Infinity, Mathf.Infinity));
            bool bc_star_onSegment =
                !bc_star.Equals(new float3(Mathf.Infinity, Mathf.Infinity, Mathf.Infinity));
            bool cd_star_onSegment =
                !cd_star.Equals(new float3(Mathf.Infinity, Mathf.Infinity, Mathf.Infinity));
            bool da_star_onSegment =
                !da_star.Equals(new float3(Mathf.Infinity, Mathf.Infinity, Mathf.Infinity));

            Debug.Log(ab_star);
            Debug.Log(bc_star);
            Debug.Log(cd_star);
            Debug.Log(da_star);

            //track how many vertices are hit in the intersection
            int endpointCount = 0;

            if (ab_star_isEndpoint)
            {
                endpointCount++;
            }
            if (bc_star_isEndpoint)
            {
                endpointCount++;
            }
            if (cd_star_isEndpoint)
            {
                endpointCount++;
            }
            if (da_star_isEndpoint)
            {
                endpointCount++;
            }

            //intersection does not hit triangle
            if (!(ab_star_onSegment || bc_star_onSegment || cd_star_onSegment || da_star_onSegment))
            {
                crossSectionRenderer.enabled = false;
                UnityEngine.Debug.Log("Line does not intersect with any of triangle sides.");
            }
            //intersection is an edge of the square
            else if (endpointCount >= 2 &&
                     (!ab_star.Equals(bc_star) || !ab_star.Equals(da_star) || !bc_star.Equals(cd_star) ||
                      !cd_star.Equals(da_star)))
            {
                crossSectionRenderer.enabled = true;

                //Case where edge is the intersection

                //drop the two trivial cases, keep the two non-trivial cases.
                UnityEngine.Vector3 result0 = ab_star;
                UnityEngine.Vector3 result1 = cd_star;
                if (result0.Equals(point) || result1.Equals(point))
                {
                    //I know that the trivial cases are on opposite sides, because this is the case where the edge is the intersection.
                    //there are only two pairs of opposite sides.  if it's not one, it's the other.
                    result0 = bc_star;
                    result1 = da_star;

                    crossSectionRenderer.SetPosition(0, result0);
                    crossSectionRenderer.SetPosition(1, result1);
                }
                else
                {
                    Debug.LogWarning("Error in calculation of line plane intersection");
                    crossSectionRenderer.enabled = false;
                }
            }
            //intersection hits one vertice and somewhere on a segment
            else if (endpointCount == 2 &&
                     (ab_star.Equals(bc_star) || bc_star.Equals(cd_star) || cd_star.Equals(da_star)))
            {
                //find which vertex is in the intersection, and from there find which of the two possible segments are the other point of intersection
                //the same logic carries through all of these subcases
                if (ab_star.Equals(bc_star))
                {
                    if (cd_star_onSegment)
                    {
                        crossSectionRenderer.SetPosition(0, b);
                        crossSectionRenderer.SetPosition(1, cd_star);
                    }
                    else
                    {
                        crossSectionRenderer.SetPosition(0, b);
                        crossSectionRenderer.SetPosition(1, da_star);
                    }
                }
                else if (bc_star.Equals(cd_star))
                {
                    if (ab_star_onSegment)
                    {
                        crossSectionRenderer.SetPosition(0, c);
                        crossSectionRenderer.SetPosition(1, ab_star);
                    }
                    else
                    {
                        crossSectionRenderer.SetPosition(0, c);
                        crossSectionRenderer.SetPosition(1, da_star);
                    }
                }
                else if (cd_star.Equals(da_star))
                {
                    if (ab_star_onSegment)
                    {
                        crossSectionRenderer.SetPosition(0, d);
                        crossSectionRenderer.SetPosition(1, ab_star);
                    }
                    else
                    {
                        crossSectionRenderer.SetPosition(0, c);
                        crossSectionRenderer.SetPosition(1, bc_star);
                    }
                }
                else if (da_star.Equals(ab_star))
                {
                    if (cd_star_onSegment)
                    {
                        crossSectionRenderer.SetPosition(0, a);
                        crossSectionRenderer.SetPosition(1, cd_star);
                    }

                    if (bc_star_onSegment)
                    {
                        crossSectionRenderer.SetPosition(0, a);
                        crossSectionRenderer.SetPosition(1, bc_star);
                    }
                }
                else
                {
                    Debug.LogWarning("Error in calculation of line plane intersection");
                    crossSectionRenderer.enabled = false;
                }
            }
            //intersection hits two segments of the square
            else
            {
                crossSectionRenderer.enabled = true;
                //use booleans to determine which two segments are in the intersection
                if (ab_star_onSegment && bc_star_onSegment)
                {
                    crossSectionRenderer.SetPosition(0, ab_star);
                    crossSectionRenderer.SetPosition(1, bc_star);
                }
                else if (ab_star_onSegment && cd_star_onSegment)
                {
                    crossSectionRenderer.SetPosition(0, ab_star);
                    crossSectionRenderer.SetPosition(1, cd_star);
                }
                else if (ab_star_onSegment && da_star_onSegment)
                {
                    crossSectionRenderer.SetPosition(0, ab_star);
                    crossSectionRenderer.SetPosition(1, da_star);
                }
                else if (bc_star_onSegment && da_star_onSegment)
                {
                    crossSectionRenderer.SetPosition(0, bc_star);
                    crossSectionRenderer.SetPosition(1, da_star);
                }
                else if (bc_star_onSegment && cd_star_onSegment)
                {
                    crossSectionRenderer.SetPosition(0, bc_star);
                    crossSectionRenderer.SetPosition(1, cd_star);
                }
                else if (cd_star_onSegment && da_star_onSegment)
                {
                    crossSectionRenderer.SetPosition(0, cd_star);
                    crossSectionRenderer.SetPosition(1, da_star);
                }
                else
                {
                    Debug.LogWarning("Error in calculation of line plane intersection");
                    crossSectionRenderer.enabled = false;
                }
            }
        }
コード例 #40
0
ファイル: DanbiLine.cs プロジェクト: kangel429/danbi
 public void SetLine(DanbiLine.ePosition ePos, float x, float y)
 {
     line.SetPosition((int)ePos,
                      new UnityEngine.Vector3(x, y) * sMutliplier);
 }