Commit Graph

236 Commits

Author SHA1 Message Date
Pär Winzell 34800d056a
Merge pull request #28 from facebookincubator/bug-fix-einherit-warning
Fix and improve inheritance warnings.
2017-10-27 15:52:35 -07:00
Par Winzell 075dc4a8c3 Fix and improve inheritance warnings.
We were warnings against eInheritRSrs, which is actually the one type of
ineritance we're good with. It's eInheritRrSs we should freak out about.

That said, no need to do it for the root node -- at that point there is
no global transform to worry about.
2017-10-27 15:47:49 -07:00
Par Winzell 22354fd7ce Use standard library log2f. 2017-10-27 15:31:32 -07:00
Par Winzell 1829f6d6a6 RawSurface.skinRigid not used. 2017-10-27 15:31:32 -07:00
Pär Winzell 6137694595
Merge pull request #26 from facebookincubator/error-fix
Fix error reporting.
2017-10-27 12:28:15 -07:00
Michael Bayne a03e252866 Fix error reporting. 2017-10-27 12:21:13 -07:00
Par Winzell b1076fa373 Default opts to empty array if it's not supplied.
Fixes a NPE on line 33 for a common case.
2017-10-25 13:24:30 -07:00
Par Winzell 91d11c88b7 Do the right thing with empty directory path.
When we convert a file that's in our CWD, on Unix the folder component
of the path will simply be "", whereas opendir() wants ".".

