getX() public method

public getX ( ) : float
return float
Ejemplo n.º 1
0
    public void showTrajectory()
    {
        List <Vector3> points = new List <Vector3>();

        for (int i = 0; i < positions.Count - 1; i++)
        {
            PedestrianPosition a = (PedestrianPosition)positions.GetByIndex(i);
            points.Add(new Vector3(a.getX(), a.getZ() + 0.01f, a.getY()));
        }

        GameObject myLine = new GameObject(name + " trajectory");

        myLine.transform.position = points[1];
        myLine.AddComponent <LineRenderer>();
        LineRenderer lr = myLine.GetComponent <LineRenderer>();

        lr.material = new Material((Material)Resources.Load("LineMaterial", typeof(Material)));
        lr.material.SetColor("_EmissionColor", myColor);
        lr.material.SetColor("_Color", myColor);
        lr.startColor   = myColor;
        lr.endColor     = myColor;
        lr.startWidth   = 0.08f;
        lr.endWidth     = 0.08f;
        lr.numPositions = points.Count;
        lr.SetPositions(points.ToArray());

        pc.trajectoriesShown = true;
        trajectoryVisible    = true;
    }
    public void setPositions(SortedList p)
    {
        positions.Clear();
        foreach (PedestrianPosition ped in p.Values)
        {
            positions.Add(ped.getTime(), ped);
        }
        PedestrianPosition pos = (PedestrianPosition)p.GetByIndex(0);

        transform.position = new Vector3(pos.getX(), 0, pos.getY());
    }
Ejemplo n.º 3
0
    public void showTrajectory()
    {
        VectorLine.SetCamera(GameObject.Find("Flycam").camera);

        List <Vector3> points = new List <Vector3>();

        for (int i = 0; i < positions.Count - 1; i++)
        {
            PedestrianPosition a = (PedestrianPosition)positions.GetByIndex(i);
            points.Add(new Vector3(a.getX(), 0.01f, a.getY()));
        }

        trajectory           = VectorLine.SetLine3D(myColor, points.ToArray());
        trajectory.lineWidth = 3.0f;
        pc.trajectoriesShown = true;
        trajectoryVisible    = true;
    }
    // Update is called once per frame
    void Update()
    {
        if (pc.playing)
        {
            GetComponent <Animation>().Play();
        }
        else
        {
            GetComponent <Animation>().Stop();
        }

        int index = _getTrait(positions, pc.current_time);

        if (index < positions.Count - 1 && index > -1)
        {
            r.enabled = true;
            PedestrianPosition pos  = (PedestrianPosition)positions.GetByIndex(index);
            PedestrianPosition pos2 = (PedestrianPosition)positions.GetByIndex(index + 1);
            start  = new Vector3(pos.getX(), 0, pos.getY());
            target = new Vector3(pos2.getX(), 0, pos2.getY());
            float   time = (float)pc.current_time;
            float   movement_percentage = (float)time - (float)pos.getTime();
            Vector3 newPosition         = Vector3.Lerp(start, target, movement_percentage);

            Vector3 relativePos = target - start;
            speed = relativePos.magnitude;

            GetComponent <Animation>()["walking"].speed = getSpeed();
            if (start != target)
            {
                transform.rotation = Quaternion.LookRotation(relativePos);
            }

            if (gp.point1active && gp.point2active)
            {
                if (FasterLineSegmentIntersection(new Vector2(gp.point1.x, gp.point1.z), new Vector2(gp.point2.x, gp.point2.z), new Vector2(transform.position.x, transform.position.z), new Vector2(newPosition.x, newPosition.z)))
                {
                    gp.lineCross(speed);
                }
            }

            if (pc.tileColoringMode != TileColoringMode.TileColoringNone)
            {
                tile.GetComponent <Renderer>().enabled = true;

                if (pc.tileColoringMode == TileColoringMode.TileColoringSpeed)
                {
                    tile.GetComponent <Renderer>().material.color = ColorHelper.ColorForSpeed(getSpeed());
                    it.updateSpeed(speed);
                }
                else if (pc.tileColoringMode == TileColoringMode.TileColoringDensity)
                {
                    densityReload = (densityReload + 1) % densityReloadInterval;
                    if (densityReload == 0)
                    {
                        getDensity();
                    }
                    float density = getDensity();
                    tile.GetComponent <Renderer>().material.color = ColorHelper.ColorForDensity(density);
                }
            }
            else
            {
                tile.GetComponent <Renderer>().enabled = false;
            }

            transform.position   = newPosition;
            gameObject.hideFlags = HideFlags.None;
        }
        else
        {
            r.enabled = false;
            tile.GetComponent <Renderer>().enabled = false;
            gameObject.hideFlags = HideFlags.HideInHierarchy;
        }
    }