ホーム › UI.Input.GameInput › GameInputMotionState
GameInputMotionState
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| accelerationX | FLOAT | 4 | +0 | +0 | X軸方向の加速度をm/s^2で示す。 |
| accelerationY | FLOAT | 4 | +4 | +4 | Y軸方向の加速度をm/s^2で示す。 |
| accelerationZ | FLOAT | 4 | +8 | +8 | Z軸方向の加速度をm/s^2で示す。 |
| angularVelocityX | FLOAT | 4 | +12 | +12 | X軸まわりの角速度をrad/sで示す。 |
| angularVelocityY | FLOAT | 4 | +16 | +16 | Y軸まわりの角速度をrad/sで示す。 |
| angularVelocityZ | FLOAT | 4 | +20 | +20 | Z軸まわりの角速度をrad/sで示す。 |
| magneticFieldX | FLOAT | 4 | +24 | +24 | X軸方向の磁界強度をμTで示す。 |
| magneticFieldY | FLOAT | 4 | +28 | +28 | Y軸方向の磁界強度をμTで示す。 |
| magneticFieldZ | FLOAT | 4 | +32 | +32 | Z軸方向の磁界強度をμTで示す。 |
| orientationW | FLOAT | 4 | +36 | +36 | 姿勢クォータニオンのW成分である。 |
| orientationX | FLOAT | 4 | +40 | +40 | 姿勢クォータニオンのX成分である。 |
| orientationY | FLOAT | 4 | +44 | +44 | 姿勢クォータニオンのY成分である。 |
| orientationZ | FLOAT | 4 | +48 | +48 | 姿勢クォータニオンのZ成分である。 |
| accelerometerAccuracy | GameInputMotionAccuracy | 4 | +52 | +52 | 加速度センサーの計測精度を示す値である。 |
| gyroscopeAccuracy | GameInputMotionAccuracy | 4 | +56 | +56 | ジャイロセンサーの計測精度を示す値である。 |
| magnetometerAccuracy | GameInputMotionAccuracy | 4 | +60 | +60 | 磁気センサーの計測精度を示す値である。 |
| orientationAccuracy | GameInputMotionAccuracy | 4 | +64 | +64 | 姿勢推定の精度を示す値である。 |
各言語での定義
#include <windows.h>
// GameInputMotionState (x64 68 / x86 68 バイト)
typedef struct GameInputMotionState {
FLOAT accelerationX;
FLOAT accelerationY;
FLOAT accelerationZ;
FLOAT angularVelocityX;
FLOAT angularVelocityY;
FLOAT angularVelocityZ;
FLOAT magneticFieldX;
FLOAT magneticFieldY;
FLOAT magneticFieldZ;
FLOAT orientationW;
FLOAT orientationX;
FLOAT orientationY;
FLOAT orientationZ;
GameInputMotionAccuracy accelerometerAccuracy;
GameInputMotionAccuracy gyroscopeAccuracy;
GameInputMotionAccuracy magnetometerAccuracy;
GameInputMotionAccuracy orientationAccuracy;
} GameInputMotionState;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct GameInputMotionState
{
public float accelerationX;
public float accelerationY;
public float accelerationZ;
public float angularVelocityX;
public float angularVelocityY;
public float angularVelocityZ;
public float magneticFieldX;
public float magneticFieldY;
public float magneticFieldZ;
public float orientationW;
public float orientationX;
public float orientationY;
public float orientationZ;
public int accelerometerAccuracy;
public int gyroscopeAccuracy;
public int magnetometerAccuracy;
public int orientationAccuracy;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure GameInputMotionState
Public accelerationX As Single
Public accelerationY As Single
Public accelerationZ As Single
Public angularVelocityX As Single
Public angularVelocityY As Single
Public angularVelocityZ As Single
Public magneticFieldX As Single
Public magneticFieldY As Single
Public magneticFieldZ As Single
Public orientationW As Single
Public orientationX As Single
Public orientationY As Single
Public orientationZ As Single
Public accelerometerAccuracy As Integer
Public gyroscopeAccuracy As Integer
Public magnetometerAccuracy As Integer
Public orientationAccuracy As Integer
End Structureimport ctypes
from ctypes import wintypes
class GameInputMotionState(ctypes.Structure):
_fields_ = [
("accelerationX", ctypes.c_float),
("accelerationY", ctypes.c_float),
("accelerationZ", ctypes.c_float),
("angularVelocityX", ctypes.c_float),
("angularVelocityY", ctypes.c_float),
("angularVelocityZ", ctypes.c_float),
("magneticFieldX", ctypes.c_float),
("magneticFieldY", ctypes.c_float),
("magneticFieldZ", ctypes.c_float),
("orientationW", ctypes.c_float),
("orientationX", ctypes.c_float),
("orientationY", ctypes.c_float),
("orientationZ", ctypes.c_float),
("accelerometerAccuracy", ctypes.c_int),
("gyroscopeAccuracy", ctypes.c_int),
("magnetometerAccuracy", ctypes.c_int),
("orientationAccuracy", ctypes.c_int),
]#[repr(C)]
pub struct GameInputMotionState {
pub accelerationX: f32,
pub accelerationY: f32,
pub accelerationZ: f32,
pub angularVelocityX: f32,
pub angularVelocityY: f32,
pub angularVelocityZ: f32,
pub magneticFieldX: f32,
pub magneticFieldY: f32,
pub magneticFieldZ: f32,
pub orientationW: f32,
pub orientationX: f32,
pub orientationY: f32,
pub orientationZ: f32,
pub accelerometerAccuracy: i32,
pub gyroscopeAccuracy: i32,
pub magnetometerAccuracy: i32,
pub orientationAccuracy: i32,
}import "golang.org/x/sys/windows"
type GameInputMotionState struct {
accelerationX float32
accelerationY float32
accelerationZ float32
angularVelocityX float32
angularVelocityY float32
angularVelocityZ float32
magneticFieldX float32
magneticFieldY float32
magneticFieldZ float32
orientationW float32
orientationX float32
orientationY float32
orientationZ float32
accelerometerAccuracy int32
gyroscopeAccuracy int32
magnetometerAccuracy int32
orientationAccuracy int32
}type
GameInputMotionState = record
accelerationX: Single;
accelerationY: Single;
accelerationZ: Single;
angularVelocityX: Single;
angularVelocityY: Single;
angularVelocityZ: Single;
magneticFieldX: Single;
magneticFieldY: Single;
magneticFieldZ: Single;
orientationW: Single;
orientationX: Single;
orientationY: Single;
orientationZ: Single;
accelerometerAccuracy: Integer;
gyroscopeAccuracy: Integer;
magnetometerAccuracy: Integer;
orientationAccuracy: Integer;
end;const GameInputMotionState = extern struct {
accelerationX: f32,
accelerationY: f32,
accelerationZ: f32,
angularVelocityX: f32,
angularVelocityY: f32,
angularVelocityZ: f32,
magneticFieldX: f32,
magneticFieldY: f32,
magneticFieldZ: f32,
orientationW: f32,
orientationX: f32,
orientationY: f32,
orientationZ: f32,
accelerometerAccuracy: i32,
gyroscopeAccuracy: i32,
magnetometerAccuracy: i32,
orientationAccuracy: i32,
};type
GameInputMotionState {.bycopy.} = object
accelerationX: float32
accelerationY: float32
accelerationZ: float32
angularVelocityX: float32
angularVelocityY: float32
angularVelocityZ: float32
magneticFieldX: float32
magneticFieldY: float32
magneticFieldZ: float32
orientationW: float32
orientationX: float32
orientationY: float32
orientationZ: float32
accelerometerAccuracy: int32
gyroscopeAccuracy: int32
magnetometerAccuracy: int32
orientationAccuracy: int32struct GameInputMotionState
{
float accelerationX;
float accelerationY;
float accelerationZ;
float angularVelocityX;
float angularVelocityY;
float angularVelocityZ;
float magneticFieldX;
float magneticFieldY;
float magneticFieldZ;
float orientationW;
float orientationX;
float orientationY;
float orientationZ;
int accelerometerAccuracy;
int gyroscopeAccuracy;
int magnetometerAccuracy;
int orientationAccuracy;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; GameInputMotionState サイズ: 68 バイト(x64)
dim st, 17 ; 4byte整数×17(構造体サイズ 68 / 4 切り上げ)
; accelerationX : FLOAT (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; accelerationY : FLOAT (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; accelerationZ : FLOAT (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; angularVelocityX : FLOAT (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; angularVelocityY : FLOAT (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; angularVelocityZ : FLOAT (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; magneticFieldX : FLOAT (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; magneticFieldY : FLOAT (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; magneticFieldZ : FLOAT (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; orientationW : FLOAT (+36, 4byte) st.9 = 値 / 値 = st.9 (lpoke/lpeek も可)
; orientationX : FLOAT (+40, 4byte) st.10 = 値 / 値 = st.10 (lpoke/lpeek も可)
; orientationY : FLOAT (+44, 4byte) st.11 = 値 / 値 = st.11 (lpoke/lpeek も可)
; orientationZ : FLOAT (+48, 4byte) st.12 = 値 / 値 = st.12 (lpoke/lpeek も可)
; accelerometerAccuracy : GameInputMotionAccuracy (+52, 4byte) st.13 = 値 / 値 = st.13 (lpoke/lpeek も可)
; gyroscopeAccuracy : GameInputMotionAccuracy (+56, 4byte) st.14 = 値 / 値 = st.14 (lpoke/lpeek も可)
; magnetometerAccuracy : GameInputMotionAccuracy (+60, 4byte) st.15 = 値 / 値 = st.15 (lpoke/lpeek も可)
; orientationAccuracy : GameInputMotionAccuracy (+64, 4byte) st.16 = 値 / 値 = st.16 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global GameInputMotionState
#field float accelerationX
#field float accelerationY
#field float accelerationZ
#field float angularVelocityX
#field float angularVelocityY
#field float angularVelocityZ
#field float magneticFieldX
#field float magneticFieldY
#field float magneticFieldZ
#field float orientationW
#field float orientationX
#field float orientationY
#field float orientationZ
#field int accelerometerAccuracy
#field int gyroscopeAccuracy
#field int magnetometerAccuracy
#field int orientationAccuracy
#endstruct
stdim st, GameInputMotionState ; NSTRUCT 変数を確保
st->accelerationX = 100
mes "accelerationX=" + st->accelerationX