20.09.2010
3D PyEngine for S60:
This small engine is written in python and uses only standart python modules (no need to install any additional modules). OpenGL is used to display 3D objects. All devices with more than ~30 mb free Ram should not have any problems to run simple graphics (over 5 textures with 512x512 pixel and over a few thousand triangles). For advanced 3D graphics devices wthout hardware acceleration will react with slowness. It works with almost any python version. Tested versions:
Current version v0.04 consists of 2 Libs:
This Engine has a few nice features:
Installation is quite simple. Just install python on your device and create a new folder called Lib in e:\Python\ (e:\ means card-slot). Copy both files (e_imp.py and e_core.py) into e:\Python\Lib\ and you are done.
If you want to use it just import e_imp.py in your script (from e_imp import *) and use it as any other python module. For aditional help just take a look at the tutorials.
All user relevant vars/functions/classes explained:
modules stores the count of imported modules.
total_modules stores the total count of modules that
should get imported.
Both values are good to check if the engine started right.
py_version contains the Python version in a list.
Useful to check under which Python runtime the script is running.
topw is 1 if TopWindow
got imported, is 2 if topwindow got imported, is 0 if import failed.
The value depends on the python version (1.4.x or smaller / 1.9.x or greater).
sen is 1 if sensor got imported,
0 if import failed.
Check if the phone has an accelerometer sensor.
sensor_on is 1 if sensor
got imported and started, 0 if start failed.
Check if the accelerometer sensor runs.(This var is also in the console)
touch_on is 1 if the device has a touchscreen,
0 if no touchscreen found.
Useful to check if the phone has a touch screen.
(This var will be soon in the console)
keyboard_on is 1 if keypress are recognized,
0 if not.
Check if the phone's keyboard can be used.(This var is also in the console)
objects stores the count of loaded models.
(This var is also in the console)
connection BT connection status,
connected as: 1(server),2(client),0(no connection)
Useful for connection dependent script
console_redraw_time (default value is 10)
after 10 frames the console gets updated
Can be changed to any value (integer) greater than 0.
running 1 if engine runs,
0 if right softkey got pressed.
Useful to check if the engine got shutdown by the user.
set_screen(mode,arg1,arg2,arg3,arg4,arg5,arg6) has 2 modes:
cleanupsensor() shutsdown the accelerometer sensor
This function function is finaly integerated into
the SensorConnection Class and is not longer available since e_core version 0.04.
start_bt_server(
service_name) starts a BT server side connection.
Var connection is now 1.
Same service_name
should be used in con_bt_client(
service_name).
con_bt_client(
service_name) connect to the BT server.
Var connection is now 2.
Same service_name
should be used in start_bt_server(
service_name).
bt_send_cmd(code)
sends python code to the server/client
All devices should be connected already
and code should be a unicode string containing python code.
bt_receive_cmd()
If there is incoming code from bt_send_cmd(
code) it gets executed.
Should be called in a loop eg. mainloop of the script.
May have bugs.
wlan_connect()
starts a wlan server, the accespoint you can select should be your wlan router or an ad-hoc accesspoint.
The script is blocked till a computer is connected. Your computer should connect to your phones IP.
receive_cmd()
should be called olny if a command comes from the computer, otherwise the script is blocked till
a command comes.
A connection must exist! I used a key to trigger this function after
i sent a command.
close_connection()
close the exsisting wlan connection.
A connection must exist!
set_exit()
has to be called in your script !.
Engine is shut down. Many functions do not work anymore! Check out the tutorial section how to use this function (temp_script.py).
set_status_txt(text)
Sets the first line in the console to the string you like.
text should be a unicode string
Same for set_status_txt2(text).
orientation()
Returns 0 if canvas x size is smaller than y size (Portrait mode if fullscreen).
Returns 1 if canvas x size is greater than y size (Landscape mode if fullscreen).
Returns None if glcanvas is None (set_exit()
got called).
can be used to find out in what mode the screen orientation is (might be portrait mode even if it returns 1 if canvas is not fullscreen !!!).
ret_running()
Returns the var running.
Removed since e_core version 0.04.
FogC(object)
create a new FogC class to have access to GL_FOG.
Example:
Keyboard(object)
Is used to check for keypress (same class as in the python reference book)
keyboard object is automaticly created and ready to use when
keyboard_on is 1.
Example:
SensorConnection(object)
Is used to check get accelerometer data
sense_conn object is automaticly created and ready to use when
sensor_on is 1.
Possible values go from -8 up to +8 while -4 to +4 are usual values if the phone is not shaken.
Example:
sense_conn = SensorConnection()
sensor_x = sense_conn.delta[0]
sensor_y = sense_conn.delta[1]
sensor_z = sense_conn.delta[2]
sense_conn.cleanup()
Cam(object)
Stores values for the camera
camera object is automaticly created
Example:
obj(object)
The most important class
creates,loads,handles 3D models.
Example: