1 | #ifndef NX_FOUNDATION_NXSTREAM
|
---|
2 | #define NX_FOUNDATION_NXSTREAM
|
---|
3 | /*----------------------------------------------------------------------------*\
|
---|
4 | |
|
---|
5 | | NovodeX Technology
|
---|
6 | |
|
---|
7 | | www.novodex.com
|
---|
8 | |
|
---|
9 | \*----------------------------------------------------------------------------*/
|
---|
10 | /** \addtogroup foundation
|
---|
11 | @{
|
---|
12 | */
|
---|
13 |
|
---|
14 | /**
|
---|
15 | \brief Callback class for data serialization.
|
---|
16 |
|
---|
17 | The user needs to supply an NnStream implimentation to a number of methods to allow the SDK to read or write
|
---|
18 | chunks of binary data. This allows flexibility for the source/destination of the data. For example the NxStream
|
---|
19 | could store data in a file, memory buffer or custom file format.
|
---|
20 |
|
---|
21 | \note It is the users resposibility to ensure that the data is written to the appropriate offset. NxStream does not
|
---|
22 | expose any seeking functionality.
|
---|
23 |
|
---|
24 | <h3>Example</h3>
|
---|
25 |
|
---|
26 | \include NxStream_Example.cpp
|
---|
27 |
|
---|
28 | @see NxPhysicsSDK.createTriangleMesh() NxPhysicsSDK.createConvexMesh() NxTriangleMesh.load()
|
---|
29 |
|
---|
30 | */
|
---|
31 | class NxStream
|
---|
32 | {
|
---|
33 | public:
|
---|
34 | /**
|
---|
35 | \brief Empty constructor.
|
---|
36 | */
|
---|
37 |
|
---|
38 | NxStream() {}
|
---|
39 | /**
|
---|
40 | \brief Virtual destructor.
|
---|
41 | */
|
---|
42 |
|
---|
43 | virtual ~NxStream() {}
|
---|
44 |
|
---|
45 | // Loading API
|
---|
46 |
|
---|
47 | /**
|
---|
48 | \brief Called to read a single unsigned byte(8 bits)
|
---|
49 |
|
---|
50 | \return Byte read.
|
---|
51 | */
|
---|
52 | virtual NxU8 readByte() const = 0;
|
---|
53 |
|
---|
54 | /**
|
---|
55 | \brief Called to read a single unsigned word(16 bits)
|
---|
56 |
|
---|
57 | \return Word read.
|
---|
58 | */
|
---|
59 | virtual NxU16 readWord() const = 0;
|
---|
60 |
|
---|
61 | /**
|
---|
62 | \brief Called to read a single unsigned dword(32 bits)
|
---|
63 |
|
---|
64 | \return DWord read.
|
---|
65 | */
|
---|
66 | virtual NxU32 readDword() const = 0;
|
---|
67 |
|
---|
68 | /**
|
---|
69 | \brief Called to read a single precision floating point value(32 bits)
|
---|
70 |
|
---|
71 | \return Floating point value read.
|
---|
72 | */
|
---|
73 | virtual NxF32 readFloat() const = 0;
|
---|
74 |
|
---|
75 | /**
|
---|
76 | \brief Called to read a double precision floating point value(64 bits)
|
---|
77 |
|
---|
78 | \return Floating point value read.
|
---|
79 | */
|
---|
80 | virtual NxF64 readDouble() const = 0;
|
---|
81 |
|
---|
82 | /**
|
---|
83 | \brief Called to read a number of bytes.
|
---|
84 |
|
---|
85 | \param[out] buffer Buffer to read bytes into, must be at least size bytes in size.
|
---|
86 | \param[in] size The size of the buffer in bytes.
|
---|
87 | */
|
---|
88 | virtual void readBuffer(void* buffer, NxU32 size) const = 0;
|
---|
89 |
|
---|
90 | // Saving API
|
---|
91 |
|
---|
92 | /**
|
---|
93 | \brief Called to write a single unsigned byte to the stream(8 bits).
|
---|
94 |
|
---|
95 | \param b Byte to store.
|
---|
96 | \return Reference to the current NxStream object.
|
---|
97 | */
|
---|
98 | virtual NxStream& storeByte(NxU8 b) = 0;
|
---|
99 |
|
---|
100 | /**
|
---|
101 | \brief Called to write a single unsigned word to the stream(16 bits).
|
---|
102 |
|
---|
103 | \param w World to store.
|
---|
104 | \return Reference to the current NxStream object.
|
---|
105 | */
|
---|
106 | virtual NxStream& storeWord(NxU16 w) = 0;
|
---|
107 |
|
---|
108 | /**
|
---|
109 | \brief Called to write a single unsigned dword to the stream(32 bits).
|
---|
110 |
|
---|
111 | \param d DWord to store.
|
---|
112 | \return Reference to the current NxStream object.
|
---|
113 | */
|
---|
114 | virtual NxStream& storeDword(NxU32 d) = 0;
|
---|
115 |
|
---|
116 | /**
|
---|
117 | \brief Called to write a single precision floating point value to the stream(32 bits).
|
---|
118 |
|
---|
119 | \param f floating point value to store.
|
---|
120 | \return Reference to the current NxStream object.
|
---|
121 | */
|
---|
122 | virtual NxStream& storeFloat(NxF32 f) = 0;
|
---|
123 |
|
---|
124 | /**
|
---|
125 | \brief Called to write a double precision floating point value to the stream(64 bits).
|
---|
126 |
|
---|
127 | \param f floating point value to store.
|
---|
128 | \return Reference to the current NxStream object.
|
---|
129 | */
|
---|
130 | virtual NxStream& storeDouble(NxF64 f) = 0;
|
---|
131 |
|
---|
132 | /**
|
---|
133 | \brief Called to write an array of bytes to the stream.
|
---|
134 |
|
---|
135 | \param[in] buffer Array of bytes, size bytes in size.
|
---|
136 | \param[in] size Size, in bytes of buffer.
|
---|
137 | \return Reference to the current NxStream object.
|
---|
138 | */
|
---|
139 | virtual NxStream& storeBuffer(const void* buffer, NxU32 size) = 0;
|
---|
140 |
|
---|
141 |
|
---|
142 | /**
|
---|
143 | \brief Store a signed byte(wrapper for the unsigned version).
|
---|
144 |
|
---|
145 | \param b Byte to store.
|
---|
146 | \return Reference to the current NxStream object.
|
---|
147 | */
|
---|
148 | NX_INLINE NxStream& storeByte(NxI8 b) { return storeByte(NxU8(b)); }
|
---|
149 |
|
---|
150 | /**
|
---|
151 | \brief Store a signed word(wrapper for the unsigned version).
|
---|
152 |
|
---|
153 | \param w Word to store.
|
---|
154 | \return Reference to the current NxStream object.
|
---|
155 | */
|
---|
156 | NX_INLINE NxStream& storeWord(NxI16 w) { return storeWord(NxU16(w)); }
|
---|
157 |
|
---|
158 | /**
|
---|
159 | \brief Store a signed dword(wrapper for the unsigned version).
|
---|
160 |
|
---|
161 | \param d DWord to store.
|
---|
162 | \return Reference to the current NxStream object.
|
---|
163 | */
|
---|
164 | NX_INLINE NxStream& storeDword(NxI32 d) { return storeDword(NxU32(d)); }
|
---|
165 | };
|
---|
166 |
|
---|
167 | /** @} */
|
---|
168 | #endif
|
---|
169 |
|
---|
170 |
|
---|
171 | //AGCOPYRIGHTBEGIN
|
---|
172 | ///////////////////////////////////////////////////////////////////////////
|
---|
173 | // Copyright © 2005 AGEIA Technologies.
|
---|
174 | // All rights reserved. www.ageia.com
|
---|
175 | ///////////////////////////////////////////////////////////////////////////
|
---|
176 | //AGCOPYRIGHTEND
|
---|
177 |
|
---|