public override bool CanLink(ShapeLink other) { if (!(other is AnchorLinkTarget)) return false; // If we are already connected, accept the link (such calls may occur) if (HasLinkTo(other)) return true; // Do not allow more than two connections for a constraint link // (a constraint accepts two anchors at maximum) if (Links.Count >= 2) return false; return true; }
/// <summary> /// Overridden function /// </summary> /// <param name="src"></param> /// <param name="target"></param> public override void OnUnlink(ShapeLink src, ShapeLink target) { base.OnUnlink(src, target); // handles trigger linking SetLinkStatus(src, target, false); }
/// <summary> /// Overridden function /// </summary> /// <param name="src"></param> /// <param name="target"></param> /// <returns></returns> public override bool CanLink(ShapeLink src, ShapeLink target) { if (base.CanLink (src, target)) return true; // see if we can link to the custom sources/targets provided by the native entity class if (_engineInstance!=null) { IEngineInstanceObject3D targetInst = null; int iLinkIndex = -1; string otherName = null; if (src.OwnerShape == this) { if (src is LinkSourceObject3D) iLinkIndex = ((LinkSourceObject3D)src).iIndex; else if (src is LinkBiDirectionalObject3D) iLinkIndex = ((LinkBiDirectionalObject3D)src).iIndex; targetInst = target.OwnerShape._engineInstance as IEngineInstanceObject3D; otherName = target.PrimaryStringId; } else if (target.OwnerShape==this) { if (target is LinkTargetObject3D) iLinkIndex = ((LinkTargetObject3D)target).iIndex; else if (target is LinkBiDirectionalObject3D) iLinkIndex = ((LinkBiDirectionalObject3D)target).iIndex; targetInst = src.OwnerShape._engineInstance as IEngineInstanceObject3D; otherName = src.PrimaryStringId; } if (iLinkIndex >= 0 && targetInst != null) if (EngineEntity.CanLink(iLinkIndex, targetInst, otherName)) return true; } return false; }
public override void OnLink(ShapeLink src, ShapeLink target) { base.OnLink(src, target); _relevantShapes = null; }
/// <summary> /// Check whether src can be linked to target. Either src or target has this shape as owner /// </summary> /// <param name="src">the link source</param> /// <param name="target">the link target</param> /// <returns>true, if the two can be linked</returns> public override bool CanLink(ShapeLink src, ShapeLink target) { if (base.CanLink(src,target)) return true; if (target.OwnerShape==this) if (src is LinkSourceConstraint) return true; return false; }
/// <summary> /// Performs the actual linking on engine instances /// </summary> /// <param name="src"></param> /// <param name="target"></param> public override void OnLink(ShapeLink src, ShapeLink target) { base.OnLink(src, target); // Ignore links which don't belong to us if (src.OwnerShape != this) return; // Get the anchor the target link points to AnchorShape anchorShape = GetAnchorFromLink(target); if (anchorShape == null || !HasEngineInstance()) return; // Get the entity instance the target points to EngineInstanceEntity entityInstance = GetEntityFromAnchor(anchorShape); // Add the actor to the constraint if (entityInstance != null) { // We have an anchor which belongs to an entity. Add the entity to the constraint // and pass the anchor position, relative to the parent entity. Vector3F anchorPositionLS = anchorShape.LocalSpacePosition; bool bResult = EngineConstraintChainInstance.AddEntityAnchor( (long)anchorShape.UniqueID, entityInstance, anchorPositionLS); Debug.Assert(bResult == true); } else { // Our anchor is statically attached to the world. // Add the static world anchor to the constraint. Pass the world space position of the anchor // for this purpose. Vector3F anchorPositionWS = anchorShape.Position; bool bResult = EngineConstraintChainInstance.AddWorldAnchor((long)anchorShape.UniqueID, anchorShape); Debug.Assert(bResult == true); } }
/// <summary> /// Inidcates whether a shape can be linked to this shape /// </summary> /// <param name="child">Shape instance to test</param> /// <returns>true, if the shape can be linked</returns> public override bool CanLink(ShapeLink src, ShapeLink target) { if (base.CanLink (src, target)) return true; // check whether we are linking two nodes. The node can be a target or source. // we always link in both directions node1 <-> node2 return (src is BidirectionalNodeLink) && (target is BidirectionalNodeLink); }
/// <summary> /// unlinks a target from a source. Either src or target has this shape as owner /// </summary> /// <param name="src">the link source</param> /// <param name="target">the link target</param> public override void OnUnlink(ShapeLink src, ShapeLink target) { base.OnUnlink (src, target); // perform the unlinking on the engine objects if (target.OwnerShape==this) { VisibilityObjectShape visobjShape = src.OwnerShape as VisibilityObjectShape; if (visobjShape!=null && visobjShape._engineInstance!=null) // at least the engine instance of the constraint can be null EngineMirror.RemoveVisibilityObject(visobjShape._engineInstance as EngineInstanceVisibilityObject); } }
public override void OnLink(ShapeLink src, ShapeLink target) { base.OnLink(src, target); // additionally notify target... if (src.OwnerShape == this) { target.OwnerShape.OnLink(src, target); } }
/// <summary> /// Check whether src can be linked to target. Either src or target has this shape as owner /// </summary> /// <param name="src">the link source</param> /// <param name="target">the link target</param> /// <returns></returns> public override bool CanLink(ShapeLink src, ShapeLink target) { if (base.CanLink(src,target)) return true; if (src.OwnerShape==this) { if (target is LinkTargetVisiblity) return true; if (target is LinkTargetObject3D) // allow for linking with custom entity links return target.OwnerShape is EntityShape; } return false; }
/// <summary> /// Check whether src can be linked to target /// </summary> /// <param name="src"></param> /// <param name="target"></param> /// <returns></returns> public override bool CanLink(ShapeLink src, ShapeLink target) { if (base.CanLink(src,target)) return true; if (src.OwnerShape==this) { if (target is LinkTargetConstraint) return true; } return false; }
/// <summary> /// Gets the anchor which belongs to the passed link target /// </summary> /// <param name="linkTarget">link target</param> /// <returns>anchor instance</returns> private AnchorShape GetAnchorFromLink(ShapeLink linkTarget) { // Get the anchor shape which is connected to the passed link AnchorShape anchorShape = linkTarget.OwnerShape as AnchorShape; Debug.Assert(anchorShape != null); return anchorShape; }
/// <summary> /// unlinks a target from a source. Either src or target has this shape as owner /// </summary> /// <param name="src">the link source</param> /// <param name="target">the link target</param> public override void OnUnlink(ShapeLink src, ShapeLink target) { base.OnUnlink(src, target); // Ignore links which don't belong to us if (src.OwnerShape != this) return; // Get the anchor the target link points to AnchorShape anchorShape = GetAnchorFromLink(target); if (anchorShape == null || !HasEngineInstance()) return; bool bResult = EngineConstraintChainInstance.RemoveAnchor((long)anchorShape.UniqueID); Debug.Assert(bResult == true); }
void SetLinkStatus(ShapeLink src, ShapeLink target, bool bStatus) { if (_engineInstance==null) return; // see if we can (un-)link to the custom sources/targets provided by the native entity class IEngineInstanceObject3D targetInst = null; int iLinkIndex = -1; string otherName = null; if (src.OwnerShape==this) { if (src is LinkSourceObject3D) iLinkIndex = ((LinkSourceObject3D)src).iIndex; else if (src is LinkBiDirectionalObject3D) iLinkIndex = ((LinkBiDirectionalObject3D)src).iIndex; targetInst = target.OwnerShape._engineInstance as IEngineInstanceObject3D; otherName = target.PrimaryStringId; } else if (target.OwnerShape==this) { if (target is LinkTargetObject3D) iLinkIndex = ((LinkTargetObject3D)target).iIndex; else if (target is LinkBiDirectionalObject3D) iLinkIndex = ((LinkBiDirectionalObject3D)target).iIndex; targetInst = src.OwnerShape._engineInstance as IEngineInstanceObject3D; otherName = src.PrimaryStringId; } if (iLinkIndex >= 0 && targetInst != null) EngineEntity.OnLink(iLinkIndex, targetInst, otherName, bStatus); }
/// <summary> /// Performs the unlinking /// </summary> /// <param name="src"></param> /// <param name="target"></param> public override void OnUnlink(ShapeLink src, ShapeLink target) { base.OnUnlink (src, target); // forward the unlinking to the engine instance so that the native class can unlink from other native instances if (src.OwnerShape==this && (target is BidirectionalNodeLink)) this.EngineNode.UnLinkNode((UIEngineInstanceDialog)target.OwnerShape._engineInstance); if (target.OwnerShape==this && (src is BidirectionalNodeLink)) this.EngineNode.UnLinkNode((UIEngineInstanceDialog)src.OwnerShape._engineInstance); }
/// <summary> /// Check whether src can be linked to target. Either src or target has this shape as owner /// </summary> /// <param name="src">the link source</param> /// <param name="target">the link target</param> /// <returns></returns> public override bool CanLink(ShapeLink src, ShapeLink target) { if (base.CanLink(src,target)) return true; if (target.OwnerShape==this) { if (src is LinkSourceVisiblity) return true; } return false; }
public override bool CanLink(ShapeLink src, ShapeLink target) { if (target.OwnerShape == this && (target is LinkTargetPath)) return true; return base.CanLink(src, target); }
/// <summary> /// unlinks a target from a source. Either src or target has this shape as owner /// </summary> /// <param name="src">the link source</param> /// <param name="target">the link target</param> public override void OnUnlink(ShapeLink src, ShapeLink target) { base.OnUnlink (src, target); // perform the unlinking on the engine objects if (target.OwnerShape==this) { ConstraintShape constraint = src.OwnerShape as ConstraintShape; if (constraint != null && constraint._engineInstance != null && this.HasEngineInstance()) // at least the engine instance of the constraint can be null EngineClothObj.RemoveConstraint(constraint._engineInstance as EngineInstanceConstraint); } }
/// <summary> /// Check whether src can be linked to target. Either src or target has this shape as owner /// </summary> /// <param name="src">the link source</param> /// <param name="target">the link target</param> /// <returns></returns> public override bool CanLink(ShapeLink src, ShapeLink target) { if (base.CanLink(src,target)) return true; if (src.OwnerShape==this) { if (target is LinkTargetGroupStaticMeshes) return true; } return false; }
/// <summary> /// Perform the actual linking. Either src or target has this shape as owner /// </summary> /// <param name="src">the link source</param> /// <param name="target">the link target</param> public override void OnLink(ShapeLink src, ShapeLink target) { base.OnLink (src, target); // adds to collections if (HasEngineInstance()) EnginePGroup.OnLinksChanged(); // perform the linking on the engine objects if (target.OwnerShape == this) { ConstraintShape constraint = src.OwnerShape as ConstraintShape; if (constraint != null && HasEngineInstance() && constraint.HasEngineInstance()) // at least the engine instance of the constraint can be null EnginePGroup.AddConstraint(constraint._engineInstance as EngineInstanceConstraint); } }
public override ShapeLink CreateShapeLink(string classname, Shape3D ownerShape, string name, string primaryID) { Type t = _cachedClassTypes.ContainsKey(classname) ? _cachedClassTypes[classname] : null; if (t == null) { // loop through all assemblies and find the type by name Assembly[] assemblies = AssemblyHelper.GetEditorAssemblies(); foreach (Assembly assembly in assemblies) { Type[] types = null; try { types = assembly.GetTypes(); } catch (Exception ex) { EditorManager.IgnoreException(ex); } if (types == null) { continue; } foreach (Type type in types) { if (type.Name == classname && type.IsSubclassOf(typeof(ShapeLink))) { t = type; break; } } if (t != null) { break; } } _cachedClassTypes[classname] = t; // can be null, which is also cached } if (t == null) { if (ThrowExceptions) { throw new Exception("Unknown shape class '" + classname + "'"); } return(null); } string moreFailInfo = ""; try { object[] args = new object[3] { ownerShape, name, primaryID }; // always use this constructor ShapeLink newObject = Activator.CreateInstance(t, args) as ShapeLink; if (newObject == null) { if (ThrowExceptions) { throw new Exception("Failed to create instance of class '" + classname + "'"); } return(null); } return(newObject); } catch (Exception ex) { EditorManager.DumpException(ex, false); moreFailInfo = "\nDetailed: "; if (ex.InnerException != null) { moreFailInfo += ex.InnerException.ToString(); } else { moreFailInfo += ex.Message; } } if (ThrowExceptions) { throw new Exception("Failed to create instance of class '" + classname + "'" + moreFailInfo); } return(null); }