private Node GetOrCreateWire(agxWire.Wire wire) { return(GetOrCreateNode(NodeType.Wire, wire.getUuid(), true, () => m_wires.Add(wire.getUuid(), wire))); }
/// <summary> /// Copies data from native instance to this wire. /// </summary> /// <param name="native">Native instance.</param> public void RestoreLocalDataFrom(agxWire.Wire native) { if (native == null) { return; } Radius = System.Convert.ToSingle(native.getRadius()); ResolutionPerUnitLength = System.Convert.ToSingle(native.getResolutionPerUnitLength()); ScaleConstant = System.Convert.ToSingle(native.getParameterController().getScaleConstant()); }
/// <summary> /// Copies data from native instance to this wire. /// </summary> /// <param name="native">Native instance.</param> public void RestoreLocalDataFrom(agxWire.Wire native) { if (native == null) { return; } Radius = System.Convert.ToSingle(native.getRadius()); ResolutionPerUnitLength = System.Convert.ToSingle(native.getResolutionPerUnitLength()); ScaleConstant = System.Convert.ToSingle(native.getParameterController().getScaleConstant()); // Is the wire enabled/active? gameObject.SetActive(native.isEnabled()); }
protected override bool Initialize() { WireRoute.ValidatedRoute validatedRoute = Route.GetValidated(); if (!validatedRoute.Valid) { Debug.LogError(validatedRoute.ErrorString, this); for (int i = 0; i < validatedRoute.Nodes.Count; ++i) { if (!validatedRoute.Nodes[i].Valid) { Debug.LogError("[" + i + "]: " + validatedRoute.Nodes[i].ErrorString, this); } } return(false); } try { Native = new agxWire.Wire(Radius, ResolutionPerUnitLength); Material = m_material != null?m_material.GetInitialized <ShapeMaterial>() : null; int nodeCounter = 0; foreach (WireRouteNode routeNode in Route) { agxWire.WireNode node = routeNode.GetInitialized <WireRouteNode>().Native; bool success = true; if (node.getType() == agxWire.WireNode.Type.CONNECTING) { // This is the first node, CM-node goes first. if (nodeCounter == 0) { success = success && Native.add(node.getAsConnecting().getCmNode()); success = success && Native.add(node); } // This has to be the last node, CM-node goes last. else { success = success && Native.add(node); success = success && Native.add(node.getAsConnecting().getCmNode()); } } else if (routeNode.Type == NodeType.WinchNode) { if (node == null) { throw new AGXUnity.Exception("Unable to initialize wire winch."); } success = success && Native.add(routeNode.Winch.Native); } else { success = success && Native.add(node); } if (!success) { throw new AGXUnity.Exception("Unable to add node " + nodeCounter + ": " + routeNode.Type); } ++nodeCounter; } Native.setName(name); GetSimulation().add(Native); Simulation.Instance.StepCallbacks.PostStepForward += OnPostStepForward; } catch (System.Exception e) { Debug.LogException(e, this); return(false); } return(Native.initialized()); }