TheSwamp

Code Red => .NET => Topic started by: kaefer on January 27, 2012, 11:55:25 AM

Title: Viewport Transforms
Post by: kaefer on January 27, 2012, 11:55:25 AM
I guess we're all familiar with gile's .NET GEOMETRY Routines (http://www.theswamp.org/index.php?topic=31865.msg373672#msg373672), which provide transformations between User, World, Display, and Paper Space Display Coordinate Systems for the Viewport and Editor classes.

While browsing the Viewport class in arxmgd.chm (hooray for that, because Exchange sucks) I came across properties named EyeToModelTransform, ModelToEyeTransform, EyeToWorldTransform, and WorldToEyeTransform. Can anybody tell what those are supposed to do and how they correspond to the more intuitive transformations mentioned above?
Title: Re: Viewport Transforms
Post by: LE3 on January 28, 2012, 11:18:51 AM
Not familiar with Gile's stuff about this.

Have used this AcGiViewport class, in an 'Object Viewer' similar to the one that comes in the vertical MEP i.e.

For a very simple example you can use this class to view or display text to be always horizontal to any view, etc.

Reference to: arxref.chm - AcGiViewport class
Title: Re: Viewport Transforms
Post by: gile on January 28, 2012, 11:43:43 AM
Hi,

I had a little look at these methods.
They apply to the GraphisInterface.Viewport class (not to the DatabaseServices.Viewport class).
I do not know the difference between Model and World forms, but the World forms works like WCS2DCS ou DCS2WCS.
I used EyeToWorldTransform in CustomOsnap (http://www.theswamp.org/index.php?topic=32031.msg375055#msg375055) to display osnap glyphes parallel to the screen.

In this message (http://www.theswamp.org/index.php?topic=40471.msg458579#msg458579), I tried to correct the transformation matrix so that the attributes text display parallel to the screen whatever the view.
I should have use EyeToWorldTransform to write:
Code - C#: [Select]
  1.             Point3d org = attRef.Position;
  2.             Matrix3d viewMat =
  3.                 Matrix3d.Displacement(vd.Viewport.CameraTarget.GetVectorTo(org)) *
  4.                 vd.Viewport.EyeToWorldTransform *
  5.                 Matrix3d.WorldToPlane(new Plane(org, attRef.Normal)) *
  6.                 Matrix3d.Rotation(-attRef.Rotation, attRef.Normal, org);
instead of:
Code - C#: [Select]
  1.             Point3d org = attRef.Position;
  2.             Vector3d zVec = vd.Viewport.ViewDirection;
  3.             Vector3d yVec = vd.Viewport.CameraUpVector;
  4.             Vector3d xVec = yVec.CrossProduct(zVec).GetNormal();
  5.             Matrix3d viewMat =
  6.                 Matrix3d.AlignCoordinateSystem(
  7.                 Point3d.Origin, Vector3d.XAxis, Vector3d.YAxis, Vector3d.ZAxis,
  8.                 org, xVec, yVec, zVec) *
  9.                 Matrix3d.WorldToPlane(new Plane(org, attRef.Normal)) *
  10.                 Matrix3d.Rotation(-attRef.Rotation, attRef.Normal, org);