Horde3D

Next-Generation Graphics Engine
It is currently 19.03.2024, 12:58

All times are UTC + 1 hour




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: 31.10.2008, 20:51 
Offline

Joined: 11.06.2008, 10:34
Posts: 119
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."

_________________

Let's bring 'em out! Any old iron! Any old iron!
A door opens and a homewife brings out a rather sophisticated-looking ground-to-air missile system, and dumps it on the cart.
Thank you.


Top
 Profile  
Reply with quote  
PostPosted: 01.11.2008, 19:40 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
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).

_________________
Tristam MacDonald - [swiftcoding]


Top
 Profile  
Reply with quote  
PostPosted: 02.11.2008, 17:31 
Offline

Joined: 26.03.2008, 02:58
Posts: 160
@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.


Top
 Profile  
Reply with quote  
PostPosted: 02.11.2008, 18:55 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
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 ;)

_________________
Tristam MacDonald - [swiftcoding]


Top
 Profile  
Reply with quote  
PostPosted: 03.11.2008, 09:03 
Offline

Joined: 11.06.2008, 10:34
Posts: 119
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 :)

_________________

Let's bring 'em out! Any old iron! Any old iron!
A door opens and a homewife brings out a rather sophisticated-looking ground-to-air missile system, and dumps it on the cart.
Thank you.


Top
 Profile  
Reply with quote  
PostPosted: 03.11.2008, 12:22 
Offline

Joined: 26.03.2008, 02:58
Posts: 160
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);


Top
 Profile  
Reply with quote  
PostPosted: 03.11.2008, 19:55 
Offline

Joined: 11.06.2008, 10:34
Posts: 119
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.

_________________

Let's bring 'em out! Any old iron! Any old iron!
A door opens and a homewife brings out a rather sophisticated-looking ground-to-air missile system, and dumps it on the cart.
Thank you.


Top
 Profile  
Reply with quote  
PostPosted: 03.11.2008, 22:07 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
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.

_________________
Tristam MacDonald - [swiftcoding]


Top
 Profile  
Reply with quote  
PostPosted: 03.11.2008, 22:20 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
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).


Top
 Profile  
Reply with quote  
PostPosted: 15.11.2008, 20:05 
Offline

Joined: 26.03.2008, 02:58
Posts: 160
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?


Top
 Profile  
Reply with quote  
PostPosted: 16.11.2008, 09:14 
Offline

Joined: 11.06.2008, 10:34
Posts: 119
Brilliant, does Horde support triangle strip?

Quote:
What else needs some tuning?

Im sure something will come up.

_________________

Let's bring 'em out! Any old iron! Any old iron!
A door opens and a homewife brings out a rather sophisticated-looking ground-to-air missile system, and dumps it on the cart.
Thank you.


Top
 Profile  
Reply with quote  
PostPosted: 06.01.2009, 00:38 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
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.


Top
 Profile  
Reply with quote  
PostPosted: 06.01.2009, 04:10 
Offline

Joined: 04.04.2008, 16:28
Posts: 13
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.


Top
 Profile  
Reply with quote  
PostPosted: 11.01.2009, 18:05 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
Since ColladaConv got support for polygon tags, Modo models should also work fine now.


Top
 Profile  
Reply with quote  
PostPosted: 14.01.2009, 11:04 
Offline

Joined: 11.06.2008, 10:34
Posts: 119
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 :)

_________________

Let's bring 'em out! Any old iron! Any old iron!
A door opens and a homewife brings out a rather sophisticated-looking ground-to-air missile system, and dumps it on the cart.
Thank you.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group