Win32 API 日本語リファレンス
ホームGraphics.Direct3D9 › D3DLIGHT7

D3DLIGHT7

構造体
サイズx64: 104 バイト / x86: 104 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
dltTypeD3DLIGHTTYPE4+0+0ライトの種別を示すD3DLIGHTTYPE。
dcvDiffuseD3DCOLORVALUE16+4+4ライトの拡散光色(D3DCOLORVALUE)。
dcvSpecularD3DCOLORVALUE16+20+20ライトの鏡面光色(D3DCOLORVALUE)。
dcvAmbientD3DCOLORVALUE16+36+36ライトの環境光色(D3DCOLORVALUE)。
dvPositionD3DVECTOR12+52+52ライトのワールド空間位置(D3DVECTOR)。
dvDirectionD3DVECTOR12+64+64ライトの照射方向(D3DVECTOR)。
dvRangeFLOAT4+76+76ライトの届く最大距離。
dvFalloffFLOAT4+80+80スポットライトの内錐から外錐への減衰の度合い。
dvAttenuation0FLOAT4+84+84距離に依存しない一定の減衰係数。
dvAttenuation1FLOAT4+88+88距離に線形比例する減衰係数。
dvAttenuation2FLOAT4+92+92距離の二乗に比例する減衰係数。
dvThetaFLOAT4+96+96スポットライトの内錐の角度(ラジアン)。
dvPhiFLOAT4+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;

// D3DLIGHT7  (x64 104 / x86 104 バイト)
typedef struct D3DLIGHT7 {
    D3DLIGHTTYPE dltType;
    D3DCOLORVALUE dcvDiffuse;
    D3DCOLORVALUE dcvSpecular;
    D3DCOLORVALUE dcvAmbient;
    D3DVECTOR dvPosition;
    D3DVECTOR dvDirection;
    FLOAT dvRange;
    FLOAT dvFalloff;
    FLOAT dvAttenuation0;
    FLOAT dvAttenuation1;
    FLOAT dvAttenuation2;
    FLOAT dvTheta;
    FLOAT dvPhi;
} D3DLIGHT7;
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 D3DLIGHT7
{
    public int dltType;
    public D3DCOLORVALUE dcvDiffuse;
    public D3DCOLORVALUE dcvSpecular;
    public D3DCOLORVALUE dcvAmbient;
    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 D3DLIGHT7
    Public dltType As Integer
    Public dcvDiffuse As D3DCOLORVALUE
    Public dcvSpecular As D3DCOLORVALUE
    Public dcvAmbient 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 Structure
import 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 D3DLIGHT7(ctypes.Structure):
    _fields_ = [
        ("dltType", ctypes.c_int),
        ("dcvDiffuse", D3DCOLORVALUE),
        ("dcvSpecular", D3DCOLORVALUE),
        ("dcvAmbient", 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 D3DLIGHT7 {
    pub dltType: i32,
    pub dcvDiffuse: D3DCOLORVALUE,
    pub dcvSpecular: D3DCOLORVALUE,
    pub dcvAmbient: 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 D3DLIGHT7 struct {
	dltType int32
	dcvDiffuse D3DCOLORVALUE
	dcvSpecular D3DCOLORVALUE
	dcvAmbient 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;

  D3DLIGHT7 = record
    dltType: Integer;
    dcvDiffuse: D3DCOLORVALUE;
    dcvSpecular: D3DCOLORVALUE;
    dcvAmbient: 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 D3DLIGHT7 = extern struct {
    dltType: i32,
    dcvDiffuse: D3DCOLORVALUE,
    dcvSpecular: D3DCOLORVALUE,
    dcvAmbient: 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

  D3DLIGHT7 {.bycopy.} = object
    dltType: int32
    dcvDiffuse: D3DCOLORVALUE
    dcvSpecular: D3DCOLORVALUE
    dcvAmbient: D3DCOLORVALUE
    dvPosition: D3DVECTOR
    dvDirection: D3DVECTOR
    dvRange: float32
    dvFalloff: float32
    dvAttenuation0: float32
    dvAttenuation1: float32
    dvAttenuation2: float32
    dvTheta: float32
    dvPhi: float32
struct D3DCOLORVALUE
{
    float r;
    float g;
    float b;
    float a;
}

struct D3DVECTOR
{
    float x;
    float y;
    float z;
}

struct D3DLIGHT7
{
    int dltType;
    D3DCOLORVALUE dcvDiffuse;
    D3DCOLORVALUE dcvSpecular;
    D3DCOLORVALUE dcvAmbient;
    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 レイアウト)
; D3DLIGHT7 サイズ: 104 バイト(x64)
dim st, 26    ; 4byte整数×26(構造体サイズ 104 / 4 切り上げ)
; dltType : D3DLIGHTTYPE (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; dcvDiffuse : D3DCOLORVALUE (+4, 16byte)  varptr(st)+4 を基点に操作(16byte:入れ子/配列)
; dcvSpecular : D3DCOLORVALUE (+20, 16byte)  varptr(st)+20 を基点に操作(16byte:入れ子/配列)
; dcvAmbient : D3DCOLORVALUE (+36, 16byte)  varptr(st)+36 を基点に操作(16byte:入れ子/配列)
; dvPosition : D3DVECTOR (+52, 12byte)  varptr(st)+52 を基点に操作(12byte:入れ子/配列)
; dvDirection : D3DVECTOR (+64, 12byte)  varptr(st)+64 を基点に操作(12byte:入れ子/配列)
; dvRange : FLOAT (+76, 4byte)  st.19 = 値  /  値 = st.19   (lpoke/lpeek も可)
; dvFalloff : FLOAT (+80, 4byte)  st.20 = 値  /  値 = st.20   (lpoke/lpeek も可)
; dvAttenuation0 : FLOAT (+84, 4byte)  st.21 = 値  /  値 = st.21   (lpoke/lpeek も可)
; dvAttenuation1 : FLOAT (+88, 4byte)  st.22 = 値  /  値 = st.22   (lpoke/lpeek も可)
; dvAttenuation2 : FLOAT (+92, 4byte)  st.23 = 値  /  値 = st.23   (lpoke/lpeek も可)
; dvTheta : FLOAT (+96, 4byte)  st.24 = 値  /  値 = st.24   (lpoke/lpeek も可)
; dvPhi : 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 D3DLIGHT7
    #field int dltType
    #field D3DCOLORVALUE dcvDiffuse
    #field D3DCOLORVALUE dcvSpecular
    #field D3DCOLORVALUE dcvAmbient
    #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, D3DLIGHT7        ; NSTRUCT 変数を確保
st->dltType = 100
mes "dltType=" + st->dltType