关于AWAY3D的MESH、GEOMETRY的区别

Meshes and Geometry objects are closely related. Geometries provide the – you guessed it – geometry of a 3D object: the vertices, triangle indices, UV coordinates, vertex normals, and what have you. Mesh objects are there to give a Geometry a place in the scene graph (and as such, a position in 3D space), as well as link it to a material. Why bother with the distinction, you may wonder. Why not just place the geometry data inside the Mesh class and be done with it? In many cases, you’d want to use the same geometry in several places. Different monsters of the same type throughout a level, for instance. The Geometry object allows you to save memory and limit the amount of data that’s uploaded to the GPU.

Both Meshes and Geometry mirror each other in that they both contain “sub”-objects (SubMesh and SubGeometry, respectively). Each SubMesh object links to a corresponding SubGeometry object in the Mesh’s Geometry object. Each SubGeometry provides the vertex and triangle data for each part that will make up the entire object. Confused? Check the graph below. The reason for this subdivision is mainly so multiple materials can be used within a single Mesh. Because of how the GPU issues draw commands, materials cannot be assigned to individual triangles in the model. Instead, several SubGeometries are used, and each can be rendered with a different material. This is achieved by assigning a material to the corresponding SubMesh. SubMesh materials are optional; if not provided, the main Mesh object’s material is used for rendering. In other words, the SubMesh material propertyoverrides the Mesh material property for the corresponding SubGeometry.

Time for a practical example. A car Mesh can refer to a Geometry object containing a SubGeometry for the car body and one for the windows. This way, a metallic BitmapMaterial can be used for the car body, and a transparent ColorMaterial can be used for the windows, by assigning the materials to the SubMesh objects.

Meshes和Geometry对象关联很紧密,Geometries提供了一个几何学上的3D对象,包括顶点、三角形、UV坐标、顶点法线给你。MESH对象给与GEOMETRY显示在空间中的资格,同时赋予它材质。为什么要把这两者区分开来呢,为什么不在MESH里固定死特定的基本几何对象呢。你想在不同的地方使用相同的几何体,比如在一个平面上显示多个同种类型的怪物,Geometry帮助你节约内存,以及降低GPU运算的数据量。

Mesh和Geometry通过包含彼此的sub对象的方式互相映射对方(SubMesh和SubGeometry),在一个Mesh的Geometry中,每一个SubMesh对象关联对应的SubGeometry。每一个SubGeometry提供顶点和三角形数据用来拼装成一个对象的整体。迷惑吗?看看下面的类图吧。之所以这样设计的原因是可以在一个独立的MESH中使用复合材质(不同的材质)。因为GPU发出绘图指令时,材质是不能指定到模型中一个独立三角形中的。所以为了解决这个问题,SubGeometries被用到了,每一个SubGeometry可以被渲染不同的材质。这也是SubMesh的功劳,因为只有SubMesh才能为SubGeometry贴图。另外,SubMesh的材质是可选的,如果你没有指定它,那么,它默认使用主体Mesh的材质。

一辆车的Mesh对象关联一个Geometry对象,这个Geometry包含多个SubGeometry,比如这辆车的车身,或者车窗,那么车身就可以用BitmapMaterial材质,车窗可以用ColorMaterial材质。

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值