Awesome x3d export script

I have just discovered a code to export things to X3D format from Unity3d, it’s in one concise file called unityx3d.cs and i have managed to export a tree mesh.

I want to adapt it to export any kind of mesh from unity, so far i have found that it ignores objects called “cube” in the scene, and that it expects mesh.name to be “cube” which is counter intuitive, as mesh has a variable name but not a .name?!?!

anyways, seeing as it saved a tree gameobject and opened it in meshlab so it’s a decent script so far.

I will find where the gameObject handle comes in and will see if i can get it to export 3d files with special colors. The aim is to randomize an object colors using unity and to be able to save the file. perhaps it will be too much for the unityx3d.cs to handle, it seems to be mostly a VR format so i’ll post my progress here.

2286658–153664–unityx3d.cs (13.6 KB)

Ok, so looked at all the U3d x3d codes online including the above, didn’t work out, so i checked the x3d format, it seems like it’s a pretty easy things to figure out. there are tons of examples showing the amazing web power of the x3d format:
http://examples.x3dom.org/simpleExamples.html

and this is a color per face example file, just have to change the arrays,

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "http://www.web3d.org/specifications/x3d-3.3.dtd" "">
<X3D>
<Scene>
<Shape>

<IndexedFaceSet colorPerVertex='false'
colorIndex='1 0 2 3 4 4'
coordIndex='0 1 2 3 -1 7 6 5 4 -1 0 3 7 4 -1 0 4 5 1 -1 1 5 6 2 -1 2 6 7 3'>

<Coordinate point='
-0.095 -0.115 0.04
0.095 -0.115 0.04
0.095 0.115 0.04
-0.095 0.115 0.04
-0.095 -0.115 0.00
0.095 -0.115 0.00
0.095 0.115 0.00
-0.095 0.115 0.00'/>

<Color color='
0.999 0.0 0.0
0.0 0.94 0.0
0.04 0.095 0.9115
0.095 -0.85 0.00
0.04 0.095 0.00115
'/>

</IndexedFaceSet>
</Shape>


</Scene>
</X3D>