just download this repo as zip and that can be used as the addon.
demo:
for this to work, your ports 8000 and 8001 should be free.
Just start the serve and go to localhost:8001
How this works?
Exports and Imports the scene as gltf lol
I made this w/ a websocket 2-way communication system for future plans for this.
Right now it just exports glb cuz idk what yall’re gonna do in your blender scene.
but world matrix changes for example can be transmitted real time.
and this can maybe have an editor like interface and you can make changes to your blender scene from your babylon view etc etc
the websocket comes in handy.
It might glitch out here and there. consider this v0. a PoC.
it’ll get better eventually.
Literally my first time making a blender addon and I crammed everything into 1 file cuz file import didn’t work only inside blender for some reason. idk.
I was wondering if, instead of using the network, having a python layer between Blender and Babylon (native) was possible. It think it’s possible to have an API to control BabylonNative (init window, load gltf stream,…)
Let me know if you’d be interested in a collab: I can handle BabylonNative python glue.
EDIT: looking at your video, I’m wondering if a bi directional comunication is possible. Like tweaking a material in Inspector, generating a mesh proceduraly, etc
Looks sheesh! and it’s right in the playground as well : O
I was wondering if, instead of using the network, having a python layer between Blender and Babylon (native) was possible. It think it’s possible to have an API to control BabylonNative (init window, load gltf stream,…)
sure we could do that! : D, but… y tho?
it’s not like passing messages is an overhead, even if it is, the larger overhead of export/import is heavier : O
looking at your video, I’m wondering if a bi directional comunication is possible. Like tweaking a material in Inspector, generating a mesh proceduraly, etc
That’s precisely I chose websocket comm to begin w/!
The plan is to not only get some realtime sync (clicking buttons eveytime for update is tedious), but also get a back sync!
an editor like interface on babylon side and you have the option translate your babylon changes back to blender : ))
Let me know if you’d be interested in a collab: I can handle BabylonNative python glue.
I haven’t been introduced to babylon native yet I don’t think : P
To make it (very, very) short, BabylonNative is like a Webbrowser, without DOM, but with much more control and the ability to add custom native components.
So, the Python component could be used by any Python client, not just Blender but potentialy other apps using Python like Maya or Substance.
I had done the exact same from Blender to Houdini (the export being used as a base for some procedural modeling in Houdini).
Something nice would be to add some “realtime” option, where you basically listen for any modification in Blender (Going from Edit to Object Mode, mesh move, new mesh, etc…). Eventually you would limit the update rate in order not to bullshit the network
I have not coded any blender python in a while but I remember finding some solution to imports of other scripts involved adding the path to the target import directory to the sys.path , eg :
here , I had my other scripts in the parent directries ‘script’ folder , like the script pipeline_process
import bpy
import os
import sys
# Get the directory of the current Blender file
blend_dir = os.path.dirname(bpy.data.filepath)
# Get the parent directory of the blend_dir
parent_dir = os.path.dirname(blend_dir)
# Get the path to the "parent scripts" directory
scripts_dir = os.path.join(parent_dir, "scripts")
# Add the "scripts" directory to sys.path
sys.path.append(scripts_dir)
import pipeline_process
from importlib import reload
reload(pipeline_process)
not sure if this info will help or work for you but thought i might share anyway incase it does.
Another gotcha of separate files and script importing , when still developing you phython code only changes to the main file blender is handling are picked up, unless you have what you see in the last line in my example
reload(pipeline_process)
I guess imports are doing some internal caching.
also , sys.path.append is global to the session , meaning inside pipeline_process script , i can import any other scripts in the same directory as it exists in itself without having to do the path set up again eg : pipeline_process.py does this :
import time
import bpy
import os
import json
from PIL import Image
# THIS SCRIPT IS RUN FROM THE SPECIFIC ROOM PIPELINE SCRIPT
#THAT SCRIPT WILL IMPORT THE REQUIRED BAKING DATA AND PASS IT TO THIS SCRIPT
#IMPORTANT , these scripts require setup of a custom import path , handled by the SPECIFIC ROOM PIPELINE SCRIPT that will import this script
import util_directories_and_paths
import util_collections_and_objects
import pipeline_preprocess_uv
import pipeline_preprocess_collections
import util_images
from importlib import reload
reload(util_directories_and_paths)
reload(util_collections_and_objects)
reload(pipeline_preprocess_uv)
reload(pipeline_preprocess_collections)
reload(util_images)
Sorry I had missed this part where you struggle with Python imports.
I have spent quite some time already working with Blender Addons (example), including networking, custom OpenGL directly inside Blender, automatic addon update from remote server on Blender launch, etc..
It’s buggy and glitchy rn and works for only a select few cases. But it’s a start! : )
I also made an ambient light postprocess, since blender world color doesn’t use the clear color, but seems to have an addition blend effect w/ the whole render.
you get the option to turn it off and just use clear color by typing app.useClearColorFromPost = false in the console.
I imagine I’ll integrate this among other things in a settings menu at some point.