I want to take another more substantial pass at texture resolution, once
we're out of urgent bugfix mode.
2017-10-25 12:02:25 -07:00
Par Winzell db3f232fc9 Cope with geometry opting out of geometry.
Some FBX files have index arrays that contain -1 (indeed, that are
nothing but negative ones). Presumably the intention is to specify "no
material". In any case, let's not segfault.
2017-10-24 20:57:55 -07:00
Pär Winzell 4e0f5e4fcf Merge pull request #15 from robertlong/master
Skip invalid animations with 0 channels.
2017-10-24 11:32:48 -07:00
Par Winzell fb7dae380b Actually initialize the dracoMesh pointer. 2017-10-24 09:15:59 -07:00
Par Winzell e417fbe90e Fix the --keep-attribute option. 2017-10-24 08:50:46 -07:00
Par Winzell f535effb8b NPM-publish of patch release 0.9.1. 2017-10-23 20:13:17 -07:00
Pär Winzell 72eb620d87 Copy texture files to output dir when appropriate. (#23)
When we've successfully located a referenced texture image on the local
filesystem and we're generating non-binary, non-embedded output, copy
the source folder wholesale into the destination directory.

This means the output folder is always a full, free-standing deployment,
one that can be dragged into e.g. https://gltf-viewer.donmccurdy.com/
2017-10-23 19:30:51 -07:00
Par Winzell 5580dcfa92 Whitespace tweaks in log output. 2017-10-23 18:59:32 -07:00
Par Winzell 5a4959d86c Don't mention texture here.
This is a general-purpose function now.
2017-10-23 17:29:00 -07:00
Pär Winzell dfb026033d Document the new v-flipping default. (#22)
The READMEs need updating, too.
2017-10-22 16:43:20 -07:00
Pär Winzell d46aeb3d46 Merge pull request #21 from zellski/feat-default-to-flipped-textures
Default to vertically flipping texture coordinates.
2017-10-22 16:32:50 -07:00
Par Winzell 998b7719cb Default to vertically flipping texture coordinates.
In the FBX world, (0, 0) is generally the lower left. By the glTF
specification, (0, 0) is the upper left. The only recourse is to
literally flip all texture files (generally unwise) or to remap the UV
space.

Is this confusing in an artist-to-engineer workflow? Maybe. But it's the
best option, and it seems reasonably easy to communicate.

To request unflipped coordinates, send in a --no-flip-v command switch.
2017-10-22 16:27:43 -07:00
Pär Winzell e0e81404f9 Multiple tweaks to README. (#19)
Update README.md with recent developments, add various relevant links to the GitHub project, clean up the language, various misc line edits.
2017-10-21 10:45:56 -07:00
Pär Winzell 8cf7f446b7 Further improvemens to texture resolution. (#16)
* Further improvemens to texture resolution.

- Move towards std::string over char * and FbxString where convenient,
- Make a clear distinction between textures whose image files have been
  located and those who haven't; warn early in the latter case.
- Extend RawTexture so we always know logical name in FBX, original file
  name in FBX, and inferred location in local filesystem.
- In non-binary mode, simply output the inferred local file basename as
  the URI; this will be the correct relative path as long as the texture
  files are located next to the .gltf and .bin files.

Primary remaining urge for a follow-up PR:

- We should be copying texture image files into the .gltf output folder,
  but before that we should switch to an off-the-shelf cross-platform
  file manipulation library like https://github.com/cginternals/cppfs.
  When we make that transition, all this texture resolution code will
  undergo another refactoring.
2017-10-20 09:42:39 -07:00
Robert Long 454cb7c864 Skip animations with 0 channels. 2017-10-19 16:27:47 -07:00
Michael Bayne 946f12361c Numerous improvements to Node API.
- Removed the shell scripts. We now invoke everything straight from Node.

- Allow passing command line arguments to the tool via the Node API.

- Require .glb or .gltf extension because the tool is automatically going to
  add that extension anyway, so we strip it off and add it back to shield the
  user from this weirdness. The tool may eventually stop adding an extension
  (and perhaps just validate it) and we can simplify our code.

- Automatically add --binary option if the requested target file is a .glb.

This also renames the bin/Windows directory to bin/Windows_NT, which is
unfortunate but that matches os.type(). This ultimately comes from uname and
that's what Windows chose to return. Let's just live with this historical
accident rather than try to paper over it.
2017-10-19 13:44:54 -07:00
Michael Bayne 9085b8d284 Add usage docs to README.
Fixes #8.
2017-10-19 11:01:51 -07:00
Par Winzell c194843239 More helpful README update. 2017-10-19 09:15:25 -07:00
Par Winzell 606d31997c Supply JSON-critical comma. 2017-10-19 09:15:01 -07:00
Par Winzell 443243a52c Only ever create one BufferViewData per file.
It is not uncommon for multiple logical textures in an FBX to reference
the same filename. Each such filename should yield one buffer view only,
and all sharing textures should reference it.
2017-10-18 21:49:45 -07:00
Par Winzell bc803213fc Delete obsolete snippets. 2017-10-17 21:19:36 -07:00
Par Winzell bf28c29f50 Multiple fixes for transparency.
- alphaMode is only BLEND for transparent materials.
- We use RawMaterial.type to figure out what's transparent.
- FBX TransparencyFactor is not opacity, but 1.0-opacity.
- Treat vertex coloured materials as transparent
  - We should at least iterate over vertices here and see if any of them
    actually are transparent
- Sort triangles properly: transparent ones render last!
2017-10-17 21:14:52 -07:00
Par Winzell d4ac174023 Don't include empty extension info. 2017-10-17 20:37:40 -07:00
Par Winzell b44d3b19a8 Fix build across all platforms. 2017-10-17 17:56:21 -07:00
Par Winzell f4a48905eb Directories for NPM published binaries.
We may revisit this way of publishing releases, but for now let's make
sure these directories always exist.
2017-10-17 17:35:34 -07:00
Par Winzell f2a057d783 Do a better job resolving texture files.
- Nix GetFileFolder(). It was not helping. Always search for textures
- near the FBX file.
- Use RawTexture::name for the texture name and ::fileName for the
  inferred local filename path.
2017-10-16 23:31:19 -07:00
Par Winzell e9067850e1 Break out material property & texture code.
Digging the property values and texture shadows thereof, associated with
a certain FbxSurfaceTexture, should clearly happen once per material,
not per polygon. Furthermore there is a pre-existing pattern of
Fbx-specific accessclasses in Fbx2Raw that we should follow.

Soon we'll be extracting more than Phong/Lambert properties here, and
then we'll need to do further refactoring.
2017-10-16 23:12:57 -07:00
Par Winzell e6cd0f012b Propertly transform UV coordinates.
We were mapping v to -v rather than 1-v, with fairly catastrophic
results. While fixing, take the trouble to introduce a more general
transformation mechanism than just an affine matrix.
2017-10-16 23:02:46 -07:00
Par Winzell 276a0dfb86 Initial commit. 2017-10-13 01:55:11 -07:00