Created
November 17, 2019 23:27
-
-
Save kohyuk91/bf59ddcf8e60f50c3c030895a5d84d24 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # | |
| # 3DE4.script.name: XZ Plane Flip | |
| # | |
| # 3DE4.script.version: v1.0 | |
| # | |
| # 3DE4.script.gui: Orientation Controls::Edit::Align Multiple Points | |
| # | |
| # 3DE4.script.comment: Align multiple selected points to XZ Plane. The operation requieres at least 3 Points. | |
| # | |
| # | |
| from vl_sdv import * | |
| cam = tde4.getCurrentCamera() | |
| pg = tde4.getCurrentPGroup() | |
| pl = tde4.getPointList(pg,1) | |
| l = [] | |
| if("CAMERA" == tde4.getPGroupType(pg)): | |
| for p in pl: | |
| if tde4.isPointCalculated3D(pg,p): | |
| p3d = tde4.getPointCalcPosition3D(pg,p) | |
| l.append(p3d) | |
| elif "OBJECT" == tde4.getPGroupType(pg): | |
| cam_pg = pg | |
| pg_list = tde4.getPGroupList(0) | |
| for cpg in pg_list: | |
| if("CAMERA" == tde4.getPGroupType(pg)): | |
| cam_pg = cpg | |
| frame = tde4.getCurrentFrame(cam) | |
| cam_rot = mat3d(tde4.getPGroupRotation3D(cam_pg, cam, frame)) | |
| cam_tra = vec3d(tde4.getPGroupPosition3D(cam_pg, cam, frame)) | |
| for p in pl: | |
| if tde4.isPointCalculated3D(pg,p): | |
| p3d = cam_rot*vec3d(tde4.getPointCalcPosition3D(pg,p)) + cam_tra | |
| l.append(p3d.list()) | |
| if len(l) > 2: | |
| rot,center = tde4.alignPlaneToPoints3D(l) | |
| rot = mat3d(rot) * -1 | |
| center = vec3d(center) | |
| center = rot*(-center) | |
| center = center.list() | |
| rot = rot.list() | |
| tde4.setScenePosition3D(center) | |
| tde4.setSceneRotation3D(rot) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment