Mach1 Spatial SDK
Loading...
Searching...
No Matches
Mach1DecodePositionalCore.h
1// Mach1 Spatial SDK
2// Copyright © 2017 Mach1. All rights reserved.
3
4/*
5DISCLAIMER:
6This header file is not an example of use but an decoder that will require periodic
7updates and should not be integrated in sections but remain as an update-able factored file.
8*/
9
10#pragma once
11
12#include "Mach1DecodeCore.h"
13#include <string>
14
15#define GLM_ENABLE_EXPERIMENTAL
16#include <glm/gtc/matrix_transform.hpp>
17#include <glm/gtx/quaternion.hpp>
18#include <glm/mat4x4.hpp>
19#include <glm/vec3.hpp>
20#include <glm/vec4.hpp>
21
22#ifndef RAD_TO_DEG_F
23# define RAD_TO_DEG_F (180.0f / PI_F)
24#endif
25
26#ifndef DEG_TO_RAD_F
27# define DEG_TO_RAD_F (PI_F / 180.0f)
28#endif
29
30#ifndef PI_F
31# define PI_F 3.14159265358979323846f
32#endif
33
35
36 private:
37 M1DecodeCore mach1Decode;
38
39 bool useFalloff = false;
40 float falloffCurve;
41
42 bool muteWhenInsideObject = false;
43 bool muteWhenOutsideObject = false;
44 bool useClosestPointRotationMuteInside = false;
45
46 bool useYawForRotation = true;
47 bool usePitchForRotation = true;
48 bool useRollForRotation = true;
49
50 glm::vec3 cameraPosition;
51 glm::quat cameraRotation;
52
53 glm::vec3 soundPosition;
54 glm::quat soundRotation;
55 glm::vec3 soundScale;
56
57 static void ConvertPositionToMach1(Mach1PlatformType platformType, float *X, float *Y, float *Z);
58 static void ConvertPositionToPlatform(Mach1PlatformType platformType, float *X, float *Y, float *Z);
59
60 static float ClosestPointOnBox(glm::vec3 point, glm::vec3 center, glm::vec3 axis0, glm::vec3 axis1, glm::vec3 axis2, glm::vec3 extents, glm::vec3 &closestPoint);
61 static bool Clip(float denom, float numer, float &t0, float &t1);
62 static int DoClipping(float t0, float t1, glm::vec3 origin, glm::vec3 direction, glm::vec3 center, glm::vec3 axis0, glm::vec3 axis1, glm::vec3 axis2, glm::vec3 extents, bool solid, glm::vec3 &point0, glm::vec3 &point1);
63
64 static glm::vec3 QuaternionToEuler(glm::quat q);
65 static glm::quat EulerToQuaternion(glm::vec3 euler);
66
67 Mach1PlatformType platformType;
68 Mach1DecodeMode decodeMode;
69
70 static glm::vec3 GetRightVector();
71 static glm::vec3 GetUpVector();
72 static glm::vec3 GetForwardVector();
73
74 float gain;
75 float dist;
76 glm::vec3 eulerAngles;
77 glm::vec3 eulerAnglesCube;
78
79 std::vector<float> coeffs;
80
81 milliseconds ms;
82 long timeLastCalculation;
83
84 glm::vec3 closestPointOnPlane;
85
86 public:
88
89 void setDecodeMode(Mach1DecodeMode mode);
90 void setPlatformType(Mach1PlatformType type);
91
92 // settings
93 void setUseAttenuation(bool useAttenuation);
94 void setAttenuationCurve(float attenuationCurve);
95
96 void setMuteWhenOutsideObject(bool muteWhenOutsideObject);
97 void setMuteWhenInsideObject(bool muteWhenInsideObject);
98
99 void setUsePlaneCalculation(bool usePlaneCalculation);
100
101 void setUseYawForRotation(bool useYawForRotation);
102 void setUsePitchForRotation(bool usePitchForRotation);
103 void setUseRollForRotation(bool useRollForRotation);
104
105 // parameters for algo
106 void setListenerPosition(Mach1Point3D *pos);
107 void setListenerRotation(Mach1Point3D *euler);
108 void setListenerRotationQuat(Mach1Point4D *quat);
109
110 void setDecoderAlgoPosition(Mach1Point3D *pos);
111 void setDecoderAlgoRotation(Mach1Point3D *euler);
112 void setDecoderAlgoRotationQuat(Mach1Point4D *quat);
113 void setDecoderAlgoScale(Mach1Point3D *scale);
114
115 void evaluatePositionResults();
116
117 void getCoefficients(float *result);
118
119 float getDist();
120
121 int getFormatChannelCount();
122 int getFormatCoeffCount();
123
124 Mach1Point3D getCurrentAngle();
125 Mach1Point3D getCurrentAngleInternal();
126 Mach1Point3D getPositionalRotation();
127
128 Mach1Point3D getClosestPointOnPlane();
129
130 void setFilterSpeed(float filterSpeed);
131
132 long getCurrentTime();
133 long getLastCalculationTime();
134};
Definition Mach1DecodeCore.h:42
Definition Mach1DecodePositionalCore.h:34
Definition Mach1Point3D.h:17
Definition Mach1Point4D.h:15