How to: load .blend @ runtime, use external textures?


I started out with Blender about a year ago and now got involved into an interactve architecture visualisation project for the web wich we want to solve using blenders game engine.

My questions concerning the game engine are:

  1. How to load/add .blend files at runtime?
  2. Can textures be loaded dynamically?
  3. Are scenes loaded seperatly when they are activated or is always the whole blend file loaded at once?
  4. Is there an overview about the Blender Data Structure for scripting purpose?

Thanks for reading.

the game actuator

textures that aren’t packed are stored outside of the .blend, using a relative path if you were careful… there is no way to load a new texture, and can’t reload texture without loading or reloading a new .blend

loaded all at once

the .blend file format? no. stuff avaialbe in the GameLogic module? yes [but it doesn’t help you much]

loaded all at once

So, to keep resources usage low, it’s better to load a small files (i mean 1 for each level of a game) instead of making a big file with different scenes ?

What’s the game actuator

I tried it but it didn’t open the blend file. I tried with relative and absolute path but nothing happened. Also if I understood it correctly it only replaces the current .blend with a new one. I want to add data from different .blends to the current .blend. The idea is to dynamically load rooms the viewer is traveling to. To keep down the loading time and a better performance.

What I was aiming for was the object data structure so I know how to point to the different objects like meshes, lamps whatever in the scene and controll them via script. fake Example: root.objectxy.x points to the x position of “objectxy”. I hope you understand now. I found the Phyton API reference, maybe that’s what I was looking for, but I think it’s for external phyton scripts only not for in game scripts. Maybe in other words: I’m looking for the game-engine/gameLogic (coding) library reference.

Anyway thanks!

I though I might share some results on my way to find out how to do lightmaps in the blender game engine.

(sorry it’s in german) click with LMB to take the tour: (1.6 mb) sorry it’s not optimized for size

this was rendered with yafray and baked with the [email protected]

second test - indoor lighting

this time rendered and baked with another 3D-app cause the rendering times of yafray are to high and the Bbaker script to unstable and slow.

texture object

lightmap object

final result


  1. build the mesh in blender
  2. exported it to .obj
  3. setup the lights and GI in another 3d-App
  4. rendered the lighting maps to .tga with automatic uv flattening
  5. saved the scene with automatic flattened uv’s as .obj
  6. imported that new .obj in blender
  7. assigned the lightmap images as realtime textures
  8. made a exact copy of the mesh.
  9. assigned the copy tiliing textures and set different uv’s
  10. fattened the original mesh with the lightmap a litte. That way no clipping problems will occour.
  11. Adjusted the Alpha-Channel of the lightmap images by combining the RGB channels to one grayscale channel and copying it into the alpha channel. Then I adjusted the contrast of the alpha channel to make the shadows more visible.

It’s still not satisfying but with some more tweaking I might get a good result soon.