public static void RenderGizmos(SharpRenderer renderer) { switch (CurrentGizmoMode) { case GizmoMode.Position: { if (allCurrentlySelectedAssets.OfType <IClickableAsset>().Count() == 1 && allCurrentlySelectedAssets.OfType <IClickableAsset>().FirstOrDefault() is AssetTRIG TRIG && TRIG.Shape == TriggerShape.Box) { TriggerGizmo = true; SetCenterRotation(TRIG.Yaw, TRIG.Pitch, TRIG.Roll); GizmoCenterPosition = TRIG.GetBoundingBox().Center; float radius = Vector3.Distance(renderer.Camera.Position, GizmoCenterPosition) / 5f; Vector3 TrigBound = new Vector3(TRIG.Position1X - TRIG.Position0X, TRIG.Position1Y - TRIG.Position0Y, TRIG.Position1Z - TRIG.Position0Z) / 2f; foreach (BoxTrigPositionGizmo g in triggerPositionGizmos) { g.SetPosition(TRIG.GetBoundingBox().Center, TrigBound, radius, GizmoCenterRotation); g.Draw(renderer); } radius = Vector3.Distance(renderer.Camera.Position, TRIG.Position) / 5f; foreach (PositionGizmo g in positionGizmos) { g.SetPosition(TRIG.Position, radius); g.Draw(renderer); } }
public static void RenderGizmos(SharpRenderer renderer) { switch (CurrentGizmoMode) { case GizmoMode.Position: var icas = allCurrentlySelectedAssets.OfType <IClickableAsset>(); if (icas.Count() == 1) { if (icas.FirstOrDefault() is AssetTRIG TRIG && TRIG.Shape == TriggerShape.Box) { TriggerGizmo = true; SetCenterRotation(TRIG.Yaw, TRIG.Pitch, TRIG.Roll); GizmoCenterPosition = TRIG.GetBoundingBox().Center; float radius = Vector3.Distance(renderer.Camera.Position, GizmoCenterPosition) / 5f; Vector3 TrigBound = new Vector3(TRIG.MaximumX - TRIG.MinimumX, TRIG.MaximumY - TRIG.MinimumY, TRIG.MaximumZ - TRIG.MinimumZ) / 2f; foreach (BoxTrigPositionGizmo g in triggerPositionGizmos) { g.SetPosition(TRIG.GetBoundingBox().Center, TrigBound, radius, GizmoCenterRotation); g.Draw(renderer); } var trig_pos = new Vector3(TRIG.PositionX, TRIG.PositionY, TRIG.PositionZ); radius = Vector3.Distance(renderer.Camera.Position, trig_pos) / 5f; foreach (PositionGizmo g in positionGizmos) { g.SetPosition(trig_pos, radius); g.Draw(renderer); } return; } if (icas.FirstOrDefault() is AssetVOLU VOLU && VOLU.VolumeShape is VolumeBox box) { TriggerGizmo = true; SetCenterRotation(0, 0, 0); GizmoCenterPosition = box.GetBoundingBox().Center; float radius = Vector3.Distance(renderer.Camera.Position, GizmoCenterPosition) / 5f; Vector3 TrigBound = new Vector3(box.MaximumX - box.MinimumX, box.MaximumY - box.MinimumY, box.MaximumZ - box.MinimumZ) / 2f; foreach (BoxTrigPositionGizmo g in triggerPositionGizmos) { g.SetPosition(box.GetBoundingBox().Center, TrigBound, radius, GizmoCenterRotation); g.Draw(renderer); } var trig_pos = new Vector3(box.CenterX, box.CenterY, box.CenterZ); radius = Vector3.Distance(renderer.Camera.Position, trig_pos) / 5f; foreach (PositionGizmo g in positionGizmos) { g.SetPosition(trig_pos, radius); g.Draw(renderer); } return; } } TriggerGizmo = false; BoundingBox bb = new BoundingBox(); bool found = false; foreach (var a in allCurrentlySelectedAssets.OfType <IClickableAsset>()) { if (!found) { found = true; bb = a.GetBoundingBox(); } else { bb = BoundingBox.Merge(bb, a.GetBoundingBox()); } } if (found) { GizmoCenterPosition = bb.Center; float distance = Vector3.Distance(renderer.Camera.Position, bb.Center) / 5f; foreach (PositionGizmo g in positionGizmos) { g.SetPosition(bb.Center, distance); g.Draw(renderer); } } return; case GizmoMode.Rotation: var iras = allCurrentlySelectedAssets.OfType <IRotatableAsset>(); if (iras.Count() != 0) { var ira = iras.FirstOrDefault(); SetCenterRotation(ira.Yaw, ira.Pitch, ira.Roll); var ira_pos = new Vector3(ira.PositionX, ira.PositionY, ira.PositionZ); GizmoCenterPosition = ira_pos; float distance = Vector3.Distance(renderer.Camera.Position, ira_pos) / 2f; for (int i = 2; i >= 0; i--) { rotationGizmos[i].SetPosition(ira_pos, distance, GizmoCenterRotation); rotationGizmos[i].Draw(renderer); } } return; case GizmoMode.Scale: var isas = allCurrentlySelectedAssets.OfType <IScalableAsset>(); if (isas.Count() != 0) { var isa = isas.FirstOrDefault(); if (isa is IRotatableAsset ira) { SetCenterRotation(ira.Yaw, ira.Pitch, ira.Roll); } else { SetCenterRotation(0, 0, 0); } var isa_pos = new Vector3(isa.PositionX, isa.PositionY, isa.PositionZ); GizmoCenterPosition = isa_pos; float distance = Vector3.Distance(renderer.Camera.Position, isa_pos) / 5f; foreach (ScaleGizmo g in scaleGizmos) { g.SetPosition(isa_pos, distance, GizmoCenterRotation); g.Draw(renderer); } } return; case GizmoMode.PositionLocal: var icas2 = allCurrentlySelectedAssets.OfType <IClickableAsset>(); if (icas2.Count() == 1) { var ica = icas2.FirstOrDefault(); if (ica is AssetTRIG TRIG && TRIG.Shape == TriggerShape.Box) { return; } if (ica is AssetVOLU VOLU && VOLU.Shape == VolumeType.Box) { return; } GizmoCenterPosition = ica.GetBoundingBox().Center; float radius = Vector3.Distance(renderer.Camera.Position, GizmoCenterPosition) / 5f; foreach (PositionLocalGizmo g in positionLocalGizmos) { g.SetPosition(ica.GetBoundingBox().Center, radius, GizmoCenterRotation); g.Draw(renderer); } } break; } }