protected override bool Initialize() { m_transform = transform; Shapes = GetShapes(); HasArticulatedRoot = GetArticulatedRoot() != null && GetArticulatedRoot().enabled; VerifyConfiguration(); m_rb = new agx.RigidBody(); m_rb.setName(name); m_rb.setEnable(IsEnabled); m_rb.getMassProperties().setAutoGenerateMask(0u); SyncNativeTransform(m_rb); SyncShapes(); GetSimulation().add(m_rb); UpdateMassProperties(); if (IsEnabled) { HandleUpdateCallbacks(true); } return(true); }
public AgX_Primitive(Guid guid, string shape, Vector3 pos, Quaternion rot, Vector3 size, double mass, string materialName) { this.guid = guid; this.shape = shape; this.size = size; this.materialName = materialName; var dynamicRBGeometry = new agxCollide.Geometry(); switch (shape) { case "Box": dynamicRBGeometry.add(new agxCollide.Box(Operations.ToAgxVec3(this.size))); break; case "Sphere": dynamicRBGeometry.add(new agxCollide.Sphere((this.size.x + this.size.y + this.size.z) / 3)); break; } dynamicRBGeometry.setMaterial(new agx.Material(materialName)); agx_Object = new agx.RigidBody(); agx_Object.add(dynamicRBGeometry); agx_Object.setLocalPosition(Operations.ToAgxVec3(pos)); ///AgX agx_Object.setLocalRotation(new agx.Quat(rot.x, rot.y, rot.z, rot.w)); ///AgX agx_Object.getMassProperties().setMass(mass); AddToSim(); }
private Node GetOrCreateRigidBody(agx.RigidBody rb, bool isRoot) { return(GetOrCreateNode(NodeType.RigidBody, rb.getUuid(), isRoot, () => m_bodies.Add(rb.getUuid(), rb))); }
protected override bool Initialize() { m_transform = transform; VerifyConfiguration(); m_rb = new agx.RigidBody(); m_rb.setName(name); m_rb.setEnable(IsEnabled); SyncNativeTransform(m_rb); SyncShapes(); GetSimulation().add(m_rb); UpdateMassProperties(); if (IsEnabled) { HandleUpdateCallbacks(true); } return(base.Initialize()); }
private RigidBody CreateRigidBody(GameObject gameObject, Link link) { var rb = GetOrCreateComponent <RigidBody>(gameObject); GetOrCreateComponent <ElementComponent>(gameObject).SetElement(link); if (link.IsStatic) { rb.MotionControl = agx.RigidBody.MotionControl.STATIC; return(rb); } // Note: When <inertial> isn't defined the collision shapes defines // the mass properties. // <inertial> defined with required <mass> and <inertia>. Create // a native rigid body with the given properties and read the // values back to our rigid body component. if (link.Inertial != null) { var native = new agx.RigidBody(); native.getMassProperties().setMass(link.Inertial.Mass, false); // Inertia tensor is given in the inertia frame. The rotation of the // CM frame can't be applied to the CM frame so we transform the inertia // CM frame and rotate the game object. var rotationMatrix = link.Inertial.Rpy.RadEulerToRotationMatrix(); var inertia3x3 = (agx.Matrix3x3)link.Inertial.Inertia; inertia3x3 = rotationMatrix.Multiply(inertia3x3).Multiply(rotationMatrix.transpose()); native.getMassProperties().setInertiaTensor(new agx.SPDMatrix3x3(inertia3x3)); native.getCmFrame().setLocalTranslate(link.Inertial.Xyz.ToVec3()); rb.RestoreLocalDataFrom(native); } return(rb); }
/*--------------------------------------------------Creating terrain--------------------------------------------------*/ //public void Create_Terrain(Guid guid, string heightmap, Vector3 position, string materialName, double restitution, double friction, double height) public AgX_Scene(Guid guid, List <Vector3> vertices, List <int> triangles, Vector3 position, string materialName) { this.guid = guid; //AgX: agx.Vec3Vector agx_vertices = new agx.Vec3Vector(); agx.UInt32Vector agx_indices = new agx.UInt32Vector(); for (int i = 0; i < vertices.Count; i++) { agx_vertices.Add(Operations.ToAgxVec3(vertices[i])); } for (int i = 0; i < triangles.Count; i++) { agx_indices.Add((uint)triangles[i]); } terrain = new agx.RigidBody(); //uint optionsMask = (uint)agxCollide.Trimesh.TrimeshOptionsFlags.TERRAIN; var terrain_trimesh = new agxCollide.Trimesh(agx_vertices, agx_indices, "handmade terrain");//, optionsMask, height); var geometry = new agxCollide.Geometry(); geometry.add(terrain_trimesh); geometry.setMaterial(new agx.Material(materialName)); terrain.add(geometry); terrain.setMotionControl(agx.RigidBody.MotionControl.STATIC); //position.y -= height; terrain.setLocalPosition(Operations.ToAgxVec3(position));//move right and -height for global 0 ///Adds terrain to simulation //simulation.add(terrain); Agx_Simulation.sim_Instance.add(terrain); }
public AgX_Frame(Guid guid, string shape, Vector3[] vertices, Vector2[] uvs, int[] triangles, double size, Vector3 pos, Quaternion rot, double mass, bool isStatic, string materialName) { this.guid = guid; this.shape = shape; this.size = size; this.materialName = materialName; //scale by 2, to fit unity. /* Vector3[] tmp_verts = vertices; * for (int i = 0; i < tmp_verts.Length; i++) * { * tmp_verts[i].x *= 2; * tmp_verts[i].y *= 2; * tmp_verts[i].z *= 2; * }*/ var tri = new agxCollide.Trimesh(Operations.ToAgxVec3Vector(vertices), Operations.ToAgxIntVector(triangles), "stdFrame"); ///Creates a geometry var dynamicRBGeometry = new agxCollide.Geometry(); dynamicRBGeometry.add(tri); dynamicRBGeometry.setMaterial(new agx.Material(materialName)); ///Creates the selected shape /*switch (shape) * { * case "Box": dynamicRBGeometry.add(new agxCollide.Box(Operations.ToAgxVec3(size))); break; * case "Sphere": dynamicRBGeometry.add(new agxCollide.Sphere((size.x + size.y + size.z) / 3)); break; * }*/ agx_Object = new agx.RigidBody(); ///Adds selected geometry to the rigidbody agx_Object.add(dynamicRBGeometry); agx_Object.setLocalPosition(Operations.ToAgxVec3(pos));///AgX //var y = new agx.EulerAngles(Operations.ToAgxVec3(rot)); //UnityEngine.Debug.Log("x: " + y.x + ", y: " + y.y + ", z: " + y.z); agx_Object.setLocalRotation(new agx.Quat(rot.x, rot.y, rot.z, rot.w));///AgX //agx_Object.setLocalRotation(new agx.EulerAngles(Operations.ToAgxVec3(rot)));///AgX //UnityEngine.Debug.Log("x: " +agx_Object.getLocalPosition().x + ", y: " + agx_Object.getLocalPosition().y + ", z: " + agx_Object.getLocalPosition().z); agx_Object.getMassProperties().setMass(mass); if (isStatic) { agx_Object.setMotionControl(agx.RigidBody.MotionControl.STATIC); } AddToSim(); }
static agxSDK.Assembly robotAssembly;// = new agxSDK.Assembly(); public static void AddToAssembly(agx.RigidBody body) { if (robotAssembly == null) { robotAssembly = new agxSDK.Assembly(); } robotAssembly.add(body); }
/// <summary> /// Destroys visual resources and removes the instance from /// the simulation if the instance has been emitted from this /// emitter (check return value). /// </summary> /// <param name="instance">Instance to destroy and remove from the simulation.</param> /// <returns>True if destroyed and removed, otherwise false.</returns> public bool TryDestroy(agx.RigidBody instance) { if (m_event == null) { return(false); } return(m_event.TryDestroy(instance)); }
public void SyncNativeTransform(agx.RigidBody nativeRb) { if (nativeRb == null) { return; } nativeRb.setPosition(transform.position.ToHandedVec3()); nativeRb.setRotation(transform.rotation.ToHandedQuat()); }
/// <summary> /// Creates native instance given current properties. /// </summary> /// <returns>Native instance of this node.</returns> protected override bool Initialize() { RigidBody rb = null; Collide.Shape shape = null; if (Parent != null) { rb = Parent.GetInitializedComponentInParent <RigidBody>(); shape = Parent.GetInitializedComponentInParent <Collide.Shape>(); } // We don't know if the parent is the rigid body. // It could be a mesh, or some other object. // Also - use world position if Type == FreeNode. agx.Vec3 point = rb != null && Type != Wire.NodeType.FreeNode ? CalculateLocalPosition(rb.gameObject).ToHandedVec3() : Position.ToHandedVec3(); agx.RigidBody nativeRb = rb != null ? rb.Native : null; if (Type == Wire.NodeType.BodyFixedNode) { Native = new agxWire.BodyFixedNode(nativeRb, point); } // Create a free node if type is contact and shape == null. else if (Type == Wire.NodeType.FreeNode || (Type == Wire.NodeType.ContactNode && shape == null)) { Native = new agxWire.FreeNode(point); } else if (Type == Wire.NodeType.ConnectingNode) { Native = new agxWire.ConnectingNode(nativeRb, point, double.PositiveInfinity); } else if (Type == Wire.NodeType.EyeNode) { Native = new agxWire.EyeNode(nativeRb, point); } else if (Type == Wire.NodeType.ContactNode) { Native = new agxWire.ContactNode(shape.NativeGeometry, CalculateLocalPosition(shape.gameObject).ToHandedVec3()); } else if (Type == Wire.NodeType.WinchNode) { if (m_winch == null) { throw new AGXUnity.Exception("No reference to a wire winch component in the winch node."); } m_winch.GetInitialized <WireWinch>(); Native = m_winch.Native != null?m_winch.Native.getStopNode() : null; } return(Native != null); }
protected override void OnDestroy() { if (GetSimulation() != null) { Simulation.Instance.StepCallbacks.PostSynchronizeTransforms -= OnPostSynchronizeTransformsCallback; GetSimulation().remove(m_rb); } m_rb = null; base.OnDestroy(); }
protected override void OnDestroy() { if (Simulation.HasInstance) { GetSimulation().remove(m_rb); } m_rb = null; m_transform = null; base.OnDestroy(); }
/// <summary> /// Peek at a temporary native instance or the current (if initialized). /// </summary> /// <param name="callback">Callback with temporary or already initialized native instance. Callback signature ( nativeRb, isTemporary ).</param> /// <remarks> /// Always assume the native instance to be temporary. It's never safe to cache an instance to the native object. /// </remarks> public void PeekTemporaryNativeOrGetNative(Action <agx.RigidBody, bool> callback) { if (callback == null) { return; } if (m_rb != null) { callback(m_rb, false); } else { Shape[] shapes = GetComponentsInChildren <Shape>(); using (agx.RigidBody rb = new agx.RigidBody()) { foreach (Shape shape in shapes) { agxCollide.Shape nativeShape = shape.CreateTemporaryNative(); if (nativeShape != null) { agxCollide.Geometry geometry = new agxCollide.Geometry(nativeShape); geometry.setEnable(shape.IsEnabled); if (shape.Material != null) { geometry.setMaterial(shape.Material.CreateTemporaryNative()); } rb.add(geometry, shape.GetNativeRigidBodyOffset(this)); } } // For center of mass position/rotation to be correct we have to // synchronize the native transform given current game object transform. SyncNativeTransform(rb); callback(rb, true); // Hitting "Update" (mass or inertia in the Inspector) several times // will crash agx if we don't remove the geometries and shapes. while (rb.getGeometries().Count > 0) { agxCollide.Geometry geometry = rb.getGeometries()[0].get(); if (geometry.getShapes().Count > 0) { geometry.remove(geometry.getShapes()[0].get()); } rb.remove(geometry); } } } }
/// <summary> /// Initialize the whole vehicle /// </summary> private void initializeVehicle() { if (m_initialized) { return; } var sim = GetSimulation(); Assert.IsNotNull(sim); // Access the hinge used for steering m_steeringHinge = GetSimulation().getHinge("WaistHingeTurning"); Assert.IsNotNull(m_steeringHinge); m_steeringHinge.getMotor1D().setEnable(true); m_steeringHinge.getMotor1D().setSpeed(0.0f); m_steeringHinge.getMotor1D().setLockedAtZeroSpeed(true); /// Access all the hinges attached to all the rims var hingeJointNames = new List <string> { "RightRearHinge", "LeftRearHinge", "RightFrontHinge", "LeftFrontHinge" }; foreach (var n in hingeJointNames) { var hinge = sim.getHinge(n); Assert.IsNotNull(hinge, string.Format("Hinge {0} is missing in Simulation", n)); m_wheelHinges.Add(hinge.getName(), hinge); } if (m_chassieRigidBody == null) { m_chassieRigidBody = sim.getRigidBody("FrontBody"); Assert.IsNotNull(m_chassieRigidBody); } //Hinge.GetController<TargetSpeedController>().Enable = true; // Make sure body exists before I start using it. //Body.GetInitialized<RigidBody>().Native.setEnable(false); initializeTires(); // Create the Vehicle class that initializes brakes etc. m_vehicle = new Vehicle(GetSimulation(), m_wheelHinges); m_initialized = true; }
protected override void OnDestroy() { if (Simulation.HasInstance) { GetSimulation().remove(m_rb); } m_rb = null; m_transform = null; Shapes = null; HasArticulatedRoot = false; base.OnDestroy(); }
/// <summary> /// Reads values from native instance. /// </summary> /// <param name="native">Source native instance.</param> public void RestoreLocalDataFrom(agx.RigidBody native) { Mass.UserValue = Convert.ToSingle(native.getMassProperties().getMass()); var nativeInertia = native.getMassProperties().getInertiaTensor(); InertiaDiagonal.UserValue = nativeInertia.getDiagonal().ToVector3(); InertiaOffDiagonal.UserValue = GetNativeOffDiagonal(nativeInertia).ToVector3(); CenterOfMassOffset.UserValue = native.getCmFrame().getLocalTranslate().ToHandedVector3(); Mass.UseDefault = false; InertiaDiagonal.UseDefault = false; InertiaOffDiagonal.UseDefault = false; CenterOfMassOffset.UseDefault = false; }
public void RestoreLocalDataFrom(agx.RigidBody native) { if (native == null) { throw new ArgumentNullException("native", "Native object is null."); } MassProperties.RestoreLocalDataFrom(native.getMassProperties()); enabled = native.getEnable(); MotionControl = native.getMotionControl(); HandleAsParticle = native.getHandleAsParticle(); LinearVelocity = native.getVelocity().ToHandedVector3(); LinearVelocityDamping = native.getLinearVelocityDamping().ToHandedVector3(); AngularVelocity = native.getAngularVelocity().ToHandedVector3(); AngularVelocityDamping = native.getAngularVelocityDamping().ToHandedVector3(); }
public bool TryDestroy(agx.RigidBody instance) { if (!m_instanceDataTable.TryGetValue(instance, out var data)) { return(false); } Destroy(data.Visual); if (Simulation.HasInstance && Simulation.Instance.Native != null) { Simulation.Instance.Native.remove(instance); } m_instanceDataTable.Remove(instance); return(true); }
/// <summary> /// Callback from RigidBody when mass properties has been calculated for a native instance. /// </summary> /// <param name="nativeRb">Native rigid body instance.</param> public void SetDefaultCalculated(agx.RigidBody nativeRb) { if (nativeRb == null) { return; } Mass.DefaultValue = Convert.ToSingle(nativeRb.getMassProperties().getMass()); float inertiaScale = 1.0f; if (!Mass.UseDefault) { inertiaScale = Mass.UserValue / Mass.DefaultValue; } InertiaDiagonal.DefaultValue = inertiaScale * nativeRb.getMassProperties().getPrincipalInertiae().ToVector3(); }
public AgX_Primitive(Guid guid, string shape, Vector3 pos, Quaternion rot, Vector3 size, double mass, string materialName, bool isStatic, bool AddToRobot) { this.guid = guid; this.shape = shape; this.size = size; this.materialName = materialName; var dynamicRBGeometry = new agxCollide.Geometry(); switch (this.shape) { case "Box": dynamicRBGeometry.add(new agxCollide.Box(Operations.ToAgxVec3(this.size))); break; case "Sphere": dynamicRBGeometry.add(new agxCollide.Sphere((this.size.x + this.size.y + this.size.z) / 3)); break; default: dynamicRBGeometry.add(new agxCollide.Box(Operations.ToAgxVec3(this.size))); break; } dynamicRBGeometry.setMaterial(new agx.Material(this.materialName)); agx_Object = new agx.RigidBody(); agx_Object.add(dynamicRBGeometry); agx_Object.setLocalPosition(Operations.ToAgxVec3(pos)); ///AgX agx_Object.setLocalRotation(new agx.Quat(rot.x, rot.y, rot.z, rot.w)); ///AgX agx_Object.getMassProperties().setMass(mass); if (isStatic) { agx_Object.setMotionControl(agx.RigidBody.MotionControl.STATIC); } if (AddToRobot) { AddToAssembly(); } else { Agx_Simulation.sim_Instance.add(agx_Object); } }
public static agx.RigidBody InstantiateTemplate(RigidBody template, Shape[] shapes) { if (template == null) { return(null); } var native = new agx.RigidBody(template.name); foreach (var shape in shapes) { var geometry = shape.CreateTemporaryNative(); geometry.setEnable(shape.IsEnabled); if (shape.Material != null) { geometry.setMaterial(shape.Material.GetInitialized <ShapeMaterial>().Native); } native.add(geometry, shape.GetNativeRigidBodyOffset(template)); } template.SyncNativeTransform(native); // MassProperties (synchronization below) wont write any data if UseDefault = true. native.getMassProperties().setAutoGenerateMask((uint)agx.MassProperties.AutoGenerateFlags.AUTO_GENERATE_ALL); native.updateMassProperties(); template.MassProperties.SetDefaultCalculated(native); native.getMassProperties().setAutoGenerateMask(0u); var prevNative = template.m_rb; try { template.m_rb = native; PropertySynchronizer.Synchronize(template); PropertySynchronizer.Synchronize(template.MassProperties); } finally { template.m_rb = prevNative; } return(native); }
protected override bool Initialize() { VerifyConfiguration(); m_rb = new agx.RigidBody(); m_rb.setName(name); m_rb.setEnable(IsEnabled); SyncNativeTransform(m_rb); SyncShapes(); GetSimulation().add(m_rb); UpdateMassProperties(); Simulation.Instance.StepCallbacks.PostSynchronizeTransforms += OnPostSynchronizeTransformsCallback; return(base.Initialize()); }
/// <summary> /// Callback from RigidBody when mass properties has been calculated for a native instance. /// </summary> /// <param name="nativeRb">Native rigid body instance.</param> public void SetDefaultCalculated(agx.RigidBody nativeRb) { if (nativeRb == null) { return; } Mass.DefaultValue = Convert.ToSingle(nativeRb.getMassProperties().getMass()); CenterOfMassOffset.DefaultValue = nativeRb.getCmFrame().getLocalTranslate().ToHandedVector3(); float inertiaScale = 1.0f; if (!Mass.UseDefault) { inertiaScale = Mass.UserValue / Mass.DefaultValue; } InertiaDiagonal.DefaultValue = inertiaScale * nativeRb.getMassProperties().getPrincipalInertiae().ToVector3(); InertiaOffDiagonal.DefaultValue = inertiaScale * GetNativeOffDiagonal(nativeRb.getMassProperties().getInertiaTensor()).ToVector3(); }
public AgX_Sensor(Guid guid, string materialName, Vector3 pos, Vector3 scale, double mass) { this.guid = guid; this.scale = scale; var dynamicRBGeometry = new agxCollide.Geometry();///AgX dynamicRBGeometry.add(new agxCollide.Box(Operations.ToAgxVec3(scale))); dynamicRBGeometry.setMaterial(new agx.Material(materialName)); agx_Object = new agx.RigidBody(); agx_Object.add(dynamicRBGeometry); agx_Object.setLocalPosition(Operations.ToAgxVec3(pos)); agx_Object.getMassProperties().setMass(mass); Agx_Simulation.sim_Instance.add(agx_Object); }
public TemporaryNative(Type nativeType, AttachmentPair attachmentPair = null) { m_rb1 = new agx.RigidBody(); m_f1 = new agx.Frame(); m_f2 = new agx.Frame(); if (attachmentPair != null) { // Some constraints, e.g., Distance Joints depends on the constraint angle during // creation so we feed the frames with the world transform of the reference and // connecting frame. attachmentPair.Synchronize(); m_f1.setLocalTranslate(attachmentPair.ReferenceFrame.Position.ToHandedVec3()); m_f1.setLocalRotate(attachmentPair.ReferenceFrame.Rotation.ToHandedQuat()); m_f2.setLocalTranslate(attachmentPair.ConnectedFrame.Position.ToHandedVec3()); m_f2.setLocalRotate(attachmentPair.ConnectedFrame.Rotation.ToHandedQuat()); } m_native = (agx.Constraint)Activator.CreateInstance(nativeType, new object[] { m_rb1, m_f1, null, m_f2 }); }
private void Generate(Node node) { if (node == null) { return; } // TODO: Skip if node.GameObject != null means "use Unity configuration". switch (node.Type) { case Node.NodeType.Assembly: agx.Frame frame = m_tree.GetAssembly(node.Uuid); node.GameObject = GetOrCreateGameObject(node); node.GameObject.name = FindName("", node.Type.ToString()); node.GameObject.transform.position = frame.getTranslate().ToHandedVector3(); node.GameObject.transform.rotation = frame.getRotate().ToHandedQuaternion(); node.GameObject.GetOrCreateComponent <Assembly>(); break; case Node.NodeType.RigidBody: agx.RigidBody nativeRb = m_tree.GetRigidBody(node.Uuid); node.GameObject = GetOrCreateGameObject(node); node.GameObject.name = FindName(nativeRb.getName(), node.Type.ToString()); node.GameObject.transform.position = nativeRb.getPosition().ToHandedVector3(); node.GameObject.transform.rotation = nativeRb.getRotation().ToHandedQuaternion(); node.GameObject.GetOrCreateComponent <RigidBody>().RestoreLocalDataFrom(nativeRb); break; case Node.NodeType.Geometry: // Ignoring geometries - handling Shape == Geometry. // The shapes are children to this node. break; case Node.NodeType.Shape: var nativeGeometry = m_tree.GetGeometry(node.Parent.Uuid); var nativeShape = m_tree.GetShape(node.Uuid); var nativeShapeType = (agxCollide.Shape.Type)nativeShape.getType(); node.GameObject = GetOrCreateGameObject(node); node.GameObject.name = FindName(nativeGeometry.getName() + "_" + nativeShapeType.ToString().ToLower().FirstCharToUpperCase(), node.Type.ToString()); node.GameObject.transform.position = nativeShape.getTransform().getTranslate().ToHandedVector3(); node.GameObject.transform.rotation = nativeShape.getTransform().getRotate().ToHandedQuaternion(); if (!CreateShape(node)) { GameObject.DestroyImmediate(node.GameObject); } break; case Node.NodeType.Material: var nativeMaterial = m_tree.GetMaterial(node.Uuid); node.Asset = ScriptAsset.Create <ShapeMaterial>().RestoreLocalDataFrom(nativeMaterial); node.Asset.name = FindName(nativeMaterial.getName(), node.Type.ToString()); node.Asset = AddOrReplaceAsset(node.Asset as ShapeMaterial, node, AGXUnity.IO.AssetType.ShapeMaterial); break; case Node.NodeType.ContactMaterial: var nativeContactMaterial = m_tree.GetContactMaterial(node.Uuid); var nativeFrictionModel = nativeContactMaterial.getFrictionModel(); var contactMaterial = ScriptAsset.Create <ContactMaterial>().RestoreLocalDataFrom(nativeContactMaterial); contactMaterial.name = FindName("ContactMaterial_" + nativeContactMaterial.getMaterial1().getName() + "_" + nativeContactMaterial.getMaterial2().getName(), node.Type.ToString()); var materials = node.GetReferences(Node.NodeType.Material); if (materials.Length == 0) { Debug.LogWarning("No materials referenced to ContactMaterial node."); } else if (materials.Length == 1) { contactMaterial.Material1 = contactMaterial.Material2 = materials[0].Asset as ShapeMaterial; } else if (materials.Length > 1) { contactMaterial.Material1 = materials[0].Asset as ShapeMaterial; contactMaterial.Material2 = materials[1].Asset as ShapeMaterial; if (materials.Length > 2) { Debug.LogWarning("More than two materials referenced to ContactMaterial (" + node.Asset.name + "). First two are used."); } } if (nativeFrictionModel != null) { var frictionModelAsset = ScriptAsset.Create <FrictionModel>().RestoreLocalDataFrom(nativeFrictionModel); frictionModelAsset.name = "FrictionModel_" + contactMaterial.name; contactMaterial.FrictionModel = AddOrReplaceAsset(frictionModelAsset, node, AGXUnity.IO.AssetType.FrictionModel); } node.Asset = contactMaterial = AddOrReplaceAsset(contactMaterial, node, AGXUnity.IO.AssetType.ContactMaterial); break; case Node.NodeType.Constraint: var nativeConstraint = m_tree.GetConstraint(node.Uuid); node.GameObject = GetOrCreateGameObject(node); node.GameObject.name = FindName(nativeConstraint.getName(), "AGXUnity." + Constraint.FindType(nativeConstraint)); if (!CreateConstraint(node)) { GameObject.DestroyImmediate(node.GameObject); } break; case Node.NodeType.Wire: var nativeWire = m_tree.GetWire(node.Uuid); node.GameObject = GetOrCreateGameObject(node); node.GameObject.name = FindName(nativeWire.getName(), "AGXUnity.Wire"); if (!CreateWire(node)) { GameObject.DestroyImmediate(node.GameObject); } break; case Node.NodeType.Cable: var nativeCable = m_tree.GetCable(node.Uuid); node.GameObject = GetOrCreateGameObject(node); node.GameObject.name = FindName(nativeCable.getName(), "AGXUnity.Cable"); if (!CreateCable(node)) { GameObject.DestroyImmediate(node.GameObject); } break; } foreach (var child in node.Children) { Generate(child); } }
public static bool IsValid(agx.RigidBody rb) { return(rb != null && !IsWireRigidBody(rb) && !IsCableRigidBody(rb)); }
public static bool IsWireRigidBody(agx.RigidBody rb) { return(agxWire.Wire.isLumpedNode(rb)); }
public static bool IsCableRigidBody(agx.RigidBody rb) { return(agxCable.Cable.getCableForBody(rb) != null); }