Horde3D
http://www.horde3d.org/forums/

Modo302 Collada Exporter from SourceForge
http://www.horde3d.org/forums/viewtopic.php?f=11&t=549
Page 1 of 2

Author:  PuG [ 31.10.2008, 20:51 ]
Post subject:  Modo302 Collada Exporter from SourceForge

Just posting to mention the Collada exporter available from SourceForge (http://sourceforge.net/projects/colladamodo) does in fact work with Horde's geo converter, though you will need to modify your DAE file after exporting.

Search and replace for the following:

Z_UP with Y_UP
and
polygons with triangles

Next strip all <p> & </p> tags located around each normal? and instead only open and close the tag once for the geometry, example:

Should look like:
Code:
    <p>10282 9240 9628 10281 9863 10281 10278 7549 7869
    10282 9240 9628 10283 7552 7872 10232 7515 7835
    10236 9232 9620 10232 7515 7835 10283 7552 7872</p>
  </triangles>
</mesh>


and not like this:

Code:
    <p>10282 9240 9628 10281 9863 10281 10278 7549 7869 </p>
    <p>10282 9240 9628 10283 7552 7872 10232 7515 7835</p> 
    <p>10236 9232 9620 10232 7515 7835 10283 7552 7872</p>
  </triangles>
</mesh>


I had started writing a small python app, however I can't figure out how to strip and only put back only the <p> tags in the correct area. Perhaps someone could finish the following:

Code:
f = open("collada_refined.dae", "w")

print "Please wait.."

for line in open("collada.dae"):
    line = line.replace("Z_UP", "Y_UP")
    line = line.replace("polygons", "triangles")
    line = line.replace("<p>", "")
    line = line.replace("</p>", "")
    f.write(line)
   
f.close()
print "Collada Refined."

Author:  swiftcoder [ 01.11.2008, 19:40 ]
Post subject:  Re: Modo302 Collada Exporter from SourceForge

It is worth noting that the exact same sequence of fixes will work for the output of the FBXConverter (for which reason I suggested we consider modifying Horde's converter).

Author:  DDd [ 02.11.2008, 17:31 ]
Post subject:  Re: Modo302 Collada Exporter from SourceForge

@PuG: If i am not mistaken you can do a replace like
line = line.replace("<polygons>","<triangles> <p>").
Test for the triangle tag and replace it with
line = line.replace("</polygons>", "</p> </triangles>")

Code:
f = open("collada_refined.dae", "w")

print "Please wait.."

for line in open("collada.dae"):
    line = line.replace("Z_UP", "Y_UP")
    line = line.replace("<polygons>","<triangles> <p>")
    line = line.replace("<p>", "")
    line = line.replace("</p>", "")
    line = line.replace("</polygons>", "</p> </triangles>")
    f.write(line)
   
f.close()
print "Collada Refined."


If this has to be changed allot of times, it may be a good idea to simply use a replacement set. Something along the lines of:
Code:
# define our method
def replace_all(file, dic):
    for i, j in dic.iteritems():
        file = file.replace(i, j)
    return file

# Replacement Set
repset = {'Z_UP':'Y_UP','<polygons>':'<triangles><p>','<p>':'', '</p>':'', '</polygons>':'</p></triangles>'}

# Call it
replace_all(my_file, repset)
Not tested!

If we need to replace a new set it's easy to simply create a new dictionary and run it. More advanced solutions can be used with regular expressions.

@Swiftcoder: I have not read the Collada spec in detail. Does the spec define the correct behavior? or is it left for the implementer? On standardization topics, following the spec is important, let's follow it and if others do not respect it then we have to correct their mistakes and hope that they will fix their exporters to be standard compliant.

Author:  swiftcoder [ 02.11.2008, 18:55 ]
Post subject:  Re: Modo302 Collada Exporter from SourceForge

DDd wrote:
@Swiftcoder: I have not read the Collada spec in detail. Does the spec define the correct behavior? or is it left for the implementer? On standardization topics, following the spec is important, let's follow it and if others do not respect it then we have to correct their mistakes and hope that they will fix their exporters to be standard compliant.
The < polygons > tag contains arbitrary polygons, so each one must be enclosed in a separate < p > tag. By contrast, the < triangles > tag contains only triangles, so they can be stored in a single < p > tag (where every 3 elements defines 1 triangle).

The problem is that many exporters export as < polygons >, even after triangulation. My preferred solution would be to add an extra case to the converter, which can parse polygon meshes, and triangulate them if they are not already - but this may be overkill for the majority of cases. However, the first time you run that script on a 300MB+ collada file, you will wish the converter did it for you ;)

Author:  PuG [ 03.11.2008, 09:03 ]
Post subject:  Re: Modo302 Collada Exporter from SourceForge

Thanks for the replies, will have a fiddle with your script DDd and see what happens - however as Swift mentioned replacing the full line could be problematic unless the information could be read in, then read out into the new replacement string? (sorry I should have posted a slightly more complete example)

Of course the best solution would be for the Geo Converter to be slightly more relaxed on the input, I tried having a fiddling around before, but its beyond me, hence the python :)

