TriMesh
Inheritance: java.lang.Object, com.aspose.threed.A3DObject, com.aspose.threed.SceneObject, com.aspose.threed.Entity
All Implemented Interfaces: java.lang.Iterable
public class TriMesh extends Entity implements Iterable<Vertex>
TriMesh は GPU が直接使用できる生データを含みます。このクラスは、頂点ごとのデータのみを含むメッシュを構築するためのユーティリティです。 Example: 次のコードは、カスタムメモリレイアウトの TriMesh を作成し、ファイルにエクスポートする方法を示しています。
//Define a vertex declaration as {FVector3 Position; FVector3 Normal; FVector2 UV}
VertexDeclaration vd = new VertexDeclaration();
vd.addField(VertexFieldDataType.F_VECTOR3, VertexFieldSemantic.POSITION);
vd.addField(VertexFieldDataType.F_VECTOR3, VertexFieldSemantic.NORMAL);
vd.addField(VertexFieldDataType.F_VECTOR2, VertexFieldSemantic.UV);
//convert a mesh to tri-mesh using specified memory layout
var mesh = (new Sphere()).toMesh();
var triMesh = TriMesh.fromMesh(vd, mesh);
//save it to a stream, 115 vertices * 32bytes per vertex
try(var s = new FileOutputStream("output.bin")) {
triMesh.writeVerticesTo(s);
//save indices as ushort to stream, 504 indices * 2 bytes per index
triMesh.write16bIndicesTo(s);
}
コンストラクタ
| コンストラクタ | 説明 |
|---|---|
| TriMesh(String name, VertexDeclaration declaration) | TriMesh のインスタンスを初期化する |
メソッド
TriMesh(String name, VertexDeclaration declaration)
public TriMesh(String name, VertexDeclaration declaration)
TriMesh のインスタンスを初期化する
Parameters:
| パラメーター | 型 | 説明 |
|---|---|---|
| 名前 | java.lang.String | この TriMesh の名前 |
| declaration | VertexDeclaration | 頂点の宣言 |
addTriangle(int a, int b, int c)
public void addTriangle(int a, int b, int c)
新しい三角形を追加する
Parameters:
| パラメーター | 型 | 説明 |
|---|---|---|
| a | int | 最初の頂点のインデックス |
| b | int | 2 番目の頂点のインデックス |
| c | int | 3 番目の頂点のインデックス |
beginVertex()
public Vertex beginVertex()
頂点の追加を開始する
Returns: Vertex - The reference of internal vertex object in type Vertex
copyFrom(TriMesh input, VertexDeclaration vd)
public static TriMesh copyFrom(TriMesh input, VertexDeclaration vd)
入力から新しい頂点レイアウトで TriMesh をコピーする
Parameters:
| パラメーター | 型 | 説明 |
|---|---|---|
| input | TriMesh | コピー用の入力 TriMesh |
| vd | VertexDeclaration | 出力 TriMesh の新しい頂点宣言 |
Returns: TriMesh - A new TriMesh instance with new vertex declaration. Example:
//Define a vertex declaration as {FVector3 Position; FVector3 Normal; FVector2 UV}
VertexDeclaration vd = new VertexDeclaration();
vd.addField(VertexFieldDataType.F_VECTOR3, VertexFieldSemantic.POSITION);
vd.addField(VertexFieldDataType.F_VECTOR3, VertexFieldSemantic.NORMAL);
vd.addField(VertexFieldDataType.F_VECTOR2, VertexFieldSemantic.UV);
//convert a mesh to TriMesh, the layout is automatically inferred from input mesh
var oldTriMesh = TriMesh.fromMesh((new Sphere()).toMesh());
//now create a new TriMesh from old TriMesh, using explicit memory layout defined by vd
var newTriMesh = TriMesh.copyFrom(oldTriMesh, vd);
endVertex()
public int endVertex()
頂点の追加を終了する
Returns: int
equals(Object arg0)
public boolean equals(Object arg0)
Parameters:
| パラメーター | 型 | 説明 |
|---|---|---|
| arg0 | java.lang.Object |
Returns: boolean
findProperty(String propertyName)
public Property findProperty(String propertyName)
プロパティを検索します。動的プロパティ(CreateDynamicProperty/SetProperty により作成)またはネイティブプロパティ(名前で識別)になる可能性があります。
Parameters:
| パラメーター | 型 | 説明 |
|---|---|---|
| propertyName | java.lang.String | プロパティ名。 |
Returns: Property - The property.
fromMesh(Mesh mesh)
public static TriMesh fromMesh(Mesh mesh)
指定されたメッシュオブジェクトから TriMesh を作成します。頂点宣言は入力メッシュの構造に基づきます。
Parameters:
| パラメーター | 型 | 説明 |
|---|---|---|
| mesh | Mesh |
Returns: TriMesh - The TriMesh generated from given Mesh Example: The following code shows how to create a TriMesh with custom memory layout, and export it to file.
//Define a vertex declaration as {FVector3 Position; FVector3 Normal; FVector2 UV}
VertexDeclaration vd = new VertexDeclaration();
vd.addField(VertexFieldDataType.F_VECTOR3, VertexFieldSemantic.POSITION);
vd.addField(VertexFieldDataType.F_VECTOR3, VertexFieldSemantic.NORMAL);
vd.addField(VertexFieldDataType.F_VECTOR2, VertexFieldSemantic.UV);
//convert a mesh to tri-mesh using specified memory layout
var mesh = (new Sphere()).toMesh();
var triMesh = TriMesh.fromMesh(vd, mesh);
//save it to a stream, 115 vertices * 32bytes per vertex
try(var s = new FileOutputStream("output.bin")) {
triMesh.writeVerticesTo(s);
//save indices as ushort to stream, 504 indices * 2 bytes per index
triMesh.write16bIndicesTo(s);
}
fromMesh(Mesh mesh, boolean useFloat)
public static TriMesh fromMesh(Mesh mesh, boolean useFloat)
指定されたメッシュオブジェクトから TriMesh を作成します。頂点宣言は入力メッシュの構造に基づきます。
Parameters:
| パラメーター | 型 | 説明 |
|---|---|---|
| mesh | Mesh | |
| useFloat | boolean | 各頂点要素コンポーネントに対して、double 型の代わりに float 型を使用します。 |
Returns: TriMesh - The TriMesh generated from given Mesh Example: The following code shows how to create a TriMesh with custom memory layout, and export it to file.
//Define a vertex declaration as {FVector3 Position; FVector3 Normal; FVector2 UV}
VertexDeclaration vd = new VertexDeclaration();
vd.addField(VertexFieldDataType.F_VECTOR3, VertexFieldSemantic.POSITION);
vd.addField(VertexFieldDataType.F_VECTOR3, VertexFieldSemantic.NORMAL);
vd.addField(VertexFieldDataType.F_VECTOR2, VertexFieldSemantic.UV);
//convert a mesh to tri-mesh using specified memory layout
var mesh = (new Sphere()).toMesh();
var triMesh = TriMesh.fromMesh(vd, mesh);
//save it to a stream, 115 vertices * 32bytes per vertex
try(var s = new FileOutputStream("output.bin")) {
triMesh.writeVerticesTo(s);
//save indices as ushort to stream, 504 indices * 2 bytes per index
triMesh.write16bIndicesTo(s);
}
fromMesh(VertexDeclaration declaration, Mesh mesh)
public static TriMesh fromMesh(VertexDeclaration declaration, Mesh mesh)
指定された頂点レイアウトを使用して、指定されたメッシュオブジェクトから TriMesh を作成する。
Parameters:
| パラメーター | 型 | 説明 |
|---|---|---|
| declaration | VertexDeclaration | 頂点の型定義、またはメモリレイアウト |
| mesh | Mesh | ソースメッシュ |
Returns: TriMesh - Instance of TriMesh converted from input mesh with specified vertex’s memory layout Example: The following code shows how to create a TriMesh with custom memory layout, and export it to file.
//Define a vertex declaration as {FVector3 Position; FVector3 Normal; FVector2 UV}
VertexDeclaration vd = new VertexDeclaration();
vd.addField(VertexFieldDataType.F_VECTOR3, VertexFieldSemantic.POSITION);
vd.addField(VertexFieldDataType.F_VECTOR3, VertexFieldSemantic.NORMAL);
vd.addField(VertexFieldDataType.F_VECTOR2, VertexFieldSemantic.UV);
//convert a mesh to tri-mesh using specified memory layout
var mesh = (new Sphere()).toMesh();
var triMesh = TriMesh.fromMesh(vd, mesh);
//save it to a stream, 115 vertices * 32bytes per vertex
try(var s = new FileOutputStream("output.bin")) {
triMesh.writeVerticesTo(s);
//save indices as ushort to stream, 504 indices * 2 bytes per index
triMesh.write16bIndicesTo(s);
}
fromRawData(VertexDeclaration vd, byte[] vertices, int[] indices, boolean generateVertexMapping)
public static TriMesh fromRawData(VertexDeclaration vd, byte[] vertices, int[] indices, boolean generateVertexMapping)
生データから TriMesh を作成する
Parameters:
| パラメーター | 型 | 説明 |
|---|---|---|
| vd | VertexDeclaration | 頂点宣言は、少なくとも 1 つのフィールドを含む必要があります。 |
| vertices | byte[] | 入力頂点データ、頂点の最小長さは頂点宣言のサイズ以上である必要があります |
| インデックス | int[] | 三角形インデックス |
| generateVertexMapping | boolean | 各頂点に対して Vertex を生成しますが、シリアライズ/デシリアライズだけの場合は必要ありません。 |
Returns: TriMesh - The TriMesh instance that encapsulated the input byte array. Remarks: The returned TriMesh will not copy the input byte array for performance, external changes on the array will be reflected to this instance. Example: The following code shows how to construct a TriMesh from raw bytes, this is useful when build your own 3D format
var indices = new int[] { 0, 1, 2 };
var vertices = new byte[]{
0, 0, 0, 191,
0, 0, 0, 0,
0, 0, 0, 191,
0, 0, 0, 191,
0, 0, 0, 0,
0, 0, 0, 63,
0, 0, 0, 63,
0, 0, 0, 0The string representation,
0, 0, 0, 63
};
VertexDeclaration vd = new VertexDeclaration();
vd.AddField(VertexFieldDataType.FVector3, VertexFieldSemantic.Position);
var triMesh = TriMesh.FromRawData(vd, vertices, indices, true);
getBoundingBox()
public BoundingBox getBoundingBox()
現在のエンティティのオブジェクト空間座標系におけるバウンディングボックスを取得します。
Returns: BoundingBox - the bounding box of current entity in its object space coordinate system. Example: The following code shows how to calculate the bounding box of a shape
Entity entity = new Sphere();
entity.setRadius(10);
var bbox = entity.getBoundingBox();
System.out.printf("The bounding box of the entity is %s ~ %s", bbox.getMinimum(), bbox.getMaximum());
getCapacity()
public int getCapacity()
事前割り当てされた頂点の容量。
Returns: int - 事前割り当てされた頂点の容量
getClass()
public final native Class<?> getClass()
Returns: java.lang.Class
getEntityRendererKey()
public EntityRendererKey getEntityRendererKey()
レンダラーに登録されたエンティティレンダラーのキーを取得します
Returns: EntityRendererKey - the key of the entity renderer registered in the renderer
getExcluded()
public boolean getExcluded()
エクスポート時にこのエンティティを除外するかどうかを取得します。
Returns: boolean - エクスポート時にこのエンティティを除外するかどうか。
getIndicesCount()
public int getIndicesCount()
この TriMesh のインデックス数。
Returns: int - この TriMesh のインデックス数
getIntIndices()
public int[] getIntIndices()
インデックスを 32 ビット整数配列に変換する
Returns: int[]
getName()
public String getName()
名前を取得します。
Returns: java.lang.String - 名前です。
getParentNode()
public Node getParentNode()
最初の親ノードを取得します。最初の親ノードを設定すると、このエンティティは他の親ノードから切り離されます。
Returns: Node - the first parent node, if set the first parent node, this entity will be detached from other parent nodes.
getParentNodes()
public ArrayList<Node> getParentNodes()
すべての親ノードを取得します。エンティティはジオメトリインスタンシングのために複数の親ノードにアタッチできます。
Returns: java.util.ArrayList<com.aspose.threed.Node> - すべての親ノード、エンティティはジオメトリ インスタンシングのために複数の親ノードにアタッチできます
getProperties()
public PropertyCollection getProperties()
すべてのプロパティのコレクションを取得します。
Returns: PropertyCollection - the collection of all properties.
getProperty(String property)
public Object getProperty(String property)
指定されたプロパティの値を取得します
Parameters:
| パラメーター | 型 | 説明 |
|---|---|---|
| プロパティ | java.lang.String | プロパティ名 |
Returns: java.lang.Object - 見つかったプロパティの値
getScene()
public Scene getScene()
このオブジェクトが属するシーンを取得します
Returns: Scene - the scene that this object belongs to
getShortIndices()
public short[] getShortIndices()
インデックスを 16 ビット整数配列に変換する
Returns: short[]
getUnmergedVerticesCount()
public int getUnmergedVerticesCount()
beginVertex と endVertex によって渡された未マージ頂点の数。
Returns: int - beginVertex と endVertex によって渡された未マージ頂点の数。
getVertexDeclaration()
public VertexDeclaration getVertexDeclaration()
TriMesh の頂点レイアウト。
Returns: VertexDeclaration - The vertex layout of the TriMesh.
getVerticesCount()
public int getVerticesCount()
この TriMesh の頂点数。
Returns: int - この TriMesh の頂点数
getVerticesSizeInBytes()
public int getVerticesSizeInBytes()
すべての頂点の合計サイズ(バイト)
Returns: int - すべての頂点の合計サイズ(バイト単位)
hashCode()
public native int hashCode()
Returns: int
indicesToArray(int[][] result)
public void indicesToArray(int[][] result)
インデックスを 32 ビット整数配列に変換する
Parameters:
| パラメーター | 型 | 説明 |
|---|---|---|
| 結果 | int[][] |
indicesToArray(short[][] result)
public void indicesToArray(short[][] result)
インデックスを 16 ビット整数配列に変換する
Parameters:
| パラメーター | 型 | 説明 |
|---|---|---|
| 結果 | short[][] |
iterator()
public Iterator<Vertex> iterator()
Vertex を列挙するための列挙子を取得する
Returns: java.util.Iterator<com.aspose.threed.Vertex>
loadVerticesFromBytes(byte[] verticesInBytes)
public void loadVerticesFromBytes(byte[] verticesInBytes)
バイトから頂点をロードします。バイトの長さは頂点サイズの整数倍である必要があります。Example: 以下のコードは、空の TriMesh を作成し、生のバイトから手動で頂点をロードする方法を示しています。
var indices = new int[] { 0, 1, 2 };
var vertices = new byte[]{
0, 0, 0, 191,
0, 0, 0, 0,
0, 0, 0, 191,
0, 0, 0, 191,
0, 0, 0, 0,
0, 0, 0, 63,
0, 0, 0, 63,
0, 0, 0, 0,
0, 0, 0, 63
};
VertexDeclaration vd = new VertexDeclaration();
vd.AddField(VertexFieldDataType.FVector3, VertexFieldSemantic.Position);
//create an empty TriMesh with specified vertex declaration
var triMesh = new TriMesh("", vd);
//load vertices directly from bytes
triMesh.LoadVerticesFromBytes(vertices);
triMesh.AddTriangle(0, 1, 2);
int[] indices = new int[] { 0, 1, 2 };
byte[] vertices = new byte[]{
0, 0, 0, 191,
0, 0, 0, 0,
0, 0, 0, 191,
0, 0, 0, 191,
0, 0, 0, 0,
0, 0, 0, 63,
0, 0, 0, 63,
0, 0, 0, 0,
0, 0, 0, 63
};
VertexDeclaration vd = new VertexDeclaration();
vd.addField(VertexFieldDataType.F_VECTOR3, VertexFieldSemantic.POSITION);
//create an empty TriMesh with specified vertex declaration
var triMesh = new TriMesh("", vd);
//load vertices directly from bytes
triMesh.loadVerticesFromBytes(vertices);
triMesh.addTriangle(0, 1, 2);
Parameters:
| パラメーター | 型 | 説明 |
|---|---|---|
| verticesInBytes | byte[] |
notify()
public final native void notify()
notifyAll()
public final native void notifyAll()
readDouble(int idx, VertexField field)
public double readDouble(int idx, VertexField field)
double フィールドを読み取る
Parameters:
| パラメーター | 型 | 説明 |
|---|---|---|
| idx | int | 読み取る頂点のインデックス |
| field | VertexField | float/double 互換のデータ型を持つフィールド |
Returns: double - 指定された頂点のフィールドの Double 値
readFVector2(int idx, VertexField field)
public FVector2 readFVector2(int idx, VertexField field)
vector2 フィールドを読み取る
Parameters:
| パラメーター | 型 | 説明 |
|---|---|---|
| idx | int | 読み取る頂点のインデックス |
| field | VertexField | Vector2/FVector2 データ型を持つフィールド |
Returns: FVector2 - FVector2 of specified vertex’s field
readFVector3(int idx, VertexField field)
public FVector3 readFVector3(int idx, VertexField field)
vector3 フィールドを読み取る
Parameters:
| パラメーター | 型 | 説明 |
|---|---|---|
| idx | int | 読み取る頂点のインデックス |
| field | VertexField | Vector3/FVector3 データ型を持つフィールド |
Returns: FVector3
readFVector4(int idx, VertexField field)
public FVector4 readFVector4(int idx, VertexField field)
vector4 フィールドを読み取ります
Parameters:
| パラメーター | 型 | 説明 |
|---|---|---|
| idx | int | 読み取る頂点のインデックス |
| field | VertexField | Vector4/FVector4 データ型を持つフィールド |
Returns: FVector4
readFloat(int idx, VertexField field)
public float readFloat(int idx, VertexField field)
float フィールドを読み取ります
Parameters:
| パラメーター | 型 | 説明 |
|---|---|---|
| idx | int | 読み取る頂点のインデックス |
| field | VertexField | float/double 互換のデータ型を持つフィールド |
Returns: float - 指定された頂点のフィールドの Float 値
readVector2(int idx, VertexField field)
public Vector2 readVector2(int idx, VertexField field)
vector2 フィールドを読み取る
Parameters:
| パラメーター | 型 | 説明 |
|---|---|---|
| idx | int | 読み取る頂点のインデックス |
| field | VertexField | Vector2/FVector2 データ型を持つフィールド |
Returns: Vector2 - Vector2 of specified vertex’s field
readVector3(int idx, VertexField field)
public Vector3 readVector3(int idx, VertexField field)
vector3 フィールドを読み取る
Parameters:
| パラメーター | 型 | 説明 |
|---|---|---|
| idx | int | 読み取る頂点のインデックス |
| field | VertexField | Vector3/FVector3 データ型を持つフィールド |
Returns: Vector3
readVector4(int idx, VertexField field)
public Vector4 readVector4(int idx, VertexField field)
vector4 フィールドを読み取ります
Parameters:
| パラメーター | 型 | 説明 |
|---|---|---|
| idx | int | 読み取る頂点のインデックス |
| field | VertexField | Vector4/FVector4 データ型を持つフィールド |
Returns: Vector4
removeProperty(Property property)
public boolean removeProperty(Property property)
動的プロパティを削除します。
Parameters:
| パラメーター | 型 | 説明 |
|---|---|---|
| property | Property | 削除するプロパティ |
Returns: boolean - プロパティが正常に削除された場合は true
removeProperty(String property)
public boolean removeProperty(String property)
名前で識別される指定されたプロパティを削除します
Parameters:
| パラメーター | 型 | 説明 |
|---|---|---|
| プロパティ | java.lang.String | 削除するプロパティ |
Returns: boolean - プロパティが正常に削除された場合は true
setExcluded(boolean value)
public void setExcluded(boolean value)
エクスポート時にこのエンティティを除外するかどうかを設定します。
Parameters:
| パラメーター | 型 | 説明 |
|---|---|---|
| 値 | boolean | 新しい値 |
setName(String value)
public void setName(String value)
名前を設定します。
Parameters:
| パラメーター | 型 | 説明 |
|---|---|---|
| 値 | java.lang.String | 新しい値 |
setParentNode(Node value)
public void setParentNode(Node value)
最初の親ノードを設定します。最初の親ノードを設定すると、このエンティティは他の親ノードから切り離されます。
Parameters:
| パラメーター | 型 | 説明 |
|---|---|---|
| value | Node | 新しい値 |
setProperty(String property, Object value)
public void setProperty(String property, Object value)
指定されたプロパティの値を設定します
Parameters:
| パラメーター | 型 | 説明 |
|---|---|---|
| プロパティ | java.lang.String | プロパティ名 |
| 値 | java.lang.Object | プロパティの値 |
toString()
public String toString()
TriMesh の文字列表現を取得します
Returns: java.lang.String - 文字列表現
verticesToArray()
public byte[] verticesToArray()
頂点データをバイト配列に変換します
Returns: byte[]
wait()
public final void wait()
wait(long arg0)
public final void wait(long arg0)
Parameters:
| パラメーター | 型 | 説明 |
|---|---|---|
| arg0 | long |
wait(long arg0, int arg1)
public final void wait(long arg0, int arg1)
Parameters:
| パラメーター | 型 | 説明 |
|---|---|---|
| arg0 | long | |
| arg1 | int |
write16bIndicesTo(Stream stream)
public void write16bIndicesTo(Stream stream)
インデックスデータを 16 ビット整数としてストリームに書き込みます Example:
//convert a mesh to TriMesh, the layout is automatically inferred from input mesh
var mesh = (new Sphere()).toMesh();
var triMesh = TriMesh.fromMesh(mesh);
//save it to a stream, 115 vertices * 32bytes per vertex
var stream = new ByteArrayOutputStream();
try(var s = Stream.wrap(stream)) {
triMesh.writeVerticesTo(s);
//save indices as ushort to stream, 504 indices * 2 bytes per index
triMesh.write16bIndicesTo(s);
}
Parameters:
| パラメーター | 型 | 説明 |
|---|---|---|
| stream | Stream |
write16bIndicesTo(OutputStream stream)
public void write16bIndicesTo(OutputStream stream)
インデックスデータを 16 ビット整数としてストリームに書き込みます
Parameters:
| パラメーター | 型 | 説明 |
|---|---|---|
| ストリーム | java.io.OutputStream |
//convert a mesh to TriMesh, the layout is automatically inferred from input mesh
var mesh = (new Sphere()).toMesh();
var triMesh = TriMesh.fromMesh(mesh);
//save it to a stream, 115 vertices * 32bytes per vertex
var stream = new ByteArrayOutputStream();
triMesh.writeVerticesTo(stream);
//save indices as ushort to stream, 504 indices * 2 bytes per index
triMesh.write16bIndicesTo(stream);
``` |
### write32bIndicesTo(Stream stream) {#write32bIndicesTo-com.aspose.threed.Stream-}
public void write32bIndicesTo(Stream stream)
インデックスデータを 32 ビット整数としてストリームに書き込みます **Example:**
//convert a mesh to TriMesh, the layout is automatically inferred from input mesh var mesh = (new Sphere()).toMesh(); var triMesh = TriMesh.fromMesh(mesh); //save it to a stream, 115 vertices * 32bytes per vertex var stream = new ByteArrayOutputStream(); try(var s = Stream.wrap(stream)) { triMesh.writeVerticesTo(s); //save indices as ushort to stream, 504 indices * 2 bytes per index triMesh.write32bIndicesTo(s); }
**Parameters:**
| パラメーター | 型 | 説明 |
| --- | --- | --- |
| stream | [Stream](../../com.aspose.threed/stream) | |
### write32bIndicesTo(OutputStream stream) {#write32bIndicesTo-java.io.OutputStream-}
public void write32bIndicesTo(OutputStream stream)
インデックスデータを 32 ビット整数としてストリームに書き込みます
**Parameters:**
| パラメーター | 型 | 説明 |
| --- | --- | --- |
| | ストリーム | java.io.OutputStream | **例:** |
//convert a mesh to TriMesh, the layout is automatically inferred from input mesh
var mesh = (new Sphere()).toMesh();
var triMesh = TriMesh.fromMesh(mesh);
//save it to a stream, 115 vertices * 32bytes per vertex
var stream = new ByteArrayOutputStream();
triMesh.writeVerticesTo(stream);
//save indices as ushort to stream, 504 indices * 2 bytes per index
triMesh.write32bIndicesTo(stream);
### writeVerticesTo(Stream stream) {#writeVerticesTo-com.aspose.threed.Stream-}
public void writeVerticesTo(Stream stream)
指定されたストリームに頂点データを書き込みます
**Parameters:**
| パラメーター | 型 | 説明 |
| --- | --- | --- |
| | stream | [Stream](../../com.aspose.threed/stream) | 頂点データが書き込まれるストリーム **例:** |
//convert a mesh to TriMesh, the layout is automatically inferred from input mesh var mesh = (new Sphere()).toMesh(); var triMesh = TriMesh.fromMesh(mesh); //save it to a stream, 115 vertices * 32bytes per vertex var stream = new ByteArrayOutputStream(); try(var s = Stream.wrap(stream)) { triMesh.writeVerticesTo(s); //save indices as ushort to stream, 504 indices * 2 bytes per index triMesh.write16bIndicesTo(s); }
### writeVerticesTo(OutputStream stream) {#writeVerticesTo-java.io.OutputStream-}
public void writeVerticesTo(OutputStream stream)
指定されたストリームに頂点データを書き込みます
**Parameters:**
| パラメーター | 型 | 説明 |
| --- | --- | --- |
| | ストリーム | java.io.OutputStream | 頂点データが書き込まれるストリーム **例:** |
//convert a mesh to TriMesh, the layout is automatically inferred from input mesh
var mesh = (new Sphere()).toMesh();
var triMesh = TriMesh.fromMesh(mesh);
//save it to a stream, 115 vertices * 32bytes per vertex
var stream = new ByteArrayOutputStream();
triMesh.writeVerticesTo(stream);
//save indices as ushort to stream, 504 indices * 2 bytes per index
triMesh.write16bIndicesTo(stream);