PhysX官方手册翻译(二)

Basics:

Math Classes

4种数据结构:

NxVec3

NxQuat

NxMat33

NxMat34

 

Simple Shapes

7种基本物理模型:

NxBounds3           轴对称边界盒

NxBox                  对象边界盒

NxCapsule            交囊

NxPlane                任意的面

NxRay                  无限射线/直线

NxSegment           有限射线/线段

NxSphere            

(事实上还有多边形,不过它应该不能称为简单)

SDK Initialization

NxCreatePhysicsSDK: 创建接口指针。

参数一:接口版本

参数二:内存管理类实体

参数三:用于输出的流

 

要点一:SDK版本要和驱动版本匹配

要点二:可以多次调用NxCreatePhysicsSDK,但是都将得到同一个实体,就象单件模式一样。但是存在引用计数,因此需要严格匹配 call release 的次数。

要点三:多次调用的时候,后设置的内存管理类将被忽略,但是输出流对象则会被覆盖。

 

Casting and Instancing

创建实例:

1、声明描述符

2、调用PhysX接口创建该实例

 

释放:

父对象的释放会引起子对象的自动释放。

 

转换:

NxShape / NxSphereShape / NxMoxsSs

向下转换

Shape->isSphere() shape->isBox()

失败返回NULL

 

Memory Management

