Is there a way to convert gltf to dae? - converters

I can make gltf files with the collada to gltf converter.
But is there a way to reverse this?

UPDATE - October 2019 - Blender 2.80 has shipped with full glTF 2.0 import/export capability. It also has COLLADA import/export capability, so can be used to convert one to the other.
UPDATE - November 2018 rewrote answer for glTF version 2.0, which has almost completely replaced 1.0 in the time since this question was originally asked.
glTF 2.0 can be processed by a variety of tools, many of which are listed on the glTF Tools section of the official Khronos glTF README.
Older glTF 1.0
While there are numerous command-line utilities for converting to glTF, the options are much more limited going the other way, from glTF to COLLADA or anything else. One thing to understand about this is that glTF is intended to be a runtime delivery format, not an interchange format like COLLADA. glTF strives to store its internal data in as close to GPU-ready form as possible, with mesh data organized into data structures that can be used as vertex attributes, and so on. Khronos has a tagline that glTF is "the JPG of 3D" meaning that it has wide distribution to rendering engines of all kinds.
So, importing a glTF into a 3D editing package is something like loading a JPG into a paint program. You can do it, but after the import you want to avoid any unnecessary round-trips to and from the delivery format. So you would use the paint program's native save format (.psd or .xcf etc), or the 3D modeler's native save format, to keep your own editable copy of your work, and ship the exported JPG or PNG or glTF for wide distribution.
Even so, I do expect more importers to become available as time goes on. glTF version 1.0 had an internal structure that made this quite difficult (its vertex shaders would use swaths of attribute data without explicitly marking them as positions or normals, etc.) glTF 2.0 replaced those custom shaders with modern pbr pipeline assets, with clearly marked mesh position, normal, and other data, opening the door for future import tools and utilities of all kinds.

Related

Importing PBR models into Xcode results in incorrect shader properties

