Blender  V3.3
Classes | Macros
GHOST_XrControllerModel.cpp File Reference
#include <cassert>
#include <Eigen/Core>
#include <Eigen/Geometry>
#include "GHOST_Types.h"
#include "GHOST_XrException.h"
#include "GHOST_Xr_intern.h"
#include "GHOST_XrControllerModel.h"
#include "tiny_gltf.h"

Go to the source code of this file.

Classes

struct  GHOST_XrControllerModelNode
 
struct  GHOST_XrPrimitive
 

Macros

#define TINYGLTF_IMPLEMENTATION
 
#define TINYGLTF_NO_STB_IMAGE
 
#define TINYGLTF_NO_STB_IMAGE_WRITE
 
#define STBIWDEF   static inline
 

Functions

glTF Utilities

Adapted from Microsoft OpenXR-Mixed Reality Samples (MIT License): https://github.com/microsoft/OpenXR-MixedReality

static void validate_accessor (const tinygltf::Accessor &accessor, const tinygltf::BufferView &buffer_view, const tinygltf::Buffer &buffer, size_t byte_stride, size_t element_size)
 
template<float(GHOST_XrControllerModelVertex::*) field>
static void read_vertices (const tinygltf::Accessor &accessor, const tinygltf::BufferView &buffer_view, const tinygltf::Buffer &buffer, GHOST_XrPrimitive &primitive)
 
static void load_attribute_accessor (const tinygltf::Model &gltf_model, const std::string &attribute_name, int accessor_id, GHOST_XrPrimitive &primitive)
 
template<typename TSrcIndex >
static void read_indices (const tinygltf::Accessor &accessor, const tinygltf::BufferView &buffer_view, const tinygltf::Buffer &buffer, GHOST_XrPrimitive &primitive)
 
static void load_index_accessor (const tinygltf::Model &gltf_model, const tinygltf::Accessor &accessor, GHOST_XrPrimitive &primitive)
 
static GHOST_XrPrimitive read_primitive (const tinygltf::Model &gltf_model, const tinygltf::Primitive &gltf_primitive)
 
static void calc_node_transforms (const tinygltf::Node &gltf_node, const float parent_transform[4][4], float r_local_transform[4][4], float r_world_transform[4][4])
 
static void load_node (const tinygltf::Model &gltf_model, int gltf_node_id, int32_t parent_idx, const float parent_transform[4][4], const std::string &parent_name, const std::vector< XrControllerModelNodePropertiesMSFT > &node_properties, std::vector< GHOST_XrControllerModelVertex > &vertices, std::vector< uint32_t > &indices, std::vector< GHOST_XrControllerModelComponent > &components, std::vector< GHOST_XrControllerModelNode > &nodes, std::vector< int32_t > &node_state_indices)
 

OpenXR Extension Functions

#define INIT_EXTENSION_FUNCTION(name)
 
static PFN_xrGetControllerModelKeyMSFT g_xrGetControllerModelKeyMSFT = nullptr
 
static PFN_xrLoadControllerModelMSFT g_xrLoadControllerModelMSFT = nullptr
 
static PFN_xrGetControllerModelPropertiesMSFT g_xrGetControllerModelPropertiesMSFT = nullptr
 
static PFN_xrGetControllerModelStateMSFT g_xrGetControllerModelStateMSFT = nullptr
 
static XrInstance g_instance = XR_NULL_HANDLE
 
static void init_controller_model_extension_functions (XrInstance instance)
 

Macro Definition Documentation

◆ INIT_EXTENSION_FUNCTION

