Author Topic: Standard for JSON 3D models.  (Read 4534 times)

0 Members and 1 Guest are viewing this topic.

Offline nikin

  • C= 64
  • **
  • Posts: 57
  • Karma: 15
    • View Profile
Standard for JSON 3D models.
« on: November 23, 2013 »
Does anyone know of a standard format to put my 3D models into JSON?
I would like to use then with WebGL. Without any external libraries. So anything goes :)
Fetures needed:
- Vertexes
- Polygons
- Normals
Would be nice:
- Texture map
- Materials (this one is tricky, as there is no standard for this AFAIK)
- Textures (also not easily standardized.. still)

If there is no such standard, i would model one using .STL as a base.. and JSON-ify it.

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Standard for JSON 3D models.
« Reply #1 on: November 24, 2013 »
Something like .obj would be easy to JSONify, but I don't know of any standards.
Jim
Challenge Trophies Won:

Offline roxtonro

  • ZX 81
  • *
  • Posts: 2
  • Karma: 0
    • View Profile
Re: Standard for JSON 3D models.
« Reply #2 on: November 27, 2013 »
Looks like you're going to have to roll your own.

Would be easier to start by converting an existing format as Jim suggests.

Depends on what you want as the final product in WebGL as to what your JSON format would need to store.

I'd guess materials would require the most work hmm although .. http://500.chromeexperiments.com/ -> Grid -> 3D might give you some ideas.

Best of luck deciding upon the format nikin.

Offline nikin

  • C= 64
  • **
  • Posts: 57
  • Karma: 15
    • View Profile
Re: Standard for JSON 3D models.
« Reply #3 on: November 27, 2013 »
Then i will go with OBJ then. And make it straight forward.

Materials are tricky. But i guess starting with some standard things like, color,opacity, reflectivenes is a start.
Also maxbe supporting multiple textures, for things like bumpmaps.

something like
Code: [Select]
{
  v:[[0.1,3,2.8],[0.3,5,7],[4,9,1]]
  n:[[0.1,0.3,0.8],[0.3,0.5,0.7],[0.1,2,4]]
  p:[[1,2,3]]
}
would do the trick
But on the other hand i should take a look at how GLES is fed with data, and try to work with that as a starting point. For ease of use. Sotmehing that goes with glDrawElements for instance. That needs all elements to be triangles. Which is a pro for many things, but will mean that any other polygons need to be converted to triangles.
That will change the above example as follows:
Code: [Select]
{
  v:[0.1,3,2.8 , 0.3,5,7 , 4,9,1]
  n:[0.1,0.3,0.8 , 0.3,0.5,0.7 , 0.1,2,4]
  p:[1,2,3]
}
problem being here that what we get as a format is not editable realy. Its an export format.
glMultiDrawElements would be nice... but its not in the ES specification.

The other solution is to go with the first version, and then write some code that produces the second version from the first, after loading.  But here we already go into the engine's business. A Pro for this, that on a Desktop implementation we can use glMultiDrawElements .

For my planned christmas intro.. the things i need are basically just polygons with basic polygon based materials. And some textures. But it would be nice to design it to be extensible. It would be quite easy to pack multiple objects into one file. so it becomes.
Code: [Select]
{
objects:{obj1:{
  v:[[0.1,3,2.8],[0.3,5,7],[4,9,1]]
  n:[[0.1,0.3,0.8],[0.3,0.5,0.7],[0.1,2,4]]
  p:[[1,2,3]]
}}
scene:{
   elements:[{o:"object1",cx:1,xy:2,cz:0,s:0.5}]
   lights:[....]
}
....
}
but i am getting waay to far :)

Offline nikin

  • C= 64
  • **
  • Posts: 57
  • Karma: 15
    • View Profile
Re: Standard for JSON 3D models.
« Reply #4 on: December 26, 2013 »
Just some heads up.
Actually it works :) OBJ was a good base format. I wrote it in PHP.

What it can do :
- converts OBJ files to TRI files (which are JSON representations of vertex, texture, element buffers)
- supports per face texturing. (if you ever did per vertex, you know why this came important :) )
- supports multiple objects / file  (sharing texture)
- only supports single texture file for now.

See my XMAS_2013 intro, to see it working.

If there is interest in it, and when i come around to fix a couple of annoyances, i will release it.

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: Standard for JSON 3D models.
« Reply #5 on: December 26, 2013 »
yep i would be interested in this i am about too head into a webgl/html/php adventure so im looking at gathering as much info together as possible having a good way too load models would be a benefit too me.

i would like too port my opengl compatible animation .x loader in a similar manner but it is very very pointer heavy and spreads across many source files porting too java php will not be the work of a moment.. i think ill give it a good go though.
Challenge Trophies Won: