api from "Blender import *" ??

Hello, I was looking through examples in the api documentation and I tried
the one under meshes… The first line gave me an error…

ImportError: No module named Blender
http://www.blender.org/documentation/248PythonDoc/

This documentation is for 2.6 right?? I don’t understand… :stuck_out_tongue:
I am use to the scripts that are from bge import… etc…

wait… i get it… bpy is only for inside blender… Different then bge… So this whole time i was reading the api docs thinking i could use all of those modules… and i can only use half?? that sucks :stuck_out_tongue: Why doesn’t blenders game engine have the option to create meshes in game play… seems like a huge limitation… :stuck_out_tongue:

Half? Rather just a Quarter up to one Third maybe!
And you are totally right, it is indeed a huge Limitation. In Fact, the Problem is just that Game Engine an Blender Internal are separated so strictly from each other. And I always wonder why…

sorry about saying “half” ha got a little carried away…
That and I really don’t know the bge good enough to make an educated guess :stuck_out_tongue:

Well…

I thought that the python bge was just a huge library of scripts? A list of many modules
that if you were to look at the source of, are nothing more then a lot of python code…
I don’t understand why you can’t import bge modules along with bpy… When your
in the python IDLE you can import pygames along with importing other library’s… Is it because
of the blender GUI?? Could you use the bge without the blender GUI application? All the source
code can be found in the api documentation… Or at least I was searching through some of it…

Couldn’t you just import the source code from the bge and bpy modules that you needed and
use that… Or would you find that a lot of the bge and bpy clash with each other??

You can’t import Blender’s Python libraries because they’re specific to Blender - they weren’t made to work with the BGE, neither in real-time, nor in a standalone game. Blender’s Python API works like Blender - the functions executed run on the next ‘update’ of Blender, of the program, not every frame, like the BGE.

I can’t really explain it, so it’s just that the BPY and BGE modules are different. They were made for different purposes. It would be nice if the BGE could create meshes real-time, though. You could create an object out of individual face objects, but it would probably run too slowly if you had a lot of faces…

EDIT: Somebody did work on this front awhile back, though. Moerdn did a lot of work with batches and automatic LOD, and, if I recall correctly, someone else started working on realtime mesh creation. I’m not quite sure, though.

Why should Blender/bpy be avoided in a game?

Lets compare Blender/BGE with the automotive industry:

Blender = car factory with

  • design department = Blender GUI
  • blue prints = Blender data ~ blend file
  • production department = Blender player
  • product: car = a game
  • driver = player

Game/Car creation process
The design department designs a new car by creating blue prints of it.
The production department assembles a new car. This is like starting the Blender player.
There are two options:

  • creating in the factory = running the integrated blender player with <p>
  • creating at the divers home (like home cooking :wink: ) = running the game executable

The car is created from the blueprints (.blend) provided by the design departments. As addition the blueprints are stored in the luggage trunk.

The car gets engines and controls. The driver can use the controls to drive the car.

Design refresh
The designer gets the idea to provide the driver a toolbox to customize the car.
So he changes the blueprints and let the production department assemble a new car.

Now the driver can change the color of the new car, replace the wheels, or improve the force from the engine.
All of that while hew is driving his new car :wink:

Design refresh advanced
Imagine we get an apprentice at the design department. He has the glorious idea to provide tools to manipulate the blue prints. This is quite easy because as long as the car is at the factory (running inside blender) the design department provides tools to access the blueprints (bpy).

The apprentice let the production department assemble a car. The driver (usually the apprentice himself) uses his cool tools to changes the blue prints at the luggage trunk.

The question:

  • After changing the blueprints - does the car he is driving change too?

What do you think?