翻译的Mesh类

本文详细介绍了3D Mesh对象的概念及其实现方式,包括如何使用VertexBuffer和IndexBuffer定义多边形表面,以及如何通过Appearance控制渲染效果。还探讨了Mesh的构造方法、属性设置与获取等关键API。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Overview 

Package 

 Class 

Use 

Tree 

Deprecated 

Index 

Help 

Nov 19, 2003

 PREV CLASS   NEXT CLASS

FRAMES    NO FRAMES    

 

SUMMARY: NESTED | FIELD | CONSTR | METHOD

DETAIL: FIELD | CONSTR | METHOD

 

<hr size=2 width="100%" align=center>

javax.microedition.m 3g
Class Mesh


  
    
  
java.lang.Object
  |
  +--javax.microedition.m3g.Object3D
        |
        +--javax.microedition.m3g.Transformable
              |
              +--javax.microedition.m3g.Node
                    |
                    +--javax.microedition.m
    
     3g
    .Mesh

Direct Known Subclasses:

MorphingMesh, SkinnedMesh


public class Mesh

extends Node

A scene graph node that represents a 3D object defined as a polygonal surface.

一个场景节点,代表被定义为多边形表面的3D对象。

This class represents a conventional rigid body mesh, while the derived classes MorphingMesh and SkinnedMesh extend it with capabilities to transform vertices independently of each other. The structure of a basic Mesh is shown in the figure below.

这个类代表了传统的刚体Mesh,它的两个子类MorphingMeshSkinnedMesh扩展到具有独立地变换彼此顶点的能力。一个基本Mesh的结构如下图所示。

A Mesh is composed of one or more submeshes and their associated Appearances. A submesh is an array of triangle strips defined by an IndexBuffer object. The triangle strips are formed by indexing the vertex coordinates and other vertex attributes in an associated VertexBuffer. All submeshes in a Mesh share the same VertexBuffer. However, in the case of a MorphingMesh, a weighted linear combination of multiple VertexBuffers is used in place of a single VertexBuffer.

一个Mesh由数个submesh及其对应的Appearance组成。一个submesh也就是由IndexBuffer对象定义的三角形带的数组。这些三角形带是通过索引它们的顶点坐标系及其它顶点属性在与之相关的VertexBuffer里的顶点属性来形成的。在一个Mesh内所有的submesh都共用同一个VertexBuffer。但是,如果是MorphingMesh,则会使用一个有重量的多个VertexBuffer的线性融合来代替一个单独的VertexBuffer

Submeshes within a Mesh are rendered in the order of ascending Appearance layers, and such that opaque submeshes are rendered before transparent submeshes on the same layer. See the setLayer method in Appearance for more discussion on layered rendering.

Mesh内的submeshAppearance层中升序的方式渲染,并且同一层内不透明的submesh先于透明submesh渲染。查看AppearancesetLayer的方法来获取更多的关于层渲染得讨论。

Rendering and picking of a submesh is disabled if its Appearance is null.

如果submeshAppearance为空,则renderingpicking都是被禁用的。

Deferred exceptions

An exception is thrown if the VertexBuffer or any of the IndexBuffers are in an invalid state when rendering or picking; see the respective class descriptions for more information. Note that it would be useless to check for these exception cases at construction time, because the application may freely change the contents of a VertexBuffer or an Appearance at any time. However, null IndexBuffers and VertexBuffers are blocked at the constructor, as usual, because the application is not able to change them afterwards.

当进行render或者pick操作时,如果VertexBuffer或者任何一个IndexBuffer处于不可用的状态时,则会抛出一个异常;查看相应类描述文档以获取更多信息。注意,在构造期间去检查这些异常也是没有作用的,因为在任何时间,程序都有可能任意地去修改VertexBuffer或者Appearance的内容。但是,在构造期间,同时为nullIndexBufferVertexBuffer是不可以的,因为这样一来就没法构造submesh,程序也就没法去改变它们了。

