AB4D Forum

Full Version: Scene Camera Mod 360
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi

I want to make the scene camera heading always between 0 and 360.

I bind the Heading to the property below, where I set the value using % 360.

This seems to work, but after a couple of whole rotations, it spins around wildly?

Why might this be??

Code:
// SceneCameraHeading
        private double _SceneCameraHeading;
        public double SceneCameraHeading
        {
            get
            {
                return _SceneCameraHeading;
            }
            set
            {
                if (value != _SceneCameraHeading)
                {
                    _SceneCameraHeading = value % 360;
                    NotifyPropertyChanged("SceneCameraHeading");

                    // IsModified
                    IsModified = true;
                }
            }
        }

(06-01-2015, 12:48 PM)ZENUAV Wrote: [ -> ]Hi

I want to make the scene camera heading always between 0 and 360.

I bind the Heading to the property below, where I set the value using % 360.

This seems to work, but after a couple of whole rotations, it spins around wildly?

Why might this be??

Code:
// SceneCameraHeading
        private double _SceneCameraHeading;
        public double SceneCameraHeading
        {
            get
            {
                return _SceneCameraHeading;
            }
            set
            {
                if (value != _SceneCameraHeading)
                {
                    _SceneCameraHeading = value % 360;
                    NotifyPropertyChanged("SceneCameraHeading");

                    // IsModified
                    IsModified = true;
                }
            }
        }

I've updated the code to this, but I get the same problem.

Code:
_SceneCameraHeading = (value % 360) + (value < 0 ? 360 : 0);

If I rotate it slowly I think it works, but if I spin it fast it spins back a full 360 I think.

Could it be to do with inertia??
Why do you need to preserve the Heading between 0 and 360?
If this is only for displaying the value I would advise you to only "normalize" the value that is shown and not the actual heading value on the camera.