public void Evaluate(int SpreadMax) { this.frameBodyOutput.Clear(); IRigidBodyContainer world = this.worldInput[0]; if (world != null) { this.persistedList.UpdateWorld(world); if (this.shapesInput.IsConnected) { for (int i = 0; i < SpreadMax; i++) { if (doCreate[i]) { RigidBodyPose pose = this.initialPoseInput.IsConnected ? this.initialPoseInput[i] : RigidBodyPose.Default; RigidBodyProperties properties = this.initialProperties.IsConnected ? this.initialProperties[i] : RigidBodyProperties.Default; ShapeCustomData shapeData = new ShapeCustomData(); shapeData.ShapeDef = this.shapesInput[i]; CollisionShape collisionShape = shapeData.ShapeDef.GetShape(shapeData); Vector3 localInertia = Vector3.Zero; Tuple<RigidBody, int> bodyCreateResult = world.CreateRigidBody(collisionShape, ref pose, ref properties, ref localInertia, 0.0f); bodyCreateResult.Item1.CollisionFlags = CollisionFlags.StaticObject; this.persistedList.Append(bodyCreateResult.Item1, bodyCreateResult.Item2); frameBodyOutput.Add(bodyCreateResult.Item1); } } } this.bodiesOutput.SliceCount = this.persistedList.Bodies.Count; this.idOutput.SliceCount = this.persistedList.Ids.Count; List<RigidBody> bodies = this.persistedList.Bodies; List<int> ids = this.persistedList.Ids; for (int i = 0; i < bodies.Count; i++) { this.bodiesOutput[i] = bodies[i]; this.idOutput[i] = ids[i]; } this.createdBodiesOutput.SliceCount = this.frameBodyOutput.Count; for (int i = 0; i < frameBodyOutput.Count; i++) { this.createdBodiesOutput[i] = frameBodyOutput[i]; } } else { this.bodiesOutput.SliceCount = 0; this.idOutput.SliceCount = 0; this.createdBodiesOutput.SliceCount = 0; } }
public void Evaluate(int SpreadMax) { this.frameBodyOutput.Clear(); this.frameIdOutput.Clear(); if (SpreadMax == 0) { this.bodiesOutput.SliceCount = 0; this.idOutput.SliceCount = 0; return; } IRigidBodyContainer world = this.worldInput[0]; if (world != null && this.shapesInput.IsConnected) { for (int i = 0; i < SpreadMax; i++) { if (doCreate[i]) { RigidBodyPose pose = this.initialPoseInput.IsConnected ? this.initialPoseInput[i] : RigidBodyPose.Default; RigidBodyProperties properties = this.initialProperties.IsConnected ? this.initialProperties[i] : RigidBodyProperties.Default; ShapeCustomData shapeData = new ShapeCustomData(); shapeData.ShapeDef = this.shapesInput[i]; CollisionShape collisionShape = shapeData.ShapeDef.GetShape(shapeData); Vector3 localInertia = Vector3.Zero; Tuple <RigidBody, int> bodyCreateResult = world.CreateRigidBody(collisionShape, ref pose, ref properties, ref localInertia, 0.0f, this.customString[i]); bodyCreateResult.Item1.CollisionFlags = CollisionFlags.StaticObject; this.frameBodyOutput.Add(bodyCreateResult.Item1); this.frameIdOutput.Add(bodyCreateResult.Item2); } } this.bodiesOutput.SliceCount = this.frameBodyOutput.Count; this.idOutput.SliceCount = this.frameIdOutput.Count; for (int i = 0; i < frameBodyOutput.Count; i++) { this.bodiesOutput[i] = frameBodyOutput[i]; this.idOutput[i] = frameIdOutput[i]; } } else { this.bodiesOutput.SliceCount = 0; this.idOutput.SliceCount = 0; } }
public void Evaluate(int SpreadMax) { if (this.FWorld.PluginIO.IsConnected && this.FShapes.PluginIO.IsConnected) { List <SoftBody> bodies = new List <SoftBody>(); for (int i = 0; i < SpreadMax; i++) { if (FDoCreate[i]) { AbstractSoftShapeDefinition shapedef = this.FShapes[i]; SoftBody body = shapedef.GetSoftBody(this.FWorld[0].WorldInfo); RigidBodyPose pose = this.initialPoseInput.IsConnected ? this.initialPoseInput[i] : RigidBodyPose.Default; body.Translate(pose.Position); body.Scale(this.FScale[i].ToBulletVector()); body.Rotate(pose.Orientation); body.Friction = this.FFriction[i]; body.Restitution = this.FRestitution[i]; SoftBodyCustomData bd = new SoftBodyCustomData(this.FWorld[0].GetNewSoftBodyId()); bd.Custom = this.FCustom[i]; bd.HasUV = shapedef.HasUV; bd.UV = shapedef.GetUV(body); bd.Definition = shapedef; body.UserObject = bd; this.FWorld[0].Register(body); bodies.Add(body); //Attach if to all nodes for (int j = 0; j < body.Nodes.Count; j++) { body.Nodes[j].Tag = (IntPtr)j; } } } this.FOutBodies.SliceCount = bodies.Count; for (int i = 0; i < bodies.Count; i++) { this.FOutBodies[i] = bodies[i]; } } else { this.FOutBodies.SliceCount = 0; } }
public void Evaluate(int SpreadMax) { for (int i = 0; i < SpreadMax; i++) { RigidBody rb = this.FInput[i]; if (rb != null && this.FSetPosition[i]) { RigidBodyPose pose = FPose.IsConnected ? FPose[i] : RigidBodyPose.Default; Matrix transform = (Matrix)pose; rb.WorldTransform = transform; rb.MotionState.WorldTransform = transform; } } }
public void Evaluate(int SpreadMax) { this.frameBodyOutput.Clear(); this.frameIdOutput.Clear(); if (SpreadMax == 0) { this.bodiesOutput.SliceCount = 0; this.idOutput.SliceCount = 0; return; } IRigidBodyContainer world = this.worldInput[0]; if (world != null && this.shapesInput.IsConnected) { for (int i = 0; i < SpreadMax; i++) { if (doCreate[i]) { RigidBodyPose pose = this.initialPoseInput.IsConnected ? this.initialPoseInput[i] : RigidBodyPose.Default; RigidBodyProperties properties = this.initialProperties.IsConnected ? this.initialProperties[i] : RigidBodyProperties.Default; RigidBodyMotionProperties motionProperties = this.initialMotionProperties.IsConnected ? this.initialMotionProperties[i] : new RigidBodyMotionProperties(); ShapeCustomData shapeData = new ShapeCustomData(); DynamicShapeDefinitionBase shape = this.shapesInput[i]; shapeData.ShapeDef = shape; CollisionShape collisionShape = shapeData.ShapeDef.GetShape(shapeData); //Build mass for dynamic object Vector3 localinertia = Vector3.Zero; if (shape.Mass > 0.0f) { collisionShape.CalculateLocalInertia(shape.Mass, out localinertia); } Tuple <RigidBody, int> createBodyResult = world.CreateRigidBody(collisionShape, ref pose, ref properties, ref localinertia, shape.Mass); createBodyResult.Item1.ApplyMotionProperties(ref motionProperties); this.frameBodyOutput.Add(createBodyResult.Item1); this.frameIdOutput.Add(createBodyResult.Item2); } } this.bodiesOutput.SliceCount = this.frameBodyOutput.Count; this.idOutput.SliceCount = this.frameIdOutput.Count; for (int i = 0; i < frameBodyOutput.Count; i++) { this.bodiesOutput[i] = frameBodyOutput[i]; this.idOutput[i] = frameIdOutput[i]; } } else { this.bodiesOutput.SliceCount = 0; this.idOutput.SliceCount = 0; } }
public void Evaluate(int SpreadMax) { IRigidBulletWorld inputWorld = this.worldInput[0]; SpreadMax = 1; if (inputWorld != null) { this.persistedList.UpdateWorld(inputWorld); if (this.chassisShape.IsConnected) { for (int i = 0; i < SpreadMax; i++) { if (this.doCreate[i]) { RigidBodyPose initialPose = this.initialPoseInput.IsConnected ? this.initialPoseInput[i] : RigidBodyPose.Default; RigidBodyProperties properties = this.initialProperties.IsConnected ? this.initialProperties[i] : RigidBodyProperties.Default; ShapeCustomData shapeData = new ShapeCustomData(); DynamicShapeDefinitionBase chassisShapeDefinition = this.chassisShape[i]; CollisionShape chassisShape = chassisShapeDefinition.GetShape(shapeData); shapeData.ShapeDef = chassisShapeDefinition; RaycastVehicle vehicle; CompoundShape compoundShape = new CompoundShape(); Matrix localTrans = Matrix.Translation(Vector3.UnitY); compoundShape.AddChildShape(localTrans, chassisShape); //Build mass for dynamic object Vector3 localInertia = Vector3.Zero; if (chassisShapeDefinition.Mass > 0.0f) { compoundShape.CalculateLocalInertia(chassisShapeDefinition.Mass, out localInertia); } Tuple <RigidBody, int> createBodyResult = inputWorld.CreateRigidBody(chassisShape, ref initialPose, ref properties, ref localInertia, chassisShapeDefinition.Mass, this.customString[i]); RigidBody carChassis = createBodyResult.Item1; RaycastVehicle.VehicleTuning tuning = new RaycastVehicle.VehicleTuning(); DefaultVehicleRaycaster vehicleRayCaster = new DefaultVehicleRaycaster(inputWorld.World); vehicle = new RaycastVehicle(tuning, carChassis, vehicleRayCaster); vehicle.SetCoordinateSystem(rightIndex, upIndex, forwardIndex); carChassis.ActivationState = ActivationState.DisableDeactivation; inputWorld.World.AddAction(vehicle); int wheelCount = this.wheelConstruction.SliceCount; //Add wheels for (int j = 0; j < this.wheelConstruction[i].SliceCount; j++) { WheelConstructionProperties wcs = this.wheelConstruction[i][j]; Vector3 connectionPointCS0 = wcs.localPosition.ToBulletVector(); WheelInfo wheel = vehicle.AddWheel(connectionPointCS0, wcs.wheelDirection.ToBulletVector(), wcs.wheelAxis.ToBulletVector(), wcs.SuspensionRestLength, wcs.WheelRadius, tuning, wcs.isFrontWheel); } //Set Wheel Properties WheelProperties wis = this.wheelInfoSettings[i] != null ? this.wheelInfoSettings[i] : new WheelProperties(); for (int j = 0; j < vehicle.NumWheels; j++) { WheelInfo wheel = vehicle.GetWheelInfo(j); wheel.SuspensionStiffness = wis.SuspensionStiffness; wheel.WheelsDampingRelaxation = wis.WheelsDampingRelaxation; wheel.WheelsDampingCompression = wis.WheelsDampingCompression; wheel.FrictionSlip = wis.FrictionSlip; wheel.RollInfluence = wis.RollInfluence; } BodyCustomData bd = (BodyCustomData)carChassis.UserObject; bd.Vehicle = vehicle; this.persistedList.Append(createBodyResult.Item1, createBodyResult.Item2); } } List <RigidBody> bodies = this.persistedList.Bodies; this.vehicleOutput.SliceCount = bodies.Count; this.chassisOutput.SliceCount = bodies.Count; for (int i = 0; i < bodies.Count; i++) { BodyCustomData bd = (BodyCustomData)bodies[i].UserObject; this.vehicleOutput[i] = bd.Vehicle; this.chassisOutput[i] = bodies[i]; } } } else { this.vehicleOutput.SliceCount = 0; this.chassisOutput.SliceCount = 0; } }
public void Evaluate(int SpreadMax) { this.frameBodyOutput.Clear(); IRigidBodyContainer inputWorld = this.worldInput[0]; if (inputWorld != null) { this.persistedList.UpdateWorld(inputWorld); if (this.shapesInput.IsConnected) { for (int i = 0; i < SpreadMax; i++) { if (doCreate[i]) { RigidBodyPose pose = this.initialPoseInput.IsConnected ? this.initialPoseInput[i] : RigidBodyPose.Default; RigidBodyProperties properties = this.initialProperties.IsConnected ? this.initialProperties[i] : RigidBodyProperties.Default; RigidBodyMotionProperties motionProperties = this.initialMotionProperties.IsConnected ? this.initialMotionProperties[i] : new RigidBodyMotionProperties(); ShapeCustomData shapeData = new ShapeCustomData(); DynamicShapeDefinitionBase shape = this.shapesInput[i]; shapeData.ShapeDef = shape; CollisionShape collisionShape = shapeData.ShapeDef.GetShape(shapeData); //Build mass for dynamic object Vector3 localinertia = Vector3.Zero; if (shape.Mass > 0.0f) { collisionShape.CalculateLocalInertia(shape.Mass, out localinertia); } Tuple <RigidBody, int> createBodyResult = inputWorld.CreateRigidBody(collisionShape, ref pose, ref properties, ref localinertia, shape.Mass); createBodyResult.Item1.CollisionFlags |= CollisionFlags.KinematicObject; createBodyResult.Item1.ApplyMotionProperties(ref motionProperties); this.persistedList.Append(createBodyResult.Item1, createBodyResult.Item2); frameBodyOutput.Add(createBodyResult.Item1); } } } this.bodiesOutput.SliceCount = this.persistedList.Bodies.Count; this.idOutput.SliceCount = this.persistedList.Ids.Count; List <RigidBody> bodies = this.persistedList.Bodies; List <int> ids = this.persistedList.Ids; for (int i = 0; i < bodies.Count; i++) { this.bodiesOutput[i] = bodies[i]; this.idOutput[i] = ids[i]; } this.createdBodiesOutput.SliceCount = this.frameBodyOutput.Count; for (int i = 0; i < frameBodyOutput.Count; i++) { this.createdBodiesOutput[i] = frameBodyOutput[i]; } } else { this.bodiesOutput.SliceCount = 0; this.idOutput.SliceCount = 0; this.createdBodiesOutput.SliceCount = 0; } }