Jump to content
3DCoat Forums

COLLADA Exporter


JamesH
 Share

Recommended Posts

  • Member

I've spent the last two or three days writing a COLLADA exporter for 2.10 and have got as far as exporting the geometry, normals and texcoords, and being able to import them into an application that supports COLLADA (For me this is the C4 Engine). I'm at the stage now of working on the materials and images that are exported and would like some help if anyone fancies offering it in the following areas:

UPDATE : The first release is available from here. Extract the ColladaPlugin.dll to the \Plugins\MeshCodecs folder of your 3DC installation.

UPDATE : 01 Oct - Added normal map reference to the node's bound material.

- Initially a couple of models in 3DC so that I can have more examples to test on.

- And then finally to test the exporter plug-in in a package that supports it.

Many thanks

James.

PS, just a quick image of two of the models in C4.

C4-C3D-DAE-002.jpg

Link to comment
Share on other sites

  • Member
Hi JamesH,

What kind of models do you need...what will help you in your testing?

I'd be glad to assist if you can clarify a little bit more of what you're looking for. :)

Many thanks for the offer, have you got anything with multiple geometries ? I've not had any models that contain more than one object to test, in theory my code should work with it.

A question for Andrew, is there any size data held for the Mesh ? At the moment I'm having to manually edit the .dae file to change the scale

I'll also be able to refine my requirements a little more this weekend as I work through some more models, sorry it's a bit vague.

Link to comment
Share on other sites

A question for Andrew, is there any size data held for the Mesh ? At the moment I'm having to manually edit the .dae file to change the scale

There is no scale info - all points has coordinates as is - no additional scaling. Also on note about exported textures.

class cSurface has array of textures Tex[]. Tex has field FileName - path to texture. There is usage of that set

Tex[0] - Color

Tex[1] - Specular

Tex[2] - Bump

Tex[3] - Normalmap

Of course if FileName is empty it means that corresponding channel is not used.

Link to comment
Share on other sites

  • Member
Howdy JamesH,

Here's a multi-object item to test:

It's a little under 20000 triangles since I figured you'd want to make sure medium-sized

geometry was tested (and not just 6-sided cubes), but the zip has an 'info.txt' file for

further, umm...well, info. :D

Thanks for the obj file, it's certainly sorting my code out !

I should have a finished plugi-in to try sometime tomorrow if you fancy taking it for a spin ?

Cheers.

Link to comment
Share on other sites

  • Member
There is no scale info - all points has coordinates as is - no additional scaling. Also on note about exported textures.

class cSurface has array of textures Tex[]. Tex has field FileName - path to texture. There is usage of that set

Tex[0] - Color

Tex[1] - Specular

Tex[2] - Bump

Tex[3] - Normalmap

Of course if FileName is empty it means that corresponding channel is not used.

Thanks for the info.

I think for the scaling and unit size I'll add the line

<unit meter="0.01" name="centimeter"/>

and users can alter it themselves in the generated file.

Link to comment
Share on other sites

  • Member

Hi Andrew, is there a way of referencing the Mesh data, i.e. Raw data and position data per individual object rather than for a whole scene ? COLLADA requires each geometry has its own vertices, normals and texcoords self contained and then referenced within the same geometry node as a polylist. I was thinking maybe of re-indexing the Raw data for each geometry, but this could be time consuming, and another way I suppose would be to include all of the scene vertex, texcoord and normal data for each geometry so at least the Raw data references would work, but the file size would be quite large and wasteful.

The only other way would maybe to include some extra data in the Mesh that is exported in the Encode function.

Have you any ideas ?

Link to comment
Share on other sites

Hi Andrew, is there a way of referencing the Mesh data, i.e. Raw data and position data per individual object rather than for a whole scene ? COLLADA requires each geometry has its own vertices, normals and texcoords self contained and then referenced within the same geometry node as a polylist. I was thinking maybe of re-indexing the Raw data for each geometry, but this could be time consuming, and another way I suppose would be to include all of the scene vertex, texcoord and normal data for each geometry so at least the Raw data references would work, but the file size would be quite large and wasteful.

The only other way would maybe to include some extra data in the Mesh that is exported in the Encode function.

Have you any ideas ?

Now every point has global position, no additional shift for every object. You can set offset (0,0,0) for the root of sub object of calculate center of sub object and subtract this value from positions. I thingk it is not very time consuming. Also one note about scale - usually all is measured in meters.

Link to comment
Share on other sites

  • Member
Now every point has global position, no additional shift for every object. You can set offset (0,0,0) for the root of sub object of calculate center of sub object and subtract this value from positions. I thingk it is not very time consuming. Also one note about scale - usually all is measured in meters.

