Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scene doesn't re-render on camera move
#1
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();
    }
}
#2
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.
#3
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.
Andrej Benedik
  


Forum Jump:


Users browsing this thread:
1 Guest(s)