Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Turning several objects into one mesh

Author
Message
Jaeg
20
Years of Service
User Offline
Joined: 16th Mar 2006
Location: Indiana
Posted: 2nd Jun 2010 05:27 Edited at: 9th Jun 2010 16:12
I've been working on an FPS and was thinking of ways of laying the roads and sidewalks in the city. I was going to use FPSC for level creation but I ran into some issues with static universes so I wrote a program that turns a 2d image contain green, blue, and red into grass, side walks, and roads.

The program I wrote works like a charm. It creates an object for each pixel in the bitmap and everything looks great. Now to my question. How can I turn this group of objects into one mesh so I can export it to .x. Or turn into one object and export as dbo?

EDIT - If people are interested in the source I can post it so you can use it. I don't think I can provide the media however. I got it from various free model packs for FPSC BUT I'm unsure if posting the media outside of their respective packs with the source would be allowed. The code isn't finished and very simple but I plan to add on to it. I'd like to make it so I can place my buildings in it like an editor and package it with my game so it can be modded.

EDIT EDIT - I think I'll wait to post it until I get it more complete. It may help more people out then. Unless I need to post it now to get my program solved.

EDIT EDIT EDIT - I have reverted to using multiple objects that are instanced as segments and have the game load it in that format. DBP natural culling is working better than the method I was using or a plugin to allow limbs to be culled. I can now turn a 42x 42 image into a 4200 x 4200 map complete with roads, sidewalks, grass, and streetlights and have it run about 120 fps. Now the real test will come when I start adding buildings but since the buildings are low poly it should be too bad.

Go ahead. Walk into Mordor.

Ball State University - Biology Major
Xsnip3rX
19
Years of Service
User Offline
Joined: 20th Feb 2007
Location: Washington State
Posted: 2nd Jun 2010 05:47 Edited at: 2nd Jun 2010 05:47
Found this in "Save Object" in the help files, don't know if it helps for your case or not but you can try it.

Jaeg
20
Years of Service
User Offline
Joined: 16th Mar 2006
Location: Indiana
Posted: 2nd Jun 2010 06:02
I'll have to wait till I can get on my machine with DBP on it. From looking at the code I'm not entirely sure if it will work for me. Is it just saving secondobject which is a copy of objectnumber and then colored red and moved? Or when you instance an object are they considered the same object? (Sorry I've only used clone object before so I'm unsure)

Even if did make them the same object I would still run into the problem of my sidewalks, roads, and grass not being the same object when saved because they are all clones three original objects which each have their own model file and texture. (These three are deleted once the program has finished processing the source image)

If you get mad and want to type something nasty about another person do this-Type what you want to say in the box then press ctrl-a and hit delete then type what you should say.
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 2nd Jun 2010 08:55
If you created the initial object (via memblocks or whatever) you can then save it.

The example shows usage of the command, ignore the first object.

My signature is NOT a moderator plaything! Stop changing it!
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 2nd Jun 2010 11:38
It might depend on how you texture, because if you need to save as a .X file, your stuck with the unholy task of making your own exporter (writing the .X file manually), or using meshes.

If you create a mesh from an object, you can add it to other objects as a limb, offset, rotate - great for level design.

If you make a mesh from a limbed object, the limbs are 'welded' in place, the mesh will have all the geometry that was there before, but in a single mesh.

Now for the nasty bit - meshes do not save their texture information, you would have to texture manually - maybe that's the best option though. So if your objects share the same texture, you can combine them into meshes, if your limbs need their own texturing then you would have to use DBO files, which support any type of object.

Personally, I would tend to have all my level bits as individual meshes, then add them as new objects or add them to other objects. Prefabs could be exported, and the actual limb information could be saved instead of handling it internally. You could even have low poly versions of your meshes, and add them in exactly the same way, but only use them for collision detection.

So those golden rules again:

Objects can have meshes added to them as limbs.
Objects can be saved as DBO files, with limbs intact.
Meshes can be made from objects, but meshes are singular, no limbs or anything like that.
Meshes can be saved as .X files.

From a performance standpoint as well - once all your textures and meshes are in memory, it is very quick to create new objects, so it might afford you the option of optimising to suit that. Like maybe you don't need to stop and load the next stage, maybe just load up the level data as you go, creating the new geometry as you go, and getting rid of old geometry too. When you can just build the object inside the engine instead of loading it, well you can do some fancy GTA style seamless stuff.


Health, Ammo, and bacon and eggs!
Jaeg
20
Years of Service
User Offline
Joined: 16th Mar 2006
Location: Indiana
Posted: 2nd Jun 2010 19:43 Edited at: 2nd Jun 2010 20:25
Thanks Mobiius for the clarification.

VanB - So you are suggesting that instead of exporting everything as a single dbo to be loaded I should make my engine load the image and convert it into the city? I kind of like the idea. One worry though. When I go to load a new level is there a way to reuse the old objects instead of having to delete them? I'v heard that deleting objects too much can cause issues. Other than that I'm pretty sure I have the ability to make my own editor to place the buildings and other objects and save their coordinates and rotations in a file to be loaded again.

Or am I totally missing your point? I'd like to make my own editor so if I can save everything as a single dbo I'll be fine with that. I originally wanted .x so I can edit it in another program but after thinking about I think I can make an editor and keep it all together.

EDIT -
Ok so I've modified the program to add the individual meshes to limbs of a central object and then export it as a dbo and it's working. I plan on adding to the layout generator so I can add buildings and export it all as dbo. What I have working now will be kind of something to lean back on incase I don't get what Van B is talking about working. I like the idea of loading the level as you go. Kind of worry about lighting/lightmapping that though..

