AB4D Forum
Scene Camera Mod 360 - Printable Version

+- AB4D Forum (https://forum.ab4d.com)
+-- Forum: Products Forums (https://forum.ab4d.com/forumdisplay.php?fid=4)
+--- Forum: Ab3d.PowerToys (https://forum.ab4d.com/forumdisplay.php?fid=9)
+--- Thread: Scene Camera Mod 360 (/showthread.php?tid=3937)



Scene Camera Mod 360 - ZENUAV - 06-01-2015

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??


RE: Scene Camera Mod 360 - abenedik - 06-05-2015

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.