See Also:

Binary format, VertexBuffer, IndexBuffer


Field Summary

 

Fields inherited from class javax.microedition.m 3g .Node

NONE, ORIGIN, X_AXIS, Y_AXIS, Z_AXIS

 

Constructor Summary

Mesh(VertexBuffer vertices, IndexBuffer[] submeshes, Appearance[] appearances)

使用给定的VertexBuffersubmesh来构造一个新的Mesh
          Constructs a new Mesh with the given VertexBuffer and submeshes.

 

Mesh(VertexBuffer vertices, IndexBuffer submesh, Appearance appearance)

构造一个只有一个submeshMesh
          Constructs a new Mesh consisting of only one submesh.

 

 

Method Summary

 Appearance

getAppearance(int index)

获得指定submesh的当前Appearance
          Gets the current Appearance of the specified submesh.

 IndexBuffer

getIndexBuffer(int index)

返回指定indexsubmesh
          Retrieves the submesh at the given index.

 int

getSubmeshCount()

获得该Mesh内的submesh的个数
          Gets the number of submeshes in this Mesh.

 VertexBuffer

getVertexBuffer()

获得该MeshvertexBuffer
          Gets the vertex buffer of this Mesh.

 void

setAppearance(int index, Appearance appearance)

为指定的submesh设置Appearance
          Sets the Appearance for the specified submesh.

 

Methods inherited from class javax.microedition.m 3g .Node

align, getAlphaFactor, getParent, getScope, getTransformTo, isPickingEnabled, isRenderingEnabled, setAlignment, setAlphaFactor, setPickingEnable, setRenderingEnable, setScope

 

Methods inherited from class javax.microedition.m 3g .Transformable

getCompositeTransform, getOrientation, getScale, getTransform, getTranslation, postRotate, preRotate, scale, setOrientation, setScale, setTransform, setTranslation, translate

 

Methods inherited from class javax.microedition.m 3g .Object3D

addAnimationTrack, animate, duplicate, find, getAnimationTrack, getAnimationTrackCount, getReferences, getUserID, getUserObject, removeAnimationTrack, setUserID, setUserObject

 

Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Constructor Detail

Mesh


  
    
  
public Mesh(VertexBuffer vertices,
            IndexBuffer submesh,
            Appearance appearance)

Constructs a new Mesh consisting of only one submesh. Rendering and picking of the Mesh is initially disabled if the Appearance is set to null.

构造一个只有一个submeshMesh。如果Appearance设置为null, 那么对这个Meshrenderpick操作就会被初始成为禁用的。

Parameters:

vertices - a VertexBuffer to use for this mesh 这个mesh使用的VertexBuffer

submesh - an IndexBuffer defining the triangle strips to draw 定义了要去画的三角形带的IndexBuffer

appearance - an Appearance to use for this mesh, or null 这个mesh要用的Appearance,或者为null

Throws:

java.lang.NullPointerException - if vertices is null

java.lang.NullPointerException - if submesh is null


Mesh


  
    
  
public Mesh(VertexBuffer vertices,
            IndexBuffer[] submeshes,
            Appearance[] appearances)

Constructs a new Mesh with the given VertexBuffer and submeshes. The number of submeshes is set equal to the length of the submeshes array. The appearances array is parallel to that, and must have at least as many elements. A null Appearance disables rendering and picking of the corresponding submesh. If the array itself is null, all appearances are initialized to null.

使用给定的VertexBuffersubmesh构造一个新的Mesh。总的submesh的数目等于传入的submeshes数组的长度。传入的appearances数组也类似,并且至少要有同样多的元素个数。一个nullAppearance就是禁用了对应submeshrenderpick操作。如果appearances数组为null,那么所有appearance都会被初始化为null

Parameters:

vertices - a VertexBuffer to use for all submeshes in this mesh 被该Mesh内所有submesh公用的VertexBuffer

