How to convert Blender blend (or obj) file to Qualcom Vuforia .h file - ios

I'm developing an iOS app with augmented reality using Qualcomm Vuforia and I have difficulty in understanding how to create 3D models from Blender (or other softwares). All the examples use .h files with the coordinates of the vertices to generate i.e. a teapot.
I can not find documentation useful for me.
Is there a tool to convert .blend or .obj files to .h (OpenGL ES)?
thanks

I developed a script called mtl2opengl that does exactly what you need, based on the project obj2opengl. The script works with .obj and .mtl files, which I think can be exported straight from Blender, and produces .h files with vertex data. I use it extensively in my iOS augmented reality applications (though I haven't used the Vuforia SDK yet) and the accompanying resources include a sample Xcode project too. Hope it helps!

You should check out BlenderVuforiaExport (developed by a coworker of mine) here:
https://github.com/StickyBeat/BlenderVuforiaExport
It exports objects from Blender to the same .h-format used in the Vuforia example project.

I don't know much about vufoia, but here are two answers about using blender to get 3d models and displaying them on iPhone. These may help you.
How to get proper number of vertices in OBJ file from DCC tools such as Blender for use in OpenGL ES?
Put a Cinema 4D model and Texture into an iPhone App

Related

How to prepare a 3D model to embed in an AR App

I have a newbie-questions regarding a 3D model I want to use in an AR App (with sceneform). The model itself is in .fbx format and I have 5 textures or maps (as .jpg files) for opacity, metal, roughness, base color and normal. Importing the .fbx model works, but I have no idea how to assign the textures to it. According to the documentation (https://developers.google.com/ar/develop/java/sceneform/custom-material), I need a .mat file. And that's my problem, how to create one. Manually or automatically. Where to start? Any idea/direction/good reading on the topic is helpful. Thank you in advance!
Convert model to .sfb using sceneform plugin or using .gltf extension.
On converted model or on model with .gltf extension, you can add texture on model pragmatically, there is a sample project for doing this on the following link
https://medium.com/temy/dynamic-textures-in-sceneform-98d7a2d35406
i implemented this in java. i hope this help you.
You only need a custom material (and a mat file) if you want to create an own shader for your model. Setting your different maps will be done in the *.sfa file. Just use the Android Studio Sceneform plugin and import your FBX model. It will automatically create a SFA file and you can set your maps there. An overview about which maps can be set for an FBX model can be found here.

Convert ( .obj / .fbx ) to .dae runtime which must support iOS SceneKit

I am facing trouble to find a way to convert .obj / .fbx to .dae (iOS scenefit Supported) automatically in background.
In python, it may be available to convert the file from .obj / .fbx to .dae file format. This process should run in background, immediately run after we will get .obj / .fbx file on server.
Here is the sample file, which we are trying to convert.
https://s3.ap-south-1.amazonaws.com/p9-platform/DAE/barware_s11624.obj
Please help me, if you have any suggestion.
Scenekit on IOS doesn’t support dae unless it was included in the app. So because of the “iOS Scenekit Supported” requirement there is no right answer, sort of. Although there are third party libraries (like https://github.com/dmsurti/AssimpKit ) to read and convert many 3d model formats, it won’t change the fact dae isn’t properly supported on IOS Scenekit .
That said, it is possible to convert OBJ to DAE in SceneKit using the following steps (in IOS 11.2 and later)
Load the obj file into a SCNScene.
Write the scene to a file with .dae extension using SCNScene’s writeToURL method.
That will create a .dae file SceneKit can support (but not directly, i.e. would need to be included in xcode or converted first) that starts with the following:
<?xml version="1.0" encoding="UTF-8"?>
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
<asset>
<contributor>
<authoring_tool>SceneKit Collada Exporter v1.0</authoring_tool>
</contributor>
I would second the recommendation for using Assimp or AssimpKit (I’ve only used the former but the latter might be an easier starting point).
I believe the DAEs on iOS aren’t DAEs at all, they just left the suffix the same and the actual files are SceneKit archives. I’m not sure if the API to write them is exposed yet, but I think it might be now since Xcode is now willing to load DAEs and write out SceneKit archives (but it adds the “.scn” suffix, not “.dae”).
It’s possible that iOS SceneKit can just load “.scn” files — it won’t load true DAEs because the DEA-reading/writing framework was licensed from Sony and is HUGE and the iOS team just doesn’t want that giant ugly framework on its system.
Another option would be to just link the iOS app against Assimp — it can load a ton of formats natively so you could skip all the intermediate stuff. It’s not NEARLY as huge as Sony’s DAE library so it might be acceptable to ship it with your app.

How to animate object 360 in ARToolKit in iOS

Currently I am working on the Augmented Reality and it works perfectly for me but I wanted to know how to animate the object in ARToolkit my issue is animation is not working for me
What i did i have created a fbx file from blender then i have converted into the .osgt format then i have converted to .osg format
Can any one help me out how we can animation the object in ARToolkit for iOS ?
You need to generate an .OSG file from whatever 3D Modelling/Animation tool you are using. You can use that .OSG file together with ARToolKit5.
For export from Blender have a look here: https://github.com/cedricpinson/osgexport
Then you need to read through this C-Interface that ARToolKit5 uses to interact with OpenSceneGraph(OSG) http://artoolkit.github.io/artoolkit5/doc/apiref/arosg_h/index.html
There are several arOSGSetModelAnimation* functions that you can use to manipulate the animation.
Have a look at the Android example: https://github.com/artoolkit/artoolkit5/tree/master/AndroidStudioProjects/ARNativeOSGProj
The C-Classes show you how you can load and use .OSG files with ARToolKit.
However, you need to use C on iOS and you cannot use Swift.
==Edit==
This question here gives some background regarding .FBX usage.
Import FBX to ARToolKit
In short .FBX is not supported and one should use the OSG commandline tool to convert .FBX to .OSG
--- Personal note ---
From my experience is easier to use the Unity3D plugin of ARToolKit5 or ARToolKit6 do you animations with Unity3D and export an iOS app.

ios : Displaying a simple 3D model with GLEssentials sample code

My goal is to display a simple 3D model and apply a texture on it.
I've downloaded the GLEssentials ios sample project to learn how to develop this (i'm new in ios OpenGL-ES API)
But the example model is a .model file, which I never heard about and which never appear in model bank websites.
What is this kind of file?
is the sample code compatible with other common model types (.obj, .c2d, .3ds)?
is it a good idea to start from this project?
Have a look at this question:
How to convert Blender blend (or obj) file to Qualcom Vuforia .h file
In my answer, I describe a script and accompanying Xcode project that converts .obj/.mtl files to header files suitable for OpenGL ES on iOS [link].
In response to your questions:
I believe the .model file is only appropriate for the sample project and is a proprietary Apple extension. It most likely contains simple data such as vertex positions.
I think you'd struggle to fit other model types into the sample code, which is very complex for OpenGL ES beginners. You might want to have a look at .pod files on Cocos2D here. I've seen and heard great things about it.
I wouldn't recommend it :)

Loading 3D model in iOS

I'm creating a game application from scratch with xcode for iOS, and I've use the OpenGL Game projet template to create mine.
I've searched a lot in the past few days, but I can't find any tutorials or example as to how I would load 3D model (via .obj files) in my application. I've found some documentation on loading them onto an app with a console script, but I need to do it programmatically.
Any help would be very appreciated
Also, my 3D models are created using blender
The future will be here momentarily — SceneKit, available in OS X since v10.8, will be in iOS 8. It can build and render a scene with COLLADA (.DAE) models directly. No need for third-party tools or code, nothing complicated to learn.
Apple's documentation is pretty good but if you prefer then other tutorials are available.
OpensceneGraph has support for iOS and a lot of prebuilt code which can help you develop the game. It supports loading OBJ models.
I recommend to use an Engine (like isgl3d, nineveh, Cocos3D, ...) for creating a 3D game, it will be hard if you use Opengl for a start.
Note: you can search for a list of game engine to choose the suitable one for you game, cause there is a lot of game engine, open-source or paid engine.
You can download the zip file from here and then run ./obj2opengl.pl 3DModel.obj in terminal .It will give you 3DModel.h file as output.
You need to use glDrawArrays instead of glDrawElements as the .h file contains array.
Obj files are simple to parse and are well described on wikipedia. You should be able to load them in one or 2 hours. But if you want to load the materials you need to invest some more time in your engine and into loading the obj file.

Resources