本文整理汇总了C#中PhysX类的典型用法代码示例。如果您正苦于以下问题:C# PhysX类的具体用法?C# PhysX怎么用?C# PhysX使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PhysX类属于命名空间,在下文中一共展示了PhysX类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:kf6kjg,项目名称:halcyon,代码行数:28,代码来源:PhysxErrorCallback.cs
示例2: OnShapeHit
public override void OnShapeHit(PhysX.ControllerShapeHit hit)
{
if (OnShapeHitCallback != null)
{
OnShapeHitCallback(hit);
}
}
开发者ID:kf6kjg,项目名称:halcyon,代码行数:7,代码来源:UserControllerHitReportDelegator.cs
示例3: OnContact
public override void OnContact(PhysX.ContactPairHeader contactPairHeader, PhysX.ContactPair[] pairs)
{
if (OnContactCallback != null)
{
OnContactCallback(contactPairHeader, pairs);
}
}
开发者ID:kf6kjg,项目名称:halcyon,代码行数:7,代码来源:SimulationEventCallbackDelegator.cs
示例4: OnTrigger
public override void OnTrigger(PhysX.TriggerPair[] pairs)
{
if (OnTriggerCallback != null)
{
OnTriggerCallback(pairs);
}
}
开发者ID:kf6kjg,项目名称:halcyon,代码行数:7,代码来源:SimulationEventCallbackDelegator.cs
示例5: OnSleep
public override void OnSleep(PhysX.Actor[] actors)
{
if (OnSleepCallback != null)
{
OnSleepCallback(actors);
}
}
开发者ID:kf6kjg,项目名称:halcyon,代码行数:7,代码来源:SimulationEventCallbackDelegator.cs
示例6: OnWake
public override void OnWake(PhysX.Actor[] actors)
{
if (OnWakeCallback != null)
{
OnWakeCallback(actors);
}
}
开发者ID:kf6kjg,项目名称:halcyon,代码行数:7,代码来源:SimulationEventCallbackDelegator.cs
示例7: OnObstacleHit
public override void OnObstacleHit(PhysX.ControllerObstacleHit hit)
{
if (OnObstacleHitCallback != null)
{
OnObstacleHitCallback(hit);
}
}
开发者ID:kf6kjg,项目名称:halcyon,代码行数:7,代码来源:UserControllerHitReportDelegator.cs
示例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;
}
开发者ID:kf6kjg,项目名称:halcyon,代码行数:8,代码来源:CollisionGroup.cs
示例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;
}
开发者ID:kf6kjg,项目名称:halcyon,代码行数:11,代码来源:Form1.cs
示例10: IsRideOnPrim
private bool IsRideOnPrim(PhysX.Shape shape)
{
if (_standingOnPrim == null)
{
return false;
}
PhysxPrim shapePrim = shape.Actor.UserData as PhysxPrim;
return IsRideOnPrim(shapePrim);
}
开发者ID:kf6kjg,项目名称:halcyon,代码行数:11,代码来源:CharacterRideOnBehavior.cs
示例11: GetBehaviorFlags
public override PhysX.ControllerBehaviorFlag GetBehaviorFlags(PhysX.Shape shape)
{
if (IsRideOnPrim(shape))
{
return PhysX.ControllerBehaviorFlag.CctCanRideOnObject;
}
else
{
return 0;
}
}
开发者ID:kf6kjg,项目名称:halcyon,代码行数:11,代码来源:CharacterRideOnBehavior.cs
示例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;
}
开发者ID:kf6kjg,项目名称:halcyon,代码行数:13,代码来源:Form1.cs
示例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;
}
开发者ID:flair2005,项目名称:PhysX.Net,代码行数:42,代码来源:DoublePendulumSample.cs
示例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;
}
}
开发者ID:kf6kjg,项目名称:halcyon,代码行数:13,代码来源:PhysxScene.cs
示例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;
}
}
}
开发者ID:digitalmystic,项目名称:halcyon,代码行数:18,代码来源:PhysxCharacter.cs
示例16: AddExternalCollidingPrimShape
private void AddExternalCollidingPrimShape(PhysX.Shape otherShape, PhysxPrim colPrim)
{
_externalCollisionReports[otherShape] = new ExternalReport { RemoveAfterReport = false, Reported = false };
HashSet<PhysX.Shape> primShapes;
if (!_externalCollisionPrims.TryGetValue(colPrim, out primShapes))
{
primShapes = new HashSet<PhysX.Shape>();
_externalCollisionPrims.Add(colPrim, primShapes);
colPrim.OnDeleted += colPrim_OnDeleted;
}
primShapes.Add(otherShape);
}
开发者ID:digitalmystic,项目名称:halcyon,代码行数:14,代码来源:PhysxCharacter.cs
示例17: RemoveExternalCollidingPrimShape
private void RemoveExternalCollidingPrimShape(PhysX.Shape otherShape, PhysxPrim colPrim)
{
_externalCollisionReports.Remove(otherShape);
HashSet<PhysX.Shape> primShapes;
if (_externalCollisionPrims.TryGetValue(colPrim, out primShapes))
{
primShapes.Remove(otherShape);
if (primShapes.Count == 0)
{
_externalCollisionPrims.Remove(colPrim);
colPrim.OnDeleted -= colPrim_OnDeleted;
}
}
}
开发者ID:digitalmystic,项目名称:halcyon,代码行数:15,代码来源:PhysxCharacter.cs
示例18: AddTorque
//
// Motor add torque. It acumulates velocity and impulse
// torques separately so that they can be applied finally at the end of the physics frame.
//
internal void AddTorque(OpenMetaverse.Vector3 force, PhysX.ForceMode mode, string code)
{
OpenMetaverse.Vector3 torque = force;
if (mode == PhysX.ForceMode.VelocityChange)
AccumTorqueVel += torque;
if (mode == PhysX.ForceMode.Impulse)
AccumTorqueImpulse += torque;
if (VehicleLimits.DebugAngular)
{
if (AccumTorqueFirst)
{
m_log.DebugFormat("[----------------------]");
m_log.DebugFormat("[VehicleMotor BgnTorque] InitialVelocity {0}", worldAngularVel * Quaternion.Inverse(rotation));
}
m_log.DebugFormat("[VehicleMotor AddTorque] {2} {1} {0}", torque * Quaternion.Inverse(rotation), code, mode);
}
AccumTorqueFirst = false;
}
开发者ID:kf6kjg,项目名称:halcyon,代码行数:22,代码来源:VehicleDynamics.cs
示例19: CalculateDepenetrationZOffset
private float CalculateDepenetrationZOffset(OpenMetaverse.Vector3 pos, PhysX.Geometry avaGeom, PhysX.Shape avaShape)
{
const int MAX_ITERATIONS = 8;
const float PUSH_MULTIPLIER = 1.5F;
float pushFactor = 0.1f;
OpenMetaverse.Vector3 offset = OpenMetaverse.Vector3.Zero;
bool foundOverlap = false;
//constant from looking at the rot returned from the live avatar,
//remember that capsules are always upright, and z rotations don't have an effect
//on their geometry
OpenMetaverse.Quaternion capsuleRot = new OpenMetaverse.Quaternion(0f, -0.7071069f, 0f, 0.7071067f);
for (int i = 0; i < MAX_ITERATIONS; i++)
{
foundOverlap = false;
OpenMetaverse.Vector3 translatedPose = pos + offset;
PhysX.Shape[] overlap = _scene.SceneImpl.OverlapMultiple(avaGeom, PhysUtil.PositionToMatrix(translatedPose, capsuleRot));
if (overlap == null)
{
foundOverlap = true;
}
else
{
foreach (var shape in overlap)
{
if (shape != avaShape && !ShapeIsVolumeDetect(shape))
{
foundOverlap = true;
break;
}
}
}
if (foundOverlap && i + 1 < MAX_ITERATIONS)
{
offset += new OpenMetaverse.Vector3(0f, 0f, pushFactor);
pushFactor *= PUSH_MULTIPLIER;
}
else
{
break;
}
}
if (foundOverlap == false && offset != OpenMetaverse.Vector3.Zero)
{
return offset.Z;
}
return 0.0f;
}
开发者ID:digitalmystic,项目名称:halcyon,代码行数:55,代码来源:PhysxCharacter.cs
示例20: VehicleMotor
public VehicleMotor(ref PhysxPrim _actor, ref VehicleProperties _props, ref PhysX.Physics _physics, ref PhysxScene _scene)
{
this._actor = _actor;
this._props = _props;
this._physics = _physics;
this._scene = _scene;
}
开发者ID:kf6kjg,项目名称:halcyon,代码行数:7,代码来源:VehicleDynamics.cs
注:本文中的PhysX类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论