- This topic has 11 replies, 5 voices, and was last updated 2 years, 5 months ago by AVerge3Der.
-
AuthorPosts
-
2019-10-28 at 11:33 pm #20763GLiFTeKCustomer
Hi
I have many unique objects to load as per potential user’s choices.
Instead of having MANY a separate .gltf file for each object,
Is there a way instead, to have a .gltf file full of all of them, and be able to designate which objects, or collections of objects would be loaded from the scene?Further, are the puzzles “append scene” and “load scene” actually loading the entire .gltf OR is it loading a specific “scene” (as per the name) in blender that can be designated to be loaded with it’s objects…
ie: 1 .gltf file has 6 “scenes”, each with it’s own objects/collections.
I could designate one specific “scene” from the .gltf and get desired results?Thanks!
Visit the GLIFTEK Verge3D Plugins Store!
GLIFTEK.com for Plugin Documentation & LIVE DEMOS!
LIKE The GLIFTEK Facebook Page for updates!
Join the Verge 3D Discord Server!
plz share Discord link & on your signature!2019-10-29 at 6:55 am #20764Yuri KovelenovStaffIs there a way instead, to have a .gltf file full of all of them, and be able to designate which objects, or collections of objects would be loaded from the scene?
ATM the engine needs to load the whole gltf file in order to access its contents (i.e. no streaming).
Further, are the puzzles “append scene” and “load scene” actually loading the entire .gltf OR is it loading a specific “scene” (as per the name) in blender that can be designated to be loaded with it’s objects…
Multiple scenes are exported to gltf, but only the first scene is available after loading.
2019-10-29 at 2:36 pm #20778jemCustomer@GlifTek, I often have the same requirement. I need to load specific objects into a 3D scene on demand. As Yuri pointed out, the Verge3D engine must load and parse a complete GLTF file just to be able to load one of the objects within it. In my scenes, this would be an incredibly inefficient technique (the user experience would suffer). I have scenes with hundreds of objects that could be loaded. Only a small handful are ever loaded during a single end-user’s session. These libraries of objects can be hundreds of megabytes in size. This is why I keep all of the objects that can be loaded on-demand in separate GLTF files. I know that managing a large number of separate GLTF files can be cumbersome, but here is the technique that I developed to make that more manageable:
1. Develop a descriptive naming system for all objects. In engineering, this is sometimes called an intelligent part number.
2. Place all objects in a single Blender file. Putting them in one place makes processing them more efficient.
3. Keep an inventory of all of the objects in the Blender file in a CSV file. This file can come in handy for other purposes such as project management.
4. Write a Python script in the Blender file that batch export a separate GLTF file for each of the rows in the CSV.
5. Develop logic in your puzzles that concatenates strings and values to create the required intelligent part numbers when needed.
6. Use puzzles to load that part and that part only.This may seem like a lot of work to set up, but it is work you will only do once. After that, you can cut and paste it into your new projects. I find that being able to produce 500 GLTF files with the press of a single button is magic. This also makes updating to the latest build of Verge3D fast and easy.
Jeremy Wernick
2019-10-30 at 8:53 am #20835Yuri KovelenovStaff2020-01-04 at 10:23 pm #22559GLiFTeKCustomerHi!
No, doesn’t sound complex at all! Sounds exactly what I’m talking about. I have a very specific serialized naming convention and aCSV file to store their data!
What would the python script look like? That is very very interesting to me!
Thanks!Visit the GLIFTEK Verge3D Plugins Store!
GLIFTEK.com for Plugin Documentation & LIVE DEMOS!
LIKE The GLIFTEK Facebook Page for updates!
Join the Verge 3D Discord Server!
plz share Discord link & on your signature!2020-01-29 at 1:26 am #23086jemCustomer@GlifTek, sorry for my delay in responding.
I have attached an archive of a simple project that uses this script. You will probably need to edit the python script to suit your requirements. I think that it is reasonably simple. I am not a programmer, and I was able to cobble it together.How to use this script.
1. Place all of your objects in the object_library.blend file.
2. Edit the CSV file. The CSV has two columns, ObjectName and BlenderFileName. This allows the GLTF file name and the object name to differ if needed.
3. Open gltf_mass_export_example.blend
4. Edit the gltf_export_script.py script. At a minimum, you will need to change the value for the fp variable to match your environment.
5. Run the script.For each object listed in the CSV, the script will append the object from the object_library.blend, save it at a separate .blend file, save it as a separate .gltf file, and then delete the object from the working blend file.
You will end up with a directory of blend files and another directory of gltf files.
The script is flexible. I have used it to perform batch transformations. There are some commented examples included.
Give it a try and see what you can do with it. I find this type of scripted batch processing to be very powerful.
# application directory fp = "D:\\verge3d\\verge3d\\applications\\gltf_mass_export_example\\" # subdirectory where exported blender files will be placed dir_blender = "blender_files" # subdirectory where exported gltf files will be placed dir_gltf = "gltf_files" # name of file containing all of the objects to be extracted and saved as gltf files combined_object_data_file = "object_library.blend" # CSV file with the names of the objects to be extracted and the name of the gltf file to create from each object csv_file_name = "my_export.csv" with open( fp + csv_file_name ) as csvfile: reader = csv.DictReader( csvfile, dialect='excel') for row in reader: # Deselect all objects bpy.ops.object.select_all(action='DESELECT') obj_name = row['ObjectName'] file_name = row['BlenderFileName'] directory = fp + combined_object_data_file + '\\Object\\' filepath = directory + obj_name bpy.ops.wm.append(filepath=filepath, filename=obj_name, directory=directory) #set the imported object active bpy.context.view_layer.objects.active = bpy.context.selected_objects[0] #print(bpy.context.active_object.name) #bpy.context.active_object.name = bpy.context.active_object.name.upper() #if you need to apply any transformations to each object, ues functions such as the following: #bpy.ops.transform.resize(value=(0.0254, 0.0254, 0.0254)) #bpy.ops.object.transform_apply(location=False, rotation=True, scale=True) #bpy.context.active_object.name = bpy.context.active_object.name.upper() bpy.ops.wm.save_as_mainfile(filepath=fp + dir_blender + '\\' + file_name + '.blend') bpy.ops.export_scene.v3d_gltf(filepath=fp + dir_gltf + '\\' + file_name + '.gltf') bpy.ops.object.delete()
Jeremy Wernick
2020-01-29 at 4:18 am #23088GLiFTeKCustomerwow,
Fantastic, Jem!
I’ll try it out.
..yet another addition to the ever expanding bag of tricks that should make this project a streamlined success!
I really appreciate your help in this.
Thanks!Visit the GLIFTEK Verge3D Plugins Store!
GLIFTEK.com for Plugin Documentation & LIVE DEMOS!
LIKE The GLIFTEK Facebook Page for updates!
Join the Verge 3D Discord Server!
plz share Discord link & on your signature!2020-01-29 at 3:05 pm #23103jemCustomerI have one more hint for using this script. If you want a specific Verge3D export option to be applied to all of the GLTF files, set that Verge3D export option in the gltf_mass_export_example.blend file. All of the .blend files and .gltf files will inherit that option.
For example, you might want to enable LZMA compression for all exports. In that case, check the LZMA checkbox in the Verge3D section of the render properties tab in the gltf_mass_export_example.blend. This technique avoids having to remember to enable that option on hundreds of separate blender files.Jeremy Wernick
2020-01-30 at 7:53 am #23117Yuri KovelenovStaff2020-02-03 at 4:39 pm #23245vkleinCustomer@GlifTek, my technique is similar to @jem ‘s but even simpler. I’m using 3dsmax and have made a script which export every top object-group(s) (no parents, only children) of the selection into a separate file with the name of the group. Simple group together what should go into one file, select all groups you want to export and click a button. My script can export to multiple file formats (every one is a button), the exportpath is saved with the max-file and the option to move the groups to scene origin prior to export and back after. So you can array the groups next to each other work on them and on export they land on 0,0,0.
2020-05-02 at 1:24 am #27076GLiFTeKCustomerI thought of a method that may suit my needs, though I’d need official agreement,cuz I’m not going to try if it won’t definitely work…
So…
Using “headless” server side working, append the file with ALL the objects, move desired object from master collection group into special collection group, delete master collection group.Does this sound like it would work?
And be memory-friendly?I have not toyed with headless operation yet.
Thnx
P.s.- server side headless rendering needs to be hosted on non-static-only capable hosting services correct?.. My terminology may be off some here.
Visit the GLIFTEK Verge3D Plugins Store!
GLIFTEK.com for Plugin Documentation & LIVE DEMOS!
LIKE The GLIFTEK Facebook Page for updates!
Join the Verge 3D Discord Server!
plz share Discord link & on your signature!2022-06-01 at 6:48 pm #52576AVerge3DerParticipantThat would be useful to see an example. Mind sharing?
-
AuthorPosts
- You must be logged in to reply to this topic.