submeshes - an IndexBuffer array defining the submeshes to draw定义了要去画的三角形带的IndexBuffer

appearances - an Appearance array parallel to submeshes submeshes相同的Appearance数组

Throws:

java.lang.NullPointerException - if vertices is null

java.lang.NullPointerException - if submeshes is null

java.lang.NullPointerException - if any element in submeshes is null

java.lang.IllegalArgumentException - if submeshes is empty

java.lang.IllegalArgumentException - if appearances.length < submeshes.length

Method Detail

setAppearance


  
    
  
public void setAppearance(int index,
                          Appearance appearance)

Sets the Appearance for the specified submesh.

为指定submesh设置Appearance

Parameters:

index - index of the submesh to set the Appearance of 要设置Appearancesubmesh的序号

appearance - Appearance to set for the submesh at index, or null to disable the submesh 为序号为indexsubmesh设置的Appearance,如果为null,则是禁用此submesh

Throws:

java.lang.IndexOutOfBoundsException - if (index < 0) || (index >= getSubmeshCount)

See Also:

getAppearance


getAppearance


  
    
  
public Appearance getAppearance(int index)

Gets the current Appearance of the specified submesh.

获得指定submesh的当前Appearance

Parameters:

index - index of the submesh to get the Appearance of –要获得Appearancesubmesh的序号

Returns:

current Appearance of the submesh at index 序号为indexsubmesh的当前Appearance

Throws:

java.lang.IndexOutOfBoundsException - if (index < 0) || (index >= getSubmeshCount)

See Also:

setAppearance


getIndexBuffer


  
    
  
public IndexBuffer getIndexBuffer(int index)

Retrieves the submesh at the given index.

返回指定序号的submesh

Parameters:

index - index of the submesh to get 要获得的submesh的序号

Returns:

current IndexBuffer at index  序号为index的当前IndexBuffer

Throws:

java.lang.IndexOutOfBoundsException - if (index < 0) || (index >= getSubmeshCount)


getVertexBuffer


  
    
  
public VertexBuffer getVertexBuffer()

Gets the vertex buffer of this Mesh. This is always the original VertexBuffer that was supplied at construction. The VertexBuffer is never written to by the implementation. Specifically, the results of morphing (MorphingMesh) and skinning (SkinnedMesh) are not written to the VertexBuffer, nor are they exposed to the application by any other means.

获得这个Mesh中的VertexBuffer。这通常就是在构造时生成的那个原始VertexBuffer。在这个规范的实现里面,VertexBuffer是永远不会被改写的。需要特别指出的是,MorphingMeshmorphing结果和SkinnedMeshskinning结果既不会写入到VertexBuffer,它们无论如何也不会直接暴露给应用程序的。

In the case of a MorphingMesh, this VertexBuffer represents the base mesh. The morph target VertexBuffers can be retrieved with the getMorphTarget method in MorphingMesh.

如果是MorphingMesh,这里的VertexBuffer指得是那个基本的Mesh。而morph目标的VertexBuffer可以通过调用MorphingMesh中的getMorphTarget方法来获得。

Returns:

the (base) VertexBuffer of this Mesh Mesh中的(基本)VertexBuffer


getSubmeshCount


  
    
  
public int getSubmeshCount()

Gets the number of submeshes in this Mesh. This is always at least 1.

获得这个Meshsubmesh的个数。至少为1

Returns:

the number of submeshes in this Mesh Meshsubmesh的个数

<hr size=2 width="100%" align=center>

Overview 

Package 

 Class 

Use 

Tree 

Deprecated 

Index 

Help 

Nov 19, 2003

 PREV CLASS   NEXT CLASS

FRAMES    NO FRAMES    

 

SUMMARY: NESTED | FIELD | CONSTR | METHOD

DETAIL: FIELD | CONSTR | METHOD

 

<hr size=2 width="100%" align=center>

Copyright © 2003 Nokia Corporation. See the Copyright Notice for details.

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值