public ClonePatternModel(ClonePattern clonePattern) { ClonePattern = clonePattern; ClonePattern.PropertyChanged += ClonePattern_PropertyChanged; ElementModels = new List <PartElementModel>(); ClonePattern.Elements.CollectionChanged += Elements_CollectionChanged; ElementModelsDirty = true; InitTranform(); }
public override void RenderModel(Camera camera, MeshRenderMode mode = MeshRenderMode.Solid) { if (ClonePattern?.Repetitions > 1) { if (ClonePattern is LinearPattern linearPattern) { float lineLength = (linearPattern.Repetitions - 1) * linearPattern.Offset; //var dir = linearPattern.Direction.ToGL(); RenderHelper.DrawLine(Transform, new Vector4(1f, 1f, 0f, 1f), Vector3.Zero, Vector3.UnitZ * lineLength, 1.5f); } if (ElementModels == null || ElementModels.Count == 0) { return; } foreach (var elem in ClonePattern.Elements) { var elemModel = ElementModels.FirstOrDefault(x => x.Element == elem); if (elemModel != null && elemModel.Visible) { var originalTrans = elemModel.Transform; var baseTransform = ItemTransform.FromMatrix(elemModel.Transform.ToLDD()); bool isSelected = elemModel.IsSelected; for (int i = 1; i < ClonePattern.Repetitions; i++) { if (ClonePattern.SkippedInstances.Contains(i)) { continue; } var trans = ClonePattern.ApplyTransform(baseTransform, i).ToMatrix().ToGL(); //elemModel.SetTransform(trans, false); elemModel.IsSelected = false; elemModel.SetTemporaryTransform(trans); elemModel.RenderModel(camera, mode); elemModel.SetTemporaryTransform(null); } elemModel.IsSelected = isSelected; //elemModel.SetTransform(originalTrans, false); } } } }