Esempio n. 1
0
    void Awake()
    {
        Pedestrians = new GameObject[PedestriansCount];
        Material red   = Resources.Load("Red", typeof(Material)) as Material;
        Material green = Resources.Load("Green", typeof(Material)) as Material;

        InitAgentsCircle();

        for (int i = 0; i < PedestriansCount; i++)
        {
            Pedestrians[i] = (GameObject)Instantiate(PedPrefab, StartPositions[i], Quaternion.Euler(StartRotation));
            MeshRenderer mesh = Pedestrians[i].GetComponent <MeshRenderer>();
            if (i < (PedestriansCount / 2))
            {
                mesh.material = green;
            }
            else
            {
                mesh.material = red;
            }
            PedVisionCamera PedCam = Pedestrians[i].GetComponent <PedVisionCamera>();
            PedCam.a_id = i;
        }

        InitializeCUDA();
        RenderTargetTex = new Texture2D(RenderTarget.width, RenderTarget.height, TextureFormat.RGBAFloat, false);
        pedStart        = 0;
        pedStop         = Pedestrians.Length;

        dataSize   = (RenderTargetTex.width * agentViewTexHeight) * 5;
        resultSize = Pedestrians.Length * 5;

        d_idata       = new CudaDeviceVariable <float4>(RenderTargetTex.width * RenderTargetTex.height);
        d_odata       = new CudaDeviceVariable <float>(dataSize);
        d_result_data = new CudaDeviceVariable <float>(resultSize);
        h_result_data = new float[Pedestrians.Length, 5];

        Positions  = new Vector2[Pedestrians.Length + 1];
        Velocities = new Vector2[Pedestrians.Length + 1];

        h_idata        = RenderTargetTex.GetPixels();
        h_idata_float4 = new float4[h_idata.Length];
    }
Esempio n. 2
0
    private void Start()
    {
        position = new Vector2(transform.position.x, transform.position.z);
        velocity = new Vector2(0.0f, 0.0f);

        goalPoint = new Vector2(-position.x, -position.y);

        personalArea   = 0.4f;
        height         = 1.6f;
        speedComfort   = 1.5f;
        accMax         = 1.0f;
        orientationVec = new Vector2(0.0f, 0.0f);
        thetaDotOld    = 0.0f;

        speedComfort = Random.Range(1.3f, 1.6f);
        pedCam       = GetComponent <PedVisionCamera>();

        orientationVec = goalPoint - position;
        orientationVec.Normalize();
        orientation = Mathf.Atan2(orientationVec.y, orientationVec.x);
    }