View Full Version : Adding lots of surfaces quickly - Importer plugin
monster
18th March 2004, 10:56 PM
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;
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.
Andy
19th March 2004, 02:59 AM
list_add_item_head(&surfaces,s);
is very quick.
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
monster
19th March 2004, 06:00 AM
Ah, yes. Thanks for the reply.
It was;
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;
ac_object_add_vertices_from_float_array
monster
19th March 2004, 07:40 AM
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?
http://monster.prohosting.com/terrain_capture.png
Andy
19th March 2004, 10:32 AM
Gorgeous!
>is there a quicker way to get a list of all the Vertex pointers?
You can use:
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
monster
19th March 2004, 10:48 AM
Hurrah! Even quicker, and even better.
Cheers.
LiveWire
19th March 2004, 02:05 PM
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
monster
21st March 2004, 03:27 AM
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
25th March 2004, 02:11 AM
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.
vBulletin® v3.7.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.