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.

AppGameKit Studio Chat / Properly prep/export multiple OBJs w Blender to be able to load them with LoadObjectWithChildren()

Author
Message
Tobias_Ripper
11
Years of Service
User Offline
Joined: 24th Mar 2013
Location: REPCONN inc.
Posted: 24th Apr 2019 19:24
Good day.

I've got a level with about 200 - 300 objects. I would really benefit from getting AGKs object culling up and running to not draw objects behind me.

Problem is that Blender doesn't have a batch export so how do you go about exporting obj file containing all your level meshes but having them load up as individual meshes to make use of the LoadObjectWithChildren() function?

Thanks
Eisenstadt Studio: Eisenstadtstudio.com
Composers Page: Milesthatch.net
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 25th Apr 2019 02:35
You can save them all together as one object
and then treat them as children and texture appropriately

or

in your scene you can resave each object one at a time
I believe there is a way of saving only the selected object in Blender
then when you load an object in agk it should be positioned correctly

fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
Tobias_Ripper
11
Years of Service
User Offline
Joined: 24th Mar 2013
Location: REPCONN inc.
Posted: 25th Apr 2019 03:06
Does AppGameKit detect them as separate objects? Even if I select ALL and export as a single OBJ? Or is there any special namig scheme I should follow to get AppGameKit to recognize separate child meshes in a single file?

Definetely NOT saving one by one,,,, there's about 500 separate objects in a level to be exported one by one.
Eisenstadt Studio: Eisenstadtstudio.com
Composers Page: Milesthatch.net
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 25th Apr 2019 04:07 Edited at: 25th Apr 2019 04:13
Hmmm,

Under the object tab in blender can you set the Parent object to an empty or just a random object that you can designate as the parent? You could write or find a script to parse through all your objects, and set them up to having the same parent quickly. I don't know know Python. I usually just use what is on the internets.




edit:

I know Blender has batch exports via FBX. I have that add-on.

According to this https://blender.stackexchange.com/questions/5382/export-multiple-objects-to-obj they also have an Obj batch export.

Attachments

Login to view attachments
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 25th Apr 2019 22:16
I wouldn't use LoadObjectWithChildren(). As far as i can see it is designed to be used for animation
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 26th Apr 2019 02:22 Edited at: 26th Apr 2019 03:43
I just tested my theory out, and it only sets them up as meshes. Which, I am glad to find out, because my last method of setting meshes took quite awhile.

But I don't know if culling works on meshes vs children?

edit: this is only fbx and dae. I don't think OBJ supports too much.
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 26th Apr 2019 03:42
BTW,

You don't need to use the add-on to export multiple FBX.

In the options if you choose to export as group it will export each group. Of course, you will have to assign groups to your objects.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 26th Apr 2019 03:56 Edited at: 26th Apr 2019 03:58
This is a (pretty raw) app i wrote to split apart a large model that is made up of a number of objects.
Because of my 3D proggy i had to export as .3ds, then convert it to .obj. This forced me to use group names that were 13 bytes long.
This is important because the group name could have a number of "switches" that would indicate what would happen to the object (is it a "cloned" object? is it a camera position? or a light position? etc)

If you want to use it i would suggest you follow these steps;

1. The example will de-atomize a model called "hoops.obj". Load that model and have a look at it in your 3Dproggy. Pay close attention to the group names. All the group names will be of the format "name~switches"
2. As i mentioned the switches help to describe the object. There is a full list of switches in the media/types.txt file
3. If you run the example it will generate the models in "C:\Users\your_name\AppData\Local\AGKApps\SceneSplitter\media" folder
4. it also creates a hoops.map file that documents the position and various attributes for the object
5. It's nice to understand the layout of the hoops.map file but it's not necessary because there is a LoadScene() function that will load the scene and return arrays containing the models/camera positions/paths/lights and so on
6. You don't need to run it every time, Only if you change your original model.


If you have any issues just let me know

Attachments

Login to view attachments
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 26th Apr 2019 04:30 Edited at: 26th Apr 2019 05:49
I also want to add culling on a per object basis is not the way to go, even if we could figure out how to do what you are asking.

Exporting out 500 objects into 1 large object that shares the same texture is much better than trying to export out 500 objects. The GPU is going to work much harder to render each object. An easy example of this is grass. If you try to make each grass its on object you are not going to have a playable game. But if the grass is just a few objects your FPS increases dramatically.

