Convert and add obj model to Web gl scene - without three.js - json

I want someone to tell me the steps to follow to convert an .obj object to json object so I can add it to my web gl scene like this : http://learningwebgl.com/blog/?p=1658
I ve tried everything. Python script, online converters etc. Every one has its flaws and I can't fix them.
I don't use the three.js lib.

Why can't you fix them?
There is no simple answer for how. The format for .obj is documented here. Read it, pull the data out you want in a format you design.
There's an infinite number of ways to convert it and an infinite number of ways to store the data. Maybe you'd like to read out the data and store the vertices in JavaScript arrays. Maybe you'd like to store them in binary which you download with XHR. Maybe you'd like to apply lossy compression to them so they download faster. Maybe you'd like to split the vertices when they reach some limit. Maybe you'd like to throw away texture coordinates because your app doesn't need them. Maybe you'd like to read higher order definitions and tessellate them into triangles. Maybe you'd like to read only some of the material parameters because you don't support all of them. Maybe you'd like to split the vertices by materials so you can more easily handle geometries with multiple materials. Maybe you'd like to reindex them so you can use gl.drawElements or maybe you'd like to flatten them so you can use gl.drawArrays.
The question you're asking is far too broad.

Related

Mask R-CNN annotation tool

I’m new to deep learning and I was reading some state of art papers and I found that mask r-cnn is utterly used in segmentation and classification of images. I would like to apply it to my MSc project but I got some questions that you may be able to answer. I apologize if this isn’t the right place to do it.
First, I would like to know what are the best strategy to get the annotations. It seems kind of labor intensive and I’m not understanding if there is any easy way. Following that, I want to know if you know any annotation tool for mask r-cnn that generates the binary masks that are manually done by the user.
I hope this can turn into a productive and informative thread so any suggestion, experience would be highly appreciated.
Regards
You can use MASK-RCNN, I recommend it, is a two-stage framework, first you can scan the image and generate areas likely contain an object. And the second stage classifies the proposal drawing bounding boxes.
But the two-big question
how to train a model from scratch? And What happens when we want to
train our own dataset?
You can use annotations downloaded from the internet, or you can start creating your own annotations, this takes a lot of time!
You have tools like:
VIA GGC image annotator
http://www.robots.ox.ac.uk/~vgg/software/via/via_demo.html
it's online and you don't have to download any program. It is the one that I recommend you, save the images in a .json file, and so you can use the class of ballons that comes by default in SAMPLES in the framework MASK R-CNN, you would only have to put your json file and your images and to train your dataset.
But there are always more options, you have labellimg which is also used for annotation and is very well known but save the files in xml, you will have to make a few changes to your Class in python. You also have labelme, labelbox, etc.

Exporting multiple animations (tracks) in a single JSON file for THREE.js from 3DS MAX

In the 'Animation / Skinning / Blending' Three.js example, the JSON model (the Marine) has multiple animation tracks (idle, walk and run). These are stored in an "animations" array in the JSON file.
My question is two-fold... Firstly, how do you "label" the animations in 3DS MAX? I tried using an FBX Multi Take plugin which does allow me to add some marking. They are present when I re-import the FBX file back into Max but do not show up when I try to export to JSON... which is my next question....
How do you then export these animation states? When I use the 'ThreeJSAnimationExporter' from within 3DS MAX, there is no option to define any animation tracks (nor will it pick up the ones I defined in the question above), it just exports everything into 1 animation. This is stored in an "animation" (not "animations") array in the resulting JSON file?
The JSON file of the Marine must have been created somehow... can it be done in MAX? If it is only possible in Blender then is there any way I can get my models and animations from 3DS MAX to Blender as I am trained in MAX and don't particularly want to learn Blender, even though it does look very good these days.
Thanks in advance.
P.s. I am using the MAX exporter that ships with r71 of THREE.js.
I have managed to get this working but it requires a lot of inelegant hacking of JSON files and excessive file duplication in MAX. Basically I have created multiple MAX files with the same rig, skin, weights, UV's and materials. I then animated each track of animation and export it using the existing ThreeJSAnimationExporter. I then open up the JSON files, extract the animation entries and combine them into a single JSON file with an "animations" property array instead of a single "animation" property. You can then rename the animation segments from 'Action' to something more useful.
If anyone has a more elegant solution I would love to hear it.
I would also love it if the clever person who created the original ThreeJSAnimationExporter script could create a new script called ThreeJSBlendedAnimationExporter which allows for a simple animation track input system, it would only need a start frame, end frame and animation label for each animation track (segment). And for the love of god, also address the smoothing while you're at it :)

