本文整理汇总了C#中PhysX类的典型用法代码示例。如果您正苦于以下问题:C# PhysX类的具体用法?C# PhysX怎么用?C# PhysX使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PhysX类属于命名空间,在下文中一共展示了PhysX类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReportError
public override void ReportError(PhysX.ErrorCode errorCode, string message, string file, int lineNumber)
{
string errorMessage = String.Format("[InWorldz.PhysxPhysics] PhysX ERROR: Code: {0} Message: {1} ({2}:{3})",
new object[] { errorCode, message, file, lineNumber });
if (errorMessage == lastMessage && lastMessageRepeat < MAX_MESSAGES_BEFORE_NOTIFICATION)
{
lastMessageRepeat++;
return;
}
else
{
if (lastMessageRepeat != 0)
{
m_log.ErrorFormat("[InWorldz.PhysxPhysics] PhysX ERROR: (Last physics message repeats {0} times)", lastMessageRepeat);
lastMessageRepeat = 0;
}
lastMessage = errorMessage;
}
m_log.ErrorFormat(errorMessage);
if (Settings.Instance.ThrowOnSdkError)
{
throw new PhysxSdkException(errorMessage);
}
}
示例2: OnShapeHit
public override void OnShapeHit(PhysX.ControllerShapeHit hit)
{
if (OnShapeHitCallback != null)
{
OnShapeHitCallback(hit);
}
}
示例3: OnContact
public override void OnContact(PhysX.ContactPairHeader contactPairHeader, PhysX.ContactPair[] pairs)
{
if (OnContactCallback != null)
{
OnContactCallback(contactPairHeader, pairs);
}
}
示例4: OnTrigger
public override void OnTrigger(PhysX.TriggerPair[] pairs)
{
if (OnTriggerCallback != null)
{
OnTriggerCallback(pairs);
}
}
示例5: OnSleep
public override void OnSleep(PhysX.Actor[] actors)
{
if (OnSleepCallback != null)
{
OnSleepCallback(actors);
}
}
示例6: OnWake
public override void OnWake(PhysX.Actor[] actors)
{
if (OnWakeCallback != null)
{
OnWakeCallback(actors);
}
}
示例7: OnObstacleHit
public override void OnObstacleHit(PhysX.ControllerObstacleHit hit)
{
if (OnObstacleHitCallback != null)
{
OnObstacleHitCallback(hit);
}
}
示例8: SetCollisionGroup
public static void SetCollisionGroup(CollisionGroupFlag group, PhysX.Shape shape)
{
PhysX.FilterData newFilterData = CollisionGroup.GetFilterData(shape.SimulationFilterData.Word0,
shape.SimulationFilterData.Word1, group);
shape.SimulationFilterData = newFilterData;
shape.QueryFilterData = newFilterData;
}
示例9: CreateBox
private PhysX.RigidDynamic CreateBox(PhysX.Scene scene, int offset)
{
const float HEIGHT = 20.0f;
var rigid = scene.Physics.CreateRigidDynamic();
var shape = rigid.CreateShape(new PhysX.BoxGeometry(1.0f, 1.0f, 1.0f), material);
rigid.GlobalPose = PhysX.Math.Matrix.Translation(130f, 130f, HEIGHT + offset);
return rigid;
}
示例10: IsRideOnPrim
private bool IsRideOnPrim(PhysX.Shape shape)
{
if (_standingOnPrim == null)
{
return false;
}
PhysxPrim shapePrim = shape.Actor.UserData as PhysxPrim;
return IsRideOnPrim(shapePrim);
}
示例11: GetBehaviorFlags
public override PhysX.ControllerBehaviorFlag GetBehaviorFlags(PhysX.Shape shape)
{
if (IsRideOnPrim(shape))
{
return PhysX.ControllerBehaviorFlag.CctCanRideOnObject;
}
else
{
return 0;
}
}
示例12: CreateSphere
private PhysX.RigidDynamic CreateSphere(PhysX.Scene scene, int offset)
{
const float HEIGHT = 20.0f;
var rigid = scene.Physics.CreateRigidDynamic();
var shape = rigid.CreateShape(new PhysX.SphereGeometry(1.0f), material);
rigid.GlobalPose = PhysX.Math.Matrix.Translation(128f, 128f, HEIGHT + offset);
rigid.AngularDamping = 0.2f;
rigid.LinearDamping = 0.2f;
return rigid;
}
示例13: LoadPhysics
protected override void LoadPhysics(PhysX.Scene scene)
{
var material = scene.Physics.CreateMaterial(0.7f, 0.7f, 0.1f);
var sphereA = scene.Physics.CreateRigidDynamic();
sphereA.CreateShape(new SphereGeometry(1), material);
sphereA.GlobalPose = Matrix4x4.CreateTranslation(0, 30, 0);
scene.AddActor(sphereA);
//
var sphereB = scene.Physics.CreateRigidDynamic();
sphereB.CreateShape(new SphereGeometry(1), material);
sphereB.GlobalPose = Matrix4x4.CreateTranslation(0, 40, 0);
scene.AddActor(sphereB);
//
var sphereC = scene.Physics.CreateRigidDynamic();
sphereC.CreateShape(new SphereGeometry(1), material);
sphereC.GlobalPose = Matrix4x4.CreateTranslation(0, 50, 0);
scene.AddActor(sphereC);
_sphereC = sphereC;
//
var revoluteABJoint = scene.CreateJoint<RevoluteJoint>(sphereA, Matrix4x4.Identity, sphereB, Matrix4x4.Identity);
revoluteABJoint.SetGlobalFrame(new Vector3(0, 35, 0), new Vector3(0, 0, 1));
revoluteABJoint.ConstraintFlag = ConstraintFlag.Visualization;
var revoluteBCJoint = scene.CreateJoint<RevoluteJoint>(sphereB, Matrix4x4.Identity, sphereC, Matrix4x4.Identity);
revoluteBCJoint.SetGlobalFrame(new Vector3(0, 45, 0), new Vector3(0, 0, 1));
revoluteBCJoint.ConstraintFlag = ConstraintFlag.Visualization;
var revoluteAJoint = scene.CreateJoint<RevoluteJoint>(sphereA, Matrix4x4.Identity, null, Matrix4x4.Identity);
revoluteAJoint.SetGlobalFrame(new Vector3(0, 30, 0), new Vector3(0, 0, 1));
revoluteAJoint.ConstraintFlag = ConstraintFlag.Visualization;
}
示例14: TryInformPrimOfContactChange
private bool TryInformPrimOfContactChange(PhysX.ContactPairHeader contactPairHeader, PhysX.ContactPair[] pairs, int actorIndex)
{
PhysxPrim prim = contactPairHeader.Actors[actorIndex].UserData as PhysxPrim;
if (prim != null)
{
prim.OnContactChangeSync(contactPairHeader, pairs, actorIndex);
return true;
}
else
{
return false;
}
}
示例15: SetToRemoveAfterReport
private void SetToRemoveAfterReport(PhysX.Shape otherShape, PhysxPrim colPrim)
{
ExternalReport report;
if (_externalCollisionReports.TryGetValue(otherShape, out report))
{
if (report.Reported)
{
//this collision was reported already. remove it
RemoveExternalCollidingPrimShape(otherShape, colPrim);
}
else
{
//this collision hasn't been reported yet. make sure the
//collision processor knows to remove it after it is reported
report.RemoveAfterReport = true;
}
}
}