Perhaps export the objects in sections? That way you have only 1 or 2 "objects" showing at a time? I am, of course, assuming you are sharing the same shader and texture.
Tobias_Ripper
11
Years of Service
User Offline
Joined: 24th Mar 2013
Location: REPCONN inc.
Posted: 27th Apr 2019 14:24
So the main reason I was asking about the LoadWithChildren is specifically BECAUSE I have a level with about 300+ Meshes and I need to be Culling the individual meshes behind the camera. I have a scene between 50k and 120k vertecies and they are all culled at once (I have to fly out of the level boundaries for culling to engage)

Does culling work with LoadWithChildren? Because with my text it shos or Culls the entire level as opposed to individual meshes or do we Have to export each individuial mesh as a separate obj?

This is why I have to export all meshes as individual .obj files.

@Blink0k Thanks for the app, This can come in helpful, appreciate the efforts!


@Golelorn So for 300 - 400+ objects i need to assign the same amount of groups? Blender 2.8 Has Collections and that did not seem to affect the export objects we have
Eisenstadt Studio: Eisenstadtstudio.com
Composers Page: Milesthatch.net
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 27th Apr 2019 16:33
Unfortunately, you will need assign each object to its own group(s). Sorry, I have 2.79. In that the group is under the Object tab.

Another idea, I had is to export it as I mentioned above in FBX(by parenting the objects to one object, thus creating meshes), and then use CreateMemblockFromObjectMesh() and then CreateObjectFromMeshMemblock().

In my experience, the mesh order is based on when the object/mesh was created in the scene, which I doubt you will remember so you'll want the names to be able to make sense out of everything.

You can get the mesh names by GetObjectMeshName(). Use the Object Data tab to name meshes.

Again, I am talking about FBX not OBJ. I have little experience with OBJ except to know you can't do much with it.
Tobias_Ripper
11
Years of Service
User Offline
Joined: 24th Mar 2013
Location: REPCONN inc.
Posted: 27th Apr 2019 17:08
To be honest I think at this point I can simply break the OBJs with the tool, create an array, read how many objects are in the level and load up all the objects into the array in a loop
Eisenstadt Studio: Eisenstadtstudio.com
Composers Page: Milesthatch.net
Tobias_Ripper
11
Years of Service
User Offline
Joined: 24th Mar 2013
Location: REPCONN inc.
Posted: 30th Apr 2019 03:35
Hey @Blink0K

Great extension is actually working sort of.
Listen I've got a scene with about 400 objects in it. And Renaming them, all one by one isn't exactly a picnic. I'm also on 2.8 so All Extensions that could Batch Rename it are dead and unsupported.
Your addon seems to be able to export some meshes even without following a naming convention and it literally does exactly what I need it to do. The problem is that meshes with the same name get overwritten because I get



However my resulting files list is:


So either it does not export or it overwrites the files with the same name.

If it's the latter, how difficult would it be to add some sort of delta time or name incrementing addition to your tool? I tried doing it myself in the MakeFilename function however doing so results in errors after a few successful obj Saves. It apparently is looking for an already saved object but the increment won't let it happen.

So in any case. I've got 300- 400+ object in the scene and I feel like I'm almost there.
Eisenstadt Studio: Eisenstadtstudio.com
Composers Page: Milesthatch.net
Tobias_Ripper
11
Years of Service
User Offline
Joined: 24th Mar 2013
Location: REPCONN inc.
Posted: 30th Apr 2019 03:48
You know what. I'm gonna give this one thing a go.

I just remembered that there was actually a Level Editor engine on Steam that everybody complained about exporting all the level assets as individual OBJ files while everyone and their mother wanted a single FBX file. It seems like I need exactly what everyone is complaining about and guess what.... apparently I own it. I've been using blender as a level editor but perhaps this is what I needed all along. A separate level editor that exports separate obj files.

I'll report on it later on, see how it fares...
Eisenstadt Studio: Eisenstadtstudio.com
Composers Page: Milesthatch.net
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 30th Apr 2019 05:34 Edited at: 30th Apr 2019 05:43
If you decide to use the app just replace the code in main.agc with this. It will add a sequence number to duplicates.
If it helps your app i might be able to make duplicate names cloned objects or instanced objects

Login to post a reply

Server time is: 2024-03-29 13:57:24
Your offset time is: 2024-03-29 13:57:24