当前位置: 首页 > news >正文

做愛偷拍视频网站站长号

做愛偷拍视频网站,站长号,沈阳个人建站模板,广州市建设集团网站首页使用Python USD API 来实现 Physics 。 以下内容中,大部分 Python 代码可以在 Physics Python 演示脚本文件中找到,本文仅作为个人学习笔记。 一.设置 USD Stage 和物理场景 Setting up a USD Stage and a Physics Scene USD Stage不知道怎么翻译&#…

使用Python USD API 来实现 Physics 。

以下内容中,大部分 Python 代码可以在 Physics Python 演示脚本文件中找到,本文仅作为个人学习笔记。

一.设置 USD Stage 和物理场景

        Setting up a USD Stage and a Physics Scene

        USD Stage不知道怎么翻译,就是放置USD文件的地方,Isaac Sim软件和官方文档全英文,就算翻译了官方文档回去使用软件也全是英文...英语菜狗,啃的累死我了...

from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf# Set up a USD Stage to define what is the up axis and set up the units,
# which is crucial, as some default simulation parameters are derived
# from the MetersPerUnit value
# 单位0.01m
stage = omni.usd.get_context().get_stage()
UsdGeom.SetStageUpAxis(stage, UsdGeom.Tokens.z)
UsdGeom.SetStageMetersPerUnit(stage, 0.01)# Physics scene definition
scene = UsdPhysics.Scene.Define(stage, "/physicsScene")# setup gravity
# note that gravity has to respect the selected units, if we are using cm, the gravity has to respect that
# 重力方向,下;重力大小,9.81m/s^2
scene.CreateGravityDirectionAttr().Set(Gf.Vec3f(0.0, 0.0, -1.0))
scene.CreateGravityMagnitudeAttr().Set(981.0)

二.创建碰撞体

        Creating Colliders 

# Cube path
cubeActorPath = "/cubeActor"# Cube parameters like size, position, orientation
# 这个500测试发现实在太高了,第一次做的时候转一圈都没找到Cube,自己用设置10,50之类的就行
size = 25.0
position = Gf.Vec3f(0.0, 0.0, 500.0)
orientation = Gf.Quatf(1.0)
color = Gf.Vec3f(71.0 / 255.0, 105.0 / 255.0, 1.0)# define the cube geom(几何)
cubeGeom = UsdGeom.Cube.Define(stage, cubeActorPath)
cubeGeom.CreateSizeAttr(size)
cubeGeom.AddTranslateOp().Set(position)
cubeGeom.AddOrientOp().Set(orientation)
cubeGeom.AddScaleOp().Set(Gf.Vec3f(1.0))
cubeGeom.CreateDisplayColorAttr().Set([color])# get the prim
cubePrim = stage.GetPrimAtPath(cubeActorPath)# setup collision, so that the cube does collider
UsdPhysics.CollisionAPI.Apply(cubePrim)

三.不同的碰撞体和渲染表现 

        Different Collision and Rendering Representations 

        必须创建两个不同的几何体,其中一个用于碰撞,另一个用于渲染(这里也可以理解为展示,一个作为碰撞箱隐藏,一个可以观察)。两个几何体的父 xform 应该设置为刚体,使它们能够一起移动。

# Top level actor, contains rigid body
rigidCompoundPath = "/compoundRigid"
rigidXform = UsdGeom.Xform.Define(stage, rigidCompoundPath)
rigidPrim = stage.GetPrimAtPath(rigidCompoundPath)# Rigid body transform
rigidCompoundPos = Gf.Vec3f(0.0, 0.0, 10.0)
rigidXform.AddTranslateOp().Set(rigidCompoundPos)
rigidXform.AddOrientOp().Set(Gf.Quatf(1.0, 0.0, 0.0, 0.0))physicsAPI = UsdPhysics.RigidBodyAPI.Apply(rigidPrim)# Collision shape
collisionShape = rigidCompoundPath + "/physicsBoxShape"size = 25.0
shapePos = Gf.Vec3f(0.0)
shapeQuat = Gf.Quatf(1.0)cubeGeom = UsdGeom.Cube.Define(stage, collisionShape)
cubePrim = stage.GetPrimAtPath(collisionShape)
cubeGeom.CreateSizeAttr(size)
cubeGeom.AddTranslateOp().Set(shapePos)
cubeGeom.AddOrientOp().Set(shapeQuat)# set it as collision
UsdPhysics.CollisionAPI.Apply(cubePrim)# hide it from rendering
cubeGeom.CreatePurposeAttr(UsdGeom.Tokens.guide)# rendering shape
renderSphere = rigidCompoundPath + "/renderingSphere"sphereGeom = UsdGeom.Sphere.Define(stage, renderSphere)
#sphereGeom.CreateSizeAttr(20.0)
sphereGeom.AddTranslateOp().Set(shapePos)
sphereGeom.AddOrientOp().Set(shapeQuat)

