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 18th March 2004, 10:56 PM   #1
monster
Member
Advanced member
 
Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 39
Default Adding lots of surfaces quickly - Importer plugin

Hi Folks,

What's the quickest way to add a lot (like 250,000 or so) surfaces to an AC3D object in an importer plugin.

Currently I use something like;
Code:
List *surfaces = NULL;
...
Surface* s = new_surface();
// Set up surface
list_add_item_head(&surfaces,s);
...
object_add_surfaces(object,surfaces);
But it seems that list_add_item[_head] is relatively slow and gets slower the more surfaces I add.

Is there something like ac_object_add_vertices_from_float_array, but for surfaces that would let me pre-allocate a bunch of surfaces and add them to my object all in one hit?

Cheers.
monster is offline   Reply With Quote
Old 19th March 2004, 02:59 AM   #2
Andy
Administrator
Professional user
 
Andy's Avatar
 
Join Date: Jun 2003
Posts: 4,379
Default Re: Adding lots of surfaces quickly - Importer plugin

Code:
list_add_item_head(&surfaces,s);
is very quick.

Code:
Prototype void object_add_surfaces(ACObject *ob, List *l);
adds each surface to the start of the surface list with list_add_item_head. (it sets the surface's owner for each too)

It looks like you have optimal code here. Perhaps there is something else causing a slowdown?

Andy
Andy is offline   Reply With Quote
Old 19th March 2004, 06:00 AM   #3
monster
Member
Advanced member
 
Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 39
Default Re: Adding lots of surfaces quickly - Importer plugin

Ah, yes. Thanks for the reply.
It was;
Code:
ac_object_get_vertex_at_index
That was taking the time.
If I run through and cache them all, it's much quicker.
But still, is there a quicker way to get a list of all the Vertex pointers?
I've created them with;
Code:
ac_object_add_vertices_from_float_array
monster is offline   Reply With Quote
Old 19th March 2004, 07:40 AM   #4
monster
Member
Advanced member
 
Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 39
Default Re: Adding lots of surfaces quickly - Importer plugin

No worries, fixed it by accessing the vertex List directly.
A 512x512 tga loaded, smoothed and 130,000 surfaces created and added in about a second. Bargain!

Thanks for your help.
Please ignore my stupidness!

Anybody want a (very simple) heightmap importer?

monster is offline   Reply With Quote
Old 19th March 2004, 10:32 AM   #5
Andy
Administrator
Professional user
 
Andy's Avatar
 
Join Date: Jun 2003
Posts: 4,379
Default Re: Adding lots of surfaces quickly - Importer plugin

Gorgeous!

>is there a quicker way to get a list of all the Vertex pointers?

You can use:

Code:
Prototype ListData *list_create_array(List *l, int numitems); // free with myfree()
on a list. It returns an array of the list-data pointers e.g. give this the list of an object's vertices. Each item in the array will then be the address of each vertex.

free the block of memory with myfree().

Andy
Andy is offline   Reply With Quote
Old 19th March 2004, 10:48 AM   #6
monster
Member
Advanced member
 
Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 39
Default Re: Adding lots of surfaces quickly - Importer plugin

Hurrah! Even quicker, and even better.

Cheers.
monster is offline   Reply With Quote
Old 19th March 2004, 02:05 PM   #7
LiveWire
Senior Member
Professional user
 
Join Date: Nov 2003
Location: Eugene OR, USA
Posts: 212
Default Re: Adding lots of surfaces quickly - Importer plugin

wow, somone else was working on a hightmap maker also, lol
anyways, id love to have that plugin, please post a link where we can download it

also, IF your plugin is 'open source' id realy like to see how you made it :wink:

good job.

Philip
LiveWire is offline   Reply With Quote
Old 21st March 2004, 03:27 AM   #8
monster
Member
Advanced member
 
Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 39
Default Re: Adding lots of surfaces quickly - Importer plugin

Well, I wouldn't say I was "working on" a heightmap importer. I just hacked one together quickly to allow me to generate a quick landscape for some vertex/fragment shader development that I'm doing.

It's available as a "bonus feature" of the Ogre mesh export plugin. I've got a bit of tidying up to do then I'll update the archive and post the URL. I'll also stick the source-code in the archive.

Stay tuned!
monster is offline   Reply With Quote
Old 25th March 2004, 02:11 AM   #9
monster
Member
Advanced member
 
Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 39
Default Re: Adding lots of surfaces quickly - Importer plugin

You can get the OGRE Plugin with bonus Height Map importer from;
http://www.green-eyed-monster.com/
The source code's available from the same place.
monster 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 04:08 AM.


AC3D Forum
(C) Inivis Limited 2020