private PhysX.Shape CreateTrimeshShape(PhysX.RigidActor actor, PhysX.Material material, ref PhysX.Math.Matrix localPose) { PhysX.Shape shape = actor.CreateShape(_triMesh, material, localPose); shape.RestOffset = REST_OFFSET; return(shape); }
public Material(PhysX.Material baseMaterial, float density) { _baseMaterial = baseMaterial; Density = density; GravityMultiplier = GRAVITY_MULTIPLIER_DEFAULT; MaterialPreset = NO_PRESET; }
public Material(PhysX.Material baseMaterial, float density, float gravityMultiplier) { _baseMaterial = baseMaterial; Density = density; GravityMultiplier = gravityMultiplier; MaterialPreset = NO_PRESET; }
internal List <PhysX.Shape> AssignToActor(PhysX.RigidActor actor, PhysX.Material material, PhysX.Math.Matrix localPose, bool physical) { switch (_shapeType) { case ShapeType.PrimitiveBox: case ShapeType.PrimitiveSphere: return(new List <PhysX.Shape> { CreatePrimitiveShape(actor, material, ref localPose, physical) }); case ShapeType.TriMesh: return(new List <PhysX.Shape> { CreateTrimeshShape(actor, material, ref localPose) }); case ShapeType.DecomposedConvexHulls: case ShapeType.SingleConvex: return(this.AssignHullsToActor(actor, material, localPose, physical)); case ShapeType.Null: return(new List <PhysX.Shape>(0)); default: throw new InvalidOperationException("Can not assign shape to actor: shapeType is missing or invalid"); } }
public Material ToLocalMaterial(PhysX.Physics physics) { if (this.MaterialPreset != NO_PRESET) { return((Material)FindImpl((OpenMetaverse.Material) this.MaterialPreset)); } else { _baseMaterial = physics.CreateMaterial(_serializedStaticFriction, _serializedDynamicFriction, _serializedRestitution); return(this); } }
public Material Duplicate(PhysX.Physics physics) { if (this.MaterialPreset != NO_PRESET) { return((Material)FindImpl((OpenMetaverse.Material) this.MaterialPreset)); } else { PhysX.Material baseMaterial = physics.CreateMaterial(StaticFriction, DynamicFriction, Restitution); return(new Material(baseMaterial, Density, GravityMultiplier)); } }
private PhysX.Shape CreatePrimitiveShape(PhysX.RigidActor actor, PhysX.Material material, ref PhysX.Math.Matrix localPose, bool physical) { PhysX.Shape shape = actor.CreateShape(_primitiveGeom, material, localPose); shape.RestOffset = REST_OFFSET; if (physical && Settings.Instance.UseCCD) { //enable CCD shape.Flags |= PhysX.ShapeFlag.UseSweptBounds; } return(shape); }
private List <PhysX.Shape> AssignHullsToActor(PhysX.RigidActor actor, PhysX.Material material, PhysX.Math.Matrix localPose, bool physical) { List <PhysX.Shape> hulls = new List <PhysX.Shape>(); foreach (PhysX.ConvexMeshGeometry geom in _convexHulls) { PhysX.Shape shape = actor.CreateShape(geom, material, localPose); shape.RestOffset = REST_OFFSET; if (physical && Settings.Instance.UseCCD) { //enable CCD shape.Flags |= PhysX.ShapeFlag.UseSweptBounds; } hulls.Add(shape); } return(hulls); }
public Material(PhysX.Physics physics, float staticFriction, float dynamicFriction, float restitution, float density, float gravityMultiplier) { _baseMaterial = physics.CreateMaterial(staticFriction, dynamicFriction, restitution); Density = density; GravityMultiplier = gravityMultiplier; }
public Material(PhysX.Physics physics, float staticFriction, float dynamicFriction, float restitution, float density) { _baseMaterial = physics.CreateMaterial(staticFriction, dynamicFriction, restitution); Density = density; GravityMultiplier = GRAVITY_MULTIPLIER_DEFAULT; }
public Material(PhysX.Material baseMaterial, float density, int materialPreset) : this(baseMaterial, density, GRAVITY_MULTIPLIER_DEFAULT) { MaterialPreset = materialPreset; }
private void ReplaceMaterialOnShapes(Material material, PhysxPrim affectedPrim, IEnumerable<PhysX.Shape> shapes) { Material oldMaterial = affectedPrim.PhysxProperties.PhysxMaterial; affectedPrim.PhysxProperties.PhysxMaterial = material; PhysX.Material[] materialArr = new PhysX.Material[] { material.PhyMaterial }; foreach (PhysX.Shape shape in shapes) { shape.SetMaterials(materialArr); } if (oldMaterial.Density != material.Density) UpdateMassAndInertia(); oldMaterial.CheckedDispose(); }
public Material ToLocalMaterial(PhysX.Physics physics) { if (this.MaterialPreset != NO_PRESET) { return (Material)FindImpl((OpenMetaverse.Material)this.MaterialPreset); } else { _baseMaterial = physics.CreateMaterial(_serializedStaticFriction, _serializedDynamicFriction, _serializedRestitution); return this; } }
private void CreateDefaults() { DEFAULT_MATERIAL = _physics.CreateMaterial(0.5f, 0.5f, 0.15f); }
private void button1_Click(object sender, EventArgs e) { PhysX.Physics phys = new PhysX.Physics(); PhysX.SceneDesc desc = new PhysX.SceneDesc(); desc.Gravity = new PhysX.Math.Vector3(0f, 0f, -9.8f); PhysX.Scene scene = phys.CreateScene(desc); material = scene.Physics.CreateMaterial(0.5f, 0.5f, 0.1f); var conn = phys.ConnectToRemoteDebugger("localhost", null, null, null, PhysX.RemoteDebuggerConnectionFlags.Debug); /*scene.SetVisualizationParameter(PhysX.VisualizationParameter.Scale, 1.0f); scene.SetVisualizationParameter(PhysX.VisualizationParameter.CollisionShapes, true); scene.SetVisualizationParameter(PhysX.VisualizationParameter.JointLocalFrames, true); scene.SetVisualizationParameter(PhysX.VisualizationParameter.JointLimits, true); scene.SetVisualizationParameter(PhysX.VisualizationParameter.ParticleSystemPosition, true); scene.SetVisualizationParameter(PhysX.VisualizationParameter.ActorAxes, true);*/ var hfGeom = this.CreateHfGeom(scene); while (true) { PhysX.RigidDynamic sphere = CreateSphere(scene, 0); sphere.Dispose(); PhysX.RigidStatic ground = CreateGround(scene, hfGeom); ground.Dispose(); GC.Collect(); } scene.AddActor(CreateGround(scene)); /*PhysX.RigidDynamic box1 = null; for (int i = 0; i < 10; i += 2) { PhysX.RigidDynamic mahBox = CreateBox(scene, i); scene.AddActor(mahBox); if (i == 0) { box1 = mahBox; ((PhysX.Actor)box1).Flags = PhysX.ActorFlag.DisableGravity; } }*/ for (int i = 0; i < 10; i += 2) { PhysX.RigidDynamic mahBox = CreateSphere(scene, i); scene.AddActor(mahBox); } Stopwatch sw = new Stopwatch(); while (true) { sw.Start(); scene.Simulate(0.025f); scene.FetchResults(true); sw.Stop(); int sleep = 25 - (int)sw.ElapsedMilliseconds; if (sleep < 0) sleep = 0; System.Threading.Thread.Sleep(sleep); sw.Reset(); //label1.Text = DecomposeToPosition(mahBox.GlobalPose).ToString(); this.Update(); } }
private void button1_Click(object sender, EventArgs e) { PhysX.Physics phys = new PhysX.Physics(); PhysX.SceneDesc desc = new PhysX.SceneDesc(); desc.Gravity = new PhysX.Math.Vector3(0f, 0f, -9.8f); PhysX.Scene scene = phys.CreateScene(desc); material = scene.Physics.CreateMaterial(0.5f, 0.5f, 0.1f); var conn = phys.ConnectToRemoteDebugger("localhost", null, null, null, PhysX.RemoteDebuggerConnectionFlags.Debug); /*scene.SetVisualizationParameter(PhysX.VisualizationParameter.Scale, 1.0f); * scene.SetVisualizationParameter(PhysX.VisualizationParameter.CollisionShapes, true); * scene.SetVisualizationParameter(PhysX.VisualizationParameter.JointLocalFrames, true); * scene.SetVisualizationParameter(PhysX.VisualizationParameter.JointLimits, true); * scene.SetVisualizationParameter(PhysX.VisualizationParameter.ParticleSystemPosition, true); * scene.SetVisualizationParameter(PhysX.VisualizationParameter.ActorAxes, true);*/ var hfGeom = this.CreateHfGeom(scene); while (true) { PhysX.RigidDynamic sphere = CreateSphere(scene, 0); sphere.Dispose(); PhysX.RigidStatic ground = CreateGround(scene, hfGeom); ground.Dispose(); GC.Collect(); } scene.AddActor(CreateGround(scene)); /*PhysX.RigidDynamic box1 = null; * for (int i = 0; i < 10; i += 2) * { * PhysX.RigidDynamic mahBox = CreateBox(scene, i); * scene.AddActor(mahBox); * * if (i == 0) * { * box1 = mahBox; * ((PhysX.Actor)box1).Flags = PhysX.ActorFlag.DisableGravity; * } * }*/ for (int i = 0; i < 10; i += 2) { PhysX.RigidDynamic mahBox = CreateSphere(scene, i); scene.AddActor(mahBox); } Stopwatch sw = new Stopwatch(); while (true) { sw.Start(); scene.Simulate(0.025f); scene.FetchResults(true); sw.Stop(); int sleep = 25 - (int)sw.ElapsedMilliseconds; if (sleep < 0) { sleep = 0; } System.Threading.Thread.Sleep(sleep); sw.Reset(); //label1.Text = DecomposeToPosition(mahBox.GlobalPose).ToString(); this.Update(); } }
internal List <PhysX.Shape> AssignToActor(PhysX.RigidActor actor, PhysX.Material material, bool physical) { return(AssignToActor(actor, material, PhysX.Math.Matrix.Identity, physical)); }