Author:  DDd [ 03.11.2008, 12:22 ]
Post subject:  Re: Modo302 Collada Exporter from SourceForge

Relaxing the converter to handle wrong tagging sound like a reasonable workaround. However, data should be triangulated by the editor IMHO.

Is there any 3d editor package that does not support triangulation? It looks like a waste of time and a possible source of new bugs (ie more code to maintain and optimize) to add triangulation code to the importer, if every editor already has the ability to export triangulated data, though sometimes with wrong tags. The content pipeline(s) should work smoothly and not overlap in functionality. assert(geoIsTriangulated);

Author:  PuG [ 03.11.2008, 19:55 ]
Post subject:  Re: Modo302 Collada Exporter from SourceForge

DDd wrote:
Relaxing the converter to handle wrong tagging sound like a reasonable workaround. However, data should be triangulated by the editor IMHO.

Is there any 3d editor package that does not support triangulation? It looks like a waste of time and a possible source of new bugs (ie more code to maintain and optimize) to add triangulation code to the importer, if every editor already has the ability to export triangulated data, though sometimes with wrong tags. The content pipeline(s) should work smoothly and not overlap in functionality. assert(geoIsTriangulated);


I agree, no point adding triangulation to the Converter - I think nearly all packages can do it, and in general you normally expect to have to do so for the file save.

Author:  swiftcoder [ 03.11.2008, 22:07 ]
Post subject:  Re: Modo302 Collada Exporter from SourceForge

PuG wrote:
DDd wrote:
Relaxing the converter to handle wrong tagging sound like a reasonable workaround. However, data should be triangulated by the editor IMHO.

Is there any 3d editor package that does not support triangulation? It looks like a waste of time and a possible source of new bugs (ie more code to maintain and optimize) to add triangulation code to the importer, if every editor already has the ability to export triangulated data, though sometimes with wrong tags. The content pipeline(s) should work smoothly and not overlap in functionality. assert(geoIsTriangulated);

I agree, no point adding triangulation to the Converter - I think nearly all packages can do it, and in general you normally expect to have to do so for the file save.
At the least I would like to see the converter detect non-triangulated polygon meshes, and display an error.

Author:  marciano [ 03.11.2008, 22:20 ]
Post subject:  Re: Modo302 Collada Exporter from SourceForge

Relaxing the converter a bit more makes sense. I would suggest to support automatic triangulation for quads, since that is very easy to realize and clean models often consist entirely of quads. BTW, thanks to phoenix64 we already have (mostly untested) support for non-triangle data (http://www.horde3d.org/forums/viewtopic.php?f=3&t=487).

Author:  DDd [ 15.11.2008, 20:05 ]
Post subject:  Re: Modo302 Collada Exporter from SourceForge

I guess i will get familiar with F.V.B. XMLParser and implement the changes on community svn.

What else needs some tuning?

I am also going to take a closer look at Volker's Bullet integration and try to extend it a bit.

marciano wrote:
Relaxing the converter a bit more makes sense. I would suggest to support automatic triangulation for quads, since that is very easy to realize and clean models often consist entirely of quads. BTW, thanks to phoenix64 we already have (mostly untested) support for non-triangle data (http://www.horde3d.org/forums/viewtopic.php?f=3&t=487).


Ill take a look at the triangulation code, the algorithm that i have in mind is simply to create an edge between point 1 and p3, but ill look up some fast way to triangulate meshes. Does pheonix64 code triangulate data, or creates support for non-triangulated data?

Author:  PuG [ 16.11.2008, 09:14 ]
Post subject:  Re: Modo302 Collada Exporter from SourceForge

Brilliant, does Horde support triangle strip?

Quote:
What else needs some tuning?

Im sure something will come up.

Author:  marciano [ 06.01.2009, 00:38 ]
Post subject:  Re: Modo302 Collada Exporter from SourceForge

Could someone please provide a small collada test asset exported from Modo, so that we can check compatibility? A sphere or cube with proper texture coordinates and normals would be sufficient.

Author:  lzdude69 [ 06.01.2009, 04:10 ]
Post subject:  Re: Modo302 Collada Exporter from SourceForge

This may be slightly OT, but I've found that running exported Collada models through the Collada Refinery tool almost always fixes them up for me (Blender) to be fed into the converter. So far the converter hasn't complained for me with fully animated models exported from Blender, however I don't know if this success is directly related to the Callada Refinery, but I do remember problems awhile back before I discovered it.

Later.

Author:  marciano [ 11.01.2009, 18:05 ]
Post subject:  Re: Modo302 Collada Exporter from SourceForge

Since ColladaConv got support for polygon tags, Modo models should also work fine now.

Author:  PuG [ 14.01.2009, 11:04 ]
Post subject:  Re: Modo302 Collada Exporter from SourceForge

Thanks marciano, its working great!

Image

Question, does GEO support double sided polygons as defined in a "material" attribute within the art program? (ive never gotten it to work), its not a problem, only means duplicating and flipping polygons :)

Page 1 of 2 All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/