Blender V4.3
GHOST_XrControllerModel.cc File Reference
#include <cassert>
#include <Eigen/Core>
#include <Eigen/Geometry>
#include "GHOST_Types.h"
#include "GHOST_XrException.hh"
#include "GHOST_Xr_intern.hh"
#include "GHOST_XrControllerModel.hh"
#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

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

◆ STBIWDEF

#define STBIWDEF   static inline

Definition at line 23 of file GHOST_XrControllerModel.cc.

◆ TINYGLTF_IMPLEMENTATION

#define TINYGLTF_IMPLEMENTATION

Definition at line 20 of file GHOST_XrControllerModel.cc.

◆ TINYGLTF_NO_STB_IMAGE

#define TINYGLTF_NO_STB_IMAGE

Definition at line 21 of file GHOST_XrControllerModel.cc.

◆ TINYGLTF_NO_STB_IMAGE_WRITE

#define TINYGLTF_NO_STB_IMAGE_WRITE

Definition at line 22 of file GHOST_XrControllerModel.cc.

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 226 of file GHOST_XrControllerModel.cc.

References float.

Referenced by load_node().

◆ init_controller_model_extension_functions()

◆ 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 100 of file GHOST_XrControllerModel.cc.

References read_vertices().

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 170 of file GHOST_XrControllerModel.cc.

References read_indices().

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 134 of file GHOST_XrControllerModel.cc.

References GHOST_XrPrimitive::indices, and validate_accessor().

Referenced by load_index_accessor().

◆ read_primitive()

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

Definition at line 199 of file GHOST_XrControllerModel.cc.

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 48 of file GHOST_XrControllerModel.cc.

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