[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Written by Eric Sunshine, [email protected].
Crystal Space is accessible from Python in two ways: (1) as a Crystal Space plugin module in which C++ code can call upon Python code, and in which Python code can call upon Crystal Space; (2) as a pure Python module named `cspace' which one can `import' from within Python programs. To use the first option, load the `cspython' plugin as you would load any other Crystal Space plugin, and interact with it via the SCF `iScript' interface (see section The iScript Interface). The second approach allows you to write Crystal Space applications entirely in Python, without any C++ coding.
Once Crystal Space is built and optionally installed, you can use the Python bindings. To do so, you need to make sure that Python can locate the appropriate Crystal Space resources. Follow these instructions:
${prefix}/share/crystalspace/bindings/python
where ${prefix} is the installation path (typically, `/usr/local'). If you did not install Crystal space, then `cspace.py' will be in the top-level build directory (this will be the `CS' directory if you configured and built in the `CS' directory).
${prefix}/share/crystalspace/bindings/python
If you did not install Crystal Space, then it will be in the top-level build directory.
There are a number of examples illustrating how to `import' the `cspace' module and utilize Crystal Space from within pure Python scripts. These scripts are installed at:
${prefix}/share/crystalspace/bindings/python
If you did not install Crystal Space, then you can find the scripts within the source tree at `CS/scripts/python'. In particular, the `tutorial#.py' scripts should be of interest since they mirror the first several C++ tutorial programs (see section Simple Tutorial 1: Basic Setup, World Creation).
You can also access Python from a C++ program by loading the `cspython' Crystal Space plugin module and interacting with it via the SCF `iScript' interface (see section The iScript Interface). The `pysimp' example program (`CS/apps/pysimp') illustrates how to do so. In addition to loading the `cspython' plugin, it loads and executes Python code from a sample script (which resides along with the other Python examples noted above).
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] |
This document was generated using texi2html 1.76.