If you get mad and want to type something nasty about another person do this-Type what you want to say in the box then press ctrl-a and hit delete then type what you should say.
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 2nd Jun 2010 22:08
Saving the whole level as a DBO is probably gonna work out fine, especially if you are lightmapping - maybe invest in darklights if you haven't already.

The idea with using meshes, was that instead of saving 100 lamp posts mesh data, you could just have one, and add it as a limb like you are doing. You could also use a single object and instance it wherever it's needed. Saving the whole level as a single object might be a bit of a strain, depends on how much detail you have in your level.


Health, Ammo, and bacon and eggs!
Jaeg
20
Years of Service
User Offline
Joined: 16th Mar 2006
Location: Indiana
Posted: 2nd Jun 2010 22:33 Edited at: 2nd Jun 2010 22:49
I'm thinking of doing a combination. Set up markers for common items. (Street lights, signs, benches, phone booths) But having the grounds and buildings being a single DBO. I might make markers for the buildings. Not sure yet.

If I use markers for street lights I could use dynamic lighting with them to have some of them flicker and a simple day night system... but I might be getting ahead of myself. I need to take it one step at a time.

I'm for sure going to get DarkLights. It'll be very helpful with this application.

I should probably start writing features I want down and think of the best possible way to achieve the results with good optimization.

Thanks for your help Van B. You've given me many ideas and helped me save the level to dbo.

EDIT -
If I was to make a large city it would probably be better to make it in segments that disappear and reappear as needed wouldn't it?

If you get mad and want to type something nasty about another person do this-Type what you want to say in the box then press ctrl-a and hit delete then type what you should say.
Jaeg
20
Years of Service
User Offline
Joined: 16th Mar 2006
Location: Indiana
Posted: 3rd Jun 2010 18:50
I have another question. When you add a limb to an object from a mesh is the mesh data getting copied or is it similar to instancing an object? I've been working on a system that excludes limbs past a certain distance from the camera to improve performance. I'm adding street stuff (Street lights, benches, etc) as limbs themselves so they too can be excluded to improvement. So far it is working. Each segment is 100 x 100 (The models are from DarkCity) So with a 32x32 image I get a 3200 x 3200 map and it's running between 100 fps to 60 fps depending on where you are standing.

I also wanted to know if there is a way to turn the limbs not on the screen. I.E. behind the camera off too. I think thats the reason for the fps moving between 100 and 60. The codes is creating a radius of tiles around you but I don't need the back half.

If you get mad and want to type something nasty about another person do this-Type what you want to say in the box then press ctrl-a and hit delete then type what you should say.
Brendy boy
21
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 3rd Jun 2010 18:57
Quote: "When you add a limb to an object from a mesh is the mesh data getting copied or is it similar to instancing an object?"

mesh data is copied

Jaeg
20
Years of Service
User Offline
Joined: 16th Mar 2006
Location: Indiana
Posted: 3rd Jun 2010 22:40
Ok. Thanks. I'm using the exclude limb commands and according to the description it doesn't even process the limbs when they are excluded so that should help with fps.

Any ideas on how to exclude limbs that aren't currently seen?

If you get mad and want to type something nasty about another person do this-Type what you want to say in the box then press ctrl-a and hit delete then type what you should say.
Brendy boy
21
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 3rd Jun 2010 23:06
i think that's not possible without creating your own frustum culling system for determining which limb is in screen and which is not

Jaeg
20
Years of Service
User Offline
Joined: 16th Mar 2006
Location: Indiana
Posted: 4th Jun 2010 03:02
Is that where I have an invisible plane in front of the camera and another way out in the distance and use rays to see if the limbs are within view?

If you get mad and want to type something nasty about another person do this-Type what you want to say in the box then press ctrl-a and hit delete then type what you should say.
Brendy boy
21
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 4th Jun 2010 15:35
something like that. Try googling for frustum culling or search the forum for lost in thought's 3d world studio importer which i believe features frustum culling that works on limb basis.

Jaeg
20
Years of Service
User Offline
Joined: 16th Mar 2006
Location: Indiana
Posted: 4th Jun 2010 16:26 Edited at: 4th Jun 2010 18:17
Thanks Brendy. I found Lost in Thought's code
http://forum.thegamecreators.com/?m=forum_view&t=67369&b=6

I'm going to do some research and experimenting.

I've also found an Octree culling plugin and kind of like it better. Now my fps stays consistent no matter how far into the map I am.

Go ahead. Walk into Mordor.

Ball State University - Biology Major
Jaeg
20
Years of Service
User Offline
Joined: 16th Mar 2006
Location: Indiana
Posted: 8th Jun 2010 23:14
I thought I'd recycle this topic instead of creating a new one.

I've been working on this project and have found that if I go above 32x32 tiles I start to notice a big fps drop. Come to find it's because of the big loop that checks to see if the tiles are close enough to be seen yet.

So I did some experimenting and reverted back to using objects. Now every tile is an instance of a parent object and with DBP built in culling the speed has increased dramatically even on larger maps. Now my question. Is it possible to set up collision with all these separate objects? I'm going to test it with sparky's but I wanted to ask too. I didn't know if there is anything in paticular that I should watch out for or avoid.

Go ahead. Walk into Mordor.

Ball State University - Biology Major

Login to post a reply

Server time is: 2026-07-25 16:20:22
Your offset time is: 2026-07-25 16:20:22