虽然不是必须的,但是PhysX提供了内存管理接口。(继承NxUserAllocator

重载了 malloc / realloc / free

一旦被设置,就不能更改。

该类提供的内存管理函数必须保证是“线程安全的”。

 

Debug Rendering

不能使对象之间的间距可视化

Debug Information通过 gScene->getDebugRenderable() 返回的 NxDebugRenderable得到。

PhysX不是图象库,使用者需要自己绘制这些信息。

 

User Data

可以给对象(Actor)关联数据。

  myShape->userData = ***;

 

User Defined Classes

8个需要用户自己实现的类:

NxUserAllocator 内存管理 NxUserOutputStream 错误信息 NxUserContactReport 反射(接触)通知 NxUserNotify 事件通知 NxUserRaycastReport  射线查询回调 NxUserTriggerReport 触发器回调 NxUserEntityReport 实体回调?? NxStream 串行化(用于数据IO

 

Error Reporting

使用NxUserOutputStream

 

Saving the Simulation State

所有通过描述符创建的对象都有2个方法:saveToDesc() loadFromDesc()

可以用于保存对象当前的状态,这个特性可以应用于保存游戏,或者其他目的。

SDK Parameters

PhysX有一套集中管理的全局变量,85个定义,其中变量83个,哑元1个,记录数量1)

使用者可以通过 setParameters() / getParameters() 来修改他们。

大多数变量的默认值是不需要更改的。

 

Parameter Summary

Parameter

Default Value

Description

NX_PENALTY_FORCE

 

DEPRECATED

NX_SKIN_WIDTH

0.025

皮肤厚度 (range: [0, inf) Unit: distance.

 

 

 

NX_DEFAULT_SLEEP_LIN_VEL_SQUARED

(0.15*0.15)

The default linear velocity, squared, below which objects start going to sleep. (range: [0, inf))

NX_DEFAULT_SLEEP_ANG_VEL_SQUARED

(0.14*0.14)

The default angular velocity, squared, below which objects start going to sleep. (range: [0, inf))

 

 

 

NX_BOUNCE_TRESHOLD

-2

A contact with a relative velocity below this will not bounce. (range: (-inf, 0])

 

 

 

NX_DYN_FRICT_SCALING

1

This lets the user scale the magnitude of the dynamic friction applied to all objects. (range: [0, inf))

NX_STA_FRICT_SCALING

1

This lets the user scale the magnitude of the static friction applied to all objects. (range: [0, inf))

 

 

 

NX_MAX_ANGULAR_VELOCITY

7

See API Reference for NxBody::setMaxAngularVelocity() for details.

 

 

 

NX_CONTINUOUS_CD

0

Enable/disable continuous collision detection ( 0.0f to disable)

 

 

 

NX_VISUALIZATION_SCALE

0

This overall visualization scale gets multiplied with the individual scales. Setting to zero turns off debug visualizations.

 

 

 

NX_VISUALIZE_WORLD_AXES

0

Visualize the world axes.

 

 

 

NX_VISUALIZE_BODY_AXES

0

Visualize a body's axes.

NX_VISUALIZE_BODY_MASS_AXES

0

Visualize a body's mass axes.

NX_VISUALIZE_BODY_LIN_VELOCITY

0

Visualize the bodies' linear velocity.

NX_VISUALIZE_BODY_ANG_VELOCITY

0

Visualize the bodies' angular velocity.

NX_VISUALIZE_BODY_JOINT_GROUPS

0

Visualize joint groups.

NX_VISUALIZE_JOINT_LOCAL_AXES

0

Visualize local joint axes.

NX_VISUALIZE_JOINT_WORLD_AXES

0

Visualize joint world axes.

NX_VISUALIZE_JOINT_LIMITS

0

Visualize joint limits.

 

 

 

NX_VISUALIZE_CONTACT_POINT

0

Visualize contact points.

NX_VISUALIZE_CONTACT_NORMAL

0

Visualize contact normals.

NX_VISUALIZE_CONTACT_ERROR

0

Visualize contact errors.

NX_VISUALIZE_CONTACT_FORCE

0

Visualize contact forces.

 

 

 

NX_VISUALIZE_ACTOR_AXES

0

Visualize actor axes.

 

 

 

NX_VISUALIZE_COLLISION_AABBS

0

Visualize bounds (AABBs in world space).

NX_VISUALIZE_COLLISION_SHAPES

0

Visualize shape.

NX_VISUALIZE_COLLISION_AXES

0

Visualize shape axes.

NX_VISUALIZE_COLLISION_COMPOUNDS

0

Visualize compound (compound AABBs in world space).

NX_VISUALIZE_COLLISION_VNORMALS

0

Visualize mesh & convex vertex normals.

NX_VISUALIZE_COLLISION_FNORMALS

0

Visualize mesh & convex face normals.

NX_VISUALIZE_COLLISION_EDGES

0

Visualize active edges for meshes.

NX_VISUALIZE_COLLISION_SPHERES

0

Visualize bounding spheres.

 

 

 

NX_VISUALIZE_COLLISION_STATIC

0

Visualize static pruning structures.

NX_VISUALIZE_COLLISION_DYNAMIC

0

Visualize dynamic pruning structures.

NX_VISUALIZE_COLLISION_FREE

0

Visualize "free" pruning structures.

NX_VISUALIZE_COLLISION_CCD

0

Visualize CCD tests.

NX_VISUALIZE_COLLISION_SKELETONS

0

Visualize CCD skeletons.

 

 

 

NX_VISUALIZE_FLUID_EMITTERS

0

Visualize emitter.

NX_VISUALIZE_FLUID_POSITION

0

Visualize particle position.

NX_VISUALIZE_FLUID_VELOCITY

0

Visualize particle velocity.

NX_VISUALIZE_FLUID_KERNEL_RADIUS

0

Visualize particle kernel radius.

NX_VISUALIZE_FLUID_BOUNDS

0

Visualize fluid AABB.

NX_VISUALIZE_FLUID_PACKETS

0

Visualize fluid packets.

NX_VISUALIZE_FLUID_MOTION_LIMIT

0

Visualize fluid motion limits.

NX_VISUALIZE_FLUID_DYN_COLLISION

0

Visualize fluid dynamic mesh collision.

NX_VISUALIZE_FLUID_STC_COLLISION

0

Not implemented: Visualize fluid static collision.

NX_VISUALIZE_FLUID_MESH_PACKETS

0

Visualize available fluid mesh packets.

NX_VISUALIZE_FLUID_DRAINS

0

Visualize fluid drain shapes.

NX_VISUALIZE_FLUID_PACKET_DATA

0

Visualize fluid data packets.

 

 

 

NX_VISUALIZE_CLOTH_MESH

0

Visualize cloth meshes.

NX_VISUALIZE_CLOTH_COLLISIONS

0

Visualize cloth rigid body collision.

NX_VISUALIZE_CLOTH_SELFCOLLISIONS

0

Visualize cloth self collision.

NX_VISUALIZE_CLOTH_WORKPACKETS

0

Visualize cloth clustering for the PPU.

NX_VISUALIZE_CLOTH_SLEEP

0

Visualize cloth sleeping.

NX_VISUALIZE_CLOTH_SLEEP_VERTEX

0

Visualize cloth sleeping with full per-vertex information.

NX_VISUALIZE_CLOTH_TEARABLE_VERTICES

0

Visualize tearable cloth vertices.

NX_VISUALIZE_CLOTH_TEARING

0

Visualize cloth tearing.

NX_VISUALIZE_CLOTH_ATTACHMENT

0

Visualize cloth attachments.

NX_VISUALIZE_CLOTH_VALIDBOUNDS

0

Visualize cloth valid bounds.

 

 

 

NX_VISUALIZE_SOFTBODY_MESH

0

Visualize soft body meshes.

NX_VISUALIZE_SOFTBODY_COLLISIONS

0

Visualize soft body collisions with rigid bodies.

NX_VISUALIZE_SOFTBODY_WORKPACKETS

0

Visualize soft body clustering for simulation on the PPU.

NX_VISUALIZE_SOFTBODY_SLEEP

0

Visualize soft body sleeping.

NX_VISUALIZE_SOFTBODY_SLEEP_VERTEX

0

Visualize soft body sleeping with full per-vertex information.

NX_VISUALIZE_SOFTBODY_TEARABLE_VERTICES

0

Visualize tearable soft body vertices.

NX_VISUALIZE_SOFTBODY_TEARING

0

Visualize soft body tearing.

NX_VISUALIZE_SOFTBODY_ATTACHMENT

0

Visualize soft body attachments.

NX_VISUALIZE_SOFTBODY_VALIDBOUNDS

0

Visualize soft body valid bounds.

 

 

 

NX_ADAPTIVE_FORCE

1

Used to enable adaptive forces to accelerate convergence of the solver.

NX_COLL_VETO_JOINTED

1

Controls default filtering for jointed bodies (true = collision disabled).

NX_TRIGGER_TRIGGER_CALLBACK

1

Controls whether two touching triggers generate a callback or not.

 

 

 

NX_SELECT_HW_ALGO

0

Internal parameter, used for debugging and testing. Not to be used.

NX_VISUALIZE_ACTIVE_VERTICES

0

Internal parameter, used for debugging and testing. Not to be used.

 

 

 

NX_CCD_EPSILON

0.01

Distance epsilon for CCD algorithm.

NX_SOLVER_CONVERGENCE_THRESHOLD

Used to accelerate the solver.

NX_BBOX_NOISE_LEVEL

0.001 

Used to accelerate HW Broad Phase.

NX_IMPLICIT_SWEEP_CACHE_SIZE

5.0

Used to set the sweep cache size.

NX_DEFAULT_SLEEP_ENERGY

0.005

The default sleep energy threshold. Objects with an energy below this threshold are allowed to go to sleep. Note: Only used when the NX_BF_ENERGY_SLEEP_TEST flag is set.

 

 

 

NX_CONSTANT_FLUID_MAX_PACKETS

925

Constant for the maximum number of packets per fluid. Used to compute the fluid packet buffer size in NxFluidPacketData.

NX_CONSTANT_FLUID_MAX_PARTICLES_PER_STEP

4096

Constant for the maximum number of new fluid particles per frame.

 

 

 

NX_VISUALIZE_FORCE_FIELDS

0

Force field visualization.

 

 

 

NX_ASYNCHRONOUS_MESH_CREATION

0

[Experimental] Disables scene locks when creating/releasing meshes.

NX_FORCE_FIELD_CUSTOM_KERNEL_EPSILON

0.001

Epsilon for custom force field kernels.

NX_IMPROVED_SPRING_SOLVER

1

Enable/disable improved spring solver for joints and wheelshapes.

NX_PARAMS_NUM_VALUES

 

This is not a parameter, it just records the current number of parameters.

 

 

 

 

 

Parameter Ranges

  • rigid body transform一个坐标向量+一个旋转矩阵
  • position vector 一个坐标向量,可能是本地坐标或者是世界坐标
  • rotation matrix 旋转矩阵
  • unit quaternion – 4元数
  • direction/extents vector - 偏移量/方向向量。
  • force vector - Linear force vector. Forces are added to the momentum of a body; care should be taken to keep the momentum from growing too large.
  • torque vector - Torque vector. A torque is added to the angular momentum of a body; care should be taken to keep the angular momentum within a reasonable range.
  • velocity vector - Linear velocity vector. Consider the magnitude of the velocity when multiplied by the mass, i.e., a large velocity when applied to a body with a large mass will result in a very large momentum.
  • angular velocity vector - Angular velocity vector. Consider the magnitude of the angular velocity when multiplied by the inertia tensor, i.e., the angular momentum.
  • momentum vector - Linear momentum vector.
  • angular momentum vector - Angular momentum vector.

Utility Functions

2.3以前可以直接调用工具函数,但是之后必须通过调用NxGetUtilLib()创建一个工具库指针,通过该指针进行调用。

Prior 2.3: NxSetFPUPrecision24();

After 2.3 NxUtilLib* gUtiLib = NxGetUtilLib();         gUtiLib-> NxSetFPUPrecision24();

你可能感兴趣的:(vector,velocity,asynchronous,debugging,Shapes,Visualization)