align 3d view to surface

Next
 From:  vector illustrator (QUARITEXA)
9607.1 
how to align 3d view to surface?
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
9607.2 In reply to 9607.1 
Hi Quaritexa, you can use the View > CPlane tool to set the construction plane to be aligned to a surface and then the 2D Top, Front, and Right views will be views relative to that surface instead of their default world axis views.

There is not a built in way to align the 3D view to a surface though. It's possible to do it by a script, would that help? Like something that aligns the 3D view to cplane's z axis so it is looking in the same direction as the Top ortho view?

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  vector illustrator (QUARITEXA)
9607.3 In reply to 9607.2 
I write this code:

/* Align 3D view to surface */ script: var vp = moi.ui.mainWindow.ViewPanel.getViewport('3D'), cp = moi.view.getCPlane(); moi.view.setCPlaneInteractive(); var vt = moi.ui.mainWindow.viewPanel.getViewport('top'); vp.setCameraAndTarget(vt.cameraPt, vt.targetPt); vp.Projection = 'Parallel'; moi.view.setCplane(cp, true, true);

But I'm not sure the code is correct.
And I don't know how to set right camera rotation.

EDITED: 7 Dec 2019 by QUARITEXA

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
9607.4 In reply to 9607.3 
Hi Quaritexa, it's pretty close. One thing is put the script: label at the very start, then you can put the /* */ comment after that.

For rotation maybe the only way currently is by the tiltAngle property.

I'll see about adding in a new method that takes a camera, target, and also an "up" direction vector. I think you can get a viewport's "up" direction from cameraFrame.yaxis but there isn't a way to set it directly. I think the tiltAngle should be an angle value that is how much the current up direction is rotated away from the world z axis.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
9607.5 In reply to 9607.3 
Try this one, it seems to be very slightly off I'm not sure why at the moment:

script: /* Align 3D view to surface */ var vp = moi.ui.mainWindow.ViewPanel.getViewport('3D'), cp = moi.view.getCPlane(); moi.view.setCPlaneInteractive(); var vt = moi.ui.mainWindow.viewPanel.getViewport('top'); vp.targetPt = vt.targetPt; vp.setAngles(vt.upDownAngle, vt.leftRightAngle, vt.tiltAngle); vp.Projection = 'Parallel'; moi.view.setCplane(cp, true, true);

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  vector illustrator (QUARITEXA)
9607.6 In reply to 9607.5 
With this script the 3D view differs from the top view:

Attachments:

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
9607.7 In reply to 9607.6 
Hi Quaritexa, I think the problem is the target point on the 2D views is not used for anything and so is not getting set. So get the target point through some other way instead of from the top view.

For the angle getting the tilt angle from the Top view and setting it as the 3D view's tilt angle seems to work, try this one:

script: /* Align 3D view to surface */ var vp = moi.ui.mainWindow.ViewPanel.getViewport('3D'), cp = moi.view.getCPlane(); moi.view.setCPlaneInteractive(); var vt = moi.ui.mainWindow.viewPanel.getViewport('top'); vp.setCameraAndTarget(vt.cameraPt, moi.view.getCPlane().origin); vp.tiltAngle = vt.tiltAngle; vp.Projection = 'Parallel'; moi.view.setCplane(cp, true, true);

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
9607.8 In reply to 9607.6 
Hi Quaritexa, ok so yes the problem is that when setting the cplane the ortho view's target point did not get updated. MoI does not use the target point on the Top/Front/Right views for anything so that's why it went previously unnoticed.

I've fixed that now for the next v4 beta and also I've added in an optional additional parameter to vp.setCameraAndTarget() so it can take an "up" direction vector to set the view rotation around the camera->target line. So that will be an additional way to control it.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  vector illustrator (QUARITEXA)
9607.9 In reply to 9607.7 
Thank you very much, Michael. That's exactly what I need.

That's how it works:

EDITED: 8 Dec 2019 by QUARITEXA

Image Attachments:
Size: 1.9 MB, Downloaded: 125 times, Dimensions: 974x696px
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All