-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/524 point cloud with multiple cameras #529
Merged
wrestledBearOnce
merged 10 commits into
develop
from
feature/524-point-cloud-w-mult-cams
Jun 22, 2022
Merged
Feature/524 point cloud with multiple cameras #529
wrestledBearOnce
merged 10 commits into
develop
from
feature/524-point-cloud-w-mult-cams
Jun 22, 2022
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Test Code: Simple Examle using Fusee.Base.Core;
using Fusee.Engine.Common;
using Fusee.Engine.Core;
using Fusee.Engine.Core.Scene;
using Fusee.Engine.Gui;
using Fusee.Math.Core;
using System;
using System.Threading.Tasks;
using static Fusee.Engine.Core.Input;
using static Fusee.Engine.Core.Time;
namespace Fusee.Examples.Simple.Core
{
[FuseeApplication(Name = "FUSEE Simple Example", Description = "A very simple example.")]
public class Simple : RenderCanvas
{
// angle variables
private static float _angleHorz, _angleVert, _angleVelHorz, _angleVelVert;
private const float RotationSpeed = 7;
private const float Damping = 0.8f;
private SceneContainer _rocketScene;
private SceneRendererDeferred _sceneRenderer;
private const float ZNear = 1f;
private const float ZFar = 1000;
private readonly float _fovy = M.PiOver4;
private SceneRendererForward _guiRenderer;
private SceneContainer _gui;
private SceneInteractionHandler _sih;
private Transform _camPivotTransform;
private bool _keys;
private WritableTexture rt1 = WritableTexture.CreateAlbedoTex(1920, 1080, new Base.Common.ImagePixelFormat(Base.Common.ColorFormat.RGBA));
private WritableTexture rt2 = WritableTexture.CreateAlbedoTex(1920, 1080, new Base.Common.ImagePixelFormat(Base.Common.ColorFormat.RGBA));
private async Task Load()
{
Console.WriteLine("Loading scene ...");
_gui = await FuseeGuiHelper.CreateDefaultGuiAsync(this, CanvasRenderMode.Screen, "FUSEE Simple Example");
// Create the interaction handler
_sih = new SceneInteractionHandler(_gui);
// Load the rocket model
_rocketScene = await AssetStorage.GetAsync<SceneContainer>("RocketFus.fus");
_camPivotTransform = new Transform();
var camNode = new SceneNode()
{
Name = "CamPivoteNode",
Children = new ChildList()
{
new SceneNode()
{
Name = "MainCam",
Components = new System.Collections.Generic.List<SceneComponent>()
{
new Transform() { Translation = new float3(0, 2, -10) },
new Camera(ProjectionMethod.Perspective, ZNear, ZFar, _fovy)
{
BackgroundColor = float4.One,
Viewport = new float4(50, 0, 50, 100),
RenderTexture = rt1
},
new Camera(ProjectionMethod.Perspective, ZNear, ZFar, _fovy)
{
BackgroundColor = float4.One,
Viewport = new float4(0, 0, 50, 100),
//RenderTexture = rt2
}
}
}
},
Components = new System.Collections.Generic.List<SceneComponent>()
{
_camPivotTransform
}
};
_rocketScene.Children.Add(camNode);
// Wrap a SceneRenderer around the model.
_sceneRenderer = new SceneRendererDeferred(_rocketScene);
_guiRenderer = new SceneRendererForward(_gui);
}
public override async Task InitAsync()
{
await Load();
await base.InitAsync();
}
// Init is called on startup.
public override void Init()
{
}
public override void Update()
{
_camPivotTransform.RotationQuaternion = QuaternionF.FromEuler(_angleVert, _angleHorz, 0);
// Mouse and keyboard movement
if (Keyboard.LeftRightAxis != 0 || Keyboard.UpDownAxis != 0)
{
_keys = true;
}
if (Mouse.LeftButton)
{
_keys = false;
_angleVelHorz = RotationSpeed * Mouse.XVel * DeltaTimeUpdate * 0.0005f;
_angleVelVert = RotationSpeed * Mouse.YVel * DeltaTimeUpdate * 0.0005f;
}
else if (Touch != null && Touch.GetTouchActive(TouchPoints.Touchpoint_0))
{
_keys = false;
var touchVel = Touch.GetVelocity(TouchPoints.Touchpoint_0);
_angleVelHorz = RotationSpeed * touchVel.x * DeltaTimeUpdate * 0.0005f;
_angleVelVert = RotationSpeed * touchVel.y * DeltaTimeUpdate * 0.0005f;
}
else
{
if (_keys)
{
_angleVelHorz = RotationSpeed * Keyboard.LeftRightAxis * DeltaTimeUpdate;
_angleVelVert = RotationSpeed * Keyboard.UpDownAxis * DeltaTimeUpdate;
}
else
{
var curDamp = (float)System.Math.Exp(-Damping * DeltaTimeUpdate);
_angleVelHorz *= curDamp;
_angleVelVert *= curDamp;
}
}
_angleHorz += _angleVelHorz;
_angleVert += _angleVelVert;
}
// RenderAFrame is called once a frame
public override void RenderAFrame()
{
_sceneRenderer.Render(RC);
_guiRenderer.Render(RC);
//Constantly check for interactive objects.
if (!Mouse.Desc.Contains("Android"))
_sih.CheckForInteractiveObjects(RC, Mouse.Position, Width, Height);
if (Touch != null && Touch.GetTouchActive(TouchPoints.Touchpoint_0) && !Touch.TwoPoint)
{
_sih.CheckForInteractiveObjects(RC, Touch.GetPosition(TouchPoints.Touchpoint_0), Width, Height);
}
// Swap buffers: Show the contents of the backbuffer (containing the currently rendered frame) on the front buffer.
Present();
}
}
} |
wrestledBearOnce
approved these changes
Jun 22, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #524
Summary
PointCloudComponent
(see PointCloudCompnent doesn't render correctly when using multiple cameras #524)added "Clear Pass": theSceneRenderers
clear for all active cameras and render for all active cameras separatelyGL.Clear
calls from RCISetRenderTarget
methods for clarityRender using multiple viewports / cameras, with or without render texture should now function correctly.