Пример #1
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);

                        body.Translate(this.FPosition[i].ToBulletVector());
                        body.Scale(this.FScale[i].ToBulletVector());
                        body.Rotate(this.FRotate[i].ToBulletQuaternion());

                        body.Friction    = this.FFriction[i];
                        body.Restitution = this.FRestitution[i];

                        SoftBodyCustomData bd = new SoftBodyCustomData();
                        bd.Id           = this.FWorld[0].GetNewBodyId();
                        bd.Custom       = this.FCustom[i];
                        bd.HasUV        = shapedef.HasUV;
                        bd.UV           = shapedef.GetUV(body);
                        body.UserObject = bd;


                        if (this.FCustomObj.PluginIO.IsConnected)
                        {
                            bd.CustomObject = (ICloneable)this.FCustomObj[i].Clone();
                        }
                        else
                        {
                            bd.CustomObject = null;
                        }



                        this.FWorld[0].Register(body);
                        bodies.Add(body);
                    }
                }

                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)
        {
            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;
            }
        }