Go Back   AC3D Forums > Technical > AC3D Developers
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 25th October 2003, 09:23 AM   #1
andi
Junior Member
Member
 
Join Date: Sep 2003
Posts: 13
Default 3ds importer

Hi
I am tired of using my programs to convert .3ds in ac3d usable .3ds format and then back to for-me-usable format, so I have started writing a .3ds import plugin using lib3ds.
A few problems have come up by now:
I started by copying the dxf importer and then modified for my needs, i.e. I have a line
ac_register_file_importer(".3ds", "3ds files", do_lib3ds_load, "plugin, version 0.1, by Andreas Beckermann");
In it. Unfortunately, when I click "import" in ac3d, select the entry "3ds files" and then import a file, my plugin is definitely not used (there are textures visible, although its not yet implemented). The default .3ds code of ac3d is used. If I replace the above line by
ac_register_file_importer(".3ds1", "3ds1 files", do_lib3ds_load, "plugin, version 0.1, by Andreas Beckermann");
(3ds -> 3ds1)
and rename my file to *.3ds1, it works perfectly. Any way around this?

A few (smaller, more code relevant) questions:
- ac_plugin.h contains a fuction object_clone(). What does this do? Is it copying/cloning all vertices of that object, or does it just clone the object which then references the original vertices?
- Is there a way to set a matrix for an object? Do translate_object_*() and friends change the vertices or do they change the vertices of the object? (atm I am simply transforming all vertices by the 3ds matrices and then apply the final values to ac3d - I'd like to change this)
- how to apply a material to an object?

CU
Andi
andi is offline   Reply With Quote
Old 1st November 2003, 07:34 AM   #2
Andy
Administrator
Professional user
 
Andy's Avatar
 
Join Date: Jun 2003
Posts: 4,381
Default Re: 3ds importer

Yes - I can see this problem.

This may be become more of a problem in the future if different file formats use the same file extension.

I suggest you use:

Code:
Prototype Boolean ac_replace_importer_function(char *suffix, ac_file_importer_func func); /** suffix e.g ".wrl" **/
To replace the internal 3ds load function.

object_clone - creates a total copy of the object passed - new vertices and surfaces etc.

ACObjects do have internal matrix stuff but it's not fully used (i.e. it's only used in loading and saving of AC3D files) and it not available from the plugin interface. All vertices are stored as global coordinates.

To apply a material to an object, set the materials of each surface with surface_set_col. See the section in the .h file for MATERIAL AND COLOUR.

Andy
Andy is offline   Reply With Quote
Old 9th November 2003, 05:47 PM   #3
andi
Junior Member
Member
 
Join Date: Sep 2003
Posts: 13
Default Re: 3ds importer

Hi all

Ok, it took longer than I had expected, but that's mainly due to licensing questions. I am more familar with the GPL than with the LGPL (which is used in lib3ds).

But now I think I have this plugin mostly completed.
What it does (compared to ac3ds default .3ds code):
- mesh instancing. If a model contains a single mesh more than once, they are all displayed.
- matrices - every instance of the mesh can contain its own matrix. Usually thats the identity matrix, but if it isn't it is used.
- as a side effect the hierarchy of the meshes/objects is preserved

What is missing:
- One mesh must contain one texture only. That might get fixed later, but I don't have/use such models anyway, so it isn't urgent for me. ac3d's default code does this, so I consider it a limitation
- Texture matrices are not honored. Every mesh can contain texture matrices that influence the texture coordinates, but they are not yet used. ac3d doesn't do this either.
- There are a couple of values in the .3ds file that are loaded by lib3ds that I don't know of how to use. Dunno whether they might be important.

You can download the plugin at
http://boson.sourceforge.net/downloa..._import.tar.gz

-> just copy the .p file into your plugin/ directory. An exporter is planned, but a bit more difficult (the importer was only a couple of hours of work after all)

CU
Andi
andi is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -4. The time now is 08:09 PM.


AC3D Forum
(C) Inivis Limited 2020