四.物理材料 

        Physics Materials

        每个碰撞器都可以分配不同的物理材料。UsdPhysicsMaterialAPI 可以应用于任何其他材料,并且此 API 添加了物理材料属性,如静态/动态摩擦。要将材料分配给碰撞器,请使用具有“物理”目的的材料绑定。

# define physics material
materialPath = "/material"
mu = 1.0
UsdShade.Material.Define(stage, materialPath)
material = UsdPhysics.MaterialAPI.Apply(stage.GetPrimAtPath(materialPath))
material.CreateStaticFrictionAttr().Set(mu)
material.CreateDynamicFrictionAttr().Set(mu)
material.CreateRestitutionAttr().Set(0.0)
material.CreateDensityAttr().Set(1000.0)collisionAPI = UsdPhysics.CollisionAPI.Get(stage, collisionShape)# add the material to the collider
bindingAPI = UsdShade.MaterialBindingAPI.Apply(collisionAPI.GetPrim())
materialPrim = material.GetPrim()
material = UsdShade.Material(materialPrim)
bindingAPI.Bind(material, UsdShade.Tokens.weakerThanDescendants, "physics")

五.使用凸网格进行圆柱和圆锥碰撞

        Using Convex Mesh for Cylinder and Cone Collision

        UsdGeom.Cylinder 和 UsdGeom.Cone prims 的碰撞默认近似为自定义几何体,以获得更高的精度。但是,您可以通过在碰撞部分下的物理设置中禁用相应的切换来将它们设置为使用凸网格。

        注意:您还可以使用 Omniverse Create 内置的圆锥和圆柱网格几何体进行凸近似。这允许您细粒度控制是否应使用凸近似或自定义几何体碰撞器模拟单个几何体。

        原文:

        UsdGeom.Cylinder and UsdGeom.Cone prims’ collision is by default approximated as custom geometry for higher precision. However, you can set them to use convex mesh instead by disabling the corresponding toggles in the Physics settings under the collision section.

        Note: you can also use the Omniverse Create built-in cone and cylinder mesh geometries for convex approximation. This allows you to fine grain control whether individual geometry should be simulated with a convex approximation or custom geometry collider.

        我想应该可以对单个物体模块进行精细修改...还没试呢,晚上找个时间弄弄看。

六.刚体

         Rigid Bodies

        刚体在 Physics 架构中表示为应用于 xformable Prim 的 UsdPhysicsRigidBodyAPI 架构。

# Cube path
cubeActorPath = "/cubeActorRigid"# Cube parameters like size, position, orientation
size = 25.0
position = Gf.Vec3f(0.0, 0.0, 500.0)
orientation = Gf.Quatf(1.0)
color = Gf.Vec3f(71.0 / 255.0, 105.0 / 255.0, 1.0)# initial velocities
linVelocity = Gf.Vec3f(2.0, 1.0, 2.0)
angularVelocity = Gf.Vec3f(1.0, 0.0, 0.0)# define the cube geom
cubeGeom = UsdGeom.Cube.Define(stage, cubeActorPath)
cubeGeom.CreateSizeAttr(size)
cubeGeom.AddTranslateOp().Set(position)
cubeGeom.AddOrientOp().Set(orientation)
cubeGeom.AddScaleOp().Set(Gf.Vec3f(1.0))
cubeGeom.CreateDisplayColorAttr().Set([color])# get the prim
cubePrim = stage.GetPrimAtPath(cubeActorPath)# setup collision, so that the cube does collider
UsdPhysics.CollisionAPI.Apply(cubePrim)# setup physics - rigid body
rigidBodyAPI = UsdPhysics.RigidBodyAPI.Apply(cubePrim)# apply initial velocities
rigidBodyAPI.CreateVelocityAttr().Set(linVelocity)
rigidBodyAPI.CreateAngularVelocityAttr().Set(angularVelocity)

在仿真过程中,如果要更改刚体的线速度,则必须更改 UsdPhysicsRigidBodyAPI 的速度属性:

rigidBodyAPI.CreateVelocityAttr().Set(newVelocity)

6.1 刚体质量属性

        Rigid Body Mass Properties

        UsdPhysicsMassAPI 定义了刚体的质量属性。UsdPhysicsMassAPI 可以应用于具有 UsdPhysicsRigidBodyAPI 或 USdPhysicsCollisionAPI 的 Prim。它提供了多种定义刚体质量属性的方法:

        physics:mass:质量属性。注意,任何子 Prim 在应用 UsdPhysicsMassAPI 时也可以具有质量属性。在这种情况下,优先规则是“父级质量属性覆盖子级的质量属性”。这可能有些反直觉,因为质量是一个计算得到的量,通常不是累积的。例如,如果父级的质量为 10,而两个子级中的一个质量为 20,允许子级的质量覆盖父级的质量将导致另一个子级的质量为 -10。

        physics:density:密度属性。在刚体物理学的背景下,密度间接地通过公式(质量 = 密度 × 对象的体积)来设置质量。在同时指定密度和质量的情况下,质量具有优先权。与质量不同,子级 Prim 的密度将覆盖父级 Prim 的密度。注意,collisionAPI 的密度也可以通过 physicsMaterial 关系来设置。材料密度在密度定义中具有最弱的优先级。注意,密度遵循单位。因此,对于单位为 1 的水密度为 1000,对于单位为 0.01,水密度为 0.001。

        physics:centerOfMass:Prim 本地空间中的质心。

        physics:diagonalInertia:未旋转状态下对角化惯性张量。

        physics:principalAxes:惯性张量主轴的方向(四元数表示),在 Prim 的本地空间中。

        解析代码会收集每个碰撞形状的质量属性,并使用计算出的惯性张量来计算体的最终质量属性。如果未找到任何 massAPI,则使用默认密度 1000 来确定最终的质量。

