From f5f5e3c7fc278cafbb93458272fd57322ab2048d Mon Sep 17 00:00:00 2001 From: Yuriy Alekseyev Date: Thu, 7 Jul 2022 20:31:26 +0300 Subject: [PATCH] Convert camera object to camera part Added button to toolbar to convert camera object in scene into rigid part helper with camera properties. --- macroscripts/MAXLancer-Toolbox.mcr | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/macroscripts/MAXLancer-Toolbox.mcr b/macroscripts/MAXLancer-Toolbox.mcr index c12a866..a791fe0 100644 --- a/macroscripts/MAXLancer-Toolbox.mcr +++ b/macroscripts/MAXLancer-Toolbox.mcr @@ -480,6 +480,7 @@ macroScript Toolbox category:"MAXLancer" tooltip:"MAXLancer Panel" buttontext:"M group "Miscellaneous" ( button createWireframesButton "Create Wireframes" width:128 height:24 align:#center tooltip:"Create wireframe shapes for selected editable meshes from visible edges." + button createCameraButton "Create Camera" width:128 height:24 align:#center tooltip:"Create camera part from selected camera object." button resetXFormButton "Reset Transforms" width:128 height:24 align:#center tooltip:"Applies and collapses XForm Reset to selected editable meshes." button centerPivotButton "Reset Center Pivots" width:128 height:24 align:#center tooltip:"Resets pivot for selected editable meshes." ) @@ -490,6 +491,27 @@ macroScript Toolbox category:"MAXLancer" tooltip:"MAXLancer Panel" buttontext:"M fn filterTargetHardpoint target = targetPart != undefined and damagePart != undefined and MAXLancer.IsHardpointHelper target and target.parent == targetPart.parent + fn filterCamera target = isValidNode target and superClassOf target == camera + + on createCameraButton pressed do ( + local target = MAXLancer.PickSceneObject filterCamera message:"Select camera object." + + if target != undefined then ( + local result = MAXLancer.CreateRigidPartHelper target.name + + result.transform = RotateXMatrix -90 * target.transform + result.isCamera = true + result.fovX = target.fov + result.fovY = 2 * atan(1 / getRendImageAspect() * tan(target.fov * .5)) + result.zNear = target.nearClip + result.zFar = target.farClip + + select result + ) + + OK + ) + on assignDestructibleButton pressed do ( targetPart = if selection.count == 1 and filterTargetPart selection[1] then selection[1] else pickObject message:"Pick target part" filter:filterTargetPart