#define INIT_EXTENSION_FUNCTION (   name)
Value:
xrGetInstanceProcAddr(instance, #name, reinterpret_cast<PFN_xrVoidFunction *>(&g_##name)), \
"Failed to get pointer to extension function: " #name);
#define CHECK_XR(call, error_msg)
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object instance

Definition at line 375 of file GHOST_XrControllerModel.cpp.

◆ STBIWDEF

#define STBIWDEF   static inline

Definition at line 21 of file GHOST_XrControllerModel.cpp.

◆ TINYGLTF_IMPLEMENTATION

#define TINYGLTF_IMPLEMENTATION

Definition at line 18 of file GHOST_XrControllerModel.cpp.

◆ TINYGLTF_NO_STB_IMAGE

#define TINYGLTF_NO_STB_IMAGE

Definition at line 19 of file GHOST_XrControllerModel.cpp.

◆ TINYGLTF_NO_STB_IMAGE_WRITE

#define TINYGLTF_NO_STB_IMAGE_WRITE

Definition at line 20 of file GHOST_XrControllerModel.cpp.

Function Documentation

◆ calc_node_transforms()

static void calc_node_transforms ( const tinygltf::Node &  gltf_node,
const float  parent_transform[4][4],
float  r_local_transform[4][4],
float  r_world_transform[4][4] 
)
static

Calculate node local and world transforms.

Definition at line 224 of file GHOST_XrControllerModel.cpp.

References float().

Referenced by load_node().

◆ init_controller_model_extension_functions()

static void init_controller_model_extension_functions ( XrInstance  instance)
static

◆ load_attribute_accessor()

static void load_attribute_accessor ( const tinygltf::Model &  gltf_model,
const std::string &  attribute_name,
int  accessor_id,
GHOST_XrPrimitive primitive 
)
static

Definition at line 97 of file GHOST_XrControllerModel.cpp.

References buffer.

Referenced by read_primitive().

◆ load_index_accessor()

static void load_index_accessor ( const tinygltf::Model &  gltf_model,
const tinygltf::Accessor &  accessor,
GHOST_XrPrimitive primitive 
)
static

Reads index data from a glTF primitive into a GHOST_XrPrimitive.

Definition at line 168 of file GHOST_XrControllerModel.cpp.

References buffer.

Referenced by read_primitive().

◆ load_node()

static void load_node ( const tinygltf::Model &  gltf_model,
int  gltf_node_id,
int32_t  parent_idx,
const float  parent_transform[4][4],
const std::string &  parent_name,
const std::vector< XrControllerModelNodePropertiesMSFT > &  node_properties,
std::vector< GHOST_XrControllerModelVertex > &  vertices,
std::vector< uint32_t > &  indices,
std::vector< GHOST_XrControllerModelComponent > &  components,
std::vector< GHOST_XrControllerModelNode > &  nodes,
std::vector< int32_t > &  node_state_indices 
)
static

◆ read_indices()

template<typename TSrcIndex >
static void read_indices ( const tinygltf::Accessor &  accessor,
const tinygltf::BufferView &  buffer_view,
const tinygltf::Buffer buffer,
GHOST_XrPrimitive primitive 
)
static

Reads index data from a glTF primitive into a GHOST_XrPrimitive. glTF indices may be 8bit, 16bit or 32bit integers. This will coalesce indices from the source type(s) into a 32bit integer.

Definition at line 131 of file GHOST_XrControllerModel.cpp.

References buffer, GHOST_XrPrimitive::indices, and validate_accessor().

◆ read_primitive()

static GHOST_XrPrimitive read_primitive ( const tinygltf::Model &  gltf_model,
const tinygltf::Primitive &  gltf_primitive 
)
static

Definition at line 197 of file GHOST_XrControllerModel.cpp.

References load_attribute_accessor(), and load_index_accessor().

Referenced by load_node().

◆ read_vertices()

template<float(GHOST_XrControllerModelVertex::*) field>
static void read_vertices ( const tinygltf::Accessor &  accessor,
const tinygltf::BufferView &  buffer_view,
const tinygltf::Buffer buffer,
GHOST_XrPrimitive primitive 
)
static

◆ validate_accessor()

static void validate_accessor ( const tinygltf::Accessor &  accessor,
const tinygltf::BufferView &  buffer_view,
const tinygltf::Buffer buffer,
size_t  byte_stride,
size_t  element_size 
)
static

Validate that an accessor does not go out of bounds of the buffer view that it references and that the buffer view does not exceed the bounds of the buffer that it references

Definition at line 46 of file GHOST_XrControllerModel.cpp.

References buffer.

Referenced by read_indices(), and read_vertices().

Variable Documentation

◆ g_instance

XrInstance g_instance = XR_NULL_HANDLE
static

◆ g_xrGetControllerModelKeyMSFT

PFN_xrGetControllerModelKeyMSFT g_xrGetControllerModelKeyMSFT = nullptr
static

◆ g_xrGetControllerModelPropertiesMSFT

PFN_xrGetControllerModelPropertiesMSFT g_xrGetControllerModelPropertiesMSFT = nullptr
static

◆ g_xrGetControllerModelStateMSFT

PFN_xrGetControllerModelStateMSFT g_xrGetControllerModelStateMSFT = nullptr
static

◆ g_xrLoadControllerModelMSFT

PFN_xrLoadControllerModelMSFT g_xrLoadControllerModelMSFT = nullptr
static