├── .gitattributes
├── .gitignore
├── Dependencies
├── CrossDomainPolicyParser.dll
├── ICSharpCode.NRefactory.dll
├── Mono.Cecil.Mdb.dll
├── Mono.Cecil.Pdb.dll
├── Mono.Cecil.dll
├── Unity.CecilTools.dll
├── Unity.DataContract.dll
├── Unity.IvyParser.dll
├── Unity.IvyParser.dll.mdb
├── Unity.Locator.dll
├── Unity.Locator.dll.mdb
├── Unity.SerializationLogic.dll
├── Unity.UNetWeaver.dll
├── Unity.UNetWeaver.dll.mdb
├── UnityEditor.Graphs.dll
├── UnityEditor.Graphs.dll.mdb
├── UnityEditor.dll
├── UnityEditor.dll.mdb
├── UnityEditor.xml
├── UnityEngine.dll
├── UnityEngine.dll.mdb
├── UnityEngine.xml
├── nunit.core.dll
├── nunit.core.interfaces.dll
├── nunit.framework.dll
├── protobuf-net.dll
├── protobuf-net.xml
└── x64
│ └── fbxImporter.dll
├── OutputLib
├── Debug
│ ├── ICSharpCode.NRefactory.dll
│ ├── Jhqc.UnityFbxLoader.dll
│ ├── Jhqc.UnityFbxLoader.dll.mdb
│ ├── Mono.Cecil.Mdb.dll
│ ├── Mono.Cecil.Pdb.dll
│ ├── Mono.Cecil.dll
│ ├── Unity.CecilTools.dll
│ ├── Unity.DataContract.dll
│ ├── Unity.SerializationLogic.dll
│ ├── Unity.UNetWeaver.dll
│ ├── Unity.UNetWeaver.dll.mdb
│ ├── UnityEditor.dll
│ ├── UnityEngine.dll
│ └── protobuf-net.dll
└── Release
│ ├── ICSharpCode.NRefactory.dll
│ ├── Jhqc.UnityFbxLoader.dll
│ ├── Jhqc.UnityFbxLoader.dll.mdb
│ ├── Mono.Cecil.Mdb.dll
│ ├── Mono.Cecil.Pdb.dll
│ ├── Mono.Cecil.dll
│ ├── Unity.CecilTools.dll
│ ├── Unity.DataContract.dll
│ ├── Unity.SerializationLogic.dll
│ ├── Unity.UNetWeaver.dll
│ ├── Unity.UNetWeaver.dll.mdb
│ ├── UnityEditor.dll
│ ├── UnityEngine.dll
│ └── protobuf-net.dll
├── README.md
├── monomake.xml
└── scripts
├── FbxLoader.cs
└── fbxImporter.cs
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Windows image file caches
2 | Thumbs.db
3 | ehthumbs.db
4 | obj/
5 |
6 | # Folder config file
7 | Desktop.ini
8 |
9 | # Recycle Bin used on file shares
10 | $RECYCLE.BIN/
11 |
12 | # Windows Installer files
13 | *.cab
14 | *.msi
15 | *.msm
16 | *.msp
17 |
18 | # Windows shortcuts
19 | *.lnk
20 |
21 | # =========================
22 | # Operating System Files
23 | # =========================
24 |
25 | # OSX
26 | # =========================
27 |
28 | .DS_Store
29 | .AppleDouble
30 | .LSOverride
31 |
32 | # Thumbnails
33 | ._*
34 |
35 | # Files that might appear in the root of a volume
36 | .DocumentRevisions-V100
37 | .fseventsd
38 | .Spotlight-V100
39 | .TemporaryItems
40 | .Trashes
41 | .VolumeIcon.icns
42 |
43 | # Directories potentially created on remote AFP share
44 | .AppleDB
45 | .AppleDesktop
46 | Network Trash Folder
47 | Temporary Items
48 | .apdisk
49 |
--------------------------------------------------------------------------------
/Dependencies/CrossDomainPolicyParser.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/Dependencies/CrossDomainPolicyParser.dll
--------------------------------------------------------------------------------
/Dependencies/ICSharpCode.NRefactory.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/Dependencies/ICSharpCode.NRefactory.dll
--------------------------------------------------------------------------------
/Dependencies/Mono.Cecil.Mdb.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/Dependencies/Mono.Cecil.Mdb.dll
--------------------------------------------------------------------------------
/Dependencies/Mono.Cecil.Pdb.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/Dependencies/Mono.Cecil.Pdb.dll
--------------------------------------------------------------------------------
/Dependencies/Mono.Cecil.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/Dependencies/Mono.Cecil.dll
--------------------------------------------------------------------------------
/Dependencies/Unity.CecilTools.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/Dependencies/Unity.CecilTools.dll
--------------------------------------------------------------------------------
/Dependencies/Unity.DataContract.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/Dependencies/Unity.DataContract.dll
--------------------------------------------------------------------------------
/Dependencies/Unity.IvyParser.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/Dependencies/Unity.IvyParser.dll
--------------------------------------------------------------------------------
/Dependencies/Unity.IvyParser.dll.mdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/Dependencies/Unity.IvyParser.dll.mdb
--------------------------------------------------------------------------------
/Dependencies/Unity.Locator.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/Dependencies/Unity.Locator.dll
--------------------------------------------------------------------------------
/Dependencies/Unity.Locator.dll.mdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/Dependencies/Unity.Locator.dll.mdb
--------------------------------------------------------------------------------
/Dependencies/Unity.SerializationLogic.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/Dependencies/Unity.SerializationLogic.dll
--------------------------------------------------------------------------------
/Dependencies/Unity.UNetWeaver.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/Dependencies/Unity.UNetWeaver.dll
--------------------------------------------------------------------------------
/Dependencies/Unity.UNetWeaver.dll.mdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/Dependencies/Unity.UNetWeaver.dll.mdb
--------------------------------------------------------------------------------
/Dependencies/UnityEditor.Graphs.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/Dependencies/UnityEditor.Graphs.dll
--------------------------------------------------------------------------------
/Dependencies/UnityEditor.Graphs.dll.mdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/Dependencies/UnityEditor.Graphs.dll.mdb
--------------------------------------------------------------------------------
/Dependencies/UnityEditor.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/Dependencies/UnityEditor.dll
--------------------------------------------------------------------------------
/Dependencies/UnityEditor.dll.mdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/Dependencies/UnityEditor.dll.mdb
--------------------------------------------------------------------------------
/Dependencies/UnityEngine.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/Dependencies/UnityEngine.dll
--------------------------------------------------------------------------------
/Dependencies/UnityEngine.dll.mdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/Dependencies/UnityEngine.dll.mdb
--------------------------------------------------------------------------------
/Dependencies/nunit.core.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/Dependencies/nunit.core.dll
--------------------------------------------------------------------------------
/Dependencies/nunit.core.interfaces.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/Dependencies/nunit.core.interfaces.dll
--------------------------------------------------------------------------------
/Dependencies/nunit.framework.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/Dependencies/nunit.framework.dll
--------------------------------------------------------------------------------
/Dependencies/protobuf-net.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/Dependencies/protobuf-net.dll
--------------------------------------------------------------------------------
/Dependencies/protobuf-net.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | protobuf-net
5 |
6 |
7 |
8 |
9 | Provides support for common .NET types that do not have a direct representation
10 | in protobuf, using the definitions from bcl.proto
11 |
12 |
13 |
14 |
15 | Creates a new instance of the specified type, bypassing the constructor.
16 |
17 | The type to create
18 | The new instance
19 | If the platform does not support constructor-skipping
20 |
21 |
22 |
23 | Writes a TimeSpan to a protobuf stream
24 |
25 |
26 |
27 |
28 | Parses a TimeSpan from a protobuf stream
29 |
30 |
31 |
32 |
33 | Parses a DateTime from a protobuf stream
34 |
35 |
36 |
37 |
38 | Writes a DateTime to a protobuf stream
39 |
40 |
41 |
42 |
43 | Parses a decimal from a protobuf stream
44 |
45 |
46 |
47 |
48 | Writes a decimal to a protobuf stream
49 |
50 |
51 |
52 |
53 | Writes a Guid to a protobuf stream
54 |
55 |
56 |
57 |
58 | Parses a Guid from a protobuf stream
59 |
60 |
61 |
62 |
63 | Reads an *implementation specific* bundled .NET object, including (as options) type-metadata, identity/re-use, etc.
64 |
65 |
66 |
67 |
68 | Writes an *implementation specific* bundled .NET object, including (as options) type-metadata, identity/re-use, etc.
69 |
70 |
71 |
72 |
73 | Optional behaviours that introduce .NET-specific functionality
74 |
75 |
76 |
77 |
78 | No special behaviour
79 |
80 |
81 |
82 |
83 | Enables full object-tracking/full-graph support.
84 |
85 |
86 |
87 |
88 | Embeds the type information into the stream, allowing usage with types not known in advance.
89 |
90 |
91 |
92 |
93 | If false, the constructor for the type is bypassed during deserialization, meaning any field initializers
94 | or other initialization code is skipped.
95 |
96 |
97 |
98 |
99 | Should the object index be reserved, rather than creating an object promptly
100 |
101 |
102 |
103 |
104 | Provides a simple buffer-based implementation of an extension object.
105 |
106 |
107 |
108 |
109 | Provides addition capability for supporting unexpected fields during
110 | protocol-buffer serialization/deserialization. This allows for loss-less
111 | round-trip/merge, even when the data is not fully understood.
112 |
113 |
114 |
115 |
116 | Requests a stream into which any unexpected fields can be persisted.
117 |
118 | A new stream suitable for storing data.
119 |
120 |
121 |
122 | Indicates that all unexpected fields have now been stored. The
123 | implementing class is responsible for closing the stream. If
124 | "commit" is not true the data may be discarded.
125 |
126 | The stream originally obtained by BeginAppend.
127 | True if the append operation completed successfully.
128 |
129 |
130 |
131 | Requests a stream of the unexpected fields previously stored.
132 |
133 | A prepared stream of the unexpected fields.
134 |
135 |
136 |
137 | Indicates that all unexpected fields have now been read. The
138 | implementing class is responsible for closing the stream.
139 |
140 | The stream originally obtained by BeginQuery.
141 |
142 |
143 |
144 | Requests the length of the raw binary stream; this is used
145 | when serializing sub-entities to indicate the expected size.
146 |
147 | The length of the binary stream representing unexpected data.
148 |
149 |
150 | Specifies a method on the root-contract in an hierarchy to be invoked before serialization.
151 |
152 |
153 | Specifies a method on the root-contract in an hierarchy to be invoked after serialization.
154 |
155 |
156 | Specifies a method on the root-contract in an hierarchy to be invoked before deserialization.
157 |
158 |
159 | Specifies a method on the root-contract in an hierarchy to be invoked after deserialization.
160 |
161 |
162 |
163 | Sub-format to use when serializing/deserializing data
164 |
165 |
166 |
167 |
168 | Uses the default encoding for the data-type.
169 |
170 |
171 |
172 |
173 | When applied to signed integer-based data (including Decimal), this
174 | indicates that zigzag variant encoding will be used. This means that values
175 | with small magnitude (regardless of sign) take a small amount
176 | of space to encode.
177 |
178 |
179 |
180 |
181 | When applied to signed integer-based data (including Decimal), this
182 | indicates that two's-complement variant encoding will be used.
183 | This means that any -ve number will take 10 bytes (even for 32-bit),
184 | so should only be used for compatibility.
185 |
186 |
187 |
188 |
189 | When applied to signed integer-based data (including Decimal), this
190 | indicates that a fixed amount of space will be used.
191 |
192 |
193 |
194 |
195 | When applied to a sub-message, indicates that the value should be treated
196 | as group-delimited.
197 |
198 |
199 |
200 |
201 | Simple base class for supporting unexpected fields allowing
202 | for loss-less round-tips/merge, even if the data is not understod.
203 | The additional fields are (by default) stored in-memory in a buffer.
204 |
205 | As an example of an alternative implementation, you might
206 | choose to use the file system (temporary files) as the back-end, tracking
207 | only the paths [such an object would ideally be IDisposable and use
208 | a finalizer to ensure that the files are removed].
209 |
210 |
211 |
212 |
213 | Indicates that the implementing type has support for protocol-buffer
214 | extensions.
215 |
216 | Can be implemented by deriving from Extensible.
217 |
218 |
219 |
220 | Retrieves the extension object for the current
221 | instance, optionally creating it if it does not already exist.
222 |
223 | Should a new extension object be
224 | created if it does not already exist?
225 | The extension object if it exists (or was created), or null
226 | if the extension object does not exist or is not available.
227 | The createIfMissing argument is false during serialization,
228 | and true during deserialization upon encountering unexpected fields.
229 |
230 |
231 |
232 | Retrieves the extension object for the current
233 | instance, optionally creating it if it does not already exist.
234 |
235 | Should a new extension object be
236 | created if it does not already exist?
237 | The extension object if it exists (or was created), or null
238 | if the extension object does not exist or is not available.
239 | The createIfMissing argument is false during serialization,
240 | and true during deserialization upon encountering unexpected fields.
241 |
242 |
243 |
244 | Provides a simple, default implementation for extension support,
245 | optionally creating it if it does not already exist. Designed to be called by
246 | classes implementing .
247 |
248 | Should a new extension object be
249 | created if it does not already exist?
250 | The extension field to check (and possibly update).
251 | The extension object if it exists (or was created), or null
252 | if the extension object does not exist or is not available.
253 | The createIfMissing argument is false during serialization,
254 | and true during deserialization upon encountering unexpected fields.
255 |
256 |
257 |
258 | Queries an extensible object for an additional (unexpected) data-field for the instance.
259 | The value returned (in "value") is the composed value after merging any duplicated content;
260 | if the value is "repeated" (a list), then use GetValues instead.
261 |
262 | The data-type of the field.
263 | The model to use for configuration.
264 | The effective value of the field, or the default value if not found.
265 | The extensible object to obtain the value from.
266 | The field identifier; the tag should not be defined as a known data-field for the instance.
267 | The data-format to use when decoding the value.
268 | Allow tags that are present as part of the definition; for example, to query unknown enum values.
269 | True if data for the field was present, false otherwise.
270 |
271 |
272 |
273 | Queries an extensible object for an additional (unexpected) data-field for the instance.
274 | Each occurrence of the field is yielded separately, making this usage suitable for "repeated"
275 | (list) fields.
276 |
277 | The extended data is processed lazily as the enumerator is iterated.
278 | The model to use for configuration.
279 | The data-type of the field.
280 | The extensible object to obtain the value from.
281 | The field identifier; the tag should not be defined as a known data-field for the instance.
282 | The data-format to use when decoding the value.
283 | An enumerator that yields each occurrence of the field.
284 |
285 |
286 |
287 | Appends the value as an additional (unexpected) data-field for the instance.
288 | Note that for non-repeated sub-objects, this equates to a merge operation;
289 | for repeated sub-objects this adds a new instance to the set; for simple
290 | values the new value supercedes the old value.
291 |
292 | Note that appending a value does not remove the old value from
293 | the stream; avoid repeatedly appending values for the same field.
294 | The model to use for configuration.
295 | The data-format to use when encoding the value.
296 | The extensible object to append the value to.
297 | The field identifier; the tag should not be defined as a known data-field for the instance.
298 | The value to append.
299 |
300 |
301 |
302 | This class acts as an internal wrapper allowing us to do a dynamic
303 | methodinfo invoke; an't put into Serializer as don't want on public
304 | API; can't put into Serializer<T> since we need to invoke
305 | accross classes, which isn't allowed in Silverlight)
306 |
307 |
308 |
309 |
310 | All this does is call GetExtendedValuesTyped with the correct type for "instance";
311 | this ensures that we don't get issues with subclasses declaring conflicting types -
312 | the caller must respect the fields defined for the type they pass in.
313 |
314 |
315 |
316 |
317 | Not all frameworks are created equal (fx1.1 vs fx2.0,
318 | micro-framework, compact-framework,
319 | silverlight, etc). This class simply wraps up a few things that would
320 | otherwise make the real code unnecessarily messy, providing fallback
321 | implementations if necessary.
322 |
323 |
324 |
325 |
326 | Intended to be a direct map to regular TypeCode, but:
327 | - with missing types
328 | - existing on WinRT
329 |
330 |
331 |
332 |
333 | Specifies the method used to infer field tags for members of the type
334 | under consideration. Tags are deduced using the invariant alphabetic
335 | sequence of the members' names; this makes implicit field tags very brittle,
336 | and susceptible to changes such as field names (normally an isolated
337 | change).
338 |
339 |
340 |
341 |
342 | No members are serialized implicitly; all members require a suitable
343 | attribute such as [ProtoMember]. This is the recmomended mode for
344 | most scenarios.
345 |
346 |
347 |
348 |
349 | Public properties and fields are eligible for implicit serialization;
350 | this treats the public API as a contract. Ordering beings from ImplicitFirstTag.
351 |
352 |
353 |
354 |
355 | Public and non-public fields are eligible for implicit serialization;
356 | this acts as a state/implementation serializer. Ordering beings from ImplicitFirstTag.
357 |
358 |
359 |
360 |
361 | Event arguments needed to perform type-formatting functions; this could be resolving a Type to a string suitable for serialization, or could
362 | be requesting a Type from a string. If no changes are made, a default implementation will be used (from the assembly-qualified names).
363 |
364 |
365 |
366 |
367 | The type involved in this map; if this is initially null, a Type is expected to be provided for the string in FormattedName.
368 |
369 |
370 |
371 |
372 | The formatted-name involved in this map; if this is initially null, a formatted-name is expected from the type in Type.
373 |
374 |
375 |
376 |
377 | Delegate type used to perform type-formatting functions; the sender originates as the type-model.
378 |
379 |
380 |
381 |
382 | Provides protobuf serialization support for a number of types
383 |
384 |
385 |
386 |
387 | Resolve a System.Type to the compiler-specific type
388 |
389 |
390 |
391 |
392 | Resolve a System.Type to the compiler-specific type
393 |
394 |
395 |
396 |
397 | This is the more "complete" version of Serialize, which handles single instances of mapped types.
398 | The value is written as a complete field, including field-header and (for sub-objects) a
399 | length-prefix
400 | In addition to that, this provides support for:
401 | - basic values; individual int / string / Guid / etc
402 | - IEnumerable sequences of any type handled by TrySerializeAuxiliaryType
403 |
404 |
405 |
406 |
407 |
408 | Writes a protocol-buffer representation of the given instance to the supplied stream.
409 |
410 | The existing instance to be serialized (cannot be null).
411 | The destination stream to write to.
412 |
413 |
414 |
415 | Writes a protocol-buffer representation of the given instance to the supplied stream.
416 |
417 | The existing instance to be serialized (cannot be null).
418 | The destination stream to write to.
419 | Additional information about this serialization operation.
420 |
421 |
422 |
423 | Writes a protocol-buffer representation of the given instance to the supplied writer.
424 |
425 | The existing instance to be serialized (cannot be null).
426 | The destination writer to write to.
427 |
428 |
429 |
430 | Applies a protocol-buffer stream to an existing instance (or null), using length-prefixed
431 | data - useful with network IO.
432 |
433 | The type being merged.
434 | The existing instance to be modified (can be null).
435 | The binary stream to apply to the instance (cannot be null).
436 | How to encode the length prefix.
437 | The tag used as a prefix to each record (only used with base-128 style prefixes).
438 | The updated instance; this may be different to the instance argument if
439 | either the original instance was null, or the stream defines a known sub-type of the
440 | original instance.
441 |
442 |
443 |
444 | Applies a protocol-buffer stream to an existing instance (or null), using length-prefixed
445 | data - useful with network IO.
446 |
447 | The type being merged.
448 | The existing instance to be modified (can be null).
449 | The binary stream to apply to the instance (cannot be null).
450 | How to encode the length prefix.
451 | The tag used as a prefix to each record (only used with base-128 style prefixes).
452 | Used to resolve types on a per-field basis.
453 | The updated instance; this may be different to the instance argument if
454 | either the original instance was null, or the stream defines a known sub-type of the
455 | original instance.
456 |
457 |
458 |
459 | Applies a protocol-buffer stream to an existing instance (or null), using length-prefixed
460 | data - useful with network IO.
461 |
462 | The type being merged.
463 | The existing instance to be modified (can be null).
464 | The binary stream to apply to the instance (cannot be null).
465 | How to encode the length prefix.
466 | The tag used as a prefix to each record (only used with base-128 style prefixes).
467 | Used to resolve types on a per-field basis.
468 | Returns the number of bytes consumed by this operation (includes length-prefix overheads and any skipped data).
469 | The updated instance; this may be different to the instance argument if
470 | either the original instance was null, or the stream defines a known sub-type of the
471 | original instance.
472 |
473 |
474 |
475 | Reads a sequence of consecutive length-prefixed items from a stream, using
476 | either base-128 or fixed-length prefixes. Base-128 prefixes with a tag
477 | are directly comparable to serializing multiple items in succession
478 | (use the tag to emulate the implicit behavior
479 | when serializing a list/array). When a tag is
480 | specified, any records with different tags are silently omitted. The
481 | tag is ignored. The tag is ignores for fixed-length prefixes.
482 |
483 | The binary stream containing the serialized records.
484 | The prefix style used in the data.
485 | The tag of records to return (if non-positive, then no tag is
486 | expected and all records are returned).
487 | On a field-by-field basis, the type of object to deserialize (can be null if "type" is specified).
488 | The type of object to deserialize (can be null if "resolver" is specified).
489 | The sequence of deserialized objects.
490 |
491 |
492 |
493 | Reads a sequence of consecutive length-prefixed items from a stream, using
494 | either base-128 or fixed-length prefixes. Base-128 prefixes with a tag
495 | are directly comparable to serializing multiple items in succession
496 | (use the tag to emulate the implicit behavior
497 | when serializing a list/array). When a tag is
498 | specified, any records with different tags are silently omitted. The
499 | tag is ignored. The tag is ignores for fixed-length prefixes.
500 |
501 | The binary stream containing the serialized records.
502 | The prefix style used in the data.
503 | The tag of records to return (if non-positive, then no tag is
504 | expected and all records are returned).
505 | On a field-by-field basis, the type of object to deserialize (can be null if "type" is specified).
506 | The type of object to deserialize (can be null if "resolver" is specified).
507 | The sequence of deserialized objects.
508 | Additional information about this serialization operation.
509 |
510 |
511 |
512 | Reads a sequence of consecutive length-prefixed items from a stream, using
513 | either base-128 or fixed-length prefixes. Base-128 prefixes with a tag
514 | are directly comparable to serializing multiple items in succession
515 | (use the tag to emulate the implicit behavior
516 | when serializing a list/array). When a tag is
517 | specified, any records with different tags are silently omitted. The
518 | tag is ignored. The tag is ignores for fixed-length prefixes.
519 |
520 | The type of object to deserialize.
521 | The binary stream containing the serialized records.
522 | The prefix style used in the data.
523 | The tag of records to return (if non-positive, then no tag is
524 | expected and all records are returned).
525 | The sequence of deserialized objects.
526 |
527 |
528 |
529 | Reads a sequence of consecutive length-prefixed items from a stream, using
530 | either base-128 or fixed-length prefixes. Base-128 prefixes with a tag
531 | are directly comparable to serializing multiple items in succession
532 | (use the tag to emulate the implicit behavior
533 | when serializing a list/array). When a tag is
534 | specified, any records with different tags are silently omitted. The
535 | tag is ignored. The tag is ignores for fixed-length prefixes.
536 |
537 | The type of object to deserialize.
538 | The binary stream containing the serialized records.
539 | The prefix style used in the data.
540 | The tag of records to return (if non-positive, then no tag is
541 | expected and all records are returned).
542 | The sequence of deserialized objects.
543 | Additional information about this serialization operation.
544 |
545 |
546 |
547 | Writes a protocol-buffer representation of the given instance to the supplied stream,
548 | with a length-prefix. This is useful for socket programming,
549 | as DeserializeWithLengthPrefix can be used to read the single object back
550 | from an ongoing stream.
551 |
552 | The type being serialized.
553 | The existing instance to be serialized (cannot be null).
554 | How to encode the length prefix.
555 | The destination stream to write to.
556 | The tag used as a prefix to each record (only used with base-128 style prefixes).
557 |
558 |
559 |
560 | Writes a protocol-buffer representation of the given instance to the supplied stream,
561 | with a length-prefix. This is useful for socket programming,
562 | as DeserializeWithLengthPrefix can be used to read the single object back
563 | from an ongoing stream.
564 |
565 | The type being serialized.
566 | The existing instance to be serialized (cannot be null).
567 | How to encode the length prefix.
568 | The destination stream to write to.
569 | The tag used as a prefix to each record (only used with base-128 style prefixes).
570 | Additional information about this serialization operation.
571 |
572 |
573 |
574 | Applies a protocol-buffer stream to an existing instance (which may be null).
575 |
576 | The type (including inheritance) to consider.
577 | The existing instance to be modified (can be null).
578 | The binary stream to apply to the instance (cannot be null).
579 | The updated instance; this may be different to the instance argument if
580 | either the original instance was null, or the stream defines a known sub-type of the
581 | original instance.
582 |
583 |
584 |
585 | Applies a protocol-buffer stream to an existing instance (which may be null).
586 |
587 | The type (including inheritance) to consider.
588 | The existing instance to be modified (can be null).
589 | The binary stream to apply to the instance (cannot be null).
590 | The updated instance; this may be different to the instance argument if
591 | either the original instance was null, or the stream defines a known sub-type of the
592 | original instance.
593 | Additional information about this serialization operation.
594 |
595 |
596 |
597 | Applies a protocol-buffer stream to an existing instance (which may be null).
598 |
599 | The type (including inheritance) to consider.
600 | The existing instance to be modified (can be null).
601 | The binary stream to apply to the instance (cannot be null).
602 | The number of bytes to consume.
603 | The updated instance; this may be different to the instance argument if
604 | either the original instance was null, or the stream defines a known sub-type of the
605 | original instance.
606 |
607 |
608 |
609 | Applies a protocol-buffer stream to an existing instance (which may be null).
610 |
611 | The type (including inheritance) to consider.
612 | The existing instance to be modified (can be null).
613 | The binary stream to apply to the instance (cannot be null).
614 | The number of bytes to consume (or -1 to read to the end of the stream).
615 | The updated instance; this may be different to the instance argument if
616 | either the original instance was null, or the stream defines a known sub-type of the
617 | original instance.
618 | Additional information about this serialization operation.
619 |
620 |
621 |
622 | Applies a protocol-buffer reader to an existing instance (which may be null).
623 |
624 | The type (including inheritance) to consider.
625 | The existing instance to be modified (can be null).
626 | The reader to apply to the instance (cannot be null).
627 | The updated instance; this may be different to the instance argument if
628 | either the original instance was null, or the stream defines a known sub-type of the
629 | original instance.
630 |
631 |
632 |
633 | This is the more "complete" version of Deserialize, which handles single instances of mapped types.
634 | The value is read as a complete field, including field-header and (for sub-objects) a
635 | length-prefix..kmc
636 |
637 | In addition to that, this provides support for:
638 | - basic values; individual int / string / Guid / etc
639 | - IList sets of any type handled by TryDeserializeAuxiliaryType
640 |
641 |
642 |
643 |
644 | Applies common proxy scenarios, resolving the actual type to consider
645 |
646 |
647 |
648 |
649 | Indicates whether the supplied type is explicitly modelled by the model
650 |
651 |
652 |
653 |
654 | Provides the key that represents a given type in the current model.
655 | The type is also normalized for proxies at the same time.
656 |
657 |
658 |
659 |
660 | Provides the key that represents a given type in the current model.
661 |
662 |
663 |
664 |
665 | Writes a protocol-buffer representation of the given instance to the supplied stream.
666 |
667 | Represents the type (including inheritance) to consider.
668 | The existing instance to be serialized (cannot be null).
669 | The destination stream to write to.
670 |
671 |
672 |
673 | Applies a protocol-buffer stream to an existing instance (which may be null).
674 |
675 | Represents the type (including inheritance) to consider.
676 | The existing instance to be modified (can be null).
677 | The binary stream to apply to the instance (cannot be null).
678 | The updated instance; this may be different to the instance argument if
679 | either the original instance was null, or the stream defines a known sub-type of the
680 | original instance.
681 |
682 |
683 |
684 | Create a deep clone of the supplied instance; any sub-items are also cloned.
685 |
686 |
687 |
688 |
689 | Indicates that while an inheritance tree exists, the exact type encountered was not
690 | specified in that hierarchy and cannot be processed.
691 |
692 |
693 |
694 |
695 | Indicates that the given type was not expected, and cannot be processed.
696 |
697 |
698 |
699 |
700 | Indicates that the given type cannot be constructed; it may still be possible to
701 | deserialize into existing instances.
702 |
703 |
704 |
705 |
706 | Returns true if the type supplied is either a recognised contract type,
707 | or a *list* of a recognised contract type.
708 |
709 | Note that primitives always return false, even though the engine
710 | will, if forced, try to serialize such
711 | True if this type is recognised as a serializable entity, else false
712 |
713 |
714 |
715 | Returns true if the type supplied is a basic type with inbuilt handling,
716 | a recognised contract type, or a *list* of a basic / contract type.
717 |
718 |
719 |
720 |
721 | Returns true if the type supplied is a basic type with inbuilt handling,
722 | or a *list* of a basic type with inbuilt handling
723 |
724 |
725 |
726 |
727 | Suggest a .proto definition for the given type
728 |
729 | The type to generate a .proto definition for, or null to generate a .proto that represents the entire model
730 | The .proto definition as a string
731 |
732 |
733 |
734 | Creates a new IFormatter that uses protocol-buffer [de]serialization.
735 |
736 | A new IFormatter to be used during [de]serialization.
737 | The type of object to be [de]deserialized by the formatter.
738 |
739 |
740 |
741 | Used to provide custom services for writing and parsing type names when using dynamic types. Both parsing and formatting
742 | are provided on a single API as it is essential that both are mapped identically at all times.
743 |
744 |
745 |
746 |
747 | Indicates the type of callback to be used
748 |
749 |
750 |
751 |
752 | Invoked before an object is serialized
753 |
754 |
755 |
756 |
757 | Invoked after an object is serialized
758 |
759 |
760 |
761 |
762 | Invoked before an object is deserialized (or when a new instance is created)
763 |
764 |
765 |
766 |
767 | Invoked after an object is deserialized
768 |
769 |
770 |
771 |
772 | Specifies the type of prefix that should be applied to messages.
773 |
774 |
775 |
776 |
777 | No length prefix is applied to the data; the data is terminated only be the end of the stream.
778 |
779 |
780 |
781 |
782 | A base-128 length prefix is applied to the data (efficient for short messages).
783 |
784 |
785 |
786 |
787 | A fixed-length (little-endian) length prefix is applied to the data (useful for compatibility).
788 |
789 |
790 |
791 |
792 | A fixed-length (big-endian) length prefix is applied to the data (useful for compatibility).
793 |
794 |
795 |
796 |
797 | Indicates that a type is defined for protocol-buffer serialization.
798 |
799 |
800 |
801 |
802 | Gets or sets the defined name of the type.
803 |
804 |
805 |
806 |
807 | Gets or sets the fist offset to use with implicit field tags;
808 | only uesd if ImplicitFields is set.
809 |
810 |
811 |
812 |
813 | If specified, alternative contract markers (such as markers for XmlSerailizer or DataContractSerializer) are ignored.
814 |
815 |
816 |
817 |
818 | If specified, do NOT treat this type as a list, even if it looks like one.
819 |
820 |
821 |
822 |
823 | Gets or sets the mechanism used to automatically infer field tags
824 | for members. This option should be used in advanced scenarios only.
825 | Please review the important notes against the ImplicitFields enumeration.
826 |
827 |
828 |
829 |
830 | Enables/disables automatic tag generation based on the existing name / order
831 | of the defined members. This option is not used for members marked
832 | with ProtoMemberAttribute, as intended to provide compatibility with
833 | WCF serialization. WARNING: when adding new fields you must take
834 | care to increase the Order for new elements, otherwise data corruption
835 | may occur.
836 |
837 | If not explicitly specified, the default is assumed from Serializer.GlobalOptions.InferTagFromName.
838 |
839 |
840 |
841 | Has a InferTagFromName value been explicitly set? if not, the default from the type-model is assumed.
842 |
843 |
844 |
845 |
846 | Specifies an offset to apply to [DataMember(Order=...)] markers;
847 | this is useful when working with mex-generated classes that have
848 | a different origin (usually 1 vs 0) than the original data-contract.
849 |
850 | This value is added to the Order of each member.
851 |
852 |
853 |
854 |
855 | If true, the constructor for the type is bypassed during deserialization, meaning any field initializers
856 | or other initialization code is skipped.
857 |
858 |
859 |
860 |
861 | Should this type be treated as a reference by default? Please also see the implications of this,
862 | as recorded on ProtoMemberAttribute.AsReference
863 |
864 |
865 |
866 |
867 | Applies only to enums (not to DTO classes themselves); gets or sets a value indicating that an enum should be treated directly as an int/short/etc, rather
868 | than enforcing .proto enum rules. This is useful *in particul* for [Flags] enums.
869 |
870 |
871 |
872 |
873 | Has a EnumPassthru value been explicitly set?
874 |
875 |
876 |
877 |
878 | Used to define protocol-buffer specific behavior for
879 | enumerated values.
880 |
881 |
882 |
883 |
884 | Indicates whether this instance has a customised value mapping
885 |
886 | true if a specific value is set
887 |
888 |
889 |
890 | Gets or sets the specific value to use for this enum during serialization.
891 |
892 |
893 |
894 |
895 | Gets or sets the defined name of the enum, as used in .proto
896 | (this name is not used during serialization).
897 |
898 |
899 |
900 |
901 | Indicates an error during serialization/deserialization of a proto stream.
902 |
903 |
904 |
905 | Creates a new ProtoException instance.
906 |
907 |
908 | Creates a new ProtoException instance.
909 |
910 |
911 | Creates a new ProtoException instance.
912 |
913 |
914 | Creates a new ProtoException instance.
915 |
916 |
917 |
918 | Indicates that a member should be excluded from serialization; this
919 | is only normally used when using implict fields.
920 |
921 |
922 |
923 |
924 | Indicates that a member should be excluded from serialization; this
925 | is only normally used when using implict fields. This allows
926 | ProtoIgnoreAttribute usage
927 | even for partial classes where the individual members are not
928 | under direct control.
929 |
930 |
931 |
932 |
933 | Creates a new ProtoPartialIgnoreAttribute instance.
934 |
935 | Specifies the member to be ignored.
936 |
937 |
938 |
939 | The name of the member to be ignored.
940 |
941 |
942 |
943 |
944 | Indicates the known-types to support for an individual
945 | message. This serializes each level in the hierarchy as
946 | a nested message to retain wire-compatibility with
947 | other protocol-buffer implementations.
948 |
949 |
950 |
951 |
952 | Creates a new instance of the ProtoIncludeAttribute.
953 |
954 | The unique index (within the type) that will identify this data.
955 | The additional type to serialize/deserialize.
956 |
957 |
958 |
959 | Creates a new instance of the ProtoIncludeAttribute.
960 |
961 | The unique index (within the type) that will identify this data.
962 | The additional type to serialize/deserialize.
963 |
964 |
965 |
966 | Gets the unique index (within the type) that will identify this data.
967 |
968 |
969 |
970 |
971 | Gets the additional type to serialize/deserialize.
972 |
973 |
974 |
975 |
976 | Gets the additional type to serialize/deserialize.
977 |
978 |
979 |
980 |
981 | Specifies whether the inherited sype's sub-message should be
982 | written with a length-prefix (default), or with group markers.
983 |
984 |
985 |
986 |
987 | Declares a member to be used in protocol-buffer serialization, using
988 | the given Tag. A DataFormat may be used to optimise the serialization
989 | format (for instance, using zigzag encoding for negative numbers, or
990 | fixed-length encoding for large values.
991 |
992 |
993 |
994 |
995 | Compare with another ProtoMemberAttribute for sorting purposes
996 |
997 |
998 |
999 |
1000 | Compare with another ProtoMemberAttribute for sorting purposes
1001 |
1002 |
1003 |
1004 |
1005 | Creates a new ProtoMemberAttribute instance.
1006 |
1007 | Specifies the unique tag used to identify this member within the type.
1008 |
1009 |
1010 |
1011 | Gets or sets the original name defined in the .proto; not used
1012 | during serialization.
1013 |
1014 |
1015 |
1016 |
1017 | Gets or sets the data-format to be used when encoding this value.
1018 |
1019 |
1020 |
1021 |
1022 | Gets the unique tag used to identify this member within the type.
1023 |
1024 |
1025 |
1026 |
1027 | Gets or sets a value indicating whether this member is mandatory.
1028 |
1029 |
1030 |
1031 |
1032 | Gets a value indicating whether this member is packed.
1033 | This option only applies to list/array data of primitive types (int, double, etc).
1034 |
1035 |
1036 |
1037 |
1038 | Indicates whether this field should *repace* existing values (the default is false, meaning *append*).
1039 | This option only applies to list/array data.
1040 |
1041 |
1042 |
1043 |
1044 | Enables full object-tracking/full-graph support.
1045 |
1046 |
1047 |
1048 |
1049 | Embeds the type information into the stream, allowing usage with types not known in advance.
1050 |
1051 |
1052 |
1053 |
1054 | Gets or sets a value indicating whether this member is packed (lists/arrays).
1055 |
1056 |
1057 |
1058 |
1059 | Additional (optional) settings that control serialization of members
1060 |
1061 |
1062 |
1063 |
1064 | Default; no additional options
1065 |
1066 |
1067 |
1068 |
1069 | Indicates that repeated elements should use packed (length-prefixed) encoding
1070 |
1071 |
1072 |
1073 |
1074 | Indicates that the given item is required
1075 |
1076 |
1077 |
1078 |
1079 | Enables full object-tracking/full-graph support
1080 |
1081 |
1082 |
1083 |
1084 | Embeds the type information into the stream, allowing usage with types not known in advance
1085 |
1086 |
1087 |
1088 |
1089 | Indicates whether this field should *repace* existing values (the default is false, meaning *append*).
1090 | This option only applies to list/array data.
1091 |
1092 |
1093 |
1094 |
1095 | Determines whether the types AsReferenceDefault value is used, or whether this member's AsReference should be used
1096 |
1097 |
1098 |
1099 |
1100 | Declares a member to be used in protocol-buffer serialization, using
1101 | the given Tag and MemberName. This allows ProtoMemberAttribute usage
1102 | even for partial classes where the individual members are not
1103 | under direct control.
1104 | A DataFormat may be used to optimise the serialization
1105 | format (for instance, using zigzag encoding for negative numbers, or
1106 | fixed-length encoding for large values.
1107 |
1108 |
1109 |
1110 |
1111 | Creates a new ProtoMemberAttribute instance.
1112 |
1113 | Specifies the unique tag used to identify this member within the type.
1114 | Specifies the member to be serialized.
1115 |
1116 |
1117 |
1118 | The name of the member to be serialized.
1119 |
1120 |
1121 |
1122 |
1123 | A stateful reader, used to read a protobuf stream. Typical usage would be (sequentially) to call
1124 | ReadFieldHeader and (after matching the field) an appropriate Read* method.
1125 |
1126 |
1127 |
1128 |
1129 | Creates a new reader against a stream
1130 |
1131 | The source stream
1132 | The model to use for serialization; this can be null, but this will impair the ability to deserialize sub-objects
1133 | Additional context about this serialization operation
1134 |
1135 |
1136 |
1137 | Creates a new reader against a stream
1138 |
1139 | The source stream
1140 | The model to use for serialization; this can be null, but this will impair the ability to deserialize sub-objects
1141 | Additional context about this serialization operation
1142 | The number of bytes to read, or -1 to read until the end of the stream
1143 |
1144 |
1145 |
1146 | Releases resources used by the reader, but importantly does not Dispose the
1147 | underlying stream; in many typical use-cases the stream is used for different
1148 | processes, so it is assumed that the consumer will Dispose their stream separately.
1149 |
1150 |
1151 |
1152 |
1153 | Reads an unsigned 32-bit integer from the stream; supported wire-types: Variant, Fixed32, Fixed64
1154 |
1155 |
1156 |
1157 |
1158 | Reads a signed 16-bit integer from the stream: Variant, Fixed32, Fixed64, SignedVariant
1159 |
1160 |
1161 |
1162 |
1163 | Reads an unsigned 16-bit integer from the stream; supported wire-types: Variant, Fixed32, Fixed64
1164 |
1165 |
1166 |
1167 |
1168 | Reads an unsigned 8-bit integer from the stream; supported wire-types: Variant, Fixed32, Fixed64
1169 |
1170 |
1171 |
1172 |
1173 | Reads a signed 8-bit integer from the stream; supported wire-types: Variant, Fixed32, Fixed64, SignedVariant
1174 |
1175 |
1176 |
1177 |
1178 | Reads a signed 32-bit integer from the stream; supported wire-types: Variant, Fixed32, Fixed64, SignedVariant
1179 |
1180 |
1181 |
1182 |
1183 | Reads a signed 64-bit integer from the stream; supported wire-types: Variant, Fixed32, Fixed64, SignedVariant
1184 |
1185 |
1186 |
1187 |
1188 | Reads a string from the stream (using UTF8); supported wire-types: String
1189 |
1190 |
1191 |
1192 |
1193 | Throws an exception indication that the given value cannot be mapped to an enum.
1194 |
1195 |
1196 |
1197 |
1198 | Reads a double-precision number from the stream; supported wire-types: Fixed32, Fixed64
1199 |
1200 |
1201 |
1202 |
1203 | Reads (merges) a sub-message from the stream, internally calling StartSubItem and EndSubItem, and (in between)
1204 | parsing the message in accordance with the model associated with the reader
1205 |
1206 |
1207 |
1208 |
1209 | Makes the end of consuming a nested message in the stream; the stream must be either at the correct EndGroup
1210 | marker, or all fields of the sub-message must have been consumed (in either case, this means ReadFieldHeader
1211 | should return zero)
1212 |
1213 |
1214 |
1215 |
1216 | Begins consuming a nested message in the stream; supported wire-types: StartGroup, String
1217 |
1218 | The token returned must be help and used when callining EndSubItem
1219 |
1220 |
1221 |
1222 | Reads a field header from the stream, setting the wire-type and retuning the field number. If no
1223 | more fields are available, then 0 is returned. This methods respects sub-messages.
1224 |
1225 |
1226 |
1227 |
1228 | Looks ahead to see whether the next field in the stream is what we expect
1229 | (typically; what we've just finished reading - for example ot read successive list items)
1230 |
1231 |
1232 |
1233 |
1234 | Compares the streams current wire-type to the hinted wire-type, updating the reader if necessary; for example,
1235 | a Variant may be updated to SignedVariant. If the hinted wire-type is unrelated then no change is made.
1236 |
1237 |
1238 |
1239 |
1240 | Verifies that the stream's current wire-type is as expected, or a specialized sub-type (for example,
1241 | SignedVariant) - in which case the current wire-type is updated. Otherwise an exception is thrown.
1242 |
1243 |
1244 |
1245 |
1246 | Discards the data for the current field.
1247 |
1248 |
1249 |
1250 |
1251 | Reads an unsigned 64-bit integer from the stream; supported wire-types: Variant, Fixed32, Fixed64
1252 |
1253 |
1254 |
1255 |
1256 | Reads a single-precision number from the stream; supported wire-types: Fixed32, Fixed64
1257 |
1258 |
1259 |
1260 |
1261 | Reads a boolean value from the stream; supported wire-types: Variant, Fixed32, Fixed64
1262 |
1263 |
1264 |
1265 |
1266 |
1267 | Reads a byte-sequence from the stream, appending them to an existing byte-sequence (which can be null); supported wire-types: String
1268 |
1269 |
1270 |
1271 |
1272 | Reads the length-prefix of a message from a stream without buffering additional data, allowing a fixed-length
1273 | reader to be created.
1274 |
1275 |
1276 |
1277 |
1278 | Reads a little-endian encoded integer. An exception is thrown if the data is not all available.
1279 |
1280 |
1281 |
1282 |
1283 | Reads a big-endian encoded integer. An exception is thrown if the data is not all available.
1284 |
1285 |
1286 |
1287 |
1288 | Reads a varint encoded integer. An exception is thrown if the data is not all available.
1289 |
1290 |
1291 |
1292 |
1293 | Reads a string (of a given lenth, in bytes) directly from the source into a pre-existing buffer. An exception is thrown if the data is not all available.
1294 |
1295 |
1296 |
1297 |
1298 | Reads a given number of bytes directly from the source. An exception is thrown if the data is not all available.
1299 |
1300 |
1301 |
1302 |
1303 | Reads a string (of a given lenth, in bytes) directly from the source. An exception is thrown if the data is not all available.
1304 |
1305 |
1306 |
1307 |
1308 | Reads the length-prefix of a message from a stream without buffering additional data, allowing a fixed-length
1309 | reader to be created.
1310 |
1311 |
1312 |
1313 | The number of bytes consumed; 0 if no data available
1314 |
1315 |
1316 |
1317 | Copies the current field into the instance as extension data
1318 |
1319 |
1320 |
1321 |
1322 | Indicates whether the reader still has data remaining in the current sub-item,
1323 | additionally setting the wire-type for the next field if there is more data.
1324 | This is used when decoding packed data.
1325 |
1326 |
1327 |
1328 |
1329 | Utility method, not intended for public use; this helps maintain the root object is complex scenarios
1330 |
1331 |
1332 |
1333 |
1334 | Reads a Type from the stream, using the model's DynamicTypeFormatting if appropriate; supported wire-types: String
1335 |
1336 |
1337 |
1338 |
1339 | Merge two objects using the details from the current reader; this is used to change the type
1340 | of objects when an inheritance relationship is discovered later than usual during deserilazation.
1341 |
1342 |
1343 |
1344 |
1345 | Gets the number of the field being processed.
1346 |
1347 |
1348 |
1349 |
1350 | Indicates the underlying proto serialization format on the wire.
1351 |
1352 |
1353 |
1354 |
1355 | Gets / sets a flag indicating whether strings should be checked for repetition; if
1356 | true, any repeated UTF-8 byte sequence will result in the same String instance, rather
1357 | than a second instance of the same string. Enabled by default. Note that this uses
1358 | a custom interner - the system-wide string interner is not used.
1359 |
1360 |
1361 |
1362 |
1363 | Addition information about this deserialization operation.
1364 |
1365 |
1366 |
1367 |
1368 | Returns the position of the current reader (note that this is not necessarily the same as the position
1369 | in the underlying stream, if multiple readers are used on the same stream)
1370 |
1371 |
1372 |
1373 |
1374 | Get the TypeModel associated with this reader
1375 |
1376 |
1377 |
1378 |
1379 | Represents an output stream for writing protobuf data.
1380 |
1381 | Why is the API backwards (static methods with writer arguments)?
1382 | See: http://marcgravell.blogspot.com/2010/03/last-will-be-first-and-first-will-be.html
1383 |
1384 |
1385 |
1386 |
1387 | Write an encapsulated sub-object, using the supplied unique key (reprasenting a type).
1388 |
1389 | The object to write.
1390 | The key that uniquely identifies the type within the model.
1391 | The destination.
1392 |
1393 |
1394 |
1395 | Write an encapsulated sub-object, using the supplied unique key (reprasenting a type) - but the
1396 | caller is asserting that this relationship is non-recursive; no recursion check will be
1397 | performed.
1398 |
1399 | The object to write.
1400 | The key that uniquely identifies the type within the model.
1401 | The destination.
1402 |
1403 |
1404 |
1405 | Writes a field-header, indicating the format of the next data we plan to write.
1406 |
1407 |
1408 |
1409 |
1410 | Writes a byte-array to the stream; supported wire-types: String
1411 |
1412 |
1413 |
1414 |
1415 | Writes a byte-array to the stream; supported wire-types: String
1416 |
1417 |
1418 |
1419 |
1420 | Indicates the start of a nested record.
1421 |
1422 | The instance to write.
1423 | The destination.
1424 | A token representing the state of the stream; this token is given to EndSubItem.
1425 |
1426 |
1427 |
1428 | Indicates the end of a nested record.
1429 |
1430 | The token obtained from StartubItem.
1431 | The destination.
1432 |
1433 |
1434 |
1435 | Creates a new writer against a stream
1436 |
1437 | The destination stream
1438 | The model to use for serialization; this can be null, but this will impair the ability to serialize sub-objects
1439 | Additional context about this serialization operation
1440 |
1441 |
1442 |
1443 | Flushes data to the underlying stream, and releases any resources. The underlying stream is *not* disposed
1444 | by this operation.
1445 |
1446 |
1447 |
1448 |
1449 | Writes any buffered data (if possible) to the underlying stream.
1450 |
1451 | The writer to flush
1452 | It is not always possible to fully flush, since some sequences
1453 | may require values to be back-filled into the byte-stream.
1454 |
1455 |
1456 |
1457 | Writes an unsigned 32-bit integer to the stream; supported wire-types: Variant, Fixed32, Fixed64
1458 |
1459 |
1460 |
1461 |
1462 | Writes a string to the stream; supported wire-types: String
1463 |
1464 |
1465 |
1466 |
1467 | Writes an unsigned 64-bit integer to the stream; supported wire-types: Variant, Fixed32, Fixed64
1468 |
1469 |
1470 |
1471 |
1472 | Writes a signed 64-bit integer to the stream; supported wire-types: Variant, Fixed32, Fixed64, SignedVariant
1473 |
1474 |
1475 |
1476 |
1477 | Writes an unsigned 16-bit integer to the stream; supported wire-types: Variant, Fixed32, Fixed64
1478 |
1479 |
1480 |
1481 |
1482 | Writes a signed 16-bit integer to the stream; supported wire-types: Variant, Fixed32, Fixed64, SignedVariant
1483 |
1484 |
1485 |
1486 |
1487 | Writes an unsigned 16-bit integer to the stream; supported wire-types: Variant, Fixed32, Fixed64
1488 |
1489 |
1490 |
1491 |
1492 | Writes an unsigned 8-bit integer to the stream; supported wire-types: Variant, Fixed32, Fixed64
1493 |
1494 |
1495 |
1496 |
1497 | Writes a signed 8-bit integer to the stream; supported wire-types: Variant, Fixed32, Fixed64, SignedVariant
1498 |
1499 |
1500 |
1501 |
1502 | Writes a signed 32-bit integer to the stream; supported wire-types: Variant, Fixed32, Fixed64, SignedVariant
1503 |
1504 |
1505 |
1506 |
1507 | Writes a double-precision number to the stream; supported wire-types: Fixed32, Fixed64
1508 |
1509 |
1510 |
1511 |
1512 | Writes a single-precision number to the stream; supported wire-types: Fixed32, Fixed64
1513 |
1514 |
1515 |
1516 |
1517 | Throws an exception indicating that the given enum cannot be mapped to a serialized value.
1518 |
1519 |
1520 |
1521 |
1522 | Writes a boolean to the stream; supported wire-types: Variant, Fixed32, Fixed64
1523 |
1524 |
1525 |
1526 |
1527 | Copies any extension data stored for the instance to the underlying stream
1528 |
1529 |
1530 |
1531 |
1532 | Used for packed encoding; indicates that the next field should be skipped rather than
1533 | a field header written. Note that the field number must match, else an exception is thrown
1534 | when the attempt is made to write the (incorrect) field. The wire-type is taken from the
1535 | subsequent call to WriteFieldHeader. Only primitive types can be packed.
1536 |
1537 |
1538 |
1539 |
1540 | Specifies a known root object to use during reference-tracked serialization
1541 |
1542 |
1543 |
1544 |
1545 | Writes a Type to the stream, using the model's DynamicTypeFormatting if appropriate; supported wire-types: String
1546 |
1547 |
1548 |
1549 |
1550 | Addition information about this serialization operation.
1551 |
1552 |
1553 |
1554 |
1555 | Get the TypeModel associated with this writer
1556 |
1557 |
1558 |
1559 |
1560 | Additional information about a serialization operation
1561 |
1562 |
1563 |
1564 |
1565 | Convert a SerializationContext to a StreamingContext
1566 |
1567 |
1568 |
1569 |
1570 | Convert a StreamingContext to a SerializationContext
1571 |
1572 |
1573 |
1574 |
1575 | Gets or sets a user-defined object containing additional information about this serialization/deserialization operation.
1576 |
1577 |
1578 |
1579 |
1580 | A default SerializationContext, with minimal information.
1581 |
1582 |
1583 |
1584 |
1585 | Gets or sets the source or destination of the transmitted data.
1586 |
1587 |
1588 |
1589 |
1590 | Provides protocol-buffer serialization capability for concrete, attributed types. This
1591 | is a *default* model, but custom serializer models are also supported.
1592 |
1593 |
1594 | Protocol-buffer serialization is a compact binary format, designed to take
1595 | advantage of sparse data and knowledge of specific data types; it is also
1596 | extensible, allowing a type to be deserialized / merged even if some data is
1597 | not recognised.
1598 |
1599 |
1600 |
1601 |
1602 | The field number that is used as a default when serializing/deserializing a list of objects.
1603 | The data is treated as repeated message with field number 1.
1604 |
1605 |
1606 |
1607 |
1608 | Releases any internal buffers that have been reserved for efficiency; this does not affect any serialization
1609 | operations; simply: it can be used (optionally) to release the buffers for garbage collection (at the expense
1610 | of having to re-allocate a new buffer for the next operation, rather than re-use prior buffers).
1611 |
1612 |
1613 |
1614 |
1615 | Maps a field-number to a type
1616 |
1617 |
1618 |
1619 |
1620 | Uses protocol buffer serialization on the specified operation; note that this
1621 | must be enabled on both the client and server.
1622 |
1623 |
1624 |
1625 |
1626 | Configuration element to swap out DatatContractSerilaizer with the XmlProtoSerializer for a given endpoint.
1627 |
1628 |
1629 |
1630 |
1631 |
1632 | Creates a new ProtoBehaviorExtension instance.
1633 |
1634 |
1635 |
1636 |
1637 | Creates a behavior extension based on the current configuration settings.
1638 |
1639 | The behavior extension.
1640 |
1641 |
1642 |
1643 | Gets the type of behavior.
1644 |
1645 |
1646 |
1647 |
1648 | Behavior to swap out DatatContractSerilaizer with the XmlProtoSerializer for a given endpoint.
1649 |
1650 | Add the following to the server and client app.config in the system.serviceModel section:
1651 |
1652 |
1653 |
1654 |
1655 |
1656 |
1657 |
1658 |
1659 |
1660 |
1661 |
1662 |
1663 |
1664 | Configure your endpoints to have a behaviorConfiguration as follows:
1665 |
1666 |
1667 |
1669 |
1670 |
1671 |
1674 |
1675 |
1676 |
1677 |
1678 |
1679 |
1680 | Describes a WCF operation behaviour that can perform protobuf serialization
1681 |
1682 |
1683 |
1684 |
1685 | Create a new ProtoOperationBehavior instance
1686 |
1687 |
1688 |
1689 |
1690 | Creates a protobuf serializer if possible (falling back to the default WCF serializer)
1691 |
1692 |
1693 |
1694 |
1695 | The type-model that should be used with this behaviour
1696 |
1697 |
1698 |
1699 |
1700 | An xml object serializer that can embed protobuf data in a base-64 hunk (looking like a byte[])
1701 |
1702 |
1703 |
1704 |
1705 | Attempt to create a new serializer for the given model and type
1706 |
1707 | A new serializer instance if the type is recognised by the model; null otherwise
1708 |
1709 |
1710 |
1711 | Creates a new serializer for the given model and type
1712 |
1713 |
1714 |
1715 |
1716 | Ends an object in the output
1717 |
1718 |
1719 |
1720 |
1721 | Begins an object in the output
1722 |
1723 |
1724 |
1725 |
1726 | Writes the body of an object in the output
1727 |
1728 |
1729 |
1730 |
1731 | Indicates whether this is the start of an object we are prepared to handle
1732 |
1733 |
1734 |
1735 |
1736 | Reads the body of an object
1737 |
1738 |
1739 |
1740 |
1741 | Used to hold particulars relating to nested objects. This is opaque to the caller - simply
1742 | give back the token you are given at the end of an object.
1743 |
1744 |
1745 |
1746 |
1747 | Indicates the encoding used to represent an individual value in a protobuf stream
1748 |
1749 |
1750 |
1751 |
1752 | Represents an error condition
1753 |
1754 |
1755 |
1756 |
1757 | Base-128 variant-length encoding
1758 |
1759 |
1760 |
1761 |
1762 | Fixed-length 8-byte encoding
1763 |
1764 |
1765 |
1766 |
1767 | Length-variant-prefixed encoding
1768 |
1769 |
1770 |
1771 |
1772 | Indicates the start of a group
1773 |
1774 |
1775 |
1776 |
1777 | Indicates the end of a group
1778 |
1779 |
1780 |
1781 |
1782 | Fixed-length 4-byte encoding
1783 | 10
1784 |
1785 |
1786 |
1787 | This is not a formal wire-type in the "protocol buffers" spec, but
1788 | denotes a variant integer that should be interpreted using
1789 | zig-zag semantics (so -ve numbers aren't a significant overhead)
1790 |
1791 |
1792 |
1793 |
1794 |
--------------------------------------------------------------------------------
/Dependencies/x64/fbxImporter.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/Dependencies/x64/fbxImporter.dll
--------------------------------------------------------------------------------
/OutputLib/Debug/ICSharpCode.NRefactory.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/OutputLib/Debug/ICSharpCode.NRefactory.dll
--------------------------------------------------------------------------------
/OutputLib/Debug/Jhqc.UnityFbxLoader.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/OutputLib/Debug/Jhqc.UnityFbxLoader.dll
--------------------------------------------------------------------------------
/OutputLib/Debug/Jhqc.UnityFbxLoader.dll.mdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/OutputLib/Debug/Jhqc.UnityFbxLoader.dll.mdb
--------------------------------------------------------------------------------
/OutputLib/Debug/Mono.Cecil.Mdb.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/OutputLib/Debug/Mono.Cecil.Mdb.dll
--------------------------------------------------------------------------------
/OutputLib/Debug/Mono.Cecil.Pdb.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/OutputLib/Debug/Mono.Cecil.Pdb.dll
--------------------------------------------------------------------------------
/OutputLib/Debug/Mono.Cecil.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/OutputLib/Debug/Mono.Cecil.dll
--------------------------------------------------------------------------------
/OutputLib/Debug/Unity.CecilTools.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/OutputLib/Debug/Unity.CecilTools.dll
--------------------------------------------------------------------------------
/OutputLib/Debug/Unity.DataContract.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/OutputLib/Debug/Unity.DataContract.dll
--------------------------------------------------------------------------------
/OutputLib/Debug/Unity.SerializationLogic.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/OutputLib/Debug/Unity.SerializationLogic.dll
--------------------------------------------------------------------------------
/OutputLib/Debug/Unity.UNetWeaver.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/OutputLib/Debug/Unity.UNetWeaver.dll
--------------------------------------------------------------------------------
/OutputLib/Debug/Unity.UNetWeaver.dll.mdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/OutputLib/Debug/Unity.UNetWeaver.dll.mdb
--------------------------------------------------------------------------------
/OutputLib/Debug/UnityEditor.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/OutputLib/Debug/UnityEditor.dll
--------------------------------------------------------------------------------
/OutputLib/Debug/UnityEngine.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/OutputLib/Debug/UnityEngine.dll
--------------------------------------------------------------------------------
/OutputLib/Debug/protobuf-net.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/OutputLib/Debug/protobuf-net.dll
--------------------------------------------------------------------------------
/OutputLib/Release/ICSharpCode.NRefactory.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/OutputLib/Release/ICSharpCode.NRefactory.dll
--------------------------------------------------------------------------------
/OutputLib/Release/Jhqc.UnityFbxLoader.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/OutputLib/Release/Jhqc.UnityFbxLoader.dll
--------------------------------------------------------------------------------
/OutputLib/Release/Jhqc.UnityFbxLoader.dll.mdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/OutputLib/Release/Jhqc.UnityFbxLoader.dll.mdb
--------------------------------------------------------------------------------
/OutputLib/Release/Mono.Cecil.Mdb.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/OutputLib/Release/Mono.Cecil.Mdb.dll
--------------------------------------------------------------------------------
/OutputLib/Release/Mono.Cecil.Pdb.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/OutputLib/Release/Mono.Cecil.Pdb.dll
--------------------------------------------------------------------------------
/OutputLib/Release/Mono.Cecil.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/OutputLib/Release/Mono.Cecil.dll
--------------------------------------------------------------------------------
/OutputLib/Release/Unity.CecilTools.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/OutputLib/Release/Unity.CecilTools.dll
--------------------------------------------------------------------------------
/OutputLib/Release/Unity.DataContract.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/OutputLib/Release/Unity.DataContract.dll
--------------------------------------------------------------------------------
/OutputLib/Release/Unity.SerializationLogic.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/OutputLib/Release/Unity.SerializationLogic.dll
--------------------------------------------------------------------------------
/OutputLib/Release/Unity.UNetWeaver.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/OutputLib/Release/Unity.UNetWeaver.dll
--------------------------------------------------------------------------------
/OutputLib/Release/Unity.UNetWeaver.dll.mdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/OutputLib/Release/Unity.UNetWeaver.dll.mdb
--------------------------------------------------------------------------------
/OutputLib/Release/UnityEditor.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/OutputLib/Release/UnityEditor.dll
--------------------------------------------------------------------------------
/OutputLib/Release/UnityEngine.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/OutputLib/Release/UnityEngine.dll
--------------------------------------------------------------------------------
/OutputLib/Release/protobuf-net.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/OutputLib/Release/protobuf-net.dll
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yangyonggit/unityRuntimeFbxloader/c5c797b64e141923e6c66dae59c50775ca2da8ff/README.md
--------------------------------------------------------------------------------
/monomake.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 10.0.20506
7 | 2.0
8 | {f093755d4-70a0-46f7-a5b0-b78f93ec430a}
9 | Library
10 | Properties
11 | Jhqc
12 | Jhqc.UnityFbxLoader
13 | v3.5
14 | 512
15 |
16 |
17 | true
18 | full
19 | false
20 | OutputLib\Debug\
21 | DEBUG;TRACE;UNITY_5_3_3;UNITY_5_3;ENABLE_PROFILER;UNITY_STANDALONE_WINDOWS;ENABLE_GENERICS;ENABLE_DUCK_TYPING;ENABLE_TERRAIN;ENABLE_MOVIES;ENABLE_WEBCAM;ENABLE_MICROPHONE;ENABLE_NETWORK;ENABLE_CLOTH;ENABLE_WWW;ENABLE_SUBSTANCE
22 | prompt
23 | 4
24 | 0169
25 |
26 |
27 | pdbonly
28 | true
29 | OutputLib\Release\
30 | TRACE
31 | prompt
32 | 4
33 | 0169
34 |
35 |
36 |
37 |
38 | Dependencies\UnityEngine.dll
39 |
40 |
41 | Dependencies\UnityEditor.dll
42 |
43 |
44 | Dependencies\protobuf-net.dll
45 |
46 |
47 |
48 |
49 |
50 |
51 |
58 |
--------------------------------------------------------------------------------
/scripts/FbxLoader.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using System.Collections;
3 | using System.Runtime.InteropServices;
4 | using System;
5 | using System.IO;
6 | using System.Collections.Generic;
7 |
8 |
9 | namespace Jhqc.UnityFbxLoader
10 | {
11 | struct USceneInfo
12 | {
13 | public int sizeofbin;
14 | public IntPtr bins;
15 | }
16 |
17 | public enum ErrorCode
18 | {
19 | LoadOk,
20 | NotInitialized,
21 | OpenFileError,
22 | UnsetPointUV,
23 | StreamDecodeError,
24 | TextureNotFound,
25 | Unknow,
26 | }
27 |
28 |
29 |
30 | public class FbxLoader
31 | {
32 | class FbxLoaderException : System.Exception
33 | {
34 | internal FbxLoaderException(ErrorCode e)
35 | {
36 | error = e;
37 | }
38 |
39 | private ErrorCode error;
40 |
41 | internal ErrorCode Error
42 | {
43 | get { return error; }
44 | }
45 | }
46 |
47 | private static bool initialized = false;
48 |
49 |
50 | private static ErrorCode lastError = ErrorCode.LoadOk;
51 | public static ErrorCode LoadFbx(string name, out GameObject fbx)
52 | {
53 | //fbx = new GameObject("fbxLoader");
54 | fbx = null;
55 | lastError = ErrorCode.LoadOk;
56 |
57 | if (!initialized)
58 | return ErrorCode.NotInitialized;
59 |
60 | if (!File.Exists(name))
61 | {
62 | return ErrorCode.OpenFileError;
63 | }
64 |
65 | try
66 | {
67 | var scenenode = _LoadFbx(name);
68 | CreateSceneObject(scenenode, out fbx);
69 | //if (fbx.transform.childCount == 1)
70 | //{
71 | // var child = fbx.transform.GetChild(0);
72 | // child.parent = null;
73 | // var oldfbx = fbx;
74 | // fbx = child.gameObject;
75 | // GameObject.Destroy(oldfbx);
76 | //}
77 | }
78 | catch(FbxLoaderException e)
79 | {
80 | return e.Error;
81 | }
82 | fbx.name = GetFileName(name);
83 |
84 | return lastError;
85 | }
86 |
87 |
88 | static string GetFileName(string path)
89 | {
90 | int index = path.LastIndexOf("\\");
91 | if (index >= 0 && index < path.Length)
92 | {
93 | string name = path.Substring(index + 1);
94 | if (name.Length > 4)
95 | name = name.Substring(0, name.Length - 4);
96 | return name;
97 | }
98 | return "GameObject";
99 | }
100 |
101 | public static ErrorCode LoadFbx(byte[] filestream,out GameObject fbx)
102 | {
103 | fbx = null;//new GameObject("fbxLoader");
104 | lastError = ErrorCode.LoadOk;
105 | if (!initialized)
106 | return ErrorCode.NotInitialized;
107 | try
108 | {
109 | var scenenode = _LoadFbx(filestream);
110 | CreateSceneObject(scenenode, out fbx);
111 | if (fbx.transform.childCount == 1)
112 | {
113 | var child = fbx.transform.GetChild(0);
114 | child.parent = null;
115 | fbx = child.gameObject;
116 | }
117 | }
118 | catch (FbxLoaderException e)
119 | {
120 | return e.Error;
121 | }
122 | return lastError;
123 | }
124 |
125 | public static void InitLoader()
126 | {
127 | InitFbxLoader();
128 | initialized = true;
129 | }
130 |
131 | public static void UnInitFbxLoader()
132 | {
133 | initialized = false;
134 | FbxLoaderExit();
135 | }
136 |
137 |
138 |
139 | static T Decode(byte[] reply) where T : global::ProtoBuf.IExtensible
140 | {
141 | T data = default(T);
142 | using (MemoryStream ms = new MemoryStream(reply))
143 | {
144 | try
145 | {
146 | data = ProtoBuf.Serializer.Deserialize(ms);
147 | }
148 | catch (System.Exception e)
149 | {
150 | //data = default(T);
151 | throw new FbxLoaderException(ErrorCode.StreamDecodeError);
152 | }
153 | }
154 | return data;
155 | }
156 |
157 |
158 | static fbxImporter.USceneNode _LoadFbx(string name)
159 | {
160 | fbxImporter.USceneNode sceneNode = null;
161 | USceneInfo sceneInfo = new USceneInfo();
162 | //IntPtr csPtr = Marshal.AllocHGlobal(Marshal.SizeOf(sceneInfo));
163 | IntPtr scene = LoadScene(name);
164 | if (scene != IntPtr.Zero)
165 | {
166 | try
167 | {
168 | sceneInfo = (USceneInfo)Marshal.PtrToStructure(scene, typeof(USceneInfo));
169 | }
170 | catch(System.Exception e)
171 | {
172 | throw new FbxLoaderException(ErrorCode.StreamDecodeError);
173 | }
174 | byte[] bins = new byte[sceneInfo.sizeofbin];
175 | Marshal.Copy(sceneInfo.bins, bins, 0, sceneInfo.sizeofbin);
176 | sceneNode = Decode(bins);
177 | ClearUSceneBin(scene);
178 | }
179 |
180 | return sceneNode;
181 | }
182 |
183 | static fbxImporter.USceneNode _LoadFbx(byte[] bins)
184 | {
185 | fbxImporter.USceneNode sceneNode = null;
186 | USceneInfo sceneInfo = new USceneInfo();
187 | //IntPtr csPtr = Marshal.AllocHGlobal(Marshal.SizeOf(sceneInfo));
188 | IntPtr scene = LoadSceneFromMemory(bins, bins.Length);
189 | if (scene != IntPtr.Zero)
190 | {
191 | try
192 | {
193 | sceneInfo = (USceneInfo)Marshal.PtrToStructure(scene, typeof(USceneInfo));
194 | }
195 | catch (System.Exception e)
196 | {
197 | //Marshal.FreeHGlobal(csPtr);
198 | throw new FbxLoaderException(ErrorCode.StreamDecodeError);
199 | }
200 | byte[] localbins = new byte[sceneInfo.sizeofbin];
201 | Marshal.Copy(sceneInfo.bins, localbins, 0, sceneInfo.sizeofbin);
202 | sceneNode = Decode(localbins);
203 | ClearUSceneBin(scene);
204 | }
205 | return sceneNode;
206 | }
207 |
208 |
209 | static void CreateSceneObject(fbxImporter.USceneNode scene,out GameObject fbx)
210 | {
211 | //fbx.transform.localRotation = Quaternion.Euler(270, 0, 0);
212 | //fbx.name = "name";
213 | fbx = null;
214 | if (scene.meshNums == 1)
215 | {
216 | fbx = CreateMesh(scene.meshList[0], fbx);
217 | }
218 | else
219 | {
220 | fbx = new GameObject(scene.meshList[0].name);
221 | fbx.transform.localRotation = Quaternion.Euler(270, 0, 0);
222 | for (int i = 0; i < scene.meshNums; ++i)
223 | {
224 | var child = CreateMesh(scene.meshList[i], fbx);
225 | if (child != null)
226 | {
227 | child.transform.parent = fbx.transform;
228 | }
229 | }
230 | }
231 | }
232 |
233 | static Quaternion MatrixToQuaternion(double[,] mat)
234 | {
235 | var matrix = Matrix4x4.zero;
236 | matrix.m00 = (float)mat[0, 0];
237 | matrix.m01 = (float)mat[0, 1];
238 | matrix.m02 = (float)mat[0, 2];
239 | matrix.m10 = (float)mat[1, 0];
240 | matrix.m11 = (float)mat[1, 1];
241 | matrix.m12 = (float)mat[1, 2];
242 | matrix.m20 = (float)mat[2, 0];
243 | matrix.m21 = (float)mat[2, 1];
244 | matrix.m22 = (float)mat[2, 2];
245 |
246 | return MatrixToQuaternion(matrix);
247 | }
248 |
249 | static Quaternion MatrixToQuaternion(Matrix4x4 mat)
250 | {
251 | mat = mat.transpose;
252 | double w = 0, x = 0, y = 0, z = 0;
253 |
254 | double fourWSquaredMinus1 = mat.m00 + mat.m11 + mat.m22;
255 | double fourXSquaredMinus1 = mat.m00 - mat.m11 - mat.m22;
256 | double fourYSquaredMinus1 = mat.m11 - mat.m00 - mat.m22;
257 | double fourZSquaredMinus1 = mat.m22 - mat.m00 - mat.m11;
258 |
259 | int biggestIndex = 0;
260 | double fourBiggestSquaredMinus1 = fourWSquaredMinus1;
261 | if (fourXSquaredMinus1 > fourBiggestSquaredMinus1)
262 | {
263 | fourBiggestSquaredMinus1 = fourXSquaredMinus1;
264 | biggestIndex = 1;
265 | }
266 | if (fourYSquaredMinus1 > fourBiggestSquaredMinus1)
267 | {
268 | fourBiggestSquaredMinus1 = fourYSquaredMinus1;
269 | biggestIndex = 2;
270 | }
271 | if (fourZSquaredMinus1 > fourBiggestSquaredMinus1)
272 | {
273 | fourBiggestSquaredMinus1 = fourZSquaredMinus1;
274 | biggestIndex = 3;
275 | }
276 |
277 | // Perform square root and division
278 | double biggestVal = (double)Math.Sqrt(fourBiggestSquaredMinus1 + 1.0f) * 0.5f;
279 | double mult = 0.25 / biggestVal;
280 | // Apply table to compute quaternion values
281 | switch (biggestIndex)
282 | {
283 | case 0:
284 | w = biggestVal;
285 | x = (mat.m12 - mat.m21) * mult;
286 | y = (mat.m20 - mat.m02) * mult;
287 | z = (mat.m01 - mat.m10) * mult;
288 | break;
289 | case 1:
290 | x = biggestVal;
291 | w = (mat.m12 - mat.m21) * mult;
292 | y = (mat.m01 + mat.m10) * mult;
293 | z = (mat.m20 + mat.m02) * mult;
294 | break;
295 | case 2:
296 | y = biggestVal;
297 | w = (mat.m20 - mat.m12) * mult;
298 | x = (mat.m01 + mat.m10) * mult;
299 | z = (mat.m12 + mat.m21) * mult;
300 | break;
301 | case 3:
302 | z = biggestVal;
303 | w = (mat.m01 - mat.m10) * mult;
304 | x = (mat.m20 + mat.m02) * mult;
305 | y = (mat.m12 + mat.m21) * mult;
306 | break;
307 | }
308 | return new Quaternion((float)x, (float)y, (float)z, (float)w);
309 | }
310 |
311 | static double[,] QuaternionToMat(Quaternion q)
312 | {
313 | double x = q.x;
314 | double y = q.y;
315 | double z = q.z;
316 | double w = q.w;
317 |
318 | var mat = new double[3,3];
319 | mat[0,0] = 1 - 2 * y * y - 2 * z * z;
320 | mat[0,1] = 2 * x * y + 2 * w * z;
321 | mat[0,2] = 2 * x * z - 2 * w * y;
322 | mat[1,0] = 2 * x * y - 2 * w * z;
323 | mat[1,1] = 1 - 2 * x * x - 2 * z * z;
324 | mat[1,2] = 2 * y * z + 2 * w * x;
325 | mat[2,0] = 2 * x * z + 2 * w * y;
326 | mat[2,1] = 2 * y * z - 2 * w * x;
327 | mat[2,2] = 1 - 2 * x * x - 2 * y * y;
328 | return mat;
329 | }
330 |
331 | static GameObject CreateMesh(fbxImporter.UMeshNode meshNode,GameObject parent)
332 | {
333 | GameObject go = new GameObject();
334 | Debug.Log(meshNode.name);
335 | if (parent != null)
336 | go.transform.SetParent(parent.transform, false);
337 |
338 | // Debug.Log(FbxVector3ToVector3(meshNode.geoTras.localrotation));
339 | //Debug.Log(FbxVector3ToVector3(meshNode.geoTras.localscaling));
340 |
341 | go.name = meshNode.name;
342 | var localT = FbxVector3ToVector3(meshNode.geoTras.localtranslation);
343 | var localR = FbxVector4ToQuaternion(meshNode.geoTras.localrotation);
344 | var localS = FbxVector3ToVector3(meshNode.geoTras.localscaling);
345 |
346 | Matrix4x4 trsMat = Matrix4x4.TRS(localT, localR, new Vector3(1,1,1));
347 | //Debug.Log(localR + " " + localR.eulerAngles);
348 | //var r2 = MatrixToQuaternion(QuaternionToMat(localR));
349 | //Debug.Log(r2 + " " + r2.eulerAngles);
350 | //Debug.Log(MatrixToQuaternion(trsMat) + " " + MatrixToQuaternion(trsMat).eulerAngles);
351 |
352 | Matrix4x4 T = new Matrix4x4();
353 | T.m00 = -1; T.m01 = 0; T.m02 = 0; T.m03 = 0;
354 | T.m10 = 0; T.m11 = 1; T.m12 = 0; T.m13 = 0;
355 | T.m20 = 0; T.m21 = 0; T.m22 = 1; T.m23 = 0;
356 | T.m30 = 0; T.m31 = 0; T.m32 = 0; T.m33 = 1;
357 | Matrix4x4 newTrs = T.transpose * trsMat * T;
358 | Vector3 position = newTrs.GetColumn(3);
359 | // Extract new local rotation
360 | Quaternion rotationLook = Quaternion.LookRotation(
361 | newTrs.GetColumn(2),
362 | newTrs.GetColumn(1)
363 | );
364 | //Debug.Log(rotationLook);
365 | //Quaternion rotation = MatrixToQuaternion(newTrs);
366 |
367 | // Extract new local scale
368 | // Vector3 scale = new Vector3(
369 | // newTrs.GetColumn(0).magnitude,
370 | // newTrs.GetColumn(1).magnitude,
371 | // newTrs.GetColumn(2).magnitude
372 | // );
373 |
374 | go.transform.localPosition = position;
375 | go.transform.localRotation = rotationLook;
376 | go.transform.localScale = localS;
377 |
378 | if (parent == null)
379 | {
380 | var q = go.transform.localRotation.eulerAngles;
381 | if (Math.Abs(q.x - 270) > 1.0f)
382 | {
383 | var tmp = position;
384 | position.y = tmp.z;
385 | position.z = -tmp.y;
386 | }
387 | q .x = 270;
388 | go.transform.localRotation = Quaternion.Euler(q);
389 | go.transform.localPosition = position;
390 | }
391 |
392 |
393 | //Debug.Log(newTrs);
394 |
395 |
396 | //Debug.Log("------------------------");
397 | //Debug.Log(localT);
398 | //Debug.Log(position);
399 | //Debug.Log(localR);
400 | //Debug.Log(rotation.eulerAngles);
401 | //Debug.Log(FbxVector3ToVector3(meshNode.geoTras.localscaling));
402 | //Debug.Log(scale);
403 |
404 |
405 |
406 | //localT.x = -localT.x;
407 |
408 |
409 | //if (Math.Abs(localR.y) > 0.01f)
410 | //{
411 | // var t = localR;
412 | // localR.x = t.z;
413 | // localR.z = t.x;
414 | //}
415 | //else
416 | //{
417 | // localR.z = -localR.z;
418 | //}
419 |
420 | //if (parent != null)
421 | //{
422 | // localT = localT + parent.transform.localPosition;
423 | // localR = localR + parent.transform.localRotation.eulerAngles;
424 | // localS.x = localS.x * parent.transform.localScale.x;
425 | // localS.y = localS.y * parent.transform.localScale.y;
426 | // localS.z = localS.z * parent.transform.localScale.z;
427 | //}
428 |
429 | //go.transform.localScale = localS;
430 | //go.transform.localRotation = Quaternion.Euler(localR);
431 | //go.transform.localPosition = localT;
432 |
433 | //Debug.Log("------------------------");
434 | //Debug.Log(localT);
435 | //Debug.Log(go.transform.localPosition);
436 | //Debug.Log(localR);
437 | //Debug.Log(go.transform.localRotation.eulerAngles);
438 | //Debug.Log(FbxVector3ToVector3(meshNode.geoTras.localscaling));
439 | //Debug.Log(go.transform.localScale);
440 |
441 | if (meshNode.Polygons != null)
442 | {
443 | var meshfilter = go.AddComponent();
444 | go.AddComponent();
445 | var mesh = meshfilter.mesh;
446 | mesh.name = meshNode.name;
447 |
448 |
449 |
450 | int vcout = 0;
451 | mesh.SetVertices(GetAllVertexs(meshNode.Polygons, meshNode.geoTras, out vcout));
452 | //mesh.SetNormals(GetAllNormals(meshNode.Polygons, meshNode.geoTras));
453 | var uvs = GetAllUVs(meshNode.Polygons);
454 | mesh.SetUVs(0, uvs);
455 | if (uvs.Count != vcout)
456 | {
457 | //GameObject.Destroy(go);
458 | //throw new FbxLoaderException(ErrorCode.UnsetPointUV);
459 | //Debug.LogError("顶点没有UV");
460 | lastError = ErrorCode.UnsetPointUV;
461 | }
462 | SetTriangle(mesh, meshNode.Polygons, meshNode.materialList);
463 | var texList = meshNode.textureList;
464 | RemoveUnusedMaterial(meshNode.materialList, ref texList);
465 | CreateMaterial(go.GetComponent(), texList.ToArray());
466 | mesh.RecalculateNormals();
467 | mesh.Optimize();
468 | }
469 |
470 | for (int i = 0; i < meshNode.childrenNums; ++i)
471 | {
472 | var child = CreateMesh(meshNode.children[i],go);
473 | if (child != null)
474 | {
475 | //child.transform.parent = go.transform;
476 | }
477 | }
478 | return go;
479 | }
480 |
481 | static void RemoveUnusedMaterial(fbxImporter.UMaterialIndex matList, ref List texList)
482 | {
483 | for (int i = 0; i < texList.Count; ++i)
484 | {
485 | if (!IsTextureUsed(texList[i].materialId, matList))
486 | {
487 | texList.Remove(texList[i]);
488 | }
489 | }
490 | }
491 |
492 | static bool IsTextureUsed(int id, fbxImporter.UMaterialIndex matList)
493 | {
494 | bool bUsed = false;
495 | for (int i = 0; i < matList.indexList.Count; ++i)
496 | {
497 | if (id == matList.indexList[i])
498 | {
499 | bUsed = true; break;
500 | }
501 | }
502 | return bUsed;
503 | }
504 |
505 | static void CreateMaterial(MeshRenderer render, fbxImporter.UTextureInfo[] texInfo)
506 | {
507 | if (texInfo.Length == 0)
508 | return;
509 | Dictionary dic = new Dictionary();
510 | for (int i = 0; i < texInfo.Length; ++i)
511 | {
512 | var shader = Shader.Find("Standard");
513 | var mat = new Material(shader);
514 |
515 | var tex = new Texture2D(2, 2);
516 | if (!File.Exists(texInfo[i].diffusePath))
517 | {
518 | //Debug.LogError("texInfo[i].diffusePath 文件不存在");
519 | lastError = ErrorCode.TextureNotFound;
520 | continue;
521 | }
522 | if (!tex.LoadImage(File.ReadAllBytes(texInfo[i].diffusePath)))
523 | {
524 | //Debug.LogError("texInfo[i].diffusePath 文件加载失败");
525 | lastError = ErrorCode.TextureNotFound;
526 | continue;
527 | //throw new FbxLoaderException(ErrorCode.TextureNotFound);
528 | }
529 | if (tex.format == TextureFormat.ARGB32)
530 | mat.EnableKeyword("_ALPHATEST_ON");
531 |
532 | mat.mainTexture = tex;
533 | dic.Add(texInfo[i].materialId, mat);
534 | }
535 |
536 | var matlist = SortMaterial(dic);
537 | render.sharedMaterials = matlist;
538 | }
539 |
540 | static Material[] SortMaterial(Dictionary dic)
541 | {
542 | var list = new List>(dic);
543 | list.Sort(delegate (KeyValuePair a, KeyValuePair b)
544 | {
545 | return a.Key.CompareTo(b.Key);
546 | }
547 | );
548 |
549 | var mats = new Material[list.Count];
550 | for (int i = 0; i < mats.Length; ++i)
551 | mats[i] = list[i].Value;
552 |
553 | return mats;
554 | }
555 |
556 | static int[] GetTriangle(fbxImporter.UPolygons polygons)
557 | {
558 | if (polygons.polygon != null && polygons.polygon.Count > 0)
559 | {
560 | List indexList = new List();
561 | int baseIndex = 0;
562 | for (int i = 0; i < polygons.polygon.Count; ++i)
563 | {
564 | int n = polygons.polygon[i].coordinates.Count;
565 | GenIndex(baseIndex, n, indexList);
566 | baseIndex += n;
567 | }
568 | //indexList.Reverse();
569 | return indexList.ToArray();
570 | }
571 | return null;
572 | }
573 |
574 | static void SetTriangle(Mesh mesh, fbxImporter.UPolygons polygons,
575 | fbxImporter.UMaterialIndex matList)
576 | {
577 | if (polygons.polygon == null || polygons.polygon.Count == 0)
578 | {
579 | return;
580 | }
581 |
582 | List matindexList;
583 | if (matList != null)
584 | matindexList = matList.indexList;
585 | else
586 | matindexList = new List();
587 |
588 | if (matindexList.Count != polygons.polygon.Count)
589 | {
590 | matindexList = new List();
591 | for (int i = 0; i < polygons.polygon.Count; ++i)
592 | matindexList.Add(0);
593 | }
594 |
595 | var dicTriangle = new Dictionary>();
596 | int baseIndex = 0;
597 | for (int i = 0; i < polygons.polygon.Count; ++i)
598 | {
599 | List indexlist = null;
600 | if (!dicTriangle.TryGetValue(matindexList[i], out indexlist))
601 | {
602 | indexlist = new List();
603 | dicTriangle.Add(matindexList[i], indexlist);
604 | }
605 | int n = polygons.polygon[i].coordinates.Count;
606 | GenIndex(baseIndex, n, indexlist);
607 | baseIndex += n;
608 | }
609 |
610 | mesh.subMeshCount = dicTriangle.Keys.Count;
611 |
612 | var list = new List>>(dicTriangle);
613 | list.Sort(delegate (KeyValuePair> a, KeyValuePair> b)
614 | {
615 | return a.Key.CompareTo(b.Key);
616 | }
617 | );
618 |
619 |
620 | for (int i = 0; i < list.Count; ++i)
621 | {
622 | mesh.SetTriangles(list[i].Value, i);
623 | }
624 | }
625 |
626 | static void GenIndex(int baseIndex, int n, List list)
627 | {
628 | if (n < 3)
629 | {
630 | return;
631 | }
632 | int i = baseIndex;
633 | int j = baseIndex + 2;
634 | while (j < baseIndex + n)
635 | {
636 | list.Add(j - 1); list.Add(i); list.Add(j);
637 | ++j;
638 | }
639 | }
640 |
641 | static List GetAllVertexs(fbxImporter.UPolygons polygons, fbxImporter.UGeometricTransform geo, out int vertexCount)
642 | {
643 | List vertexs = new List();
644 | vertexCount = 0;
645 | if (polygons.polygon != null && polygons.polygon.Count > 0)
646 | {
647 | for (int i = 0; i < polygons.polygon.Count; ++i)
648 | {
649 | for (int j = 0; j < polygons.polygon[i].coordinates.Count; ++j)
650 | {
651 | Vector3 pos = FbxVector3ToVector3(polygons.polygon[i].coordinates[j]);
652 | pos.x *= geo.scaling.x;
653 | pos.y *= geo.scaling.y;
654 | pos.z *= geo.scaling.z;
655 | //pos = pos + Quaternion.Euler(FbxVector3ToVector3(geo.rotation)) * pos;
656 | pos += FbxVector3ToVector3(geo.translation);
657 | pos.x = -pos.x;
658 | vertexs.Add(pos);
659 | ++vertexCount;
660 | }
661 | }
662 | }
663 |
664 | //Debug.Log("GetAllVertexs " + count);
665 | return vertexs;
666 | }
667 |
668 | static Vector3 ToUnityXYZ(Vector3 p)
669 | {
670 | var pp = Vector3.zero;
671 | pp.x = -p.x;
672 | pp.y = p.z;
673 | pp.z = -p.y;
674 | return pp;
675 | }
676 |
677 | static List GetAllUVs(fbxImporter.UPolygons polygons)
678 | {
679 | List vertexs = new List();
680 | if (polygons.polygon != null && polygons.polygon.Count > 0)
681 | {
682 | for (int i = 0; i < polygons.polygon.Count; ++i)
683 | {
684 | for (int j = 0; j < polygons.polygon[i].texUV.Count; ++j)
685 | {
686 | vertexs.Add(FbxVector2ToVector2(polygons.polygon[i].texUV[j]));
687 | }
688 | }
689 | }
690 | return vertexs;
691 | }
692 |
693 | static List GetAllNormals(fbxImporter.UPolygons polygons, fbxImporter.UGeometricTransform geo)
694 | {
695 | List vertexs = new List();
696 | if (polygons.polygon != null && polygons.polygon.Count > 0)
697 | {
698 | for (int i = 0; i < polygons.polygon.Count; ++i)
699 | {
700 | for (int j = 0; j < polygons.polygon[i].normal.Count; ++j)
701 | {
702 | Vector3 pos = FbxVector3ToVector3(polygons.polygon[i].normal[j]);
703 | //pos = Quaternion.Euler(FbxVector3ToVector3(geo.rotation)) * pos;
704 | pos.x = -pos.x;
705 | vertexs.Add(pos.normalized);
706 | }
707 | }
708 | }
709 | return vertexs;
710 | }
711 |
712 | static Vector3 FbxVector3ToVector3(fbxImporter.Vector3 vec)
713 | {
714 | return new Vector3(vec.x, vec.y, vec.z);
715 | }
716 |
717 | static Quaternion FbxVector4ToQuaternion(fbxImporter.Vector4 vec)
718 | {
719 | return new Quaternion(vec.x, vec.y, vec.z,vec.w);
720 | }
721 |
722 | static Vector2 FbxVector2ToVector2(fbxImporter.Vector2 vec)
723 | {
724 | return new Vector2(vec.x, vec.y);
725 | }
726 |
727 |
728 |
729 | [DllImport("fbxImporter")]
730 | private static extern void InitFbxLoader();
731 |
732 | [DllImport("fbxImporter")]
733 | private static extern void FbxLoaderExit();
734 |
735 | [DllImport("fbxImporter")]
736 | private static extern IntPtr LoadScene(string n);
737 |
738 | [DllImport("fbxImporter")]
739 | private static extern IntPtr LoadSceneFromMemory(byte[] bins, long len);
740 |
741 | [DllImport("fbxImporter")]
742 | private static extern void ClearUSceneBin(IntPtr ptr);
743 | }
744 |
745 |
746 | }
--------------------------------------------------------------------------------
/scripts/fbxImporter.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 | // Generated from: fbxImporter.proto
11 | namespace fbxImporter
12 | {
13 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"Vector2")]
14 | public partial class Vector2 : global::ProtoBuf.IExtensible
15 | {
16 | public Vector2() {}
17 |
18 | private float _x;
19 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"x", DataFormat = global::ProtoBuf.DataFormat.FixedSize)]
20 | public float x
21 | {
22 | get { return _x; }
23 | set { _x = value; }
24 | }
25 | private float _y;
26 | [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"y", DataFormat = global::ProtoBuf.DataFormat.FixedSize)]
27 | public float y
28 | {
29 | get { return _y; }
30 | set { _y = value; }
31 | }
32 | private global::ProtoBuf.IExtension extensionObject;
33 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
34 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
35 | }
36 |
37 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"Vector3")]
38 | public partial class Vector3 : global::ProtoBuf.IExtensible
39 | {
40 | public Vector3() {}
41 |
42 | private float _x;
43 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"x", DataFormat = global::ProtoBuf.DataFormat.FixedSize)]
44 | public float x
45 | {
46 | get { return _x; }
47 | set { _x = value; }
48 | }
49 | private float _y;
50 | [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"y", DataFormat = global::ProtoBuf.DataFormat.FixedSize)]
51 | public float y
52 | {
53 | get { return _y; }
54 | set { _y = value; }
55 | }
56 | private float _z;
57 | [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"z", DataFormat = global::ProtoBuf.DataFormat.FixedSize)]
58 | public float z
59 | {
60 | get { return _z; }
61 | set { _z = value; }
62 | }
63 | private global::ProtoBuf.IExtension extensionObject;
64 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
65 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
66 | }
67 |
68 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"Vector4")]
69 | public partial class Vector4 : global::ProtoBuf.IExtensible
70 | {
71 | public Vector4() {}
72 |
73 | private float _x;
74 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"x", DataFormat = global::ProtoBuf.DataFormat.FixedSize)]
75 | public float x
76 | {
77 | get { return _x; }
78 | set { _x = value; }
79 | }
80 | private float _y;
81 | [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"y", DataFormat = global::ProtoBuf.DataFormat.FixedSize)]
82 | public float y
83 | {
84 | get { return _y; }
85 | set { _y = value; }
86 | }
87 | private float _z;
88 | [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"z", DataFormat = global::ProtoBuf.DataFormat.FixedSize)]
89 | public float z
90 | {
91 | get { return _z; }
92 | set { _z = value; }
93 | }
94 | private float _w;
95 | [global::ProtoBuf.ProtoMember(4, IsRequired = true, Name=@"w", DataFormat = global::ProtoBuf.DataFormat.FixedSize)]
96 | public float w
97 | {
98 | get { return _w; }
99 | set { _w = value; }
100 | }
101 | private global::ProtoBuf.IExtension extensionObject;
102 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
103 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
104 | }
105 |
106 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"UPolygon")]
107 | public partial class UPolygon : global::ProtoBuf.IExtensible
108 | {
109 | public UPolygon() {}
110 |
111 | private readonly global::System.Collections.Generic.List _coordinates = new global::System.Collections.Generic.List();
112 | [global::ProtoBuf.ProtoMember(1, Name=@"coordinates", DataFormat = global::ProtoBuf.DataFormat.Default)]
113 | public global::System.Collections.Generic.List coordinates
114 | {
115 | get { return _coordinates; }
116 | }
117 |
118 | private readonly global::System.Collections.Generic.List _texUV = new global::System.Collections.Generic.List();
119 | [global::ProtoBuf.ProtoMember(2, Name=@"texUV", DataFormat = global::ProtoBuf.DataFormat.Default)]
120 | public global::System.Collections.Generic.List texUV
121 | {
122 | get { return _texUV; }
123 | }
124 |
125 | private readonly global::System.Collections.Generic.List _normal = new global::System.Collections.Generic.List();
126 | [global::ProtoBuf.ProtoMember(3, Name=@"normal", DataFormat = global::ProtoBuf.DataFormat.Default)]
127 | public global::System.Collections.Generic.List normal
128 | {
129 | get { return _normal; }
130 | }
131 |
132 | private global::ProtoBuf.IExtension extensionObject;
133 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
134 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
135 | }
136 |
137 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"UPolygons")]
138 | public partial class UPolygons : global::ProtoBuf.IExtensible
139 | {
140 | public UPolygons() {}
141 |
142 | private readonly global::System.Collections.Generic.List _polygon = new global::System.Collections.Generic.List();
143 | [global::ProtoBuf.ProtoMember(1, Name=@"polygon", DataFormat = global::ProtoBuf.DataFormat.Default)]
144 | public global::System.Collections.Generic.List polygon
145 | {
146 | get { return _polygon; }
147 | }
148 |
149 | private global::ProtoBuf.IExtension extensionObject;
150 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
151 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
152 | }
153 |
154 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"UGeometricTransform")]
155 | public partial class UGeometricTransform : global::ProtoBuf.IExtensible
156 | {
157 | public UGeometricTransform() {}
158 |
159 | private fbxImporter.Vector3 _translation;
160 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"translation", DataFormat = global::ProtoBuf.DataFormat.Default)]
161 | public fbxImporter.Vector3 translation
162 | {
163 | get { return _translation; }
164 | set { _translation = value; }
165 | }
166 | private fbxImporter.Vector3 _rotation;
167 | [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"rotation", DataFormat = global::ProtoBuf.DataFormat.Default)]
168 | public fbxImporter.Vector3 rotation
169 | {
170 | get { return _rotation; }
171 | set { _rotation = value; }
172 | }
173 | private fbxImporter.Vector3 _scaling;
174 | [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"scaling", DataFormat = global::ProtoBuf.DataFormat.Default)]
175 | public fbxImporter.Vector3 scaling
176 | {
177 | get { return _scaling; }
178 | set { _scaling = value; }
179 | }
180 | private fbxImporter.Vector3 _localtranslation;
181 | [global::ProtoBuf.ProtoMember(4, IsRequired = true, Name=@"localtranslation", DataFormat = global::ProtoBuf.DataFormat.Default)]
182 | public fbxImporter.Vector3 localtranslation
183 | {
184 | get { return _localtranslation; }
185 | set { _localtranslation = value; }
186 | }
187 | private fbxImporter.Vector4 _localrotation;
188 | [global::ProtoBuf.ProtoMember(5, IsRequired = true, Name=@"localrotation", DataFormat = global::ProtoBuf.DataFormat.Default)]
189 | public fbxImporter.Vector4 localrotation
190 | {
191 | get { return _localrotation; }
192 | set { _localrotation = value; }
193 | }
194 | private fbxImporter.Vector3 _localscaling;
195 | [global::ProtoBuf.ProtoMember(6, IsRequired = true, Name=@"localscaling", DataFormat = global::ProtoBuf.DataFormat.Default)]
196 | public fbxImporter.Vector3 localscaling
197 | {
198 | get { return _localscaling; }
199 | set { _localscaling = value; }
200 | }
201 | private global::ProtoBuf.IExtension extensionObject;
202 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
203 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
204 | }
205 |
206 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"UMaterialIndex")]
207 | public partial class UMaterialIndex : global::ProtoBuf.IExtensible
208 | {
209 | public UMaterialIndex() {}
210 |
211 | private string _mapping = "";
212 | [global::ProtoBuf.ProtoMember(1, IsRequired = false, Name=@"mapping", DataFormat = global::ProtoBuf.DataFormat.Default)]
213 | [global::System.ComponentModel.DefaultValue("")]
214 | public string mapping
215 | {
216 | get { return _mapping; }
217 | set { _mapping = value; }
218 | }
219 | private string _referenceMode = "";
220 | [global::ProtoBuf.ProtoMember(2, IsRequired = false, Name=@"referenceMode", DataFormat = global::ProtoBuf.DataFormat.Default)]
221 | [global::System.ComponentModel.DefaultValue("")]
222 | public string referenceMode
223 | {
224 | get { return _referenceMode; }
225 | set { _referenceMode = value; }
226 | }
227 | private readonly global::System.Collections.Generic.List _indexList = new global::System.Collections.Generic.List();
228 | [global::ProtoBuf.ProtoMember(3, Name=@"indexList", DataFormat = global::ProtoBuf.DataFormat.ZigZag)]
229 | public global::System.Collections.Generic.List indexList
230 | {
231 | get { return _indexList; }
232 | }
233 |
234 | private global::ProtoBuf.IExtension extensionObject;
235 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
236 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
237 | }
238 |
239 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"UTextureInfo")]
240 | public partial class UTextureInfo : global::ProtoBuf.IExtensible
241 | {
242 | public UTextureInfo() {}
243 |
244 | private int _materialId;
245 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"materialId", DataFormat = global::ProtoBuf.DataFormat.ZigZag)]
246 | public int materialId
247 | {
248 | get { return _materialId; }
249 | set { _materialId = value; }
250 | }
251 | private string _diffusePath = "";
252 | [global::ProtoBuf.ProtoMember(2, IsRequired = false, Name=@"diffusePath", DataFormat = global::ProtoBuf.DataFormat.Default)]
253 | [global::System.ComponentModel.DefaultValue("")]
254 | public string diffusePath
255 | {
256 | get { return _diffusePath; }
257 | set { _diffusePath = value; }
258 | }
259 | private fbxImporter.Vector2 _diffuvScale = null;
260 | [global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"diffuvScale", DataFormat = global::ProtoBuf.DataFormat.Default)]
261 | [global::System.ComponentModel.DefaultValue(null)]
262 | public fbxImporter.Vector2 diffuvScale
263 | {
264 | get { return _diffuvScale; }
265 | set { _diffuvScale = value; }
266 | }
267 | private fbxImporter.Vector2 _diffvTranslation = null;
268 | [global::ProtoBuf.ProtoMember(4, IsRequired = false, Name=@"diffvTranslation", DataFormat = global::ProtoBuf.DataFormat.Default)]
269 | [global::System.ComponentModel.DefaultValue(null)]
270 | public fbxImporter.Vector2 diffvTranslation
271 | {
272 | get { return _diffvTranslation; }
273 | set { _diffvTranslation = value; }
274 | }
275 | private bool _diffswapUV = default(bool);
276 | [global::ProtoBuf.ProtoMember(5, IsRequired = false, Name=@"diffswapUV", DataFormat = global::ProtoBuf.DataFormat.Default)]
277 | [global::System.ComponentModel.DefaultValue(default(bool))]
278 | public bool diffswapUV
279 | {
280 | get { return _diffswapUV; }
281 | set { _diffswapUV = value; }
282 | }
283 | private global::ProtoBuf.IExtension extensionObject;
284 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
285 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
286 | }
287 |
288 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"UMeshNode")]
289 | public partial class UMeshNode : global::ProtoBuf.IExtensible
290 | {
291 | public UMeshNode() {}
292 |
293 | private string _name;
294 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"name", DataFormat = global::ProtoBuf.DataFormat.Default)]
295 | public string name
296 | {
297 | get { return _name; }
298 | set { _name = value; }
299 | }
300 | private fbxImporter.UPolygons _Polygons = null;
301 | [global::ProtoBuf.ProtoMember(2, IsRequired = false, Name=@"Polygons", DataFormat = global::ProtoBuf.DataFormat.Default)]
302 | [global::System.ComponentModel.DefaultValue(null)]
303 | public fbxImporter.UPolygons Polygons
304 | {
305 | get { return _Polygons; }
306 | set { _Polygons = value; }
307 | }
308 | private fbxImporter.UGeometricTransform _geoTras = null;
309 | [global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"geoTras", DataFormat = global::ProtoBuf.DataFormat.Default)]
310 | [global::System.ComponentModel.DefaultValue(null)]
311 | public fbxImporter.UGeometricTransform geoTras
312 | {
313 | get { return _geoTras; }
314 | set { _geoTras = value; }
315 | }
316 | private int _childrenNums;
317 | [global::ProtoBuf.ProtoMember(4, IsRequired = true, Name=@"childrenNums", DataFormat = global::ProtoBuf.DataFormat.ZigZag)]
318 | public int childrenNums
319 | {
320 | get { return _childrenNums; }
321 | set { _childrenNums = value; }
322 | }
323 | private readonly global::System.Collections.Generic.List _children = new global::System.Collections.Generic.List();
324 | [global::ProtoBuf.ProtoMember(5, Name=@"children", DataFormat = global::ProtoBuf.DataFormat.Default)]
325 | public global::System.Collections.Generic.List children
326 | {
327 | get { return _children; }
328 | }
329 |
330 | private fbxImporter.UMaterialIndex _materialList = null;
331 | [global::ProtoBuf.ProtoMember(6, IsRequired = false, Name=@"materialList", DataFormat = global::ProtoBuf.DataFormat.Default)]
332 | [global::System.ComponentModel.DefaultValue(null)]
333 | public fbxImporter.UMaterialIndex materialList
334 | {
335 | get { return _materialList; }
336 | set { _materialList = value; }
337 | }
338 | private readonly global::System.Collections.Generic.List _textureList = new global::System.Collections.Generic.List();
339 | [global::ProtoBuf.ProtoMember(7, Name=@"textureList", DataFormat = global::ProtoBuf.DataFormat.Default)]
340 | public global::System.Collections.Generic.List textureList
341 | {
342 | get { return _textureList; }
343 | }
344 |
345 | private global::ProtoBuf.IExtension extensionObject;
346 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
347 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
348 | }
349 |
350 | [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"USceneNode")]
351 | public partial class USceneNode : global::ProtoBuf.IExtensible
352 | {
353 | public USceneNode() {}
354 |
355 | private int _meshNums;
356 | [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"meshNums", DataFormat = global::ProtoBuf.DataFormat.ZigZag)]
357 | public int meshNums
358 | {
359 | get { return _meshNums; }
360 | set { _meshNums = value; }
361 | }
362 | private readonly global::System.Collections.Generic.List _meshList = new global::System.Collections.Generic.List();
363 | [global::ProtoBuf.ProtoMember(2, Name=@"meshList", DataFormat = global::ProtoBuf.DataFormat.Default)]
364 | public global::System.Collections.Generic.List meshList
365 | {
366 | get { return _meshList; }
367 | }
368 |
369 | private global::ProtoBuf.IExtension extensionObject;
370 | global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
371 | { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
372 | }
373 |
374 | }
--------------------------------------------------------------------------------