ホーム › Graphics.Direct3D9 › D3DLIGHT
D3DLIGHT
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| dwSize | DWORD | 4 | +0 | +0 | 本構造体のサイズ(バイト単位)。 |
| dltType | D3DLIGHTTYPE | 4 | +4 | +4 | ライトの種別を示すD3DLIGHTTYPE。 |
| dcvColor | D3DCOLORVALUE | 16 | +8 | +8 | ライトの色(D3DCOLORVALUE)。 |
| dvPosition | D3DVECTOR | 12 | +24 | +24 | ライトのワールド空間位置(D3DVECTOR)。 |
| dvDirection | D3DVECTOR | 12 | +36 | +36 | ライトの照射方向(D3DVECTOR)。 |
| dvRange | FLOAT | 4 | +48 | +48 | ライトの届く最大距離。 |
| dvFalloff | FLOAT | 4 | +52 | +52 | スポットライトの内錐から外錐への減衰の度合い。 |
| dvAttenuation0 | FLOAT | 4 | +56 | +56 | 距離に依存しない一定の減衰係数。 |
| dvAttenuation1 | FLOAT | 4 | +60 | +60 | 距離に線形比例する減衰係数。 |
| dvAttenuation2 | FLOAT | 4 | +64 | +64 | 距離の二乗に比例する減衰係数。 |
| dvTheta | FLOAT | 4 | +68 | +68 | スポットライトの内錐の角度(ラジアン)。 |
| dvPhi | FLOAT | 4 | +72 | +72 | スポットライトの外錐の角度(ラジアン)。 |
各言語での定義
#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;
// D3DLIGHT (x64 76 / x86 76 バイト)
typedef struct D3DLIGHT {
DWORD dwSize;
D3DLIGHTTYPE dltType;
D3DCOLORVALUE dcvColor;
D3DVECTOR dvPosition;
D3DVECTOR dvDirection;
FLOAT dvRange;
FLOAT dvFalloff;
FLOAT dvAttenuation0;
FLOAT dvAttenuation1;
FLOAT dvAttenuation2;
FLOAT dvTheta;
FLOAT dvPhi;
} D3DLIGHT;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 D3DLIGHT
{
public uint dwSize;
public int dltType;
public D3DCOLORVALUE dcvColor;
public D3DVECTOR dvPosition;
public D3DVECTOR dvDirection;
public float dvRange;
public float dvFalloff;
public float dvAttenuation0;
public float dvAttenuation1;
public float dvAttenuation2;
public float dvTheta;
public float dvPhi;
}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 D3DLIGHT
Public dwSize As UInteger
Public dltType As Integer
Public dcvColor As D3DCOLORVALUE
Public dvPosition As D3DVECTOR
Public dvDirection As D3DVECTOR
Public dvRange As Single
Public dvFalloff As Single
Public dvAttenuation0 As Single
Public dvAttenuation1 As Single
Public dvAttenuation2 As Single
Public dvTheta As Single
Public dvPhi 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 D3DLIGHT(ctypes.Structure):
_fields_ = [
("dwSize", wintypes.DWORD),
("dltType", ctypes.c_int),
("dcvColor", D3DCOLORVALUE),
("dvPosition", D3DVECTOR),
("dvDirection", D3DVECTOR),
("dvRange", ctypes.c_float),
("dvFalloff", ctypes.c_float),
("dvAttenuation0", ctypes.c_float),
("dvAttenuation1", ctypes.c_float),
("dvAttenuation2", ctypes.c_float),
("dvTheta", ctypes.c_float),
("dvPhi", 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 D3DLIGHT {
pub dwSize: u32,
pub dltType: i32,
pub dcvColor: D3DCOLORVALUE,
pub dvPosition: D3DVECTOR,
pub dvDirection: D3DVECTOR,
pub dvRange: f32,
pub dvFalloff: f32,
pub dvAttenuation0: f32,
pub dvAttenuation1: f32,
pub dvAttenuation2: f32,
pub dvTheta: f32,
pub dvPhi: 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 D3DLIGHT struct {
dwSize uint32
dltType int32
dcvColor D3DCOLORVALUE
dvPosition D3DVECTOR
dvDirection D3DVECTOR
dvRange float32
dvFalloff float32
dvAttenuation0 float32
dvAttenuation1 float32
dvAttenuation2 float32
dvTheta float32
dvPhi float32
}type
D3DCOLORVALUE = record
r: Single;
g: Single;
b: Single;
a: Single;
end;
D3DVECTOR = record
x: Single;
y: Single;
z: Single;
end;
D3DLIGHT = record
dwSize: DWORD;
dltType: Integer;
dcvColor: D3DCOLORVALUE;
dvPosition: D3DVECTOR;
dvDirection: D3DVECTOR;
dvRange: Single;
dvFalloff: Single;
dvAttenuation0: Single;
dvAttenuation1: Single;
dvAttenuation2: Single;
dvTheta: Single;
dvPhi: 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 D3DLIGHT = extern struct {
dwSize: u32,
dltType: i32,
dcvColor: D3DCOLORVALUE,
dvPosition: D3DVECTOR,
dvDirection: D3DVECTOR,
dvRange: f32,
dvFalloff: f32,
dvAttenuation0: f32,
dvAttenuation1: f32,
dvAttenuation2: f32,
dvTheta: f32,
dvPhi: f32,
};type
D3DCOLORVALUE {.bycopy.} = object
r: float32
g: float32
b: float32
a: float32
D3DVECTOR {.bycopy.} = object
x: float32
y: float32
z: float32
D3DLIGHT {.bycopy.} = object
dwSize: uint32
dltType: int32
dcvColor: D3DCOLORVALUE
dvPosition: D3DVECTOR
dvDirection: D3DVECTOR
dvRange: float32
dvFalloff: float32
dvAttenuation0: float32
dvAttenuation1: float32
dvAttenuation2: float32
dvTheta: float32
dvPhi: float32struct D3DCOLORVALUE
{
float r;
float g;
float b;
float a;
}
struct D3DVECTOR
{
float x;
float y;
float z;
}
struct D3DLIGHT
{
uint dwSize;
int dltType;
D3DCOLORVALUE dcvColor;
D3DVECTOR dvPosition;
D3DVECTOR dvDirection;
float dvRange;
float dvFalloff;
float dvAttenuation0;
float dvAttenuation1;
float dvAttenuation2;
float dvTheta;
float dvPhi;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; D3DLIGHT サイズ: 76 バイト(x64)
dim st, 19 ; 4byte整数×19(構造体サイズ 76 / 4 切り上げ)
; dwSize : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; dltType : D3DLIGHTTYPE (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; dcvColor : D3DCOLORVALUE (+8, 16byte) varptr(st)+8 を基点に操作(16byte:入れ子/配列)
; dvPosition : D3DVECTOR (+24, 12byte) varptr(st)+24 を基点に操作(12byte:入れ子/配列)
; dvDirection : D3DVECTOR (+36, 12byte) varptr(st)+36 を基点に操作(12byte:入れ子/配列)
; dvRange : FLOAT (+48, 4byte) st.12 = 値 / 値 = st.12 (lpoke/lpeek も可)
; dvFalloff : FLOAT (+52, 4byte) st.13 = 値 / 値 = st.13 (lpoke/lpeek も可)
; dvAttenuation0 : FLOAT (+56, 4byte) st.14 = 値 / 値 = st.14 (lpoke/lpeek も可)
; dvAttenuation1 : FLOAT (+60, 4byte) st.15 = 値 / 値 = st.15 (lpoke/lpeek も可)
; dvAttenuation2 : FLOAT (+64, 4byte) st.16 = 値 / 値 = st.16 (lpoke/lpeek も可)
; dvTheta : FLOAT (+68, 4byte) st.17 = 値 / 値 = st.17 (lpoke/lpeek も可)
; dvPhi : FLOAT (+72, 4byte) st.18 = 値 / 値 = st.18 (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 D3DLIGHT
#field int dwSize
#field int dltType
#field D3DCOLORVALUE dcvColor
#field D3DVECTOR dvPosition
#field D3DVECTOR dvDirection
#field float dvRange
#field float dvFalloff
#field float dvAttenuation0
#field float dvAttenuation1
#field float dvAttenuation2
#field float dvTheta
#field float dvPhi
#endstruct
stdim st, D3DLIGHT ; NSTRUCT 変数を確保
st->dwSize = 100
mes "dwSize=" + st->dwSize