Sorry Andrew, ignore my ramblings, it's amazing what a night's sleep can do ! I'd forgotten to initialize a variable and it was giving unpredictable results.

Anyway, the geometry is being output correctly now and I'm just re-going through file with COLLADA refinery to make sure it adheres to the spec.

Link to comment
Share on other sites

  • Member

I'm just finishing off understanding COLLADA texture file locations and UV scale, once that's done, I'll post a plug-in to try. There's still a lot of optimizing to do, but I'll get it working correctly first.

Anyway, here's the test model exported from 3DC and imported into a game engine.

C4-C3D-DAE-003.jpg

Link to comment
Share on other sites

  • New Member
...I just used TinyXML and the COLLADA spec.

I used TinyXML for the last Collada exporter I wrote as well, but I was thinking of moving onto the Collada DOM to support more advanced features, and to make it easier to write out conforming Collada files.

However, in the case of 3DC, it doesn't appear that it supports animation or hierarchical transforms, so TinyXML will probably do just fine for basic Collada files that are only handling static, multi-textured geometry.

Please let me know if I can help out with the implementation of writing out the texture file locations - it's a bit subtle how the cross references are supposed to work.

Link to comment
Share on other sites

  • Member

Here is a plug-in to try.

It still has a bit of work needed, namely in the materials department, and it needs created & modified dates adding, but it works for me.

Extract ColladaPlugin.zip to your \Plugins\MeshCodecs folder so that the .dll is directly in that folder (MeshCodecs). Then run 3DC, load up a model and select Export, using the dae filetype.

I'll be adding more later in the week.

Let me know how you get on

Cheers.

EDIT: You may want to change the <unit> size as well if it is too small.

EDIT2: I've changed the default unit size and updated the zip file - I'll also post a link on the first post

Link to comment
Share on other sites

  • Advanced Member

Howdy JamesH,

I've placed the .dll into the 'Plugins->MeshCodecs' folder but I am unable to see/choose

'.dae' as an option for export (I've tried with both export options from the 'File' menu

on both my laptop and desktop, also tried with DX and OGL versions on each machine).

What's the secret ...

Link to comment
Share on other sites

  • Member
Howdy JamesH,

I've placed the .dll into the 'Plugins->MeshCodecs' folder but I am unable to see/choose

'.dae' as an option for export (I've tried with both export options from the 'File' menu

on both my laptop and desktop, also tried with DX and OGL versions on each machine).

What's the secret ...

Are you running 2.10.10 ?

Link to comment
Share on other sites

  • Member
indeed... if it's of any importance or bearing, I've got .NET 2.0 installed on my desktop (not

sure which on the laptop)

perhaps someone else can test it too?

(can't imagine I've managed to screw up your install instructions that badly) :D

In the root folder there should be a file named Log.txt, can you have a look for the three entries

cMeshIO::AddCodec(): Added "Obj" mesh codec.
cMeshIO::AddCodec(): Added "Lwo" mesh codec.
cMeshIO::AddCodec(): Added "Fbx" mesh codec.

And there should be one just before that reads if the plug-in is being loaded

cMeshIO::AddCodec(): Added "dae" mesh codec.

Link to comment
Share on other sites

  • Advanced Member

doesn't seem to be loading properly for me...the entry before those three is: Loaded image file "textures\vista3.dds"

(I can't find 'cMeshIO::AddCodec(): Added "dae" mesh codec.' in the text file)

anything hard-coded in the .dll in terms of paths? (cause I've installed 3dC into a c:\graphics\3d-Coat-2-10 path)

gonna sleep now, but I'll test more tomorrow.

Link to comment
Share on other sites

  • Member
doesn't seem to be loading properly for me...the entry before those three is: Loaded image file "textures\vista3.dds"

(I can't find 'cMeshIO::AddCodec(): Added "dae" mesh codec.' in the text file)

anything hard-coded in the .dll in terms of paths? (cause I've installed 3dC into a c:\graphics\3d-Coat-2-10 path)

gonna sleep now, but I'll test more tomorrow.

There's nothing hardcoded, and I've just uninstalled and re-installed into a similar location and it works fine.

Incidentally, what OS are you using ? I'm running XP SP2 and XP SP3 on my dev machines, I have another with Vista that I can try tonight to see if I can reproduce your problem.

Has anyone else tried the plug-in ?

Cheers.

Link to comment
Share on other sites

  • Member
It works well on last ALPHA. It creates DAE file with reference to texture.

Is there some viewer to look it rendered?

Is it possible to export with normalmap? I see it is referred in DAE file, but will it be accepted by external render?

I've got the Normal map included for the next build which I'll release tonight.

Try COLLADA Loader to view the file.

Cheers

James.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...