Пример #1
0
 // Use this for initialization
 void Start()
 {
     _OldobjectInVicinity = _objectInVicinity;
     // Grabbing the renderer bounds
     if (GetComponent <Renderer>() != null)
     {
         //Debug.Log("Renderer of " + name + " was not null.");
         renderingBounds = GetComponent <Renderer>().bounds;
     }
     else // If there was no renderer attached to the immediate children, make a deep search for a renderer.
     {
         renderers = new List <Renderer>();
         GetComponentInChildrenRecursively(transform, ref renderers);
         if (renderers.Count != 0)
         {
             // Calculating an average center, with the size of maximum extends.
             // Note that this needs to be improved so that a union of extents are included.
             var centers = renderers.Select(r => r.bounds.center);
             var extents = renderers.Select(r => r.bounds.extents);
             //var maxs = renderers.Select(r => r.bounds.max);
             renderingBounds =
                 new Bounds(
                     new Vector3(centers.Average(c => c.x), centers.Average(c => c.y), centers.Average(c => c.z)),
                     //new Vector3(maxs.Max(m => m.x), maxs.Max(m => m.y), maxs.Max(m => m.z)) * 2);
                     new Vector3(extents.Max(m => m.x), extents.Max(m => m.y), extents.Max(m => m.z)));
         }
     }
     frustum = Camera.main.GetComponent <CameraFrustumScript>();
     if (frustum == null)
     {
         UseFrustumForUpdate = false;
     }
     mcamera = frustum.GetComponent <Camera>();
     PerformAction(true);
 }
Пример #2
0
 /// <summary>
 /// Initializes the FaceCamera class
 /// </summary>
 void Start()
 {
     camera  = Camera.main.transform;
     frustum = camera.GetComponent <CameraFrustumScript>();
     if (frustum == null)
     {
         useFrustumForUpdate = false;
     }
 }
Пример #3
0
 /// <summary>
 /// Initializes the fields when the script starts.
 /// </summary>
 void Start()
 {
     if (simulationIntegrated)
     {
         trafficData          = (TrafficIntegrationData)this.GetComponent("TrafficIntegrationData");
         vehControllers       = new Dictionary <string, TrafficIntegrationVehicle>();
         timeStepIndex        = 0;
         lastTimeStepExecuted = -1;
         cameraFrustum        = Camera.main.GetComponent <CameraFrustumScript>();
         routingContr         = FindObjectOfType <RoutingController>();
     }
 }
Пример #4
0
 /// <summary>
 /// Initializes the fields when the script starts.
 /// </summary>
 void Start()
 {
     if (conf.integrateSumo)
     {
         mc                = FindObjectOfType <SumoMainController>();
         tdb               = (SumoTrafficDB)this.GetComponent("SumoTrafficDB");
         vehControllers    = new Dictionary <string, SumoVehicleController>();
         timeStepIndex     = 0;
         cameraFrustum     = Camera.main.GetComponent <CameraFrustumScript>();
         routingController = FindObjectOfType <RoutingController>();
     }
 }
Пример #5
0
    // Use this for initialization
    void Start()
    {
        Cursor.visible = false;

        SetMaterial();
        pool = new List <Vector3>();

        for (int i = 0; i < 10000; i++)
        {
            pool.Add(new Vector3());
        }

        result = new List <float>();

        TextAsset    asset  = Resources.Load("positions") as TextAsset;
        Stream       s      = new MemoryStream(asset.bytes);
        BinaryReader reader = new BinaryReader(s);

//		BinaryReader reader = new BinaryReader(File.Open("positions.json", FileMode.Open));
        JSONNode ja = SimpleJSON.JSONNode.Deserialize(reader);

        for (int i = 0; i < ja.Count; i++)
        {
            Vector3 vec = UtilScript.JsonToVector3(ja[i]);

            posList.Add(vec);
        }

        pos = posList.ToArray();

        Debug.Log("Num Lines: " + pos.Length);

        CameraFrustumScript cfs = Camera.main.GetComponent <CameraFrustumScript>();

        front = cfs.GetFrontPlane();
        back  = new Vector3[4];

        for (int i = 0; i < front.Length; i++)
        {
            back[i]   = UtilScript.CloneVec3(front[i]);
            back[i].z = Camera.main.farClipPlane - Camera.main.nearClipPlane;
        }
    }
Пример #6
0
    // Use this for initialization
    void Start()
    {
        ren = GetComponent <Renderer>() != null?GetComponent <Renderer>() : GetComponentInChildren <Renderer>();

        frustum = Camera.main.GetComponent <CameraFrustumScript>();
        if (frustum == null)
        {
            UseFrustumForUpdate = false;
        }

        ActionScriptBehaviour = GetComponent(ActionScript);
        if (ActionScriptBehaviour == null)
        {
            //Obsolete method, and there is no FrustumBasedAction.cs in the folder.
            //UnityEngineInternal.APIUpdaterRuntimeServices.AddComponent(gameObject, "Assets/Scripts/GaPSLabs/FrustumSystem/FrustumBasedAction.cs (53,13)", ActionScript);
            ActionScriptBehaviour = GetComponent(ActionScript);
        }
        if (UseFrustumForUpdate)
        {
            if (UnityEngine.GeometryUtility.TestPlanesAABB(frustum.Frustum, ren.bounds))
            {
                _isInFrustum   = true;
                oldIsInFrustum = _isInFrustum;
                if (ActionScriptBehaviour == null)
                {
                    Debug.Log("There is no " + ActionScript);
                }
                else
                {
                    // Debug.Log(name + " START Entered the frustum.");
                    ActionScriptBehaviour.SendMessage(ActionMethodWhenEnteredFrustum);
                }
            }
            else
            {
                _isInFrustum   = false;
                oldIsInFrustum = _isInFrustum;
                // Debug.Log(name + " START Exited the frustum.");
                ActionScriptBehaviour.SendMessage(ActionMethodWhenExitFrustum);
                oldIsInFrustum = _isInFrustum;
            }
        }
    }
Пример #7
0
    // Use this for initialization
    void Start()
    {
//		float input = 237.5654665f;
//
//		float part1 = GetColorPart1(input, 0, 1024);
//		float part2 = GetColorPart2(input, 0, 1024);
//
//		Debug.Log ("MAP1: " + part1);
//		Debug.Log ("MAP2: " + part2);
//		Debug.Log ("Convert: " + PartsToFloat(part1, part2, 0, 1024));

        cam = Camera.main;

        cfs = cam.GetComponent <CameraFrustumScript>();

        front = cfs.GetFrontPlane();
        back  = new Vector3[4];

        for (int i = 0; i < front.Length; i++)
        {
            back[i]   = UtilScript.CloneVec3(front[i]);
            back[i].z = cam.farClipPlane - cam.nearClipPlane;
        }

        totalWidth  = front[1].x - front[0].x;
        totalHeight = front[2].y - front[0].y;
        totalDepth  = back[0].z - front[0].z;

        camPos = cam.transform.position;

        if (lumarcaMode == LUMARCA_MODE.Dots)
        {
            GenerateDots();
        }
        else
        {
            GenerateLines();
            MakeDiscreetAndCutOutsideOfCube();
        }

        SetColorToPart();
    }