ホーム › Graphics.Direct3D9 › D3DLIGHT9
D3DLIGHT9
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Type | D3DLIGHTTYPE | 4 | +0 | +0 | ライトの種別を示すD3DLIGHTTYPE(点/方向/スポット)。 |
| Diffuse | D3DCOLORVALUE | 16 | +4 | +4 | ライトの拡散光色(D3DCOLORVALUE)。 |
| Specular | D3DCOLORVALUE | 16 | +20 | +20 | ライトの鏡面光色(D3DCOLORVALUE)。 |
| Ambient | D3DCOLORVALUE | 16 | +36 | +36 | ライトの環境光色(D3DCOLORVALUE)。 |
| Position | D3DVECTOR | 12 | +52 | +52 | ライトのワールド空間位置(方向光では無視)。 |
| Direction | D3DVECTOR | 12 | +64 | +64 | ライトの照射方向(点光源では無視)。 |
| Range | FLOAT | 4 | +76 | +76 | ライトの届く最大距離。 |
| Falloff | FLOAT | 4 | +80 | +80 | スポットライトの内錐から外錐への減衰の度合い。 |
| Attenuation0 | FLOAT | 4 | +84 | +84 | 距離に依存しない一定の減衰係数。 |
| Attenuation1 | FLOAT | 4 | +88 | +88 | 距離に線形比例する減衰係数。 |
| Attenuation2 | FLOAT | 4 | +92 | +92 | 距離の二乗に比例する減衰係数。 |
| Theta | FLOAT | 4 | +96 | +96 | スポットライトの内錐の角度(ラジアン)。 |
| Phi | FLOAT | 4 | +100 | +100 | スポットライトの外錐の角度(ラジアン)。 |
各言語での定義
#include <windows.h>
// D3DCOLORVALUE (x64 16 / x86 16 バイト)
typedef struct D3DCOLORVALUE {
FLOAT r;
FLOAT g;
FLOAT b;
FLOAT a;
} D3DCOLORVALUE;
// D3DVECTOR (x64 12 / x86 12 バイト)
typedef struct D3DVECTOR {
FLOAT x;
FLOAT y;
FLOAT z;
} D3DVECTOR;
// D3DLIGHT9 (x64 104 / x86 104 バイト)
typedef struct D3DLIGHT9 {
D3DLIGHTTYPE Type;
D3DCOLORVALUE Diffuse;
D3DCOLORVALUE Specular;
D3DCOLORVALUE Ambient;
D3DVECTOR Position;
D3DVECTOR Direction;
FLOAT Range;
FLOAT Falloff;
FLOAT Attenuation0;
FLOAT Attenuation1;
FLOAT Attenuation2;
FLOAT Theta;
FLOAT Phi;
} D3DLIGHT9;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 D3DVECTOR
{
public float x;
public float y;
public float z;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct D3DLIGHT9
{
public int Type;
public D3DCOLORVALUE Diffuse;
public D3DCOLORVALUE Specular;
public D3DCOLORVALUE Ambient;
public D3DVECTOR Position;
public D3DVECTOR Direction;
public float Range;
public float Falloff;
public float Attenuation0;
public float Attenuation1;
public float Attenuation2;
public float Theta;
public float Phi;
}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 D3DVECTOR
Public x As Single
Public y As Single
Public z As Single
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure D3DLIGHT9
Public Type As Integer
Public Diffuse As D3DCOLORVALUE
Public Specular As D3DCOLORVALUE
Public Ambient As D3DCOLORVALUE
Public Position As D3DVECTOR
Public Direction As D3DVECTOR
Public Range As Single
Public Falloff As Single
Public Attenuation0 As Single
Public Attenuation1 As Single
Public Attenuation2 As Single
Public Theta As Single
Public Phi 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 D3DVECTOR(ctypes.Structure):
_fields_ = [
("x", ctypes.c_float),
("y", ctypes.c_float),
("z", ctypes.c_float),
]
class D3DLIGHT9(ctypes.Structure):
_fields_ = [
("Type", ctypes.c_int),
("Diffuse", D3DCOLORVALUE),
("Specular", D3DCOLORVALUE),
("Ambient", D3DCOLORVALUE),
("Position", D3DVECTOR),
("Direction", D3DVECTOR),
("Range", ctypes.c_float),
("Falloff", ctypes.c_float),
("Attenuation0", ctypes.c_float),
("Attenuation1", ctypes.c_float),
("Attenuation2", ctypes.c_float),
("Theta", ctypes.c_float),
("Phi", ctypes.c_float),
]#[repr(C)]
pub struct D3DCOLORVALUE {
pub r: f32,
pub g: f32,
pub b: f32,
pub a: f32,
}
#[repr(C)]
pub struct D3DVECTOR {
pub x: f32,
pub y: f32,
pub z: f32,
}
#[repr(C)]
pub struct D3DLIGHT9 {
pub Type: i32,
pub Diffuse: D3DCOLORVALUE,
pub Specular: D3DCOLORVALUE,
pub Ambient: D3DCOLORVALUE,
pub Position: D3DVECTOR,
pub Direction: D3DVECTOR,
pub Range: f32,
pub Falloff: f32,
pub Attenuation0: f32,
pub Attenuation1: f32,
pub Attenuation2: f32,
pub Theta: f32,
pub Phi: f32,
}import "golang.org/x/sys/windows"
type D3DCOLORVALUE struct {
r float32
g float32
b float32
a float32
}
type D3DVECTOR struct {
x float32
y float32
z float32
}
type D3DLIGHT9 struct {
Type int32
Diffuse D3DCOLORVALUE
Specular D3DCOLORVALUE
Ambient D3DCOLORVALUE
Position D3DVECTOR
Direction D3DVECTOR
Range float32
Falloff float32
Attenuation0 float32
Attenuation1 float32
Attenuation2 float32
Theta float32
Phi float32
}type
D3DCOLORVALUE = record
r: Single;
g: Single;
b: Single;
a: Single;
end;
D3DVECTOR = record
x: Single;
y: Single;
z: Single;
end;
D3DLIGHT9 = record
Type: Integer;
Diffuse: D3DCOLORVALUE;
Specular: D3DCOLORVALUE;
Ambient: D3DCOLORVALUE;
Position: D3DVECTOR;
Direction: D3DVECTOR;
Range: Single;
Falloff: Single;
Attenuation0: Single;
Attenuation1: Single;
Attenuation2: Single;
Theta: Single;
Phi: Single;
end;const D3DCOLORVALUE = extern struct {
r: f32,
g: f32,
b: f32,
a: f32,
};
const D3DVECTOR = extern struct {
x: f32,
y: f32,
z: f32,
};
const D3DLIGHT9 = extern struct {
Type: i32,
Diffuse: D3DCOLORVALUE,
Specular: D3DCOLORVALUE,
Ambient: D3DCOLORVALUE,
Position: D3DVECTOR,
Direction: D3DVECTOR,
Range: f32,
Falloff: f32,
Attenuation0: f32,
Attenuation1: f32,
Attenuation2: f32,
Theta: f32,
Phi: f32,
};type
D3DCOLORVALUE {.bycopy.} = object
r: float32
g: float32
b: float32
a: float32
D3DVECTOR {.bycopy.} = object
x: float32
y: float32
z: float32
D3DLIGHT9 {.bycopy.} = object
Type: int32
Diffuse: D3DCOLORVALUE
Specular: D3DCOLORVALUE
Ambient: D3DCOLORVALUE
Position: D3DVECTOR
Direction: D3DVECTOR
Range: float32
Falloff: float32
Attenuation0: float32
Attenuation1: float32
Attenuation2: float32
Theta: float32
Phi: float32struct D3DCOLORVALUE
{
float r;
float g;
float b;
float a;
}
struct D3DVECTOR
{
float x;
float y;
float z;
}
struct D3DLIGHT9
{
int Type;
D3DCOLORVALUE Diffuse;
D3DCOLORVALUE Specular;
D3DCOLORVALUE Ambient;
D3DVECTOR Position;
D3DVECTOR Direction;
float Range;
float Falloff;
float Attenuation0;
float Attenuation1;
float Attenuation2;
float Theta;
float Phi;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; D3DLIGHT9 サイズ: 104 バイト(x64)
dim st, 26 ; 4byte整数×26(構造体サイズ 104 / 4 切り上げ)
; Type : D3DLIGHTTYPE (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; Diffuse : D3DCOLORVALUE (+4, 16byte) varptr(st)+4 を基点に操作(16byte:入れ子/配列)
; Specular : D3DCOLORVALUE (+20, 16byte) varptr(st)+20 を基点に操作(16byte:入れ子/配列)
; Ambient : D3DCOLORVALUE (+36, 16byte) varptr(st)+36 を基点に操作(16byte:入れ子/配列)
; Position : D3DVECTOR (+52, 12byte) varptr(st)+52 を基点に操作(12byte:入れ子/配列)
; Direction : D3DVECTOR (+64, 12byte) varptr(st)+64 を基点に操作(12byte:入れ子/配列)
; Range : FLOAT (+76, 4byte) st.19 = 値 / 値 = st.19 (lpoke/lpeek も可)
; Falloff : FLOAT (+80, 4byte) st.20 = 値 / 値 = st.20 (lpoke/lpeek も可)
; Attenuation0 : FLOAT (+84, 4byte) st.21 = 値 / 値 = st.21 (lpoke/lpeek も可)
; Attenuation1 : FLOAT (+88, 4byte) st.22 = 値 / 値 = st.22 (lpoke/lpeek も可)
; Attenuation2 : FLOAT (+92, 4byte) st.23 = 値 / 値 = st.23 (lpoke/lpeek も可)
; Theta : FLOAT (+96, 4byte) st.24 = 値 / 値 = st.24 (lpoke/lpeek も可)
; Phi : FLOAT (+100, 4byte) st.25 = 値 / 値 = st.25 (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 D3DVECTOR
#field float x
#field float y
#field float z
#endstruct
#defstruct global D3DLIGHT9
#field int Type
#field D3DCOLORVALUE Diffuse
#field D3DCOLORVALUE Specular
#field D3DCOLORVALUE Ambient
#field D3DVECTOR Position
#field D3DVECTOR Direction
#field float Range
#field float Falloff
#field float Attenuation0
#field float Attenuation1
#field float Attenuation2
#field float Theta
#field float Phi
#endstruct
stdim st, D3DLIGHT9 ; NSTRUCT 変数を確保
st->Type = 100
mes "Type=" + st->Type