Device.SetTexture(Int32,BaseTexture)
SetTexture メソッド
使用例
- メッシュのマテリアルとテクスチャのレンダリング
- デバイス上でのテクスチャの設定
テクスチャをデバイス ステージに割り当てる。
定義
Visual Basic | Public Sub SetTexture( _ ByVal stage As Integer, _ ByVal texture As BaseTexture _ ) |
C# | public void SetTexture( int stage, BaseTexture texture ); |
Managed C++ | public: void SetTexture( int stage, BaseTexture* texture ); |
JScript | public function SetTexture( stage : int, texture : BaseTexture ) : void; |
パラメータ
stage | System.Int32. |
texture | Microsoft.DirectX.Direct3D.BaseTexture. |
使用例
メッシュのマテリアルとテクスチャのレンダリング
この例では、メッシュ オブジェクトにマテリアルとテクスチャのプロパティを適用する方法を示す。
プロパティが適用されたメッシュは、Mesh.DrawSubset メソッドを呼び出せばディスプレイにレンダリングされる。
using Microsoft.DirectX.Direct3D;
public class Meshes : System.Windows.Forms.Form
{
// Global variables for this project
Device device = null; // Rendering device
Mesh mesh = null; // Mesh object
Material[] meshMaterials; // Materials for mesh
Texture[] meshTextures; // Textures for mesh
private void Render()
{
// Meshes are divided into subsets, one for each material.
// Render them in a loop.
for( int i=0; i<meshMaterials.Length; i++ )
{
// Set the material and texture for this subset\
device.Material = meshMaterials[i];
device.SetTexture(0, meshTextures[i]);
// Draw the mesh subset
mesh.DrawSubset(i);
.
.
.
}
.
.
}
デバイス上でのテクスチャの設定
この例では、デバイス テクスチャを、ロードしたテクスチャ オブジェクトとして設定する方法を示す。
SetTexture メソッドは 2 つの引数をとる。1 つはステージ識別子で、この場合は 0 番目のステージとなる (設定できる値は 0 ~ 7)。 もう 1 つは、設定するテクスチャ オブジェクトである。
using Microsoft.DirectX.Direct3D;
public class Textures : System.Windows.Forms.Form
{
// Global variables for this project
Device device = null; // Rendering device
Texture texture = null; // Texture object
private void Render()
{
// Set up texture.
device.SetTexture(0,texture);
.
.
.
}
.
.
.
}
対象
© 2002 Microsoft Corporation. All rights reserved. Terms of use.