It’s not a ready-for-use product, but anyway you can try to get some results with it, or even improve it
What you need
Development version of Panda3D (1.9)
Blender version 2.7 (not tested, but possible it will work on 2.6 too )
latest version of YABEE from GIT: github.com/09th/YABEE
Scene Exporter (Blender plugin): github.com/09th/Blender4Panda-plugin
Scene Loader (Python package for P3D): github.com/09th/Blender4Panda-loader
You should have installed and enabled both YABEE and Scene exporter plugins.
Plugins can be installed by dropping they unzipped folders into <blender_path>//scripts/addons directory or from Blender User Preferences (Ctrl+Alt+U) → Addons → Install from file (zip file in this case). After installing you can find and enable it by keyword “Panda”.
Usage
When all done, you can found new panel in the tools shelf (hotkey “T”) called SE4P3D and “Export scene” button on it. Press the export button and select a directory for saving scene. Exporter will create <scene_name>.jsd file with the scene description and subfolder called “res”. Created subfolder will contain <scene_name>.egg file with the scene geometry and various files (shaders and images) related to the scene materials.
Now you can try to load exported scene:
from direct.showbase.ShowBase import ShowBase
from SceneLoader import Scene # SceneLoader is folder, with the Blender4Panda-loader content
base = ShowBase()
sc = Scene(render, loader, base) # pass root node for scene, loader and ShowBase object
sc.load('untitled.jsd') # load our .jsd file
sc.switch_camera() # Switch to the first camera if exist. You can comment this line and use default Panda's camera
base.run()
Restrictions and notes:
[]We are talking about “Blender Game” rendering engine[/]
[]All objects should have material[/]
[]At current stage we talking about the static scene with the meshes, materials, lights and cameras[/]
[]Shader materials aka shader nodes also can be used[/]
[]Do not try to use “Assets”, they not work yet[/]
[]Blender has a bug with the spot light: it casts shadow and provide appropriate shaders when “Shadow” checkbox is unchecked. Make sure that checkbox state corresponds to what you see.[/]
[]If you have scene which not exported, or exported incorrectly (considering known limitations), then you can send it to me and I’ll try to improve exporter[/]
About extensions
extensions usage scheme download/file.php?id=324
Simplest extensions:
Blender
order = 25
target = 'scene'
def invoke(all_data, target_data, context, fname, flags=None):
target_data['my_message'] = 'Hello'
Panda
order = 25
target = 'scene'
def invoke(scene, data, action):
if action == 'LOAD':
if 'my_message' in data:
print data['my_message'], 'from', scene.jsd_file
some scene usable variables
...
self.root = root
self.loader = loader
self.show_base = show_base
self.path_dict = {'sounds':'res',
'meshes':'res',
'images':'res',
'materials':'res'
}
# Raw data, which should loaded from JSON file
self.data_dict = {'objects':{},
'assets':{},
'scene':{},
'materials':{}
}
# Data after passing through import extension will be stored in
# variables below this comment
self.objects = {}
self.lights = {}
self.sounds = {}
self.cameras = {}
self.textures = {}
self.meshes = {}
...
*.jsd structure
{
"scene": {
/*various common scene parameters*/
"parameter_1": value,
...
"parameter_N": value
},
"assets": {
/*
List of used assets.
Assets is a complex objects, which can be reused.
Assets not implemented yet.
*/
"asset_name_1": {/*asset parameters*/},
...
"asset_name_N": {/*asset parameters*/}
},
"objects": {
/*
List of used objects, for example meshes, lights, sounds e.t.c.
Object also can be exemplar of asset.
*/
"object_name_1": {/*object parameters*/},
...
"object_name_N": {/*object parameters*/}
},
"materials": {
/*
List of used materials, added mostly in purposes of implementing
Blender shader.
*/
"material_name_1": {/*material parameters*/},
...
"material_name_N": {/*material parameters*/}
}
}
Old first post: