1/****************************************************************************************
2
3 Copyright (C) 2015 Autodesk, Inc.
4 All rights reserved.
5
6 Use of this software is subject to the terms of the Autodesk license agreement
7 provided at the time of installation or download, or which otherwise accompanies
8 this software in either electronic or hard copy form.
9
10****************************************************************************************/
11
12/** \file fbxtypes.h
13 * Basic types definition.
14 *
15 * Standard basic types used across the FBX SDK. There is also platform independent
16 * definitions that guarantee size across operating systems. The FBXSDK_SYSTEM_IS_LP64
17 * define is set to 1 when the operating system defines the "long" C++ type as 64-bit.
18 */
19#ifndef _FBXSDK_CORE_ARCH_TYPES_H_
20#define _FBXSDK_CORE_ARCH_TYPES_H_
21
22#include <fbxsdk/core/arch/fbxarch.h>
23
24//Note: On MacOSX and Linux 64-bit, long is defined as 64-bits while on Windows
25//it is still a 32-bits for backward compatibility. We stick with Windows standard.
26#if defined(FBXSDK_CPU_64) && !defined(FBXSDK_ENV_WIN)
27 #define FBXSDK_SYSTEM_IS_LP64 1
28#endif
29
30#include <fbxsdk/fbxsdk_nsbegin.h>
31
32class FbxObject;
33
34typedef bool FbxBool;
35typedef signed char FbxChar;
36typedef unsigned char FbxUChar;
37typedef signed short FbxShort;
38typedef unsigned short FbxUShort;
39typedef signed int FbxInt;
40typedef unsigned int FbxUInt;
41typedef float FbxFloat;
42typedef double FbxDouble;
43
44typedef FbxBool* FbxBoolPtr;
45typedef FbxChar* FbxCharPtr;
46typedef FbxUChar* FbxUCharPtr;
47typedef FbxShort* FbxShortPtr;
48typedef FbxUShort* FbxUShortPtr;
49typedef FbxInt* FbxIntPtr;
50typedef FbxUInt* FbxUIntPtr;
51typedef FbxFloat* FbxFloatPtr;
52typedef FbxDouble* FbxDoublePtr;
53
54typedef FbxInt FbxEnum;
55typedef FbxObject* FbxReference;
56
57//-------------------------------------------------------------------------------------
58//Architecture independent defines (guarantee size)
59#if defined(FBXSDK_COMPILER_MSC)
60 #define FBXSDK_LONGLONG(x) (x##i64)
61 #define FBXSDK_ULONGLONG(x) (x##Ui64)
62
63 typedef signed __int8 FbxInt8;
64 typedef unsigned __int8 FbxUInt8;
65 typedef signed __int16 FbxInt16;
66 typedef unsigned __int16 FbxUInt16;
67 typedef signed __int32 FbxInt32;
68 typedef unsigned __int32 FbxUInt32;
69 typedef signed __int64 FbxInt64;
70 typedef unsigned __int64 FbxUInt64;
71#else
72 #define FBXSDK_LONGLONG(x) (x##LL)
73 #define FBXSDK_ULONGLONG(x) (x##ULL)
74
75 typedef signed char FbxInt8;
76 typedef unsigned char FbxUInt8;
77 typedef signed short FbxInt16;
78 typedef unsigned short FbxUInt16;
79 typedef signed int FbxInt32;
80 typedef unsigned int FbxUInt32;
81 typedef signed long long FbxInt64;
82 typedef unsigned long long FbxUInt64;
83#endif
84
85#ifdef FBXSDK_SYSTEM_IS_LP64
86 typedef signed int FbxLong;
87 typedef unsigned int FbxULong;
88#else
89 typedef signed long FbxLong;
90 typedef unsigned long FbxULong;
91#endif
92typedef FbxInt64 FbxLongLong;
93typedef FbxUInt64 FbxULongLong;
94
95typedef FbxLong* FbxLongPtr;
96typedef FbxULong* FbxULongPtr;
97typedef FbxLongLong* FbxLongLongPtr;
98typedef FbxULongLong* FbxULongLongPtr;
99
100
101#if defined(FBXSDK_ENV_EMSCRIPTEN)
102 typedef FbxInt32 __int32_t;
103 typedef FbxUInt32 __uint32_t;
104 typedef FbxInt64 __int64_t;
105 typedef FbxUInt64 __uint64_t;
106#endif
107
108//-------------------------------------------------------------------------------------
109//Minimum and Maximum values for types
110#define FBXSDK_CHAR_MIN -128
111#define FBXSDK_CHAR_MAX 127
112#define FBXSDK_UCHAR_MIN 0
113#define FBXSDK_UCHAR_MAX 255
114#define FBXSDK_SHORT_MIN -32768
115#define FBXSDK_SHORT_MAX 32767
116#define FBXSDK_USHORT_MIN 0
117#define FBXSDK_USHORT_MAX 65535
118#define FBXSDK_INT_MIN 0x80000000
119#define FBXSDK_INT_MAX 0x7fffffff
120#define FBXSDK_UINT_MIN 0
121#define FBXSDK_UINT_MAX 0xffffffff
122#define FBXSDK_LONG_MIN FBXSDK_INT_MIN
123#define FBXSDK_LONG_MAX FBXSDK_INT_MAX
124#define FBXSDK_ULONG_MIN FBXSDK_UINT_MIN
125#define FBXSDK_ULONG_MAX FBXSDK_UINT_MAX
126#define FBXSDK_LONGLONG_MIN FBXSDK_LONGLONG(0x8000000000000000)
127#define FBXSDK_LONGLONG_MAX FBXSDK_LONGLONG(0x7fffffffffffffff)
128#define FBXSDK_ULONGLONG_MIN FBXSDK_ULONGLONG(0)
129#define FBXSDK_ULONGLONG_MAX FBXSDK_ULONGLONG(0xffffffffffffffff)
130#define FBXSDK_FLOAT_MIN FLT_MIN
131#define FBXSDK_FLOAT_MAX FLT_MAX
132#define FBXSDK_FLOAT_EPSILON FLT_EPSILON
133#define FBXSDK_DOUBLE_MIN DBL_MIN
134#define FBXSDK_DOUBLE_MAX DBL_MAX
135#define FBXSDK_DOUBLE_EPSILON DBL_EPSILON
136#define FBXSDK_TOLERANCE (1.0e-6)
137
138//-------------------------------------------------------------------------------------
139//Handle and atomic definition (size change depending of architecture)
140#if defined(FBXSDK_CPU_32)
141 typedef FbxUInt32 FbxHandle;
142 #define FBXSDK_REF_MIN FBXSDK_UINT_MIN
143 #define FBXSDK_REF_MAX FBXSDK_UINT_MAX
144
145 typedef FbxLong FbxAtomic;
146 #define FBXSDK_ATOMIC_MIN FBXSDK_LONG_MIN
147 #define FBXSDK_ATOMIC_MAX FBXSDK_LONG_MAX
148#elif defined(FBXSDK_CPU_64)
149 typedef FbxUInt64 FbxHandle;
150 #define FBXSDK_REF_MIN FBXSDK_ULONGLONG_MIN
151 #define FBXSDK_REF_MAX FBXSDK_ULONGLONG_MAX
152
153 typedef FbxInt64 FbxAtomic;
154 #define FBXSDK_ATOMIC_MIN FBXSDK_LONGLONG_MIN
155 #define FBXSDK_ATOMIC_MAX FBXSDK_LONGLONG_MAX
156#else
157 #error Unsupported architecture!
158#endif
159
160//-------------------------------------------------------------------------------------
161//Various utility functions for fbxsdk basic types
162inline const FbxChar FbxMin(const FbxChar){ return FBXSDK_CHAR_MIN; }
163inline const FbxUChar FbxMin(const FbxUChar){ return FBXSDK_UCHAR_MIN; }
164inline const FbxShort FbxMin(const FbxShort){ return FBXSDK_SHORT_MIN; }
165inline const FbxUShort FbxMin(const FbxUShort){ return FBXSDK_USHORT_MIN; }
166inline const FbxInt FbxMin(const FbxInt){ return FBXSDK_INT_MIN; }
167inline const FbxUInt FbxMin(const FbxUInt){ return FBXSDK_UINT_MIN; }
168inline const FbxLongLong FbxMin(const FbxLongLong){ return FBXSDK_LONGLONG_MIN; }
169inline const FbxULongLong FbxMin(const FbxULongLong){ return FBXSDK_ULONGLONG_MIN; }
170inline const FbxFloat FbxMin(const FbxFloat){ return FBXSDK_FLOAT_MIN; }
171inline const FbxDouble FbxMin(const FbxDouble){ return FBXSDK_DOUBLE_MIN; }
172
173inline const FbxChar FbxMax(const FbxChar){ return FBXSDK_CHAR_MAX; }
174inline const FbxUChar FbxMax(const FbxUChar){ return FBXSDK_UCHAR_MAX; }
175inline const FbxShort FbxMax(const FbxShort){ return FBXSDK_SHORT_MAX; }
176inline const FbxUShort FbxMax(const FbxUShort){ return FBXSDK_USHORT_MAX; }
177inline const FbxInt FbxMax(const FbxInt){ return FBXSDK_INT_MAX; }
178inline const FbxUInt FbxMax(const FbxUInt){ return FBXSDK_UINT_MAX; }
179inline const FbxLongLong FbxMax(const FbxLongLong){ return FBXSDK_LONGLONG_MAX; }
180inline const FbxULongLong FbxMax(const FbxULongLong){ return FBXSDK_ULONGLONG_MAX; }
181inline const FbxFloat FbxMax(const FbxFloat){ return FBXSDK_FLOAT_MAX; }
182inline const FbxDouble FbxMax(const FbxDouble){ return FBXSDK_DOUBLE_MAX; }
183
184#ifndef FBXSDK_SYSTEM_IS_LP64
185 inline const FbxLong FbxMin(const FbxLong){ return FBXSDK_LONG_MIN; }
186 inline const FbxULong FbxMin(const FbxULong){ return FBXSDK_ULONG_MIN; }
187 inline const FbxLong FbxMax(const FbxLong){ return FBXSDK_LONG_MAX; }
188 inline const FbxULong FbxMax(const FbxULong){ return FBXSDK_ULONG_MAX; }
189#endif
190
191template<class T> inline const T FbxMin(const T){};
192template<class T> inline const T FbxMax(const T){};
193
194template<class T> inline T FbxMin(const T x, const T y){ return (x < y) ? x : y; }
195template<class T> inline T FbxMax(const T x, const T y){ return (x > y) ? x : y; }
196
197//-------------------------------------------------------------------------------------
198//Vector Template Types
199template<class T> class FBXSDK_DLL FbxVectorTemplate2
200{
201public:
202 inline FbxVectorTemplate2(){ *this = T(0); }
203 inline explicit FbxVectorTemplate2(T pValue){ *this = pValue; }
204 inline FbxVectorTemplate2(T pData0, T pData1){ mData[0] = pData0; mData[1] = pData1; }
205 inline ~FbxVectorTemplate2(){}
206 inline T& operator[](int pIndex){ return mData[pIndex]; }
207 inline const T& operator[](int pIndex) const { return mData[pIndex]; }
208 inline FbxVectorTemplate2<T>& operator=(const T& pValue){ mData[0] = pValue; mData[1] = pValue; return *this; }
209 inline FbxVectorTemplate2<T>& operator=(const FbxVectorTemplate2<T>& pVector){ mData[0] = pVector.mData[0]; mData[1] = pVector.mData[1]; return *this; }
210 inline bool operator==(const FbxVectorTemplate2<T>& pVector) const { return ((mData[0] == pVector.mData[0]) && (mData[1] == pVector.mData[1])); }
211 inline bool operator!=(const FbxVectorTemplate2<T>& pVector) const { return !operator==( pVector ); }
212 inline T* Buffer(){ return mData; }
213 inline const T* Buffer() const { return mData; }
214 T mData[2];
215};
216
217template<class T> class FBXSDK_DLL FbxVectorTemplate3
218{
219public:
220 inline FbxVectorTemplate3(){ *this = T(0); }
221 inline explicit FbxVectorTemplate3(T pValue){ *this = pValue; }
222 inline FbxVectorTemplate3(T pData0, T pData1, T pData2){ mData[0] = pData0; mData[1] = pData1; mData[2] = pData2; }
223 inline ~FbxVectorTemplate3(){}
224 inline T& operator[](int pIndex) { return mData[pIndex]; }
225 inline const T& operator[](int pIndex) const { return mData[pIndex]; }
226 inline operator FbxVectorTemplate2<T>& () const { return *((FbxVectorTemplate2<T>*)this); }
227 inline FbxVectorTemplate3<T>& operator=(T const &pValue){ mData[0] = pValue; mData[1] = pValue; mData[2] = pValue; return *this; }
228 inline FbxVectorTemplate3<T>& operator=(const FbxVectorTemplate2<T>& pVector){ mData[0] = pVector.mData[0]; mData[1] = pVector.mData[1]; return *this; }
229 inline FbxVectorTemplate3<T>& operator=(const FbxVectorTemplate3<T>& pVector){ mData[0] = pVector.mData[0]; mData[1] = pVector.mData[1]; mData[2] = pVector.mData[2]; return *this; }
230 inline bool operator==(const FbxVectorTemplate3<T>& pVector) const { return ((mData[0] == pVector.mData[0]) && (mData[1] == pVector.mData[1]) && (mData[2] == pVector.mData[2])); }
231 inline bool operator!=(const FbxVectorTemplate3<T>& pVector) const { return !operator==(pVector); }
232 inline T* Buffer(){ return mData; }
233 inline const T* Buffer() const { return mData; }
234 T mData[3];
235};
236
237template<class T> class FBXSDK_DLL FbxVectorTemplate4
238{
239public:
240 inline FbxVectorTemplate4(){ *this = T(0); }
241 inline explicit FbxVectorTemplate4(T pValue){ *this = pValue; }
242 inline FbxVectorTemplate4(T pData0, T pData1, T pData2, T pData3){ mData[0] = pData0; mData[1] = pData1; mData[2] = pData2; mData[3] = pData3; }
243 inline ~FbxVectorTemplate4(){}
244 inline T& operator[](int pIndex){ return mData[pIndex]; }
245 inline const T& operator[](int pIndex) const { return mData[pIndex]; }
246 inline operator FbxVectorTemplate3<T>& () const { return *((FbxVectorTemplate3<T>*)this); }
247 inline FbxVectorTemplate4<T>& operator=(const T& pValue){ mData[0] = pValue; mData[1] = pValue; mData[2] = pValue; mData[3] = pValue; return *this; }
248 inline FbxVectorTemplate4<T>& operator=(const FbxVectorTemplate3<T>& pValue){ mData[0] = pValue[0]; mData[1] = pValue[1]; mData[2] = pValue[2]; return *this; }
249 inline FbxVectorTemplate4<T>& operator=(const FbxVectorTemplate4<T>& pVector){ mData[0] = pVector.mData[0]; mData[1] = pVector.mData[1]; mData[2] = pVector.mData[2]; mData[3] = pVector.mData[3]; return *this; }
250 inline bool operator==(const FbxVectorTemplate4<T>& pVector) const { return ((mData[0] == pVector.mData[0]) && (mData[1] == pVector.mData[1]) && (mData[2] == pVector.mData[2]) && (mData[3] == pVector.mData[3])); }
251 inline bool operator!=(const FbxVectorTemplate4<T>& pVector) const { return !operator==( pVector ); }
252 inline T* Buffer(){ return mData; }
253 inline const T* Buffer() const { return mData; }
254 T mData[4];
255};
256
257typedef FbxVectorTemplate2<FbxDouble> FbxDouble2;
258typedef FbxVectorTemplate3<FbxDouble> FbxDouble3;
259typedef FbxVectorTemplate4<FbxDouble> FbxDouble4;
260typedef FbxVectorTemplate4<FbxDouble4> FbxDouble4x4;
261
262#include <fbxsdk/fbxsdk_nsend.h>
263
264#endif /* _FBXSDK_CORE_ARCH_TYPES_H_ */
265