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)
        {
            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;
            }
        }
示例#4
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;
            }
        }