Blending the two Python Modules

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Post Reply
metaphorz
Posts: 21
Joined: Sun Nov 10, 2002 3:20 am

Blending the two Python Modules

Post by metaphorz »

From my brief experimentation with the Game Python API, it
seems that while it is possible to place Blender and GameLogic
modules inside the same script, during "game play" (P in the
3d window) only GameLogic modules and methods are available
in realtime (changes made with Blender methods work but
only after the game is finished, pressing an ESC in the 3D
window).

There are three consequences of this for the two major Python
modules (GameLogic and Blender):

(1) There are duplicates of some functions in each module, and
these functions do essentially the same thing in the 3D window
(like getting or setting object attributes) -- moving things around
in real time in this window.

(2) Some things possible when rendering a movie, using a Python
script, cannot be accomplished when constrained to GameLogic.
For example, I couldn't see a way of dynamically creating meshes
in realtime (which is easy in the Blender module).

(3) Some things possible when in a game, like physics operations,
are not available in the Blender module. This would be very
nice to have physics when rendering a movie.

One solution would appear to be to remove duplicates, and more
completely integrate both Python modules, allowing
complete cross-functionality for making movies and playing
games.

Do any of the developers have this plan?

ascotan
Posts: 0
Joined: Thu May 29, 2003 10:32 pm
Location: Maryland, U.S.

Post by ascotan »

The 2 APIs are completely different and there isn't any plans as of now to integrate them as a single api. They are both maintained by different peeps. At some future point when the python modeling API become more complete I think that this would be a good thing to disscuss but until then I don't think this will be the case. (unless someone else wants to take this one on :) .

Part of the reason here is that there are 2 interpreters and the idea was to maintain 2 separate API's one for each. However there shouldn't be any reason that we can't 'import' the modules from the other blender API into the interpreter at startup. I'm not sure why we don't do this. Maybe a good point for discussion.....

metaphorz
Posts: 21
Joined: Sun Nov 10, 2002 3:20 am

cross-use of Python modules

Post by metaphorz »

ascotan said:

"..However there shouldn't be any reason that we can't 'import' the modules from the other blender API into the interpreter at startup. I'm not sure why we don't do this. Maybe a good point for discussion.....


Yes, it is a good point for discussion. Let's begin with something
really simple like setting location while in the game engine using
the Blender module. I realize that GameLogic has its own methods
for setting position, but let's use this as an example: the question
becomes this: "can the Blender module methods write to the 3D
window?". Here are 2 observations:

(1) Using both GameLogic and Blender module methods and attributes
is possible in Blender, and does not cause any run-time Python
errors.

(2) Blender module methods do write to the 3D window and update
geometry in real-time when a game is not being played (i.e. when
the script is run via ALT-P). Any run of a script will demonstrate
this.

(3) When the game is being played, Blender module methods are
prohibited from writing to the 3D window until just after the
game is terminated with ESC, at which time, the methods
execute successfully.

I suppose my question is why (3) can't be easily turned into the
situation where the Blender module methods can update the
same variables that GameLogic is accessing - the same window
(3D) is used, and the same Blender geometry is accessed with
both modules (Blender and GameLogic).

Doing this would be a small step toward an eventual integration,
but it would simultaneously provide Game script writers and Blender
script writers with vastly improved functionality.

z3r0_d
Posts: 289
Joined: Wed Oct 16, 2002 2:38 am
Contact:

Post by z3r0_d »

Wasn't there a decision before to not allow the Blender module in the game engine because the standalone player would become blender's size by having to include all of blender's functionality?

the game engine tries to remain small probably with the intention of having a web plugin again [which shouldn't be bigger than a meg]

metaphorz
Posts: 21
Joined: Sun Nov 10, 2002 3:20 am

size is not an issue

Post by metaphorz »

Well, when we use the Blender game engine, we are not
using a web browser (plugin), and so size is not an issue.
If I want to use a web plugin, I would use X3D or VRML.
When scouring the web, most game engines are not web
compatible. My feeling is that the benefits of having
uniform Python access outweighs restrictions imposed
by trying to make the Game engine code small. I would
personally vote for more expressive and powerful Python
access.

Post Reply