Convert Jupiter Tessellation(JT) files to JSON to render in THREE.js

How do I render .JT files in THREE.js? I checked following options and could not get anything to proceed with:
checked in Three.js on different loaders which are available - didn't get loader for JT files. Please let me know if there is anything already present which I am missing in three.js.
http://www.johannes-raida.de/jnetcad.htm - if I have to write my own conversion method, at this of point, not sure how to proceed with. any pointer will be helpful
Any help or pointers will be appriciated.
Thanks in advance,
Pradeep
JNetCAD won't help you a huge amount unless you write it as a web service. Its Java (server side code) while three.js is client side. If you wanted to go down this route though, you could create a small RESTful web service that took a .JT file as input and returned the converted JSON. This does require a fair amount of Java knowledge though.
Unless you specifically need on-the-fly transformation, you're probably going to find it a lot easier to just run the .JT file through the tool yourself and work directly from a supported format. This is what they have done on the JNetCAD web page to good effect.

neo4j graph to JSON

I'm considering different options to use Neo4J graph and display it all on the web, at the moment I am considering a Java based reader of the database that creates JSON output for display by the web.
Is JSON suitable for display tree-like structures? In my case I have a parent-child(s) style organisation chart.
Could you give me an example if this is possible. Thanks.
Yes. Use JSON to pass over all the geometry: lists of nodes and edges, location and sizes of nodes, spline data for edges, etc. Convert all the data to an SVG DOM, which can be done dynamically. (Hint for HTML 4: make sure you use the SVG namespace in CreateElement.) The real trick, more than anything, is to do all the calculations before the data hits the browser. Simple calculations work fine in JavaScript, but anything complicated is best done elsewhere.
No example, unfortunately. The code I wrote is not available to the public.

Creating 3d models and converting them into a form usable by WebGL - a beginners guide?

I'm looking for some simple (free!) entry level software that will allow me to create simple 3d models and export them in a format (JSON?) that can then be read into a webGL programme.
Simple geometry would be a start, then textures would be nice too... I've looked at Blender, and it's just far too advanced for me, and the tutorials I've found are hopeless.
Something simple like sketchup would be good, but afaik you can't export in JSON. I've found some converters that will do .dae to .json, but the ones I've found seem to be for advanced users.
WebGL is new enough that there aren't many packages like this built up around it just yet. That doesn't mean you don't have some options though:
Blender is a good modeler, and if you are willing to put a little bit more time into learning it you can use exporters from Three.js or some others that are around the net. This seems to be the most popular option at the moment.
Unity 3D is more of a scene builder than a modeling app, but it has a lot of ways to get content into it and both J3D and myself have implemented exporters from it.
Maya is a great modeling tool if you have a way to get access to it (it's commercial), and has Inka to get WebGL content out.
If you want to use something like SketchUp, it should be able to export to COLLADA, which can then be imported into Blender/Unity/What have you and exported from there using one of the previous methods.
As far as formats go, there's no real standards just yet. Most of the exporters will spit out JSON, mine uses a mix of JSON and Binary for speed/size, and some will actually give you Javascript code to execute. Which format to use probably depends on what you want to do with it. I encourage you to experiment with several and see what you like and what you don't.