ホーム › Graphics.Direct3D9 › D3DMATERIAL9
D3DMATERIAL9
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Diffuse | D3DCOLORVALUE | 16 | +0 | +0 | 拡散反射光の色(D3DCOLORVALUE)。 |
| Ambient | D3DCOLORVALUE | 16 | +16 | +16 | 環境光反射の色(D3DCOLORVALUE)。 |
| Specular | D3DCOLORVALUE | 16 | +32 | +32 | 鏡面反射光の色(D3DCOLORVALUE)。 |
| Emissive | D3DCOLORVALUE | 16 | +48 | +48 | 自己発光の色(D3DCOLORVALUE)。 |
| Power | FLOAT | 4 | +64 | +64 | 鏡面反射のシャープさを示す指数(浮動小数点)。 |
各言語での定義
#include <windows.h>
// D3DCOLORVALUE (x64 16 / x86 16 バイト)
typedef struct D3DCOLORVALUE {
FLOAT r;
FLOAT g;
FLOAT b;
FLOAT a;
} D3DCOLORVALUE;
// D3DMATERIAL9 (x64 68 / x86 68 バイト)
typedef struct D3DMATERIAL9 {
D3DCOLORVALUE Diffuse;
D3DCOLORVALUE Ambient;
D3DCOLORVALUE Specular;
D3DCOLORVALUE Emissive;
FLOAT Power;
} D3DMATERIAL9;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct D3DCOLORVALUE
{
public float r;
public float g;
public float b;
public float a;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct D3DMATERIAL9
{
public D3DCOLORVALUE Diffuse;
public D3DCOLORVALUE Ambient;
public D3DCOLORVALUE Specular;
public D3DCOLORVALUE Emissive;
public float Power;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure D3DCOLORVALUE
Public r As Single
Public g As Single
Public b As Single
Public a As Single
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure D3DMATERIAL9
Public Diffuse As D3DCOLORVALUE
Public Ambient As D3DCOLORVALUE
Public Specular As D3DCOLORVALUE
Public Emissive As D3DCOLORVALUE
Public Power As Single
End Structureimport ctypes
from ctypes import wintypes
class D3DCOLORVALUE(ctypes.Structure):
_fields_ = [
("r", ctypes.c_float),
("g", ctypes.c_float),
("b", ctypes.c_float),
("a", ctypes.c_float),
]
class D3DMATERIAL9(ctypes.Structure):
_fields_ = [
("Diffuse", D3DCOLORVALUE),
("Ambient", D3DCOLORVALUE),
("Specular", D3DCOLORVALUE),
("Emissive", D3DCOLORVALUE),
("Power", ctypes.c_float),
]#[repr(C)]
pub struct D3DCOLORVALUE {
pub r: f32,
pub g: f32,
pub b: f32,
pub a: f32,
}
#[repr(C)]
pub struct D3DMATERIAL9 {
pub Diffuse: D3DCOLORVALUE,
pub Ambient: D3DCOLORVALUE,
pub Specular: D3DCOLORVALUE,
pub Emissive: D3DCOLORVALUE,
pub Power: f32,
}import "golang.org/x/sys/windows"
type D3DCOLORVALUE struct {
r float32
g float32
b float32
a float32
}
type D3DMATERIAL9 struct {
Diffuse D3DCOLORVALUE
Ambient D3DCOLORVALUE
Specular D3DCOLORVALUE
Emissive D3DCOLORVALUE
Power float32
}type
D3DCOLORVALUE = record
r: Single;
g: Single;
b: Single;
a: Single;
end;
D3DMATERIAL9 = record
Diffuse: D3DCOLORVALUE;
Ambient: D3DCOLORVALUE;
Specular: D3DCOLORVALUE;
Emissive: D3DCOLORVALUE;
Power: Single;
end;const D3DCOLORVALUE = extern struct {
r: f32,
g: f32,
b: f32,
a: f32,
};
const D3DMATERIAL9 = extern struct {
Diffuse: D3DCOLORVALUE,
Ambient: D3DCOLORVALUE,
Specular: D3DCOLORVALUE,
Emissive: D3DCOLORVALUE,
Power: f32,
};type
D3DCOLORVALUE {.bycopy.} = object
r: float32
g: float32
b: float32
a: float32
D3DMATERIAL9 {.bycopy.} = object
Diffuse: D3DCOLORVALUE
Ambient: D3DCOLORVALUE
Specular: D3DCOLORVALUE
Emissive: D3DCOLORVALUE
Power: float32struct D3DCOLORVALUE
{
float r;
float g;
float b;
float a;
}
struct D3DMATERIAL9
{
D3DCOLORVALUE Diffuse;
D3DCOLORVALUE Ambient;
D3DCOLORVALUE Specular;
D3DCOLORVALUE Emissive;
float Power;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; D3DMATERIAL9 サイズ: 68 バイト(x64)
dim st, 17 ; 4byte整数×17(構造体サイズ 68 / 4 切り上げ)
; Diffuse : D3DCOLORVALUE (+0, 16byte) varptr(st)+0 を基点に操作(16byte:入れ子/配列)
; Ambient : D3DCOLORVALUE (+16, 16byte) varptr(st)+16 を基点に操作(16byte:入れ子/配列)
; Specular : D3DCOLORVALUE (+32, 16byte) varptr(st)+32 を基点に操作(16byte:入れ子/配列)
; Emissive : D3DCOLORVALUE (+48, 16byte) varptr(st)+48 を基点に操作(16byte:入れ子/配列)
; Power : FLOAT (+64, 4byte) st.16 = 値 / 値 = st.16 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global D3DCOLORVALUE
#field float r
#field float g
#field float b
#field float a
#endstruct
#defstruct global D3DMATERIAL9
#field D3DCOLORVALUE Diffuse
#field D3DCOLORVALUE Ambient
#field D3DCOLORVALUE Specular
#field D3DCOLORVALUE Emissive
#field float Power
#endstruct
stdim st, D3DMATERIAL9 ; NSTRUCT 変数を確保
st->Power = 100
mes "Power=" + st->Power