protected void InitCameraData() { // Default camera data CameraData cameradata = new CameraData(); cameradata.CharHeight = 0.9f; cameradata.CameraHeight = 13f + 3.6f; cameradata.CameraDistance = -20f - 6F; cameradata.Fov = 20.0f; cameradata.YRotate = 0f; m_CameraData[( int)eCAMERA_STATE.NORMAL] = cameradata; }
public void ChangeCamera() { _currentCameraDataIndex++; EnsureBounds(); var cameraType = _typesQueue[_currentCameraDataIndex]; _currentCameraData = CameraDatas.Find(p => p.Type == cameraType); UpdateCameraToCameraData(); }
public void Init( Transform playerTransform, CameraData cameraPosition, float fCompleteTime) { if ( null == playerTransform) { Debug.LogError( "playerTransform == null "); return; } if ( null == cameraPosition) { Debug.LogError( "cameraPosition == null "); return; } m_PlayerTransform = playerTransform; m_CameraPosition = cameraPosition; m_vec3MoveDirection = GetCameraMoveDirection( m_CameraPosition); m_vec3SourcePos = GetPosition( cameraPosition.CameraHeight, cameraPosition.CameraDistance, cameraPosition.YRotate); m_vec3SourcePos = m_vec3SourcePos - ( m_vec3MoveDirection * -8.0f); ResetCameraLocalPos(); }
/// <inheritdoc/> public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) { CommandBuffer cmd = CommandBufferPool.Get(m_ProfilerTag); using (new ProfilingScope(cmd, m_ProfilingSampler)) { context.ExecuteCommandBuffer(cmd); cmd.Clear(); var sortFlags = renderingData.cameraData.defaultOpaqueSortFlags; var drawSettings = CreateDrawingSettings(m_ShaderTagId, ref renderingData, sortFlags); drawSettings.perObjectData = PerObjectData.None; ref CameraData cameraData = ref renderingData.cameraData; Camera camera = cameraData.camera; if (cameraData.isStereoEnabled) { context.StartMultiEye(camera); } m_FilteringSettings.layerMask = camera.cullingMask; context.DrawRenderers(renderingData.cullResults, ref drawSettings, ref m_FilteringSettings); }
//这里你可以实现渲染逻辑。 //使用<c>ScriptableRenderContext</c>来发出绘图命令或执行命令缓冲区 // https://docs.unity3d.com/ScriptReference/Rendering.ScriptableRenderContext.html //你不必调用ScriptableRenderContext。提交时,渲染管道会在管道中的特定点调用它。 public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) { // 获取命令缓冲区 CommandBuffer cmd = CommandBufferPool.Get(m_ProfilerTag); using (new ProfilingScope(cmd, new ProfilingSampler(m_ProfilerTag))) { // 执行命令缓存 context.ExecuteCommandBuffer(cmd); // 清楚数据缓存 cmd.Clear(); // 相机的排序标志 var sortFlags = renderingData.cameraData.defaultOpaqueSortFlags; // 创建绘制设置 var drawSettings = CreateDrawingSettings(m_ShaderTagId, ref renderingData, sortFlags); // 设置对象数据 drawSettings.perObjectData = PerObjectData.None; // 检测是否是VR设备 ref CameraData cameraData = ref renderingData.cameraData; Camera camera = cameraData.camera; if (cameraData.isStereoEnabled) { context.StartMultiEye(camera); } // 设置覆盖材质 drawSettings.overrideMaterial = depthNormalsMaterial; // 绘制渲染器 context.DrawRenderers(renderingData.cullResults, ref drawSettings, ref m_FilteringSettings); // 设置全局纹理 cmd.SetGlobalTexture("_CameraDepthNormalsTexture", depthAttachmentHandle.id); }
/// <inheritdoc/> public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) { // NOTE: Do NOT mix ProfilingScope with named CommandBuffers i.e. CommandBufferPool.Get("name"). // Currently there's an issue which results in mismatched markers. CommandBuffer cmd = CommandBufferPool.Get(); using (new ProfilingScope(cmd, m_ProfilingSampler)) { context.ExecuteCommandBuffer(cmd); cmd.Clear(); var sortFlags = renderingData.cameraData.defaultOpaqueSortFlags; var drawSettings = CreateDrawingSettings(m_ShaderTagId, ref renderingData, sortFlags); drawSettings.perObjectData = PerObjectData.None; ref CameraData cameraData = ref renderingData.cameraData; Camera camera = cameraData.camera; if (cameraData.isStereoEnabled) { context.StartMultiEye(camera, eyeIndex); } context.DrawRenderers(renderingData.cullResults, ref drawSettings, ref m_FilteringSettings); }
static void Main(string[] args) { EasyDecoder decoder = EasyDecoder.Default(bitsPerChannel: 6, fullRange: false); EasyData data = null; try { data = decoder.Decode(new ImageData(args[0], 10, 75)); } catch (System.Exception e) { Console.Out.WriteLine("Error " + e.ToString()); data = null; } if (null != data) { CameraData cameraData = data.CameraData; Console.Out.WriteLine("T={0}, X={1}, Y={2}, Z={3}, XR={4}, YR={5}, ZR={6}, FOV={7}", cameraData.Time, cameraData.XPosition, cameraData.YPosition, cameraData.ZPosition, cameraData.XRotation, cameraData.YRotation, cameraData.ZRotation, cameraData.Fov); } System.Console.ReadLine(); }
public CameraController() { // Main camera handles UI only Camera.main.farClipPlane = 1000; cameraData = World.Current.CameraData; // currentLayer = World.Current.Depth; KeyboardManager keyboardManager = KeyboardManager.Instance; keyboardManager.RegisterInputAction("MoveCameraEast", KeyboardMappedInputType.Key, () => { frameMoveHorizontal++; }); keyboardManager.RegisterInputAction("MoveCameraWest", KeyboardMappedInputType.Key, () => { frameMoveHorizontal--; }); keyboardManager.RegisterInputAction("MoveCameraNorth", KeyboardMappedInputType.Key, () => { frameMoveVertical++; }); keyboardManager.RegisterInputAction("MoveCameraSouth", KeyboardMappedInputType.Key, () => { frameMoveVertical--; }); keyboardManager.RegisterInputAction("ZoomOut", KeyboardMappedInputType.Key, () => ChangeZoom(0.1f)); keyboardManager.RegisterInputAction("ZoomIn", KeyboardMappedInputType.Key, () => ChangeZoom(-0.1f)); keyboardManager.RegisterInputAction("MoveCameraUp", KeyboardMappedInputType.KeyUp, ChangeLayerUp); keyboardManager.RegisterInputAction("MoveCameraDown", KeyboardMappedInputType.KeyUp, ChangeLayerDown); keyboardManager.RegisterInputAction("ApplyCameraPreset1", KeyboardMappedInputType.KeyUp, () => ApplyPreset(cameraData.presets[0])); keyboardManager.RegisterInputAction("ApplyCameraPreset2", KeyboardMappedInputType.KeyUp, () => ApplyPreset(cameraData.presets[1])); keyboardManager.RegisterInputAction("ApplyCameraPreset3", KeyboardMappedInputType.KeyUp, () => ApplyPreset(cameraData.presets[2])); keyboardManager.RegisterInputAction("ApplyCameraPreset4", KeyboardMappedInputType.KeyUp, () => ApplyPreset(cameraData.presets[3])); keyboardManager.RegisterInputAction("ApplyCameraPreset5", KeyboardMappedInputType.KeyUp, () => ApplyPreset(cameraData.presets[4])); keyboardManager.RegisterInputAction("AssignCameraPreset1", KeyboardMappedInputType.KeyUp, () => AssignPreset(0)); keyboardManager.RegisterInputAction("AssignCameraPreset2", KeyboardMappedInputType.KeyUp, () => AssignPreset(1)); keyboardManager.RegisterInputAction("AssignCameraPreset3", KeyboardMappedInputType.KeyUp, () => AssignPreset(2)); keyboardManager.RegisterInputAction("AssignCameraPreset4", KeyboardMappedInputType.KeyUp, () => AssignPreset(3)); keyboardManager.RegisterInputAction("AssignCameraPreset5", KeyboardMappedInputType.KeyUp, () => AssignPreset(4)); // Set default zoom value on camera Camera.main.orthographicSize = zoomTarget; positionTarget = Camera.main.transform.position; TimeManager.Instance.EveryFrameNotModal += (time) => Update(); }
public void SetLive(GameManager.GameStates state) { Debug.Log("SETLIVE{0}"); CameraData tmpData = null; foreach (var cam in cameras) { if (cam.GetComponent <CameraData>().refState == state) { tmpData = cam.GetComponent <CameraData>(); //Set active cam to live priority if (tmpData != null) { tmpData.targetCam.m_Priority = 10; liveCam = tmpData.targetCam; //Set active canvas if ther's one if (tmpData.targetCanvas != null) { tmpData.targetCanvas.gameObject.SetActive(true); } } else if (liveCam != null) { liveCam.m_Priority = 10; } } else { //If not active gamestate - disable camera and canvas cam.GetComponent <CameraData>().targetCam.m_Priority = 0; } } }
private void parseJSON(JSONNode json) { for (var i = 0; i < json["screens"].Count; i++) { string cameraDataName = json["screens"][i]["screen"] + " CameraData"; CameraData cameraData = spawnCameraData(cameraDataName); JSONArray tlJArray = json["screens"][i]["viewport"]["tl"].AsArray; JSONArray trJArray = json["screens"][i]["viewport"]["tr"].AsArray; JSONArray blJArray = json["screens"][i]["viewport"]["bl"].AsArray; JSONArray brJArray = json["screens"][i]["viewport"]["br"].AsArray; cameraData.viewport.tl = new Vector2(tlJArray[0], tlJArray[1]); cameraData.viewport.tr = new Vector2(trJArray[0], trJArray[1]); cameraData.viewport.bl = new Vector2(blJArray[0], blJArray[1]); cameraData.viewport.br = new Vector2(brJArray[0], brJArray[1]); cameraData.viewport.t = json["screens"][i]["viewport"]["t"]; cameraData.viewport.b = json["screens"][i]["viewport"]["b"]; cameraData.viewport.l = json["screens"][i]["viewport"]["l"]; cameraData.viewport.r = json["screens"][i]["viewport"]["r"]; cameraData.display = json["screens"][i]["display"].AsInt; cameraData.screen = json["screens"][i]["screen"]; } }
private void SetupWorld(int width, int height, int depth) { // Set the current world to be this world. // TODO: Do we need to do any cleanup of the old world? Current = this; Width = width; Height = height; Depth = depth; tiles = new Tile[Width, Height, Depth]; RoomManager = new RoomManager(); RoomManager.Adding += (room) => roomGraph = null; RoomManager.Removing += (room) => roomGraph = null; FillTilesArray(); FurnitureManager = new FurnitureManager(); FurnitureManager.Created += OnFurnitureCreated; UtilityManager = new UtilityManager(); CharacterManager = new CharacterManager(); InventoryManager = new InventoryManager(); jobQueue = new JobQueue(); GameEventManager = new GameEventManager(); PowerNetwork = new PowerNetwork(); FluidNetwork = new FluidNetwork(); temperature = new Temperature(); ShipManager = new ShipManager(); Wallet = new Wallet(); CameraData = new CameraData(); LoadSkybox(); AddEventListeners(); }
private void ViewModelViewCameraChangedHandler(object sender, RoutedEventArgs e) { CameraData = ViewModel.GetCameraInformation(); }
public LookAtDirectionState(ref CameraData cameraData) { this.c_cameraData = cameraData; }
/// <summary> /// Returns a usable OutcastEncoder object for the given camera. /// </summary> /// <remarks> /// This method should be used to connect to a given Outcast Encoder. While it is possible to connect by instantiating /// a new <see cref="Granicus.MediaManager.SDK.OutcastEncoder"/> object and manually connecting it, it is not recommended.</remarks> /// <param name="Camera">The CameraData object for the desired OutcastEncoder.</param> /// <returns>A connected and usable OutcastEncoder instance.</returns> public OutcastEncoder GetOutcastEncoder(CameraData Camera) { OutcastEncoder encoder = new OutcastEncoder(); encoder.Connect(Camera, ImpersonationToken); return encoder; }
/// <summary> /// GUI の出力時に実行されます。 /// </summary> void OnGUI() { #region Style GUIStyle marginStyle = GUI.skin.label; marginStyle.wordWrap = true; marginStyle.margin = new RectOffset(5, 5, 5, 5); #endregion Style this.scrollPosition = EditorGUILayout.BeginScrollView(this.scrollPosition, GUI.skin.box); EditorGUILayout.LabelField("現在の設定で画像をキャプチャします。", marginStyle); if (GUILayout.Button("Click to Save")) { CaptureImage(); } // 指定したキー入力が実行されたとき、画像を保存します。 if (Event.current != null && Event.current.type == EventType.keyDown && Event.current.keyCode == this.imageCaptureKey && this.enableImageCaptureKey) { CaptureImage(); } EditorGUILayout.LabelField("有効なとき、指定したキー入力によって画像をキャプチャします。", marginStyle); EditorGUILayout.BeginHorizontal(GUI.skin.label); { this.enableImageCaptureKey = EditorGUILayout.Toggle(this.enableImageCaptureKey); this.imageCaptureKey = (KeyCode)EditorGUILayout.EnumPopup(this.imageCaptureKey); } EditorGUILayout.EndHorizontal(); #region OutputDirectory EditorGUILayout.LabelField("キャプチャ画像の出力ディレクトリを設定します。", marginStyle); EditorGUILayout.BeginHorizontal(GUI.skin.label); { if (GUILayout.Button("Open")) { string tempPath = EditorUtility.SaveFolderPanel("Open", this.outputDirectory, ""); // Cancel された場合を考慮します。 if (!tempPath.Equals("")) { this.outputDirectory = EditorGUILayout.TextField(tempPath); this.Repaint(); } } else { this.outputDirectory = EditorGUILayout.TextField(this.outputDirectory); } } EditorGUILayout.EndHorizontal(); if (this.outputDirectory == null || this.outputDirectory.Equals("")) { this.outputDirectory = Application.dataPath + "/"; } #endregion Output Directory EditorGUILayout.LabelField ("キャプチャ画像の基底のファイル名を設定します。", marginStyle); this.outputFileName = EditorGUILayout.TextField(this.outputFileName); EditorGUILayout.LabelField ("キャプチャ画像のファイル名に与えられるインデックスです。", marginStyle); this.currentFileNameIndex = EditorGUILayout.IntField(this.currentFileNameIndex); int[] gameViewResolution = GetGameViewResolution(); EditorGUILayout.Separator(); for (int i = 0; i < cameraList.Count; i++) { CameraData data = cameraList[i]; GUILayout.Box("", GUILayout.Width(this.position.width), GUILayout.Height(1)); data.enable = EditorGUILayout.Toggle("Camera[" + i + "]キャプチャ", data.enable); EditorGUILayout.LabelField ("キャプチャ画像のファイル名の末尾につける文字列を指定します。", marginStyle); data.suffix = EditorGUILayout.TextField("Suffix", data.suffix); EditorGUILayout.LabelField ("画像をキャプチャするカメラを指定します。指定しないとき MainCamera の画像をキャプチャします。", marginStyle); data.camera = EditorGUILayout.ObjectField("Camera", data.camera, typeof(Camera), true) as Camera; EditorGUILayout.LabelField ("キャプチャ画像の水平方向の解像度。0 のとき、GameView の解像度(" + gameViewResolution[0] + ")になります。", marginStyle); data.width = EditorGUILayout.IntSlider(data.width, 0, 9999); EditorGUILayout.LabelField ("出力する画像の垂直方向の解像度。0 のとき、GameView の解像度(" + gameViewResolution[1] + ")になります。", marginStyle); data.height = EditorGUILayout.IntSlider(data.height, 0, 9999); } EditorGUILayout.BeginHorizontal(GUI.skin.label); { if (GUILayout.Button("+")) { cameraList.Add(new CameraData("Camera_" + cameraList.Count.ToString())); } if ((GUILayout.Button("-")) && (cameraList.Count > 0)) { cameraList.RemoveAt(cameraList.Count - 1); } } EditorGUILayout.EndHorizontal(); GUILayout.Box("", GUILayout.Width(this.position.width), GUILayout.Height(1)); EditorGUILayout.Separator(); EditorGUILayout.LabelField ("キャプチャ画像の解像度の倍率。2 を設定するとき、指定した解像度の 2 倍の解像度になります。", marginStyle); this.imageScale = EditorGUILayout.IntSlider(this.imageScale, 1, 10); EditorGUILayout.LabelField ("カメラの設定にかかわらず背景を透過するとき有効にします。", marginStyle); this.enableBackgroundAlpha = EditorGUILayout.Toggle(this.enableBackgroundAlpha); EditorGUILayout.EndScrollView(); }
[DllImport("usdi")] public static extern Bool usdiCameraReadSample(Camera cam, ref CameraData dst, double t);
/// <inheritdoc/> public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) { if (renderingData.cameraData.cameraType != CameraType.Game) { return; } if (!renderingData.cameraData.postProcessEnabled) { return; } if (m_CopyDepthMaterial == null) { Debug.LogErrorFormat("Missing {0}. {1} render pass will not execute. Check for missing reference in the renderer resources.", m_CopyDepthMaterial, GetType().Name); return; } CommandBuffer cmd = CommandBufferPool.Get(m_ProfilerTag); RenderTargetIdentifier depthSurface = source.Identifier(); RenderTargetIdentifier copyDepthSurface = destination.Identifier(); RenderTextureDescriptor descriptor = renderingData.cameraData.cameraTargetDescriptor; int cameraSamples = descriptor.msaaSamples; CameraData cameraData = renderingData.cameraData; switch (cameraSamples) { case 8: cmd.DisableShaderKeyword(ShaderKeywordStrings.DepthMsaa2); cmd.DisableShaderKeyword(ShaderKeywordStrings.DepthMsaa4); cmd.EnableShaderKeyword(ShaderKeywordStrings.DepthMsaa8); break; case 4: cmd.DisableShaderKeyword(ShaderKeywordStrings.DepthMsaa2); cmd.EnableShaderKeyword(ShaderKeywordStrings.DepthMsaa4); cmd.DisableShaderKeyword(ShaderKeywordStrings.DepthMsaa8); break; case 2: cmd.EnableShaderKeyword(ShaderKeywordStrings.DepthMsaa2); cmd.DisableShaderKeyword(ShaderKeywordStrings.DepthMsaa4); cmd.DisableShaderKeyword(ShaderKeywordStrings.DepthMsaa8); break; // MSAA disabled default: cmd.DisableShaderKeyword(ShaderKeywordStrings.DepthMsaa2); cmd.DisableShaderKeyword(ShaderKeywordStrings.DepthMsaa4); cmd.DisableShaderKeyword(ShaderKeywordStrings.DepthMsaa8); break; } cmd.SetGlobalTexture("_CameraDepthAttachment", source.Identifier()); // Blit has logic to flip projection matrix when rendering to render texture. // Currently the y-flip is handled in CopyDepthPass.hlsl by checking _ProjectionParams.x // If you replace this Blit with a Draw* that sets projection matrix double check // to also update shader. // scaleBias.x = flipSign // scaleBias.y = scale // scaleBias.z = bias // scaleBias.w = unused float flipSign = (cameraData.IsCameraProjectionMatrixFlipped()) ? -1.0f : 1.0f; Vector4 scaleBias = (flipSign < 0.0f) ? new Vector4(flipSign, 1.0f, -1.0f, 1.0f) : new Vector4(flipSign, 0.0f, 1.0f, 1.0f); cmd.SetGlobalVector(m_ScaleBiasId, scaleBias); cmd.DrawMesh(RenderingUtils.fullscreenMesh, Matrix4x4.identity, m_CopyDepthMaterial); context.ExecuteCommandBuffer(cmd); CommandBufferPool.Release(cmd); }
public void PrepareRender(RenderableData data, Camera camera) { var dataVersion = data.Version; var cameraData = prepardWithCameraData = camera.GetDataCopy(); // without Parallel.ForEach = 130 fps // with ConcurrentBag = 180 fps // with ConcurrentQueue = 200 fps // with lock List = 200 fps var frustum = prepardWithCameraData.GetFrustum(); var camPos = prepardWithCameraData.ViewPointPosition; var possibleRenderables = data.Renderers; var possibleRenderablesCount = possibleRenderables.Count; IRenderable[] toRender; int toRenderCount; Debug.AddValue("rendering / meshes / total possible", possibleRenderablesCount); // clear references to IRenderables in part of the array that will not be used, there is a chance that it might hang onto references thus stopping GC from collecting IRenderables if (lastTotalPossible > possibleRenderablesCount) { Array.Clear(passedFrustumCulling, possibleRenderablesCount, lastTotalPossible - possibleRenderablesCount); Array.Clear(passedRasterizationCulling, possibleRenderablesCount, lastTotalPossible - possibleRenderablesCount); Array.Clear(toRenderDefferred, possibleRenderablesCount, lastTotalPossible - possibleRenderablesCount); Array.Clear(toRenderTransparent, possibleRenderablesCount, lastTotalPossible - possibleRenderablesCount); } lastTotalPossible = possibleRenderablesCount; rasterizer?.Clear(); if (EnableCulling) { int wantToBeRendered = 0; int passedFrustumCullingIndex = 0; { Action <IRenderable> work = renderable => { if (renderable.ShouldRenderInContext(camera, RenderContext)) { Interlocked.Increment(ref wantToBeRendered); if (renderable.ForcePassFrustumCulling) { var newIndex = Interlocked.Increment(ref passedFrustumCullingIndex) - 1; passedFrustumCulling[newIndex] = renderable; rasterizer?.AddTriangles(renderable.GetCameraSpaceOccluderTriangles(cameraData)); } else { var bounds = renderable.GetFloatingOriginSpaceBounds(camPos); if ( frustum.VsSphere(bounds.Center, bounds.Extents.LengthFast) && frustum.VsBounds(bounds) ) { var newIndex = Interlocked.Increment(ref passedFrustumCullingIndex) - 1; passedFrustumCulling[newIndex] = renderable; rasterizer?.AddTriangles(renderable.GetCameraSpaceOccluderTriangles(cameraData)); } else { renderable.SetCameraRenderStatusFeedback(camera, RenderStatus.NotRendered); } } } }; WorkLoad(0, possibleRenderables.Count, i => { IRenderable renderable; if (possibleRenderables.TryGetAtIndex(i, out renderable)) { work(renderable); } }); Debug.AddValue("rendering / meshes / want to be rendered", wantToBeRendered); } Debug.AddValue("rendering / meshes / passed frustum culling", passedFrustumCullingIndex); if (rasterizer != null && EnableRasterizerCulling) { int passedRasterizationCullingIndex = 0; Action <IRenderable> work = renderable => { if (renderable.ForcePassRasterizationCulling) { var newIndex = Interlocked.Increment(ref passedRasterizationCullingIndex) - 1; passedRasterizationCulling[newIndex] = renderable; } else { var bounds = renderable.GetCameraSpaceBounds(cameraData); if (rasterizer.AreBoundsVisible(bounds)) { var newIndex = Interlocked.Increment(ref passedRasterizationCullingIndex) - 1; passedRasterizationCulling[newIndex] = renderable;; } else { renderable.SetCameraRenderStatusFeedback(camera, RenderStatus.NotRendered); } } }; WorkLoad(0, passedFrustumCullingIndex, (i) => { work(passedFrustumCulling[i]); }); //var range = cameraData.FarClipPlane - cameraData.NearClipPlane; //SuggestedCameraZNear = cameraData.NearClipPlane + rasterizer.totalMinZ.Clamp(0, 1) * range; //SuggestedCameraZFar = cameraData.NearClipPlane + rasterizer.totalMaxZ.Clamp(0, 1) * range; //if (SuggestedCameraZNear + 1 > SuggestedCameraZFar) SuggestedCameraZFar = SuggestedCameraZNear + 1; //cameraData.NearClipPlane = SuggestedCameraZNear * 0.5f; //cameraData.FarClipPlane = SuggestedCameraZFar; //cameraData.RecalculateProjectionMatrix(); Debug.AddValue("rendering / meshes / passed rasterization culling", passedRasterizationCullingIndex); toRender = passedRasterizationCulling; toRenderCount = passedRasterizationCullingIndex; } else { var a = passedFrustumCulling.Where(renderable => renderable != null && renderable.ShouldRenderInContext(camera, RenderContext)).ToArray(); toRender = a; toRenderCount = a.Length; } } else { var a = possibleRenderables.Where(renderable => renderable != null && renderable.ShouldRenderInContext(camera, RenderContext)).ToArray(); toRender = a; toRenderCount = a.Length; } // final prepare step { toRenderDefferredCount = 0; toRenderTransparentCount = 0; Action <IRenderable> work = renderable => { if (renderable.Material.RenderShader.IsTransparent) { renderable.SetCameraRenderStatusFeedback(camera, RenderStatus.RenderedAndVisible); var newIndex = Interlocked.Increment(ref toRenderTransparentCount) - 1; toRenderTransparent[newIndex] = renderable; distancesToCameraTransparent[newIndex] = -renderable.GetCameraSortDistance(cameraData); } else { renderable.SetCameraRenderStatusFeedback(camera, RenderStatus.RenderedAndVisible); var newIndex = Interlocked.Increment(ref toRenderDefferredCount) - 1; toRenderDefferred[newIndex] = renderable; distancesToCameraDeferred[newIndex] = renderable.GetCameraSortDistance(cameraData); } }; WorkLoad(0, toRenderCount, (i) => { work(toRender[i]); }); if (SortRenderables) { // sort renderables so closest to camera are first // could use paraller sort: e.g.: https://gist.github.com/wieslawsoltes/6592526 Array.Sort(distancesToCameraDeferred, toRenderDefferred, 0, toRenderDefferredCount, Comparer <float> .Default); Array.Sort(distancesToCameraTransparent, toRenderTransparent, 0, toRenderTransparentCount, Comparer <float> .Default); } } if (dataVersion != data.Version) { //Log.Warn("started render prepare with different data to render version"); } }
public void UpdateCamera(CameraData camera) { this.Invoke("UpdateCamera", new object[] { camera}); }
public void SetCurCameraData( CameraData data) { m_mainCamera.fov = data.Fov; //m_CameraComponent.SetCurCameraData( data); }
public void SetCameraData( CameraData SourceData, float fTime) { if( null == m_mainCamera) { Debug.LogError( "null == m_mainCamera"); return; } if( null == m_CameraComponent) { Debug.LogError( "null == m_CameraComponent"); return; } m_CameraComponent.Init( m_PlayerTransform, SourceData, fTime); m_mainCamera.fov = SourceData.Fov; }
private void RenderGBuffer(UniformBlock ubo, CameraData camera) { // G BUFFER GRAB PASS { gBuffer.BindAllFrameBuffersForDrawing(); // SKYBOX PASS if (Debug.GetCVar("rendering / debug / render white background")) { GL.ClearColor(System.Drawing.Color.White); MyGL.Check(); GL.DepthMask(true); MyGL.Check(); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); MyGL.Check(); } else if (Debug.GetCVar("rendering / debug / render black background")) { GL.ClearColor(System.Drawing.Color.Black); MyGL.Check(); GL.DepthMask(true); MyGL.Check(); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); MyGL.Check(); } else { GL.ClearColor(System.Drawing.Color.Black); MyGL.Check(); GL.DepthMask(true); MyGL.Check(); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); MyGL.Check(); if (SkyboxCubeMap != null) { GL.Disable(EnableCap.DepthTest); MyGL.Check(); GL.DepthMask(false); MyGL.Check(); GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill); MyGL.Check(); var shader = Factory.GetShader("internal/deferred.skybox.shader"); shader.Uniforms.Set("skyboxCubeMap", SkyboxCubeMap); shader.Bind(); Factory.SkyBoxMesh.Draw(); } } SetPolygonMode(); // RENDER ALL OBJECTS { gl.DepthWrite(true); gl.DepthTest(true); gl.Blend(false); for (int i = 0; i < toRenderDefferredCount; i++) { var renderable = toRenderDefferred[i]; renderable.Material.BeforeBindCallback(); renderable.Material.Uniforms.SendAllUniformsTo(renderable.Material.RenderShader.Uniforms); renderable.Material.RenderShader.Bind(); renderable.UploadUBOandDraw(camera, ubo); } // GL.MultiDrawElementsIndirect } gBuffer.Unbind(); } }
private void AddAbilities() { CameraData defaultCamera = AssetDatabase.LoadAssetAtPath <CameraData>("Assets/Dias Games/Third Person System/Camera Data/Default.asset"); if (character.GetComponent <AnimatorManager>() == null) { character.gameObject.AddComponent <AnimatorManager>(); } if (character.GetComponent <UnityInputManager>() == null) { character.gameObject.AddComponent <UnityInputManager>(); } Locomotion m_Locomotion = character.GetComponent <Locomotion>(); if (m_Locomotion == null) { m_Locomotion = character.gameObject.AddComponent <Locomotion>(); m_Locomotion.AbilityPhysicMaterial = groundFriction; m_Locomotion.CameraData = defaultCamera; } JumpAbility m_Jump = character.GetComponent <JumpAbility>(); if (m_Jump == null) { m_Jump = character.gameObject.AddComponent <JumpAbility>(); m_Jump.AbilityPhysicMaterial = zeroFriction; } FallAbility m_Fall = character.GetComponent <FallAbility>(); if (m_Fall == null) { m_Fall = character.gameObject.AddComponent <FallAbility>(); m_Fall.AbilityPhysicMaterial = zeroFriction; } RollAbility m_Roll = character.GetComponent <RollAbility>(); if (m_Roll == null) { m_Roll = character.gameObject.AddComponent <RollAbility>(); } CrouchAbility m_Crouch = character.GetComponent <CrouchAbility>(); if (m_Crouch == null) { m_Crouch = character.gameObject.AddComponent <CrouchAbility>(); m_Crouch.AbilityPhysicMaterial = groundFriction; m_Crouch.CameraData = AssetDatabase.LoadAssetAtPath <CameraData>("Assets/Dias Games/Third Person System/Camera Data/CrouchCamera.asset"); } // -------------------------- SET IGNORE ABILITIES ---------------------------------- // // Jump m_Jump.IgnoreAbilities = new List <ThirdPersonAbility>(); m_Jump.IgnoreAbilities.Add(m_Locomotion); // Roll m_Roll.IgnoreAbilities = new List <ThirdPersonAbility>(); m_Roll.IgnoreAbilities.Add(m_Locomotion); m_Roll.IgnoreAbilities.Add(m_Crouch); //Crouch m_Crouch.IgnoreAbilities = new List <ThirdPersonAbility>(); m_Crouch.IgnoreAbilities.Add(m_Locomotion); // -------------------------------------------------------------------------------- // }
private void RenderLights(UniformBlock ubo, CameraData camera, IList <ILight> allLights) { lock (allLights) { for (int lightIndex = 0; lightIndex < allLights.Count; lightIndex++) { var light = allLights[lightIndex]; if (light == null) { continue; } var shadowMap = light.ShadowMap; #region SHADOW MAAPING /* * if (shadowsEnabled && light.HasShadows) * { * //GL.Enable(EnableCap.CullFace); * //GL.CullFace(CullFaceMode.Back); * * shadowMap.FrameBufferForWriting(); * * GL.Enable(EnableCap.DepthTest); My.Check(); * GL.DepthMask(true); My.Check(); * * shadowMap.Clear(); * * shadowMap.shadowViewCamera.UploadDataToUBO(ubo); * * for (int i = 0; i < allRenderers.Count; i++) * { * var renderer = allRenderers[i]; * if (renderer == null) continue; * * //if (renderer.CanBeFrustumCulled == false || GeometryUtility.TestPlanesAABB(frustrumPlanes, renderer.bounds)) * { * renderer.Material.BeforeBindCallback(); * renderer.Material.Uniforms.SendAllUniformsTo(renderer.Material.DepthGrabShader.Uniforms); * renderer.Material.DepthGrabShader.Bind(); * renderer.UploadUBOandDraw(shadowMap.shadowViewCamera, ubo); * } * } * }*/ #endregion SHADOW MAAPING camera.UploadCameraDataToUBO(ubo); // bind camera view params // G BUFFER LIGHT PASS { gl.DepthWrite(false); gl.DepthTest(false); gl.DrawLinesOnly(false); light.UploadUBOdata(camera, ubo, lightIndex); var shader = Factory.GetShader("internal/deferred.oneLight.shader"); gBuffer.BindForLightPass(shader); if (lightIndex == 0) { GL.Clear(ClearBufferMask.ColorBufferBit); MyGL.Check(); } if (ShadowsEnabled && light.HasShadows) { shadowMap.BindUniforms(shader); } if (shader.Bind()) { //GL.Enable(EnableCap.Blend); //GL.BlendEquationSeparate(BlendEquationMode.FuncAdd, BlendEquationMode.FuncAdd); //GL.BlendFunc(BlendingFactorSrc.SrcColor, BlendingFactorDest.SrcColor); GL.BlendEquation(BlendEquationMode.FuncAdd); MyGL.Check(); GL.BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.One); MyGL.Check(); Factory.QuadMesh.Draw(); GL.Disable(EnableCap.Blend); MyGL.Check(); } gBuffer.Unbind(); } } } }
protected void PlayActionSequence ( ArrayList p_actionSequence ) { // check here if cueueble or action is uninteractibe. if( !this.IsInteractible() ) { if( m_bEventIsCueable ) { // Sanity check.. // 1. Should not Add ActionSequence that is currently playing // 2. Should not Add ActionSequence that is already in cue foreach( string action in p_actionSequence ) { bool containsAction = false; foreach( string cuedAction in m_cuedActions ) { if( action.Equals(cuedAction) ) containsAction = true; } if( !containsAction ) { m_cuedActions.Add(action); } #if DEBUG_CUEABLES if( containsAction ) Debug.LogError("Dragon::PlayActionSequence Dragon is not Interactible. adding "+action+" to cue."); else Debug.LogError("Dragon::PlayActionSequence Dragon is not Interactible and already contains cueable "+action+" action."); #else if( containsAction ) Log("Dragon::PlayActionSequence Dragon is not Interactible. adding "+action+" to cue."); else Log("Dragon::PlayActionSequence Dragon is not Interactible and already contains cueable "+action+" action."); #endif } return; } #if DEBUG_CUEABLES Debug.LogError("Dragon::PlayActionSequence Cannot Play this Action because Action is not Interactibe."); //Debug.Break(); #else //Log("Dragon::PlayActionSequence Cannot Play this Action:"+MiniJSON.jsonEncode(p_actionSequence)+" because Action is not Interactibe."); Debug.LogWarning("Dragon::PlayActionSequence Cannot Play this Action:"+MiniJSON.jsonEncode(p_actionSequence)+" because Action is not Interactibe. \n"); #endif return; } // clear actions DragonAnimationQueue.getInstance().ClearAll(); SoundManager.Instance.StopAnimationSound( PettingMain.Instance.HeadSoundContainer ); SoundManager.Instance.StopAnimationSound( PettingMain.Instance.BodySoundContainer ); SoundManager.Instance.StopAnimationSound( PettingMain.Instance.HeadAndBodySoundContainer ); foreach( string action in p_actionSequence ) { // Body Animations ArrayList bodyActionSequence = SequenceReader.GetInstance().ReadBodySequence(action); Log("----------- Playing Reaction:"+action+" -----------"); //LogWarning(">>>>>>> Checking action: \""+action+"\"\n"); if( bodyActionSequence != null ) { // +KJ:06132013 Shared Parameter. this supports the same random value that a cue is sharing foreach( object actionData in bodyActionSequence ) { ArrayList actionDataList = actionData as ArrayList; BodyData bodyData = new BodyData(); bodyData.Action = action; bodyData.Start = Utility.ParseToInt(actionDataList[0]); bodyData.ActionKey = actionDataList[1].ToString(); bodyData.Duration = float.Parse(actionDataList[2].ToString()); if( actionDataList.Count > 3 ) { bodyData.Param = actionDataList[3] as Hashtable; } bodyData.ExtractHashtableValues( bodyData.Param ); bodyData.EventTrigger = this.FormulateEventTriggers( bodyData.Param ); DragonAnimationQueue.getInstance().AddBodyCue( bodyData.GenerateHashtable() ); } } // Head Animations ArrayList headActionSequence = SequenceReader.GetInstance().ReadHeadSequence(action); if( headActionSequence != null ) { foreach( object actionData in headActionSequence ) { ArrayList actionDataList = actionData as ArrayList; HeadData headData = new HeadData(); headData.Action = action; headData.Start = Utility.ParseToInt(actionDataList[0]); headData.ActionKey = actionDataList[1].ToString(); headData.Duration = float.Parse(actionDataList[2].ToString()); if( actionDataList.Count > 3 ) { headData.Param = actionDataList[3] as Hashtable; } headData.ExtractHashtableValues( headData.Param ); headData.EventTrigger = this.FormulateEventTriggers( headData.Param ); DragonAnimationQueue.getInstance().AddHeadCue( headData.GenerateHashtable() ) ; } } // Update Queue ArrayList updateActionQueue = SequenceReader.GetInstance().ReadUpdate(action); if( updateActionQueue != null ) { foreach( object actionData in updateActionQueue ) { ArrayList actionDataList = actionData as ArrayList; UpdateData updateData = new UpdateData(); updateData.Action = action; updateData.Start = Utility.ParseToInt(actionDataList[0]); updateData.ActionKey = actionDataList[1].ToString(); updateData.Duration = float.Parse(actionDataList[2].ToString()); if( actionDataList.Count > 3 ) { updateData.Param = actionDataList[3] as Hashtable; } updateData.EventTrigger = this.FormulateEventTriggers( updateData.Param ); DragonAnimationQueue.getInstance().AddUpdateCue( updateData.GenerateHashtable() ); } } // Transition Queue ArrayList transitionQueue = SequenceReader.GetInstance().ReadTransform(action); if( transitionQueue != null ) { foreach( object actionData in transitionQueue ) { ArrayList actionDataList = actionData as ArrayList; TransformData transformData = new TransformData(); transformData.Action = action; transformData.Start = Utility.ParseToInt(actionDataList[0]); transformData.ActionKey = actionDataList[1].ToString(); transformData.Duration = float.Parse(actionDataList[2].ToString()); if( actionDataList.Count > 3 ) { transformData.Param = actionDataList[3] as Hashtable; } transformData.EventTrigger = this.FormulateEventTriggers( transformData.Param ); DragonAnimationQueue.getInstance().AddTransformCue( transformData.GenerateHashtable() ); } } ArrayList cameraQueue = SequenceReader.GetInstance().ReadCamera(action); if( cameraQueue != null ) { foreach( object actionData in cameraQueue ) { ArrayList actionDataList = actionData as ArrayList; CameraData cameraData = new CameraData(); cameraData.Action = action; cameraData.Start = Utility.ParseToInt(actionDataList[0]); cameraData.ActionKey = actionDataList[1].ToString(); cameraData.Duration = float.Parse(actionDataList[2].ToString()); if( actionDataList.Count > 3 ) { cameraData.Param = actionDataList[3] as Hashtable; } cameraData.EventTrigger = this.FormulateEventTriggers( cameraData.Param ); DragonAnimationQueue.getInstance().AddCameraCue( cameraData.GenerateHashtable() ); } } ArrayList eventQueue = SequenceReader.GetInstance().ReadEventTriggers(action); if( eventQueue != null ) { foreach( object actionData in eventQueue ) { ArrayList actionDataList = actionData as ArrayList; EventData eventData = new EventData(); eventData.Action = action; eventData.Start = Utility.ParseToInt(actionDataList[0]); eventData.ActionKey = actionDataList[1].ToString(); eventData.Duration = float.Parse(actionDataList[2].ToString()); if( actionDataList.Count > 3 ) { eventData.Param = actionDataList[3] as Hashtable; } eventData.EventTrigger = this.FormulateEventTriggers( eventData.Param ); DragonAnimationQueue.getInstance().AddEventCue( eventData.GenerateHashtable() ); } } // + LA 072613 ArrayList soundQueue = SequenceReader.GetInstance().ReadSounds(action); if( soundQueue != null ) { foreach( object actionData in soundQueue ) { ArrayList actionDataList = actionData as ArrayList; SoundData soundData = new SoundData(); soundData.Action = action; soundData.Start = Utility.ParseToInt(actionDataList[0]); soundData.ActionKey = actionDataList[1].ToString(); soundData.Duration = float.Parse(actionDataList[2].ToString()); if( actionDataList.Count > 3 ) { soundData.Param = actionDataList[3] as Hashtable; } soundData.EventTrigger = this.FormulateEventTriggers( soundData.Param ); DragonAnimationQueue.getInstance().AddSoundCue( soundData.GenerateHashtable() ); } } // - LA } DragonAnimationQueue.getInstance().PlayQueuedAnimations(); }
public void Setup() { cameraObject = MonoBehaviour.Instantiate(Resources.Load <GameObject>("Prefabs/Camera")); cameraData = cameraObject.GetComponent <CameraData>(); cam = cameraObject.GetComponent <CameraS>(); }
void Awake() { if (!mInstance) mInstance = this; //otherwise, if we do, kill this thing else { Destroy(this.gameObject); return; } artData = GetComponent<ArtData>(); filtersManager = GetComponent<FiltersManager>(); StartCoroutine(GetServerData(json_galleries_Url)); cameraData = GetComponent<CameraData>(); fade = GetComponentInChildren<Fade>(); areaData = GetComponent<AreaData>(); fade.gameObject.SetActive(true); roomsData = GetComponent<RoomsData>(); filtersManager = GetComponent<FiltersManager>(); DontDestroyOnLoad(this.gameObject); Screen.autorotateToLandscapeLeft = true; Screen.autorotateToLandscapeRight = false; Screen.autorotateToPortrait = false; Screen.autorotateToPortraitUpsideDown = false; Events.ToggleUnit += ToggleUnits; }
/// <summary> /// Helper method to copy data from a <see cref="CameraData"/> /// to a <see cref="CameraInfo"/> instance. /// </summary> /// <param name="info">The full data instance.</param> /// <param name="data">The data instance.</param> public static void CopyFrom(this CameraInfo info, CameraData data) { info.Link = data?.Link; info.Name = data?.Name; info.RoomId = data?.Room; }
public void Start() { if (!IsAvailable) { Debug.LogError("Ansel is not available or enabled on this platform. Did you forget to whitelist your executable?"); return; } // Get our camera (this script _must_ be attached to the main camera which renders the 3D scene) mainCam = GetComponent <UnityEngine.Camera>(); // Hint example, call this right before setting HDR render target active. This will notify Ansel that HDR buffer is about to bind. // Use that if Ansel is incorrectly determining HDR buffer to be used. (by default it is not the case). // This is only the example, consider trying different CameraEvents in the rendering pipeline. /* * mainCam.AddCommandBuffer(CameraEvent.BeforeImageEffects, hintBufferPreBindCBs[(int)HintBufferType.kBufferTypeHDR]); */ anselConfig = new ConfigData(); // Default coordinate system is left handed. // If your project is using different coordinate system please adjust accordingly anselConfig.right = new float[3] { 1, 0, 0 }; anselConfig.up = new float[3] { 0, 1, 0 }; anselConfig.forward = new float[3] { 0, 0, 1 }; // Can be set by user from the editor anselConfig.translationalSpeedInWorldUnitsPerSecond = TranslationalSpeedInWorldUnitsPerSecond; anselConfig.rotationalSpeedInDegreesPerSecond = RotationalSpeedInDegreesPerSecond; anselConfig.captureLatency = CaptureLatency; anselConfig.captureSettleLatency = CaptureSettleLatency; anselConfig.metersInWorldUnit = MetersInWorldUnit; // These should always be true unless there is some special scenario anselConfig.isCameraOffcenteredProjectionSupported = true; anselConfig.isCameraRotationSupported = true; anselConfig.isCameraTranslationSupported = true; anselConfig.isCameraFovSupported = true; anselInit(ref anselConfig); // Ansel will return camera parameters here anselCam = new CameraData(); // Default session configuration which allows everything. // Game can reconfigure session anytime session is not active by calling ConfigureSession. SessionData ses = new SessionData(); ses.isAnselAllowed = true; // if false none of the below parameters is relevant ses.isFovChangeAllowed = true; ses.isHighresAllowed = true; ses.isPauseAllowed = true; ses.isRotationAllowed = true; ses.isTranslationAllowed = true; ses.is360StereoAllowed = true; ses.is360MonoAllowed = true; anselConfigureSession(ref ses); // Custom Control example // Add your own slider or boolean toggle into the Ansel UI. You can then poll values at any time, but // it makes sense to do it only when anselIsSessionOn() is true. It is a good way to add the control // over game specific settings like for instance day/night switch or bloom intensity. /* * { * anselAddUserControlSlider(1, "My Custom Slider", 0.2f)); * float myValue = anselGetUserControlSliderValue(2) * } */ if (!IsAvailable) { Debug.LogError("Ansel failed to configure session. Please check Ansel log for more details."); } else { print("Ansel is initialized and ready to use"); } }
// -------------------------------------------------------------------------------- public void Start() { if (!IsAvailable) { Debug.LogError("Ansel is not available or enabled on this platform. Did you forget to whitelist your executable?"); return; } // Get our camera (this script _must_ be attached to the main camera which renders the 3D scene) mainCam = GetComponent <UnityEngine.Camera>(); anselConfig = new ConfigData(); // Default coordinate system is left handed. // If your project is using different coordinate system please adjust accordingly anselConfig.right = new float[3] { 1, 0, 0 }; anselConfig.up = new float[3] { 0, 1, 0 }; anselConfig.forward = new float[3] { 0, 0, 1 }; // Can be set by user from the editor anselConfig.translationalSpeedInWorldUnitsPerSecond = TranslationalSpeedInWorldUnitsPerSecond; anselConfig.rotationalSpeedInDegreesPerSecond = RotationalSpeedInDegreesPerSecond; anselConfig.captureLatency = CaptureLatency; anselConfig.captureSettleLatency = CaptureSettleLatency; anselConfig.metersInWorldUnit = MetersInWorldUnit; // These should always be true unless there is some special scenario anselConfig.isCameraOffcenteredProjectionSupported = true; anselConfig.isCameraRotationSupported = true; anselConfig.isCameraTranslationSupported = true; anselConfig.isCameraFovSupported = true; // This value can be used to allow users to run some cool filter through entire game anselConfig.isFilterOutsideSessionAllowed = IsFilterOutsideSessionAllowed; anselInit(ref anselConfig); // Ansel will return camera parameters here anselCam = new CameraData(); // Default session configuration which allows everything. // Game can reconfigure session anytime session is not active by calling ConfigureSession. SessionData ses = new SessionData(); ses.isAnselAllowed = true; // if false none of the below parameters is relevant ses.isFovChangeAllowed = true; ses.isHighresAllowed = true; ses.isPauseAllowed = true; ses.isRotationAllowed = true; ses.isTranslationAllowed = true; ses.is360StereoAllowed = true; ses.is360MonoAllowed = true; anselConfigureSession(ref ses); if (!IsAvailable) { Debug.LogError("Ansel failed to configure session. Please check Ansel log for more details."); } else { print("Ansel is initialized and ready to use"); } }
private void AddAbilities() { CameraData defaultCamera = AssetDatabase.LoadAssetAtPath <CameraData>("Assets/Dias Games/Third Person System/Camera Data/Default.asset"); CameraData climbingCamera = AssetDatabase.LoadAssetAtPath <CameraData>("Assets/Dias Games/Climbing System/Camera Data/ClimbingCamera.asset"); CameraData ladderCamera = AssetDatabase.LoadAssetAtPath <CameraData>("Assets/Dias Games/Climbing System/Camera Data/LadderCamera.asset"); if (character.GetComponent <DiasGames.ThirdPersonSystem.AnimatorManager>() == null) { character.gameObject.AddComponent <DiasGames.ThirdPersonSystem.AnimatorManager>(); } if (character.GetComponent <DiasGames.ThirdPersonSystem.UnityInputManager>() == null) { character.gameObject.AddComponent <DiasGames.ThirdPersonSystem.UnityInputManager>(); } DiasGames.ThirdPersonSystem.Locomotion m_Locomotion = character.GetComponent <DiasGames.ThirdPersonSystem.Locomotion>(); if (m_Locomotion == null) { m_Locomotion = character.gameObject.AddComponent <DiasGames.ThirdPersonSystem.Locomotion>(); m_Locomotion.AbilityPhysicMaterial = zeroFriction; m_Locomotion.CameraData = defaultCamera; } DiasGames.ThirdPersonSystem.JumpAbility m_Jump = character.GetComponent <DiasGames.ThirdPersonSystem.JumpAbility>(); if (m_Jump == null) { m_Jump = character.gameObject.AddComponent <DiasGames.ThirdPersonSystem.JumpAbility>(); m_Jump.AbilityPhysicMaterial = zeroFriction; } DiasGames.ThirdPersonSystem.FallAbility m_Fall = character.GetComponent <DiasGames.ThirdPersonSystem.FallAbility>(); if (m_Fall == null) { m_Fall = character.gameObject.AddComponent <DiasGames.ThirdPersonSystem.FallAbility>(); m_Fall.AbilityPhysicMaterial = zeroFriction; } DiasGames.ThirdPersonSystem.RollAbility m_Roll = character.GetComponent <DiasGames.ThirdPersonSystem.RollAbility>(); if (m_Roll == null) { m_Roll = character.gameObject.AddComponent <DiasGames.ThirdPersonSystem.RollAbility>(); } DiasGames.ThirdPersonSystem.CrouchAbility m_Crouch = character.GetComponent <DiasGames.ThirdPersonSystem.CrouchAbility>(); if (m_Crouch == null) { m_Crouch = character.gameObject.AddComponent <DiasGames.ThirdPersonSystem.CrouchAbility>(); m_Crouch.AbilityPhysicMaterial = groundFriction; } LayerMask m_FootLayers = (1 << 0) | (1 << 14) | (1 << 16) | (1 << 17) | (1 << 18) | (1 << 19) | (1 << 20); // Vault ability DiasGames.ThirdPersonSystem.ClimbingSystem.VaultAbility m_Vault = character.GetComponent <DiasGames.ThirdPersonSystem.ClimbingSystem.VaultAbility>(); if (m_Vault == null) { m_Vault = character.gameObject.AddComponent <DiasGames.ThirdPersonSystem.ClimbingSystem.VaultAbility>(); } m_Vault.ClimbingMask = (1 << 21); //// // Step Up ability Setup DiasGames.ThirdPersonSystem.ClimbingSystem.StepUpAbility m_StepUp = character.GetComponent <DiasGames.ThirdPersonSystem.ClimbingSystem.StepUpAbility>(); if (m_StepUp == null) { m_StepUp = character.gameObject.AddComponent <DiasGames.ThirdPersonSystem.ClimbingSystem.StepUpAbility>(); } m_StepUp.ClimbingMask = (1 << 16); //// // Half Climb ability Setup DiasGames.ThirdPersonSystem.ClimbingSystem.LowerClimbAbility m_LowerClimb = character.GetComponent <DiasGames.ThirdPersonSystem.ClimbingSystem.LowerClimbAbility>(); if (m_LowerClimb == null) { m_LowerClimb = character.gameObject.AddComponent <DiasGames.ThirdPersonSystem.ClimbingSystem.LowerClimbAbility>(); } m_LowerClimb.ClimbingMask = (1 << 17); //// // Climbing ability setup DiasGames.ThirdPersonSystem.ClimbingSystem.ClimbingAbility m_Climbing = character.GetComponent <DiasGames.ThirdPersonSystem.ClimbingSystem.ClimbingAbility>(); if (m_Climbing == null) { m_Climbing = character.gameObject.AddComponent <DiasGames.ThirdPersonSystem.ClimbingSystem.ClimbingAbility>(); } m_Climbing.ClimbingMask = (1 << 18) | (1 << 19); m_Climbing.CameraData = climbingCamera; //// DiasGames.ThirdPersonSystem.ClimbingSystem.ClimbIK m_ClimbIK = character.GetComponent <DiasGames.ThirdPersonSystem.ClimbingSystem.ClimbIK>(); if (m_ClimbIK == null) { m_ClimbIK = character.AddComponent <DiasGames.ThirdPersonSystem.ClimbingSystem.ClimbIK>(); } m_ClimbIK.m_FeetLayers = m_FootLayers; DiasGames.ThirdPersonSystem.ClimbingSystem.DropToClimbAbility m_DropToClimb = character.GetComponent <DiasGames.ThirdPersonSystem.ClimbingSystem.DropToClimbAbility>(); if (m_DropToClimb == null) { m_DropToClimb = character.gameObject.AddComponent <DiasGames.ThirdPersonSystem.ClimbingSystem.DropToClimbAbility>(); } m_DropToClimb.DroppableLayer = (1 << 19) | (1 << 20); m_DropToClimb.CameraData = climbingCamera; DiasGames.ThirdPersonSystem.ClimbingSystem.ClimbLadderAbility m_Ladder = character.GetComponent <DiasGames.ThirdPersonSystem.ClimbingSystem.ClimbLadderAbility>(); if (m_Ladder == null) { m_Ladder = character.gameObject.AddComponent <DiasGames.ThirdPersonSystem.ClimbingSystem.ClimbLadderAbility>(); } m_Ladder.CameraData = ladderCamera; // -------------------------- SET IGNORE ABILITIES ---------------------------------- // // Jump m_Jump.IgnoreAbilities = new List <DiasGames.ThirdPersonSystem.ThirdPersonAbility>(); m_Jump.IgnoreAbilities.Add(m_Locomotion); // Roll m_Roll.IgnoreAbilities = new List <DiasGames.ThirdPersonSystem.ThirdPersonAbility>(); m_Roll.IgnoreAbilities.Add(m_Locomotion); m_Roll.IgnoreAbilities.Add(m_Crouch); //Crouch m_Crouch.IgnoreAbilities = new List <ThirdPersonAbility>(); m_Crouch.IgnoreAbilities.Add(m_Locomotion); // Climb ladder m_Ladder.IgnoreAbilities = new List <DiasGames.ThirdPersonSystem.ThirdPersonAbility>(); m_Ladder.IgnoreAbilities.Add(m_Locomotion); m_Ladder.IgnoreAbilities.Add(m_Fall); m_Ladder.IgnoreAbilities.Add(m_Jump); // Step up m_StepUp.IgnoreAbilities = new List <DiasGames.ThirdPersonSystem.ThirdPersonAbility>(); m_StepUp.IgnoreAbilities.Add(m_Locomotion); // Half climb m_LowerClimb.IgnoreAbilities = new List <DiasGames.ThirdPersonSystem.ThirdPersonAbility>(); m_LowerClimb.IgnoreAbilities.Add(m_Locomotion); m_LowerClimb.IgnoreAbilities.Add(m_Fall); m_LowerClimb.IgnoreAbilities.Add(m_Jump); // Climbing m_Climbing.IgnoreAbilities = new List <DiasGames.ThirdPersonSystem.ThirdPersonAbility>(); m_Climbing.IgnoreAbilities.Add(m_Fall); m_Climbing.IgnoreAbilities.Add(m_Jump); // Drop to climb m_DropToClimb.IgnoreAbilities = new List <DiasGames.ThirdPersonSystem.ThirdPersonAbility>(); m_DropToClimb.IgnoreAbilities.Add(m_Locomotion); // Vault m_Vault.IgnoreAbilities = new List <ThirdPersonAbility>(); m_Vault.IgnoreAbilities.Add(m_Locomotion); m_Vault.IgnoreAbilities.Add(m_Jump); m_Vault.IgnoreAbilities.Add(m_Fall); m_Vault.IgnoreAbilities.Add(m_Crouch); // -------------------------------------------------------------------------------- // }
[DllImport("usdi")] public static extern Bool usdiCameraWriteSample(Camera cam, ref CameraData src, double t);
public GameInitializator(GameController gameController, PlayerData playerData, CameraData cameraData) { new PlayerInitializator(gameController, playerData); new CameraInitializator(gameController, cameraData); }
/// <summary> /// キャプチャしたイメージを Texture2D として取得します。 /// </summary> /// <returns> /// キャプチャされたイメージが与えられた Texture2D 。 /// </returns> private Texture2D GenerateCaptureImage(CameraData data) { Camera fixedCamera; if (data.camera == null) { fixedCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>(); } else { fixedCamera = data.camera; } int fixedWidth = data.width; int fixedHiehgt = data.height; int bit = 32; int[] gameViewResolution = GetGameViewResolution(); if (fixedWidth == 0) { fixedWidth = gameViewResolution[0]; } if (fixedHiehgt == 0) { fixedHiehgt = gameViewResolution[1]; } fixedWidth *= this.imageScale; fixedHiehgt *= this.imageScale; Color presetBackgroundColor = fixedCamera.backgroundColor; CameraClearFlags presetClearFlags = fixedCamera.clearFlags; if (this.enableBackgroundAlpha) { fixedCamera.backgroundColor = Color.clear; fixedCamera.clearFlags = CameraClearFlags.SolidColor; } RenderTexture presetRenderTexture = fixedCamera.targetTexture; // カメラに出力用の RenderTexture を設定してレンダリングを実行し、 // その情報を Texture2D に保存して返す。 RenderTexture outputRenderTexture = new RenderTexture(fixedWidth, fixedHiehgt, bit); fixedCamera.targetTexture = outputRenderTexture; Texture2D captureImage = new Texture2D(fixedWidth, fixedHiehgt, TextureFormat.ARGB32, false); fixedCamera.Render(); RenderTexture.active = outputRenderTexture; captureImage.ReadPixels (new Rect(0, 0, fixedWidth, fixedHiehgt), 0, 0); // 設定を元に戻します。 fixedCamera.backgroundColor = presetBackgroundColor; fixedCamera.clearFlags = presetClearFlags; fixedCamera.targetTexture = presetRenderTexture; // 解放してから終了します。 RenderTexture.active = null; outputRenderTexture.Release(); DestroyImmediate(outputRenderTexture); return(captureImage); }
public int CreateCamera(CameraData CameraData) { object[] results = this.Invoke("CreateCamera", new object[] { CameraData}); return ((int)(results[0])); }
private static extern void anselUpdateCamera(ref CameraData cam);
// Reset camera move direction protected Vector3 GetCameraMoveDirection( CameraData cameraPosData) { Vector3 vec3Direction = GetPosition( cameraPosData.CameraHeight, cameraPosData.CameraDistance, cameraPosData.YRotate); vec3Direction.y -= cameraPosData.CharHeight; return vec3Direction.normalized; }
public static RenderCommand DrawGeometry(CameraData camera, Matrix4 cameraTransform) { return(new RenderCommand("Draw Geometry", (ref RenderContext context) => { if (!context.TryGetData(out GeometryRenderData geometryData)) { return; } if (!context.TryGetData(out LightsRenderData lightData)) { return; } //if (MainDevWindowGL.Window.KeyboardState.IsKeyDown(OpenTK.Windowing.GraphicsLibraryFramework.Keys.I)) // yaw += 0.1f; //if (MainDevWindowGL.Window.KeyboardState.IsKeyDown(OpenTK.Windowing.GraphicsLibraryFramework.Keys.O)) // yaw -= 0.1f; //if (MainDevWindowGL.Window.KeyboardState.IsKeyDown(OpenTK.Windowing.GraphicsLibraryFramework.Keys.K)) // pitch += 0.1f; //if (MainDevWindowGL.Window.KeyboardState.IsKeyDown(OpenTK.Windowing.GraphicsLibraryFramework.Keys.L)) // pitch -= 0.1f; Ogl.Viewport(0, 0, AppScreen.Resolution.x, AppScreen.Resolution.y); Ogl.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); Light mainLight = lightData.lights[0]; Matrix4 projection = camera.CalculateProjection(); List <MeshRenderGroup> renderGroups = geometryData.GetRenderGroups(); for (int i = 0; i < renderGroups.Count; i++) { MeshRenderGroup renderGroup = renderGroups[i]; RenderMesh pair = renderGroup.MeshRender; List <Matrix4> positions = renderGroup.Transforms; pair.mat.SetDepthMap(new DepthTexture(mainLight.Framebuffer.DepthBuffer)); GraphicsAPI.UseMeshMaterial(pair.mesh, pair.mat); //Update camera pos for material //TODO: Use 'Uniform buffer objects' to globally share this data pair.mat.SetMatrix("view", cameraTransform); pair.mat.SetMatrix("projection", projection); pair.mat.SetVector3("directionalLight", new Vector3(1, 1, 1)); pair.mat.SetVector3("ambientLight", new Vector3(0.5f, 0.5f, 0.5f)); pair.mat.SetVector3("directionalDir", LIGHT_FORWARD_NORMALIZED); pair.mat.SetMatrix("lightSpace", LIGHT_VIEW * mainLight.GetProjection()); for (int p = 0; p < positions.Count; p++) { pair.mat.SetMatrix("model", positions[p]); GraphicsAPI.DrawTriangles(pair.mesh.GetIndiceCount()); } GraphicsAPI.FreeMeshMaterial(pair.mesh, pair.mat); } }));
public void ServeCamera(CameraData data) { msServerServeCamera(self, data); }
public void RenderPostProcess(CommandBuffer cmd, ref CameraData cameraData, RenderTextureFormat colorFormat, RenderTargetIdentifier source, RenderTargetIdentifier dest, bool opaqueOnly) { RenderPostProcess(cmd, ref cameraData, colorFormat, source, dest, opaqueOnly, !cameraData.isStereoEnabled && cameraData.camera.targetTexture == null); }
[DllImport(Lib.name)] static extern void msServerServeCamera(IntPtr self, CameraData data);