public static Actor CreateGroundPlane()
        {
            // Create a plane with default descriptor
            var planeDesc = new PlaneShapeDescription();
            var actorDesc = new ActorDescription();

            actorDesc.Shapes.Add(planeDesc);
            return(PhysX.Instance.Scene.CreateActor(actorDesc));
        }
Example #2
0
        private void CreateGround(Nx.Material material)
        {
            var planeShapeDesc = new PlaneShapeDescription(0, 1, 0, 0)
            {
                Material = material,
            };
            var actorDesc = new ActorDescription(planeShapeDesc)
            {
                BodyDescription = null,
                UserData        = _planeModel
            };

            _scene.CreateActor(actorDesc);
        }
Example #3
0
        public PlaneShape(RigidBody rigidBody, Matrix4x4 realParentPose, Material material, PlaneShapeDescriptor descriptor)
        {
            var planeShapeDescription = new PlaneShapeDescription(descriptor.Normal.ToPhysX(), descriptor.DistanceFromOrigin) { Material = material._wrappedMaterial };
            _wrappedPlaneShape =
                (StillDesign.PhysX.PlaneShape)
                rigidBody.WrappedActor.CreateShape(planeShapeDescription);
            _normal = descriptor.Normal;
            _distanceFromOrigin = descriptor.DistanceFromOrigin;
            _pose = realParentPose;

            SetRealParentPose(realParentPose);


            UserData = descriptor.UserData;
            if (rigidBody.HasDefaultShape)
            {
                rigidBody.WrappedActor.Shapes[0].Dispose();
                rigidBody.HasDefaultShape = false;
            }
        }
        public void ResetScene()
        {
            Scene.FlushStream();
            Scene.FlushCaches();
            Scene.FetchResults(SimulationStatus.RigidBodyFinished, true);
            Scene.FlushStream();
            Scene.FlushCaches();
            foreach (var a in Scene.Actors.ToArray())
            {
                a.Dispose();
            }

            var desc = new PlaneShapeDescription(0, 1, 0, 0);

            var aDesc = new ActorDescription(desc);

            Scene.CreateActor(aDesc);
            //Scene.Dispose();
            //Scene = CreateDefaultScene();
        }
Example #5
0
        protected override void Initialize()
        {
            this.iniPhysics();
            //Костыль для плоскости
            PlaneShapeDescription planeDesc = new PlaneShapeDescription();

            planeDesc.Normal = new StillDesign.PhysX.MathPrimitives.Vector3(0, 1, 0);

            ActorDescription actorPlane = new ActorDescription();

            actorPlane.Shapes.Add(planeDesc);
            scene.CreateActor(actorPlane);
            //

            ElementDesc wheelDesc = new ElementDesc();

            wheelDesc.TypeJoint      = "Cylindrical";
            wheelDesc.GlobalPosition = new StillDesign.PhysX.MathPrimitives.Vector3(2.0f, 200.0f, 2.0f);



            camera = new myCamera.Camera(this);
            Car car = new Car(this, 1, "car", new Vector3(2.0f, 30.0f, 0.0f));

            car.ElementsDesc.Add("wheel1", wheelDesc);

            Wheel wheel = new Wheel(this, 2, "wheel");

            car.addElement("Cylindrical", wheel);
            elements.Add(wheel);
            //car.addElement(new Motor(this, 3));

            elements.Add(car);

            Components.Add(camera);
            base.Initialize();
        }
Example #6
0
        public PlaneShape(RigidBody rigidBody, Matrix4x4 realParentPose, Material material, PlaneShapeDescriptor descriptor)
        {
            var planeShapeDescription = new PlaneShapeDescription(descriptor.Normal.ToPhysX(), descriptor.DistanceFromOrigin)
            {
                Material = material._wrappedMaterial
            };

            _wrappedPlaneShape =
                (StillDesign.PhysX.PlaneShape)
                rigidBody.WrappedActor.CreateShape(planeShapeDescription);
            _normal             = descriptor.Normal;
            _distanceFromOrigin = descriptor.DistanceFromOrigin;
            _pose = realParentPose;

            SetRealParentPose(realParentPose);


            UserData = descriptor.UserData;
            if (rigidBody.HasDefaultShape)
            {
                rigidBody.WrappedActor.Shapes[0].Dispose();
                rigidBody.HasDefaultShape = false;
            }
        }
Example #7
0
        private void CreateGround(Nx.Material material)
        {
            var planeShapeDesc = new PlaneShapeDescription(0, 1, 0, 0)
                                     {

                                         Material = material,
                                         UserData = _planeModel
                                     };
            var actorDesc = new ActorDescription(planeShapeDesc) { BodyDescription = null };
            _scene.CreateActor(actorDesc);
        }
Example #8
0
        protected override void Initialize()
        {
            this.iniPhysics();
            //Костыль для плоскости
            PlaneShapeDescription planeDesc = new PlaneShapeDescription();
            planeDesc.Normal = new StillDesign.PhysX.MathPrimitives.Vector3(0, 1, 0);

            ActorDescription actorPlane = new ActorDescription();
            actorPlane.Shapes.Add(planeDesc);
            scene.CreateActor(actorPlane);
            //

            ElementDesc wheelDesc = new ElementDesc();
            wheelDesc.TypeJoint = "Cylindrical";
            wheelDesc.GlobalPosition = new StillDesign.PhysX.MathPrimitives.Vector3(2.0f, 200.0f, 2.0f);

            camera = new myCamera.Camera(this);
            Car car = new Car(this, 1, "car", new Vector3(2.0f,30.0f,0.0f));
            car.ElementsDesc.Add("wheel1", wheelDesc);

            Wheel wheel = new Wheel(this, 2, "wheel");
            car.addElement("Cylindrical", wheel);
            elements.Add(wheel);
            //car.addElement(new Motor(this, 3));

            elements.Add(car);

            Components.Add(camera);
            base.Initialize();
        }
Example #9
0
 private Actor CreateGroundPlane()
 {
     // Create a plane with default descriptor
     var planeDesc = new PlaneShapeDescription();
     var actorDesc = new ActorDescription();
     StillDesign.PhysX.Material defaultMaterial = Scene.Materials[0];
     planeDesc.Material = defaultMaterial;
     actorDesc.Shapes.Add(planeDesc);
     // actorDesc.ContactPairFlags = ContactPairFlag.All;
     //Scene.SetGroupCollisionFlag(1, 2, true);
     actorDesc.Group = 1;
     return Scene.CreateActor(actorDesc);
 }