# Cube path
cubeActorPath = "/cubeActorRigidMass"# Cube parameters like size, position, orientation
size = 25.0
position = Gf.Vec3f(0.0, 0.0, 500.0)
orientation = Gf.Quatf(1.0)
color = Gf.Vec3f(71.0 / 255.0, 105.0 / 255.0, 1.0)# define the cube geom
cubeGeom = UsdGeom.Cube.Define(stage, cubeActorPath)
cubeGeom.CreateSizeAttr(size)
cubeGeom.AddTranslateOp().Set(position)
cubeGeom.AddOrientOp().Set(orientation)
cubeGeom.AddScaleOp().Set(Gf.Vec3f(1.0))
cubeGeom.CreateDisplayColorAttr().Set([color])# get the prim
cubePrim = stage.GetPrimAtPath(cubeActorPath)# setup collision, so that the cube does collider
UsdPhysics.CollisionAPI.Apply(cubePrim)# setup physics - rigid body, so that cube does simulate as a rigid body
UsdPhysics.RigidBodyAPI.Apply(cubePrim)# custom center of mass
massAPI = UsdPhysics.MassAPI.Apply(cubePrim)
massAPI.CreateCenterOfMassAttr().Set(Gf.Vec3f(0.0, 0.0, 10.0))

七.静态体和动态体的区别

        Difference Between a Static Body and a Dynamic Body

        如果找到具有 UsdPhysicsCollisionAPI 的 Geom Prim,则它可以属于静态实体或动态实体。决定的逻辑是这样的:

  • 如果层次结构中的 prim 或任何父 Prim 上没有应用 UsdPhysicsRigidBodyAPI,则具有 UsdPhysicsCollisionAPI 的几何体将被视为静态实体。

  • 还:

    1. 如果 physics:rigidBodyEnabled 属性为 true(默认值),则几何属于动态实体。

    2. 否则,Geom 属于静态实体。

八.运动体

        Kinematic Body

        如果需要通过动画或用户定义的目标位置来驱动身体,则应将 UsdPhysicsRigidBodyAPI 上的 physics:kinematicEnabled 属性设置为 true。

九.CPU 与 GPU 刚体动力学

        CPU vs GPU Rigid Body Dynamics

        默认情况下,在 GPU 上执行刚体仿真。可以在 Physics Debug 窗口中或使用场景属性覆盖管道。 为了使用 CPU 仿真,请在 UsdPhysicsScene prim 中添加一个 PhysxSceneAPI 并设置以下属性:

  • physxScene:broadphaseType - MBP

  • physxScene:enableGPUDynamics - 错误

对于 GPU 模拟,第一个设置为 GPU,第二个设置为 True。

http://www.dinnco.com/news/19462.html

相关文章:

  • 深圳网站建设ue深圳百度seo怎么做
  • 公司做网站花销会计分录独立站优化
  • 佛山网站建设佛山网络推广什么是百度竞价排名
  • php怎么做直播网站百度网站推广电话
  • 如何做自己的网站广告公司是做什么的
  • 网站总体设计怎么写成都网多多
  • 公司网站开发费能记研发费用哪个科目百度搜索竞价
  • 重庆网站建设 优化济南网站优化公司排名
  • 如何实现一个制作好的网站深圳外贸网络推广
  • 网站建设 前沿文章谷歌应用商店下载
  • 四大门户网站流量对比深圳seo培训
  • 做网站的账务处理永久免费个人网站注册
  • 福建省建设局网站实名制搜索引擎seo如何赚钱
  • 焦作网站建设哪家正规cfa三级和一二级关系大吗
  • 网站建设包括哪几个方面网站推广怎么做
  • 学校网站源码百度首页关键词优化
  • 劳动服务公司网站源码广州百度推广客服电话
  • 叫人做网站要注意广州网站优化公司如何
  • 专线怎么做网站服务器facebook海外推广
  • 电商详情页模板台州seo
  • 手机网站二级域名接推广app任务的平台
  • web制作网站个人永久免费自助建站
  • 做网站不备案深圳网络营销推广外包
  • 股票交易网站建设惠州seo管理
  • 舆情网站设计优化大师兑换码
  • 给我推荐一个网站b站免费建网站
  • 网站支付链接怎么做的深圳网络推广公司
  • 巴州建设局网站排名优化软件点击
  • wordpress多站点注册页郑州优化公司有哪些
  • 企业网站的类型包括军事新闻 今日关注