/// <summary> /// Creates a visualization of the current depth image. /// </summary> /// <param name="texture">The texture to which the visualization is rendered (must be DepthWidth by DepthHeight).</param> public void VisualizeDepth(Texture2D texture) { if (texture.width != CameraModule.DepthWidth || texture.height != CameraModule.DepthHeight) { throw new Exception("Texture dimensions must match depth image dimensions."); } Unity.Collections.NativeArray <Color32> rawData = texture.GetRawTextureData <Color32>(); for (int i = 0; i < rawData.Length; i++) { rawData[i] = Hud.SensorBackgroundColor; } for (int r = 0; r < CameraModule.DepthHeight; r++) { for (int c = 0; c < CameraModule.DepthWidth; c++) { if (this.DepthImage[r][c] != CameraModule.minCode && this.DepthImage[r][c] != CameraModule.maxCode) { rawData[(CameraModule.DepthHeight - r) * texture.width + c] = CameraModule.InterpolateDepthColor(DepthImage[r][c]); } } } texture.Apply(); }
public void FadeIn() { if (cam == null) { cam = Controller.TMTVO.Instance.Api.FindModule("CameraModule") as CameraModule; } if (standings == null) { standings = Controller.TMTVO.Instance.Api.FindModule("LiveStandings") as LiveStandingsModule; } int carIdx = cam.FollowedDriver; if (Active || carIdx < 0) { return; } float rpm = ((float[])Controller.TMTVO.Instance.Api.GetData("CarIdxRPM"))[carIdx]; if (rpm < 0) { return; } Active = true; Storyboard sb = FindResource("FadeIn") as Storyboard; sb.Begin(); }
// 컨트롤 모듈을 얻는다. public CameraModule getModule() { if (this.module == null) { this.module = this.GetComponent <CameraModule>(); } return(this.module); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.F1)) { on = !on; } if (on) { byte unityFlag = sharedMemory.cursor.ReadByte(sharedMemory.GetLocation("unityFlag")); #if UNITY_IPC_SYNC if (unityFlag == 0) { #endif //NOTE(KARAN) : Upload car data sharedMemory.cursor.WriteArray <float>(sharedMemory.GetLocation("carData"), car.carControlsData, 0, car.carControlsData.Length); //NOTE(KARAN) : Upload each camera's images //TODO(KARAN) : Consider making this async for (int i = 0; i < cameraModules.Length; i++) { CameraModule cm = cameraModules[i]; int imageWidth = cameraModules[i].settings.imageWidth; int imageHeight = cameraModules[i].settings.imageHeight; int bytesPerPixel = cameraModules[i].settings.bytesPerPixel; sharedMemory.cursor.Write(sharedMemory.GetLocation(cm.name + "ImageWidth"), imageWidth); sharedMemory.cursor.Write(sharedMemory.GetLocation(cm.name + "ImageHeight"), imageHeight); sharedMemory.cursor.Write(sharedMemory.GetLocation(cm.name + "BytesPerPixel"), bytesPerPixel); sharedMemory.cursor.WriteArray <byte>(sharedMemory.GetLocation(cm.name), cm.capturedImage, 0, cm.capturedImage.Length); } //NOTE(KARAN) : Set unity flag to 1 indicating new data for consumption is available sharedMemory.cursor.Write(sharedMemory.GetLocation("unityFlag"), (byte)1); #if UNITY_IPC_SYNC } #endif #if PYTHON_IPC_SYNC byte pythonFlag = sharedMemory.cursor.ReadByte(sharedMemory.GetLocation("pythonFlag")); if (pythonFlag == 1) { #endif //NOTE(KARAN) : Get python data int read = sharedMemory.cursor.ReadArray <float>(sharedMemory.GetLocation("pythonData"), car.pythonData, 0, car.pythonData.Length); //NOTE(KARAN) : Set python flag to 0 indicating we read python's decision. sharedMemory.cursor.Write(sharedMemory.GetLocation("pythonFlag"), (byte)0); #if PYTHON_IPC_SYNC } #endif } }
// ================================================================ // // MonoBehaviour에서 상속. void Awake() { this.module = this.gameObject.GetComponent<CameraModule>(); if(this.module == null) { this.module = this.gameObject.AddComponent<CameraModule>(); } }
// ================================================================ // // MonoBehaviour에서 상속. void Awake() { this.module = this.gameObject.GetComponent <CameraModule>(); if (this.module == null) { this.module = this.gameObject.AddComponent <CameraModule>(); } }
public override void InstallBindings() { var world = new EcsWorld(); Container.BindInterfacesAndSelfTo <DefaultSystemsExecutor>().AsSingle().NonLazy(); Container.BindInstance(world); PlayerModule.Install(Container); CameraModule.Install(Container); SpawnerModule.Install(Container); }
public void FadeIn() { if (cam == null) { cam = API.Instance.FindModule("CameraModule") as CameraModule; } if (standings == null) { standings = API.Instance.FindModule("LiveStandings") as LiveStandingsModule; } int carIdx = cam.FollowedDriver; if (Active || carIdx < 0) { return; } float rpm = ((float[])API.Instance.GetData("CarIdxRPM"))[carIdx]; if (rpm < 0) { return; } prevGear = ((int[])API.Instance.GetData("CarIdxGear"))[carIdx]; if (canUpdateGear) { sb_Completed(null, null); currentGear = prevGear; } Active = true; Storyboard sb = FindResource("FadeIn") as Storyboard; sb.Begin(); }
private void OnValidate() { if (_activeRagdoll == null) { _activeRagdoll = GetComponent <ActiveRagdoll.ActiveRagdoll>(); } if (_physicsModule == null) { _physicsModule = GetComponent <PhysicsModule>(); } if (_animationModule == null) { _animationModule = GetComponent <AnimationModule>(); } if (_gripModule == null) { _gripModule = GetComponent <GripModule>(); } if (_cameraModule == null) { _cameraModule = GetComponent <CameraModule>(); } }
// ================================================================ // protected void update_optical_zoom() { if (this.optical_zoom != this.optical_zoom_current) { float near = this.GetComponent <Camera>().nearClipPlane; float far = this.GetComponent <Camera>().farClipPlane; float top = Mathf.Tan(this.GetComponent <Camera>().fieldOfView / 2.0f * Mathf.Deg2Rad) * near; float right = this.GetComponent <Camera>().aspect *top; switch (this.optical_zoom) { case OPTICAL_ZOOM._2BY2_0_0: { Matrix4x4 m = CameraModule.createFrustumProjectionMatrix(0.0f, -right, top, 0.0f, near, far); this.GetComponent <Camera>().projectionMatrix = m; } break; case OPTICAL_ZOOM._2BY2_1_0: { Matrix4x4 m = CameraModule.createFrustumProjectionMatrix(right, 0.0f, top, 0.0f, near, far); this.GetComponent <Camera>().projectionMatrix = m; } break; case OPTICAL_ZOOM._2BY2_0_1: { Matrix4x4 m = CameraModule.createFrustumProjectionMatrix(0.0f, -right, 0.0f, -top, near, far); this.GetComponent <Camera>().projectionMatrix = m; } break; case OPTICAL_ZOOM._2BY2_1_1: { Matrix4x4 m = CameraModule.createFrustumProjectionMatrix(right, 0.0f, 0.0f, -top, near, far); this.GetComponent <Camera>().projectionMatrix = m; } break; case OPTICAL_ZOOM.AS_IS: { Matrix4x4 m = CameraModule.createFrustumProjectionMatrix(right, -right, top, -top, near, far); this.GetComponent <Camera>().projectionMatrix = m; } break; default: case OPTICAL_ZOOM.OFF: { this.GetComponent <Camera>().ResetProjectionMatrix(); } break; } this.optical_zoom_current = this.optical_zoom; } }
public void FadeIn(DriverInfoMode mode) { if (cameraModule == null) { cameraModule = TMTVO.Controller.TMTVO.Instance.Api.FindModule("CameraModule") as CameraModule; } if (standingsModule == null) { standingsModule = TMTVO.Controller.TMTVO.Instance.Api.FindModule("LiveStandings") as LiveStandingsModule; } if (sessionTimer == null) { sessionTimer = TMTVO.Controller.TMTVO.Instance.Api.FindModule("SessionTimer") as SessionTimerModule; } if (Active) { return; } int camIndex = cameraModule.FollowedDriver; driver = standingsModule.FindDriver(camIndex); if (driver == null) { return; } Active = true; this.mode = mode; DriversName.Text = driver.Driver.LastUpperName; TeamCarName.Text = Controller.TMTVO.Instance.Cars.GetValue(driver.Driver.Car.CarName); DriversNumber.Text = driver.Driver.Car.CarNumber; NumberPlate.Fill = new SolidColorBrush(driver.Driver.LicColor); Storyboard sb = FindResource("FadeInName") as Storyboard; sb.Begin(); if (mode != DriverInfoMode.NameOnly) { int position = 0; if (mode == DriverInfoMode.QualiTimeOnly || mode == DriverInfoMode.QualiTimeWithGap) { position = GridModule.FindDriverStatic(driver).Position; } else { position = driver.PositionLive; } if (position == 1) { BackgroundLeader.Visibility = Visibility.Visible; } else { BackgroundLeader.Visibility = Visibility.Hidden; } Position.Text = position.ToString("0"); (FindResource("FadeInPosition") as Storyboard).Begin(); pActive = true; } if (mode == DriverInfoMode.Improvements) { BestTime.Text = driver.FastestLapTime.ConvertToTimeString(); LastTime.Text = driver.LastLapTime.ConvertToTimeString(); int improvement = GridModule.FindDriverStatic(camIndex).Position - driver.PositionLive; if (improvement < 0) { Improvement.Text = (-improvement).ToString("0"); ImpAngle.Angle = lostAngle; ImpTriangle.Fill = lostBrush; } else if (improvement == 0) { Improvement.Text = "0"; ImpAngle.Angle = neutralAngle; ImpTriangle.Fill = neutralBrush; } else { Improvement.Text = improvement.ToString("0"); ImpAngle.Angle = improvedAngle; ImpTriangle.Fill = improvedBrush; } (FindResource("FadeInImprovements") as Storyboard).Begin(); bActive = true; } if (mode == DriverInfoMode.FastestLapTimeOnly || mode == DriverInfoMode.FastestLapTimeWithGap || mode == DriverInfoMode.QualiTimeOnly || mode == DriverInfoMode.QualiTimeWithGap) { FastestTime.Text = ((mode == DriverInfoMode.QualiTimeOnly || mode == DriverInfoMode.QualiTimeWithGap) ? GridModule.FindDriverStatic(camIndex).QualiTime : driver.FastestLapTime).ConvertToTimeString(); (FindResource("FadeInFastestLap") as Storyboard).Begin(); fActive = true; } if (mode == DriverInfoMode.FastestLapTimeWithGap || mode == DriverInfoMode.QualiTimeWithGap) { if (mode == DriverInfoMode.FastestLapTimeWithGap) { Gap.Text = "+" + (driver.FastestLapTime - standingsModule.Leader.FastestLapTime).ConvertToTimeString(); } else { Gap.Text = "+" + (GridModule.FindDriverStatic(camIndex).QualiTime - GridModule.GetLeader().QualiTime).ConvertToTimeString(); } (FindResource("FadeInGap") as Storyboard).Begin(); gActive = true; } }
public override void execute() { CameraModule camera_module = CameraControl.get().getModule(); // ---------------------------------------------------------------- // // 다음 상태로 전환할지 체크. switch (this.step.do_transition()) { case STEP.IDLE: { this.step.set_next(STEP.START); } break; case STEP.START: { this.step.set_next(STEP.KABUSAN_TOJO); } break; case STEP.KABUSAN_TOJO: { if (this.step.get_time() > 2.0f) { this.step.set_next(STEP.KABUSAN_TALK); } } break; case STEP.KABUSAN_TALK: { if (Input.GetMouseButtonUp(0)) { this.step.set_next(STEP.END); } } break; case STEP.END: { this.step.set_next(STEP.IDLE); } break; } // ---------------------------------------------------------------- // // 상태 전환 시 초기화. while (this.step.get_next() != STEP.NONE) { switch (this.step.do_initialize()) { case STEP.IDLE: { } break; case STEP.START: { camera_module.parallelMoveTo(new Vector3(0.0f, 12.4f, -13.0f)); this.step.set_next(STEP.KABUSAN_TOJO); } break; case STEP.KABUSAN_TOJO: { } break; case STEP.KABUSAN_TALK: { Navi.get().dispatchKabusanSpeech(); } break; case STEP.END: { this.kabu_san.beginMove(); } break; } } // ---------------------------------------------------------------- // // 각 상태에서의 실행 처리. switch (this.step.do_execution(Time.deltaTime)) { case STEP.IDLE: { } break; } // ---------------------------------------------------------------- // }
// 컨트롤 모듈을 얻는다. public CameraModule getModule() { if(this.module == null) { this.module = this.GetComponent<CameraModule>(); } return(this.module); }
private void Awake() { // Put initialization code here. Add(typeof(SFXManager)); camMod = new CameraModule(); }
public override void execute() { CameraModule camera_module = CameraControl.get().getModule(); float ougi_pos_y0 = -3.2f; float ougi_pos_y1 = 0.0f; // ---------------------------------------------------------------- // // 다음 상태로 이동할지 체크. switch (this.step.do_transition()) { case STEP.START: { } break; // "!" 말풍선. case STEP.BIKKURI: { if (this.step.get_time() > 1.0f) { this.sprite_bikkuri.setVisible(false); this.step.set_next(STEP.TURN_AND_RISE); } } break; // 빙글 돌아 모션 재생. case STEP.TURN_AND_RISE: { if (this.step.get_time() > 2.0f) { this.step.set_next(STEP.STICK_THROW); } } break; // 아이스 스틱을 던진다. case STEP.STICK_THROW: { if (this.player.control.getMotionCurrentTime() > 0.3f) { this.step.set_next(STEP.STICK_FLYING); } } break; // 아이스 스틱이 날라온다. case STEP.STICK_FLYING: { if (!this.ice_fcurve.isMoving()) { ItemWindow.get().setItem(Item.SLOT_TYPE.MISC, this.slot_index, this.item_favor); this.player.item_slot.miscs[this.slot_index].is_using = false; this.step.set_next(STEP.END); } } break; case STEP.END: { this.step.set_next(STEP.IDLE); } break; } // ---------------------------------------------------------------- // // 상태 전환 시 초기화. while (this.step.get_next() != STEP.NONE) { switch (this.step.do_initialize()) { case STEP.START: { Vector3 player_position = this.player.control.getPosition(); // -------------------------------------------------------- // // 카메라. CameraControl.get().beginOuterControll(); camera_module.pushPosture(); this.cam_posture0 = camera_module.getPosture(); this.cam_posture1.position = player_position + new Vector3(0.0f, 5.3f, -3.5f); this.cam_posture1.intererst = player_position + Vector3.forward * 2.0f; this.cam_posture1.up = Vector3.up; this.camera_fcurve.setSlopeAngle(70.0f, 5.0f); this.camera_fcurve.setDuration(0.5f); this.camera_fcurve.start(); // 플레이어. this.player.beginOuterControll(); this.player.GetComponent <Rigidbody>().Sleep(); // 피라미 적 캐릭터의 움직임을 멈춘다. LevelControl.get().beginStillEnemies(); // this.step.set_next_delay(STEP.BIKKURI, 1.0f); } break; // "!" 말풍선. case STEP.BIKKURI: { this.bikkuri_spring.k = 750.0f; this.bikkuri_spring.reduce = 0.77f; this.bikkuri_spring.start(-2.75f); this.sprite_bikkuri.setVisible(true); } break; // 빙글 돌아 모션 재생. case STEP.TURN_AND_RISE: { // 뒤의 부채. this.ougi_position = this.player.control.getPosition() + Vector3.forward * 1.0f; this.ougi_position.y = ougi_pos_y0; this.ougi = EffectRoot.get().createAtariOugi(this.ougi_position); this.ougi_fcurve.setSlopeAngle(70.0f, 5.0f); this.ougi_fcurve.setDuration(0.5f); this.ougi_fcurve.start(); // 플레이어. if (this.player_weapon != null) { this.player_weapon.SetActive(false); } this.player.control.cmdSetMotion("m004_use", 1); // 아이스바 모델. this.ice_bar.SetActive(true); // 종을 울림. SoundManager.getInstance().playSE(Sound.ID.DDG_JINGLE04); // 플레이어 가까이 있는 적을 지운다. this.hide_enemies = LevelControl.get().getRoomEnemiesInRange(null, this.player.getPosition(), 2.0f); foreach (var enemy in this.hide_enemies) { enemy.damage_effect.startFadeOut(0.1f); } } break; // 아이스 스틱을 던진다. case STEP.STICK_THROW: { // 플레이어. this.player.control.cmdSetMotion("m003_attack", 1); } break; // 아이스 스틱이 날라온다. case STEP.STICK_FLYING: { this.cam_posture1 = camera_module.getPosture(); this.camera_fcurve.setSlopeAngle(10.0f, 5.0f); this.camera_fcurve.setDuration(1.0f); this.camera_fcurve.start(); // 당첨 말풍선. this.atari_fcurve.setSlopeAngle(50.0f, 30.0f); this.atari_fcurve.setDuration(0.5f); this.atari_fcurve.start(); // 뒤 부채. this.ougi_fcurve.setSlopeAngle(70.0f, 5.0f); this.ougi_fcurve.setDuration(1.0f); this.ougi_fcurve.start(); // 아이스. this.ice_fcurve.setSlopeAngle(60.0f, 20.0f); this.ice_fcurve.setDuration(1.0f); this.ice_fcurve.start(); this.sprite_ice_bar.setVisible(true); // 플레이어가 가진 아이스바(당첨). this.ice_bar.gameObject.destroy(); } break; case STEP.END: { GameObject.Destroy(this.ice_bar); if (this.player_weapon != null) { this.player_weapon.SetActive(true); } this.player.GetComponent <Rigidbody>().WakeUp(); this.player.endOuterControll(); this.sprite_bikkuri.destroy(); this.sprite_atari.destroy(); this.sprite_ice_bar.destroy(); this.ougi.destroy(); camera_module.popPosture(); CameraControl.get().endOuterControll(); // 피래미 적 캐릭터의 움직임을 재개한다. LevelControl.get().endStillEnemies(null, 2.0f); foreach (var enemy in this.hide_enemies) { enemy.damage_effect.startFadeIn(0.5f); } } break; } } // ---------------------------------------------------------------- // // 각 상태에서의 실행 처리. switch (this.step.do_execution(Time.deltaTime)) { // "!" 말풍선. case STEP.BIKKURI: { this.bikkuri_spring.execute(Time.deltaTime); Vector2 position = new Vector2(0.0f, 80.0f); position += Vector2.up * 8.0f * this.bikkuri_spring.position; this.sprite_bikkuri.setPosition(position); } break; // 빙글 돌아 모션 재생. case STEP.TURN_AND_RISE: { // -------------------------------------------------------- // // 카메라. this.camera_fcurve.execute(Time.deltaTime); if (this.camera_fcurve.isMoving()) { CameraModule.Posture posture = CameraModule.lerp(this.cam_posture0, this.cam_posture1, this.camera_fcurve.getValue()); camera_module.setPosture(posture); } else { float dolly = camera_module.getDistance(); camera_module.dolly(dolly * (1.0f - 0.05f * Time.deltaTime)); } // -------------------------------------------------------- // // 플레이어. this.player.control.cmdSmoothHeadingTo(CameraControl.get().transform.position); if (this.player.control.getMotionCurrentTime() > 0.5f) { this.player.control.getAnimationPlayer().Stop(); } // -------------------------------------------------------- // // 뒤의 부채. this.ougi_fcurve.execute(Time.deltaTime); this.ougi_position.y = Mathf.Lerp(ougi_pos_y0, ougi_pos_y1, this.ougi_fcurve.getValue()); this.ougi.transform.position = this.ougi_position; // -------------------------------------------------------- // // 플레이어가 가지고 있는 아이스바(당첨). // 카메라 방향으로 향한다. Vector3 dir = CameraControl.get().gameObject.getPosition() - this.ice_bar.getPosition(); this.ice_bar.setRotation(Quaternion.LookRotation(-dir.Y(0.0f), Quaternion.AngleAxis(20.0f, Vector3.forward) * Vector3.up)); // 줌 if (this.step.is_acrossing_time(0.3f)) { this.ice_zoom_fcurve.setSlopeAngle(70.0f, 5.0f); this.ice_zoom_fcurve.setDuration(0.3f); this.ice_zoom_fcurve.start(); } this.ice_zoom_fcurve.execute(Time.deltaTime); this.ice_bar.setLocalScale(Vector3.one * Mathf.Lerp(0.2f, 0.8f, this.ice_zoom_fcurve.getValue())); // -------------------------------------------------------- // // 당첨 말풍선. if (this.step.is_acrossing_time(0.3f)) { this.spring.k = 750.0f; this.spring.reduce = 0.87f; this.spring.start(-0.75f); this.sprite_atari.setVisible(true); } this.spring.execute(Time.deltaTime); float scale = this.spring.position + 1.0f; this.sprite_atari.setScale(new Vector2(scale, scale)); } break; // 아이스 스틱을 던진다. case STEP.STICK_THROW: { // -------------------------------------------------------- // // カメラ. float dolly = camera_module.getDistance(); camera_module.dolly(dolly * (1.0f - 0.05f * Time.deltaTime)); // -------------------------------------------------------- // // Vector3 dir = CameraControl.get().gameObject.getPosition() - this.player.gameObject.getPosition(); dir = Quaternion.AngleAxis(-90.0f, Vector3.up) * dir.Y(0.0f); this.player.control.cmdSmoothHeadingTo(this.player.gameObject.getPosition() + dir); } break; // 아이스 스틱이 날아온다. case STEP.STICK_FLYING: { // -------------------------------------------------------- // // 카메라. this.camera_fcurve.execute(Time.deltaTime); CameraModule.Posture posture = CameraModule.lerp(this.cam_posture1, this.cam_posture0, this.camera_fcurve.getValue()); camera_module.setPosture(posture); // -------------------------------------------------------- // // 당첨 말풍선. this.atari_fcurve.execute(Time.deltaTime); this.sprite_atari.setScale(Vector2.one * Mathf.Lerp(1.0f, 0.0f, this.atari_fcurve.getValue())); // -------------------------------------------------------- // // 뒤 풍선. this.ougi_fcurve.execute(Time.deltaTime); this.ougi_position.y = Mathf.Lerp(ougi_pos_y1, ougi_pos_y0, this.ougi_fcurve.getValue()); this.ougi.transform.position = this.ougi_position; // -------------------------------------------------------- // // 이쪽으로 날아오는 아이스 스틱. this.ice_fcurve.execute(Time.deltaTime); this.tracer.proceedToDistance(this.ice_fcurve.getValue() * this.tracer.curve.calcTotalDistance()); Vector2 on_curve_position = this.tracer.cv.position.xz() * 480.0f / 2.0f; // 커브의 종단점이 아이템 윈도의 아이콘 위치가 되도록 보정한다. do { if (this.slot_index < 0) { break; } if (this.ice_fcurve.getValue() <= 0.5f) { break; } float blend_rate = Mathf.InverseLerp(0.5f, 1.0f, this.ice_fcurve.getValue()); Vector2 icon_position = ItemWindow.get().getIconPosition(Item.SLOT_TYPE.MISC, this.slot_index); Vector2 curve_end = this.tracer.curve.cvs.back().position.xz() * 480.0f / 2.0f; on_curve_position += (icon_position - curve_end) * blend_rate; } while(false); this.sprite_ice_bar.setPosition(on_curve_position); this.sprite_ice_bar.setAngle(this.step.get_time() * 360.0f * 5.0f); this.sprite_ice_bar.getMaterial().SetFloat("_BlendRate", this.ice_fcurve.getValue()); } break; } }