Feature request: Oblique projection (or custom projection)

I would like to be able to achieve a projection such as the one described here https://en.wikipedia.org/wiki/Oblique_projection , with an angle and a fore-shortening factor. Currently I can only do Orthographic or Perspective projections. I have no way of defining a custom projection mode. Such a feature would be very useful. 

4

Comments

11 comments
Date Votes
  • Hello Charbel,

    Can you share a picture of what you are trying to obtain?

    0
  • Hi Alberto,

    Here is what such a projection would look like (when the camera plane is XY).

     

    Similar to what is in the wikipedia article, we want the projection on coordinates to be  (x, y, z) -> (x + az, y + bz, 0).

    0
  • Perhaps this screenshot would be more useful:

     

     

    These two squares have the exact same X and Y coordinates, but with different Z.

    0
  • Thanks Charbel, this is more clear.

    In what field of application is this useful?

    0
  • In our case it is for customized viewing, drawing and manipulating a complex conductor network indented/related to power and grounding systems.

    0
  • Hello Charbel,

    I see, thank you. We probably need to implement this: https://stackoverflow.com/questions/6100614/opengl-oblique-projection

    0
  • Yes. Ideally we would like to be able to modify the angle and fore-shortening factor. Is this something you would be interested in implementing?

    0
  • Hi Charbel,

    I made some tests in order to introduce this feature, however there are some limitations with planar reflections and ZoomFit operations, that we cannot overcome at the moment (if you have any suggestions about implementation or do you know any CAD tool with this kind of projection, please let us know!);
    however, I managed to find a way to show this projection with a custom Camera class, by overriding the GetProjectionMatrix method.

    The result is as follows: could it be a feasible solution for you? 

    internal class MyCamera : Camera
    {
        public double Phi { get; set; } = Utility.DegToRad(45);
        public double Theta { get; set; } = Utility.DegToRad(45);

        public double ObliqueFactorTheta { get; set; } = 0.33;
        public double ObliqueFactorPhi { get; set; } = 0.33;

        private bool IsOblique => ProjectionMode == projectionType.Orthographic && (Phi != Utility.PI_2 || Theta != Utility.PI_2);

        public MyCamera(Camera another) : base(another)
        {
            
        }

        protected override double[] GetProjectionMatrix(double nearDistance, double farDistance, CameraEyePosType cameraEyePos)
        {
            var m = base.GetProjectionMatrix(nearDistance, farDistance, cameraEyePos);

            if(IsOblique)
            {
                double[] obliqueComponent = new double[16];
                obliqueComponent[0] = obliqueComponent[5] = obliqueComponent[10] = obliqueComponent[15] = 1;

                obliqueComponent[8] = -(ObliqueFactorTheta / Math.Tan(Theta));
                obliqueComponent[9] = -(ObliqueFactorPhi / Math.Tan(Phi));

                var ortho = new Transformation(m);
                var oblique = new Transformation(obliqueComponent);

                return (oblique * ortho).MatrixAsVectorByRow;
            }

            return m;
        }
    }

    Here you can download a simple sample using it; please, note that the download will expire in 7 days.

    0
  • Hi Federico. Thanks for the help. The display does indeed seem to work. However I am now encountering a few issues. For example, the camera rotation seems to go all over the place. This happens for example when I set the Center explicitly.

    0
  • Hi Charbel,

    as I stated in my previous message, we encountered a few limitations too.

    Unfortunately, we never used neither encountered this specific projection in other commercial tools: due to the nature of the given projection, we supposed that it could just be useful in top/front/side views; however, if you can give us any hint on a tool that adopts this projection, we can take a look on how it should work in more general use cases.

    0
  • I was really unable to find any popular software that supports this projection mode. As far as display goes, changing the projection matrix seems to display the objects well. It's just some of the other features around it that seem broken. It is mostly useful  top/front/side views but it may be used in other views as well.

    0

Please sign in to leave a comment.

Didn't find what you were looking for?

New post