【physX】physX 5.1的笔记1:初识

5.1的笔记
所有内容参考自官方文档
https://nvidia-omniverse.github.io/PhysX/physx/5.1.0/index.html#

所有的demo示例都被称为Snippet。源码可以在physx/snippets目录中找到。

每个都是一个完整的可执行目标。

Hello world

physx\snippets\snippethelloworld\SnippetHelloWorld.cpp
目录下是Hello World程序。是刚体的一个模拟程序。官方推荐从这里看起。

一般流程:

首先要:

  1. 使用PxCreateFoundation()函数创建一个 gFoundation对象,这个对象是管理内存和错误回调的单例。
  2. 使用 PxCreatePhysics() 函数创建一个gPhysics对象,这个对象也是单例,用来设置tolerance和PVD(physX visualization debugger)等。用户还可以改用PxCreateBasePhysics()来替代PxCreatePhysics() ,从而关闭不需要的功能模块。

所有的程序都需要这两个全局单例对象。我们来看一个例子
位于physx\snippets\snippethelloworld\SnippetHelloWorld.cpp 的第81行

在这里插入图片描述
这里我们已经提到了

  1. gFoundation用来管理内存和报错
  2. gPvd用来管理可视化调试器(visualization debugger)
  3. gPhysics设置容差和选择使用的功能模块等。
  4. gScene是场景对象。(下面会细说)
  5. gMaterial是材质对象。
  6. 最后addActor()创建了一个actor对象。(下面会细说)

这里面最重要的两个对象:场景对象和actor对象。

这两个概念在文档中如下描述:

The basic concepts of the world within a PhysX simulation are easy to
describe: The PhysX world comprises a collection of Scenes, each
containing objects called Actors;

  • Each Scene defines its own reference frame encompassing all of space
    and time;

  • Actors in different Scenes do not interact with each other;

  • Characters and vehicles are complex specialized objects made from
    Actors;

  • Actors have physical state : position and orientation; velocity or
    momentum; energy; etc,

  • Actor physical state may evolve over time due to applied forces,
    constraints such as joints or contacts, and interactions between
    Actors.

也就是说 physx之中有许多场景(类似关卡)。每个场景互不影响。每个场景中有许多actor。每个actor具有物理属性(速度、位置、姿态、能量等)。这个actor就是我们要真正实现模拟的对象。一个复杂的对象(比如一辆车)可以由多个actor所组成。

stepPhysics

在stepPhysics当中进行模拟。注意最重要 的是gScene->simulate(dt)
在这里插入图片描述

最后的gScene->fetchResults 也十分关键。它是用来传回结果的。在physX当中,所有的仿真都默认是异步的。因此,你模拟完了之后,要有一个传回仿真结果的操作。

PBD

目前PBD还不是很完整,只有四个demo。在physX当中,他们被称为ParticleSystem。

PBD模块的demo位于
physx\snippets\snippetpbdcloth
physx\snippets\snippetpbdinflatable
physx\snippets\snippetpbf
physx\snippets\snippetpbfmultimat

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值