AB4D Forum
Scene doesn't re-render on camera move - Printable Version

+- AB4D Forum (https://forum.ab4d.com)
+-- Forum: Products Forums (https://forum.ab4d.com/forumdisplay.php?fid=4)
+--- Forum: Ab4d.SharpEngine (https://forum.ab4d.com/forumdisplay.php?fid=12)
+--- Thread: Scene doesn't re-render on camera move (/showthread.php?tid=4443)



Scene doesn't re-render on camera move - zac - 03-19-2024

This is pretty much straight out of the WPF code sample but when I tumble around with my mouse the scene doesn't get re-rendered. I can only get it to update by resizing the window.
Is there something I'm doing wrong or do I just need to manage my own render loop?

Code:
sealed class SharpView : UserControl, IDisposable
{
    readonly SharpEngineSceneView _view = new();
    readonly MouseCameraController _camController;

    public SharpView()
    {
        _view.Initialize();
        var scene = _view.Scene;
        var sceneView = _view.SceneView;

        // init scene

        scene.RootNode.Add(new BoxModelNode(
            new Vector3(0, 0, 0),
            new Vector3(80, 40, 60),
            StandardMaterials.Gold,
            "billy"));

        // init lights

        scene.Lights.Clear();
        scene.Lights.Add(new DirectionalLight(new Vector3(-1, -0.3f, 0)));
        scene.Lights.Add(new PointLight(new Vector3(500, 200, 100), range: 10000));
        scene.SetAmbientLight(intensity: 0.3f);

        // init camera

        sceneView.BackgroundColor = Colors.Black;
        sceneView.Camera = new TargetPositionCamera()
        {
            Heading = -40,
            Attitude = -25,
            Distance = 300,
            TargetPosition = new Vector3(0, 0, 0),
            // If there are no other light in the Scene, then add a camera light that illuminates the scene from the camera's position
            ShowCameraLight = ShowCameraLightType.Auto
        };
        _camController = new MouseCameraController(_view)
        {
            RotateAroundMousePosition = false,
            ZoomMode = CameraZoomMode.ViewCenter,
        };

        Content = _view;
    }

    public void Dispose()
    {
        _view.Dispose();
    }
}



RE: Scene doesn't re-render on camera move - zac - 04-02-2024

I tried running this code on my other computer and it worked. Not sure what the problem was, but I'm glad that fixed it.


RE: Scene doesn't re-render on camera move - abenedik - 04-05-2024

Sorry for the late reply.

I was not able to reproduce your issue. 

Are you sure that you did not change anything? Does the code now work on the first computer?

I would assume that the camera was not updated because some controls from the parent window prevented passing the mouse events to the child UserControl that has MouseCameraController.