public RayTracingEngine(int quality, int width, int height) { maxSampleNum_ = quality; width_ = width; height_ = height; CameraParam cameraParam = new CameraParam(); cameraParam.lookFrom.Set(13.0f, 2.0f, 3.0f); cameraParam.lookAt.Set(0.0f, 0.0f, 0.0f); cameraParam.aspect = (float)width_ / (float)height_; cameraParam.fstop = 4.0f; cameraParam.focusDistance = 10.0f; cameraParam.fov = 20.0f; cameraParam.t1 = 1.0f; cameraRay_ = new CameraRay(cameraParam); pixel_ = new Color[width_, height_]; for (int y = height_ - 1; y >= 0; --y) { for (int x = 0; x < width_; ++x) { pixel_[x, y] = Color.black; } } y_ = 0; }
void Start() { // 9. 別オブジェクトにアタッチしているスクリプトをオブジェクト名で参照する GameObject anotherObject = GameObject.Find("FirstPersonCharacter"); RSSCript = anotherObject.GetComponent <CameraRay>(); }
private void Awake() { if (Instance == null) { Instance = this; } }
void DrawPicture() { int sampleCount = 1; Hitable sphere1 = new Sphere(new Vector3(0, 0, -1), 0.5f); Hitable sphere2 = new Sphere(new Vector3(0, -100.5f, -1), 100); List <Hitable> hitList = new List <Hitable>(); hitList.Add(sphere1); hitList.Add(sphere2); Hitable world = new HitableList(hitList); CameraRay camRay = new CameraRay(); for (int i = 0; i < screenWidth; ++i) { for (int j = 0; j < screenHeight; ++j) { Color c = Color.black; for (int k = 0; k < sampleCount; ++k) { float t1 = Random.Range(0.0f, 1.0f); float t2 = Random.Range(0.0f, 1.0f); Ray r = camRay.GetRay((i + t1) / screenWidth, (j + t2) / screenHeight); c += GetColor(r, world); } c = c / sampleCount; MoDraw.Instance.DrawPoint(new Vector2Int(i, j), c); } } }
private void Awake() { if (_instance != null && _instance != this) { Destroy(this.gameObject); } else { _instance = this; } }
void TraceRays(IScene scene, int count) { for (int i = 0; i < count; i++) { Position2 position = new((float)Utils.ThreadRandom.NextDouble(), (float)Utils.ThreadRandom.NextDouble()); Direction2 direction = new((float)Utils.ThreadRandom.NextDouble(), (float)Utils.ThreadRandom.NextDouble()); CameraRay ray = scene.Camera.GetCameraRay(position, direction); try { ISpectrum light = Sample(scene, ray, ISpectrum.White, 0); ISample sample = new Sample() { Position = position, Direction = direction, Light = light, Intersection = ray.Intersection, PrimaryBVHTraversals = ray.BVHTraversals }; scene.Camera.Film.RegisterSample(sample); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } }
private void Awake() { onoffCameraRay = arCamera.GetComponent <CameraRay>(); Screen.sleepTimeout = SleepTimeout.NeverSleep; }
// Start is called before the first frame update void Start() { cameraRay = FindObjectOfType(typeof(CameraRay)) as CameraRay; targets_text = GetComponentInChildren <Text>(); }
// Check playerGameObject if it's local player or another one private void editPlayerGameObj(GameObject cloneGameObj, string playerName, string roleName) { //string player = HD.UDPChat.instance.username + "|" + HD.UDPChat.clientNo; string player = "boss" + "|" + "0"; if (cloneGameObj.name == player) { // It's local player gameobject localPlayer = cloneGameObj.GetComponent <Player>(); playerStatus.player = cloneGameObj.GetComponent <Player>(); cloneGameObj.GetComponent <Player>().setRoleName(roleName); CameraRay camRay = cloneGameObj.transform.GetChild(0).gameObject.AddComponent <CameraRay>(); camRay.hitItemInfo = hitItemInfo; camRay.mask = 2; } else { // It's another player's gameobject, delete playerController and change cam display PlayerController playerCont = cloneGameObj.GetComponent <PlayerController>(); Camera camera = cloneGameObj.transform.GetChild(0).gameObject.GetComponent <Camera>(); camera.targetDisplay = 1; Destroy(playerCont); } TextMeshPro playerNameText = cloneGameObj.GetComponent <Player>().nameText; playerNameText.SetText(playerName); // Add object to playerObjList playerObjList.Add(cloneGameObj); // spawn playerObjects at specific positions depending on their index in playerObjList //int index = playerObjList.IndexOf(cloneGameObj); int index = 0; switch (index) { case 0: cloneGameObj.transform.position = new Vector3(0, 1, 0); break; case 1: cloneGameObj.transform.position = new Vector3(2, 1, 1); break; case 2: cloneGameObj.transform.position = new Vector3(-2, 1, 3); break; case 3: cloneGameObj.transform.position = new Vector3(4, 0, 2); break; default: break; } }