I have been experimenting with different 3D model file formats in Xcode, primarily .obj and .dae.
However, after I export these files from Blender, they either don't have any lighting associated with them or all of the values (especially their metalness and roughness) are not what they were initially setup to be.
.obj export,
.dae export,
then the blender version.
Is the issue how I'm exporting the models from Blender, the models themselves, or something else?
obj
If you create a model in Blender (or in Maya), remember, every app has its own internal shaders that may differ from SceneKit's shaders. When you export any model as .obj you also get a corresponding uv-mapped .mtl texture file. There are no lights inside .obj, because this format does support only geometry (with smoothness, normals and UV IDs). And one more thing – .obj doesn't support animation.
dae
.dae format allows you export not only 3D geometry with animations but also its corresponding shaders (like Phong, Blinn or Lambert) with colours and textures (however, Blender or Maya's procedural textures are not supported). And all the lights that were in 3D scene will be also exported.
usdz
The best candidate for export is .usdz file. Not all 3D authoring tools have export usdz option, but Autodesk Maya 2022, thanks to USD plugin, has.
.usdz format has all the features that .dae format has, but in addition to that I can say it's native to RealityKit, SceneKit, Reality Composer and QuickLook, its hierarchical system was adapted for larger scenes and it supports Python USDZ schemas.

Issues in THREEJS with converted GLTF 2.0 models

I have over 100k of GLTF 1.0 models. We are in the process of converting to 2.0, and is hitting a brick wall.
The source models are Collada at first, and we used Collada2GLTF converter to generate the GLTF files. But we did do this using the KHR_materials_common setting, which created perfect results for us.
But now we want to convert the GLTF files to 2.0, and this is proven quite problematic. The process works fine, but the converted model gets the 'KHR_materials_common' extension. It is through that material that the texture is bound.
As we are using the THREE JS renderer, its GLTF loader does not yet support this extension, and no texture is displayed. It only gets a totally black surface.
I have given it (a quick) got to add that extension locally, using MeshBasicMaterial, but with no good result.
So, my question is, what are my options, if any?
Is there a way to convert and remove the KHR_materials_common from the GLTF 1.0 source?
Can the conversion process (gltf-pipeline) remove the extension?
Is there any work in progress to add the support in THREEJS GLTFLoader?
Conversion from source to GLTF 2.0 works, but I do not have all sources available. Some are customers property, and we do not store that.
Reversing back to COLLADA is not supported (here)
A quick summary of the material types in glTF 1.0 and glTF 2.0, as of late 2018:
glTF 1.0
(Core): Custom GLSL shaders.
KHR_materials_common: Blinn, Phong, Lambert, and Constant/unlit.
glTF 2.0
(Core): Metal/rough PBR.
KHR_materials_pbrSpecularGlossiness: Spec/gloss PBR.
KHR_materials_unlit: Constant/unlit.
KHR_techniques_webgl: Custom GLSL shaders. (in progress)
Note that there are no blinn, phong, or lambert materials in glTF 2.0. Do you know what types of materials, or what types of textures, are used by your 100,000 models? That will help to answer which glTF 2.0 material you should be using.
Three.js implements all of the glTF 2.0 material options, except KHR_techniques_webgl, for which the specification is not complete. Three.js does not implement KHR_materials_common, because it isn't part of glTF 2.0.
Most likely, if you used unlit materials in glTF 1.0, you should use the KHR_materials_unlit extension in glTF 2.0. If you used blinn, phong, or lambert, you should use metal/rough or spec/gloss PBR in glTF 2.0. The PBR conversion of those materials should look quite good, although if you're looking for an exact match of the legacy materials, you may need to consider the custom GLSL extension.
I don't think glTF-Pipeline can do this conversion, but it would be well worth filing an issue there (it looks like you already have?) to request it. If not, the conversion is probably something you can implement yourself. It's much easier, for example, than converting anything to/from a GLSL material.

Modification 3D file to the website

I use WebGL.
Is there a way to modify a .obj file (or another 3D file) for example on photoshop? When I do some change on such a file, I would like it to keep the changes I made when I load it on a website.
I know it is not possible with .obj, so is there another format to do this?
I think you can load some 3d files into photoshop these days, but I'm pretty sure you will not be able to modify them.
To modify .obj files you can use 3d software such as 3DS Max or Maya, or you could use an online tools such as the three.js editor or claria.io
There are probably various ways to achieve what you want.
If I understood you correctly, you actually have multiple questions, here are some answers:
Which 3D editing software could I use?
If you want to perform some modification with a powerful 3D modeling tool, I would recommend to download and try blender. It is completely free, but in fact a very advanced 3D modeling software.
In case you just want to smooth your mesh, simplify it, or apply some other generic operation like this, then MeshLab might be sufficient (also available for free).
Which 3D model format should I use for delivering my 3D asset on the Web?
If you use X3DOM for displaying your 3D file, you can use the standardized X3D format (like OBJ, X3D content can be imported / exported in both, blender and meshlab). This has the advantage that you can use X3DOM's inline tag and directly import an X3D file, which means you can edit the 3D content without needing to re-convert your data for the Web.
However, using OBJ, X3D or whatever text-based delivery format might not be the wisest choice if your 3D asset is large, since this will introduce long download times. Therefore, if you have complex assets / scenes, you should also consider to convert your 3D assets to a compact, optimized delivery format for the Web, such as glTF or SRC.

Exporting Maya Animation and Bones to .Json

Iv'e tried every setting of so many exporters to get this to work, the blacktowers modified exporter for three.js, Inka3d, clara.io and online converters, and trying opening the FBX with animation into blender to no avil.
The FBX has animation and plays on websites such as clara.io and inside of Maya / 3DS Max, however when exporting the .json or .js it doesn't work inside the online editor or offline editors.
Is there any other way to get Animations with skinned bones / joints from Maya to .js / .json that will work inside of Three.Js?
The other answer is inaccurate. It is possible (and, indeed, common) to export animations and bones to three.js-friendly JSON files, from all the major 3d formats (FBX, DAE, etc.). The most robust and foolproof way seems to be through the JSON exporter in Blender - sometimes it still requires some fidgeting with, but the pipeline is mostly functional in 99% percent of the cases I've seen.
Currently (Jan '16) there is no need to use the blacktower exporter; the standard JSON exporter for Blender works just fine.
This is a good tutorial, although current practices (at least my own) differ slightly and you may have to play with various exporter options to make it work for you. If you're still running into problems, please post a clearer description of your specific issue and I'll try to help you get it working.
None of the JSON formats for ThreeJS support keyframe or bone data I understand. Right now I believe on Collada and possibly the MD* file types can be imported into ThreeJS directly with bone and keyframe data.

How to import Blender 3D animation to iPhone OpenGL ES?

I am trying to do animations on iPhone using OpenGL ES. I am able to do the animation in Blender 3D software. I can export as a .obj file from Blender to OpenGL and it works on iPhone.
But I am not able to export my animation work from Blender 3D to OpenGL. Can anyone please help me to solve this?
If you have a look at this article by Jeff LaMarche, you'll find a blender script that will output a 3D model to a C header file. There's also a followup article that improves upon the aforementioned script.
After you've run the script, it's as simple as including the header in your source, and passing the array of vertices through your drawing function. Ideally you'd want a method of loading arbitrary model files at runtime, but for prototyping this method is the simplest to implement.
Seeing as you already have a method of importing models (obj) then the above may not apply. However, the advantage of using a blender script is that you can then modify the script to suit your own needs, perhaps also exporting bone information or model keyframes.
Well first off, I wouldn't recommend .obj for this purpose since the obj file format doesn't support animation, only static 3D models. So you'll need to export the animation data as a separate file that you load at the same time as the obj.
Which file format I would recommend depends on what exactly your animations are. I don't remember off the top of my head what file formats Blender supports, but as I recall it does not export Collada files with animation, which would be the most general recommendation. Other options would be md2 for character animations, or 3ds for simple "rigid objects moving around" animations. I think Blender's FBX exporter will work, although that file format may be too complicated for your needs.
That said, and assuming you only need simple rigid object movements, you could use .obj for the 3D model shapes and then write a simple Python script to export a file from Blender that has at the keyframes listed, with the frame, position, and rotation for each keyframe. Then load that data in your code and play back those keyframes on the 3D model.
This is an old question and since then some new iOS frameworks have been released such as GLKit. I recommend relying on them as much as possible when you can, since they take care of many inherent conversions like this, though I haven't researched the specifics. Also, while not on iOS, the new Scene Graph technology for OS X (which will likely arrive on iOS) in the future, take all this quite a bit further and a crafty individual could do some conversions with that tool and then take the output to iOS.
Also have a look at SIO2.
I haven't used recent versions of Blender, but my understanding is that it supports exporting mesh animation as a sequence of .obj files. If you can already display a single .obj in your app, then displaying several of them one after another will achieve what you want.
Now, note that this is not the most efficient form to export this type of animation, since each .obj file will have a lot of duplicated info. If your mesh stays fixed over time (i.e. only the vertices move with the polygon structure, uv coords, etc. all fixed) then you can just import the entire first .obj and from the rest just read the vertex array.
If you wanted to optimize this even more, you could compress the vertex arrays so that you only store the differences from the previous frame of the animation.
Edit: I see that Blender 2.59 has export to COLLADA. According to the Blender manual, you can export object transformations, and you can also export baked animation for rigged objects. The benefit for you in supporting the COLLADA format in your iPhone app is that you are free to switch between animation tools, since most of them export this format.

Resources