Example #1
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Box         iBox      = Box.Empty;
            bool        iDynamic  = true;
            Material    iMaterial = PxGhManager.DefaultMaterial;
            double      iMass     = double.NaN;
            Vector3d    iInitialLinearVelocity   = Vector3d.Unset;
            Vector3d    iInitialLAngularVelocity = Vector3d.Unset;
            double      iLinearDamping           = double.NaN;
            double      iAngularDamping          = double.NaN;
            List <Mesh> iDisplayedMeshes         = new List <Mesh>();

            DA.GetData(0, ref iBox);
            DA.GetData(1, ref iDynamic);
            DA.GetData(2, ref iMaterial);
            DA.GetData(3, ref iMass);
            DA.GetData(4, ref iInitialLinearVelocity);
            DA.GetData(5, ref iInitialLAngularVelocity);
            DA.GetData(6, ref iLinearDamping);
            DA.GetData(7, ref iAngularDamping);
            DA.GetDataList(8, iDisplayedMeshes);

            if (iDynamic)
            {
                PxGhRigidDynamic rigidObject = new PxGhRigidDynamicBox(iBox, iMaterial, (float)iMass, iInitialLinearVelocity, iInitialLAngularVelocity);
                rigidObject.Actor.LinearDamping  = (float)iLinearDamping;
                rigidObject.Actor.AngularDamping = (float)iAngularDamping;
                DA.SetData(0, rigidObject);
            }
            else
            {
                DA.SetData(0, new PxGhRigidStaticBox(iBox, iMaterial));
            }
        }
Example #2
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Box      iBox      = new Box();
            bool     isDynamic = true;
            Material iMaterial = PhysXManager.Physics.CreateMaterial(0.5f, 0.5f, 0.5f);

            DA.GetData(0, ref iBox);
            DA.GetData(1, ref isDynamic);
            DA.GetData(2, ref iMaterial);

            Plane plane = iBox.Plane;

            plane.Translate(iBox.Center - iBox.Plane.Origin);

            if (isDynamic)
            {
                PxGhRigidDynamic rigidDynamic =
                    new PxGhRigidDynamicBox(plane, (float)iBox.X.Length, (float)iBox.Y.Length, (float)iBox.Z.Length, iMaterial, 1);

                DA.SetData(0, rigidDynamic);
            }
            else
            {
                PxGhRigidStaticBox rigidStatic =
                    new PxGhRigidStaticBox(plane, (float)iBox.X.Length, (float)iBox.Y.Length, (float)iBox.Z.Length, iMaterial);

                DA.SetData(0, rigidStatic);
            }
        }