2 registered members (TipmyPip, 1 invisible),
18,758
guests, and 8
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
python wrapper
#270067
06/05/09 20:24
06/05/09 20:24
|
Joined: May 2002
Posts: 7,441
ventilator
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2002
Posts: 7,441
|
when cleaning up the mess on my harddisk recently i came across my python wrapper which i started for a6 but never really finished. i played around with it a bit again and updated it to a7. is there anyone interested in something like that? i think there aren't many python users here? currently it wraps about 75% of the engine api so it still would need some work... here is an example: # python version of e_tutorial.cpp
from a7 import *
lesson = 3
###############################################################################
if lesson == 1:
e = Engine("earth.mdl -nwnd -nc")
while e.frame():
pass
e.close()
###############################################################################
if lesson == 2:
e = Engine("-nwnd -nc")
e.fps_max = 50
camera = e.camera
add_folder("C:\Program Files (x86)\GStudio7\samples")
level_load("small.hmp")
while e.frame():
camera.pan += -3 * e.key_force.x
camera.tilt += 3 * e.key_force.y
move = Vector()
move.x = 6 * (e.key_w - e.key_s)
move.y = 6 * (e.key_a - e.key_d)
camera.position += move.rotate(camera.orientation)
e.close()
###############################################################################
if lesson == 3:
def plop():
ball.playsound(pong, 100)
def kick():
speed = Vector(150, 0, 0)
speed = speed.rotate(camera.orientation)
speed.z = 75
ball.ph_addvelcentral(speed)
plop()
e = Engine("-nwnd -nc")
e.shadow_stencil = 4
e.sound_vol = 100
camera = e.camera
add_folder("C:\Program Files (x86)\GStudio7\samples")
pong = Sound("tap.wav")
splash = Panel()
splash.bmap = Bitmap("digital.pcx")
splash.scale_x = float(e.screen_size.x) / splash.bmap.width()
splash.scale_y = float(e.screen_size.y) / splash.bmap.height()
splash.flags |= VISIBLE
for i in range(3): e.frame()
level_load("small.hmp")
ticks = 0
while ticks < 16:
ticks += e.time_step
e.frame()
splash.remove()
Entity("blood_gsmall+6.tga", flags2=SKY|CUBE, layer=0)
ball = Entity("earth.mdl", (0, 0, 100), None)
ball.ph_settype(PH_RIGID, PH_SPHERE)
ball.ph_setmass(1, PH_SPHERE)
ball.ph_setfriction(90)
ball.ph_setelasticity(75, 100)
ball.ph_setdamping(30, 5)
ball.ph_addvelcentral((2, 2, 0))
ball.flags |= SHADOW|CAST
ball.event = plop
ball.emask |= ENABLE_FRICTION
ph_setgravity((0, 0, -500))
e.on_space = kick
speed = Vector()
angular_speed = Vector()
while e.frame():
force = Vector()
force.x = -5 * (e.key_force.x + e.mouse_force.x)
force.y = 5 * (e.key_force.y + e.mouse_force.y)
move = vec_accelerate(angular_speed, force, 0.8)
camera.orientation += move
force.x = 6 * (e.key_w - e.key_s)
force.y = 6 * (e.key_a - e.key_d)
force.z = 6 * (e.key_home - e.key_end)
move = vec_accelerate(speed, force, 0.5)
camera.position += move.rotate(camera.orientation)
e.close() with python it's also possible to do a scheduler: from a7_scheduler import *
@schedule
def rotate_entity():
while 1:
e.my.pan += 5 * e.time_step
yield(1) # wait 1 frame
@schedule
def move_camera():
camera = e.camera
speed = Vector()
angular_speed = Vector()
while 1:
force = Vector()
force.x = -5 * (e.key_force.x + e.mouse_force.x)
force.y = 5 * (e.key_force.y + e.mouse_force.y)
move = vec_accelerate(angular_speed, force, 0.8)
camera.orientation += move
force.x = 6 * (e.key_w - e.key_s)
force.y = 6 * (e.key_a - e.key_d)
force.z = 6 * (e.key_home - e.key_end)
move = vec_accelerate(speed, force, 0.5)
camera.position += move.rotate(camera.orientation)
yield(1) # wait 1 frame
@schedule
def main():
add_folder("C:\Program Files (x86)\GStudio7\samples")
e.video_mode = 8
yield(3) # wait 3 frames
level_load("small.hmp")
Entity("blood_gsmall+6.tga", flags2=SKY|CUBE, layer=0)
Entity("earth.mdl", (0, 0, 100), rotate_entity)
move_camera()
main()
scheduler() functions that use wait() need to be decorated with @schedule and wait() = yield() in python but otherwise it works just like in lite-c. 
|
|
|
Re: python wrapper
[Re: Pappenheimer]
#270108
06/06/09 10:33
06/06/09 10:33
|
Joined: May 2002
Posts: 7,441
ventilator
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2002
Posts: 7,441
|
i don't have an advanced ai example but here are some advantages of python: - automatic memory management
- powerful built-in dynamic data structures (lists, dictionaries, sets,...)
- powerful string handling
- the huge python standard library with modules for almost everything you could ever need (web access,...)
- no long compile times (you can even change the program while it is running.)
- object orientation (which means that you can subclass Entity() and create different entity types for example, you can use Vector() objects like v1 + (2 * (v2 * -v1)) * v2 instead of having to use the cumbersome vec_ commands, skills aren't necessary because you can just assign an unlimited number of arbitrary properties to entities,...)
disadvantages of python: - it is slower than C but in most of my tests it has been fast enough (one case that could be a bit problematic is particle callbacks. calling tenthousands of them per frame is a bit slow with python. such problems can be solved by moving the bottleneck to C though (which is quite easy with tools like cython). for example there could be some predefined particle callbacks in C (they always look very similar anyway) and python just controls their parameters.)
there are projects like google's unladen-swallow or pypy which aim to make python faster.
|
|
|
Re: python wrapper
[Re: Pappenheimer]
#270162
06/06/09 16:56
06/06/09 16:56
|
Joined: May 2002
Posts: 7,441
ventilator
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2002
Posts: 7,441
|
i don't think it would work with lite-c because the acknex.dll needs to be bound to the python.exe and as far as i know only the gamestudio editions can do that. <edit> it could be that it works with the lite-c editions too if you work directly in the lite-c directory. the acknex.dll security mechanism checks if some files are present in the same directory (like sed.exe and some others) and if it finds them it probably doesn't have to be bound to python.exe. </edit> originally my plan was to do the wrapper for gamestudio first (in order to learn how all of this wrapping stuff works) and later move it to ogre or irrlicht. an open source solution with gamestudio-like scripting would be nice. but it would be a lot of work which i have procrastinated so far. 
|
|
|
Re: python wrapper
[Re: ventilator]
#270183
06/06/09 18:01
06/06/09 18:01
|
Joined: Sep 2003
Posts: 5,900 Bielefeld, Germany
Pappenheimer
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
|
an open source solution with gamestudio-like scripting would be nice. but it would be a lot of work which i have procrastinated so far. I don't understand this last sentence. Do you mean an own engine similar to acknex? Or, do you mean a dll or whatever which calls the acknex engine and its functions, but is independent to the achnex.dll?
|
|
|
Re: python wrapper
[Re: Pappenheimer]
#270190
06/06/09 18:37
06/06/09 18:37
|
Joined: May 2002
Posts: 7,441
ventilator
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2002
Posts: 7,441
|
i mean something totally independent of acknex.dll. my plan was to use the same (or similar) wrapper with ogre or irrlicht. it would require another layer inbetween which offers an interface similar to acknex.dll. probably it will never happen though since it would be a lot of work.  several months probably. but if it worked out there would be a free gamestudio alternative (together with the upcoming blender 2.5 as an user friendly editor). Would your proposed wrapper work with Commercial A7 ? yes, it would work with all gamestudio editions. i am not sure about the lite-c editions though. someone would have to try that.
|
|
|
Re: python wrapper
[Re: ventilator]
#271364
06/12/09 15:53
06/12/09 15:53
|
Joined: May 2002
Posts: 7,441
ventilator
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2002
Posts: 7,441
|
here is an alpha version: pya7_alpha.exe ~14mb i have quickly converted knights on wheels to python as an example but it's all still a bit unpolished. it's compiled for python 2.6 and you need the engine version 7.77 or later. you have to edit the bat files and use them to create a dll which is bound to python.exe or pythonw.exe (depending on what you or your IDE use).
|
|
|
Re: python wrapper
[Re: Damocles_]
#271422
06/13/09 02:17
06/13/09 02:17
|
Joined: May 2002
Posts: 7,441
ventilator
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2002
Posts: 7,441
|
Which editor do you recommend to code with python? IDLE (which comes with python) isn't that bad but it has the problem that by default it starts scripts in the same process itself runs in. this means that it crashes if the script causes an engine crash (like SED in debug mode :)). as far as i know this behaviour can be changed somehow but i forgot how so i use drpython at the moment. there are many other powerful editors for python but i like it simple. since python code depends on proper indentation and mixed use of tabs and spaces is not good, it's important that the used editor can be set to either use tabs or spaces and doesn't make it too easy to mix both by mistake. Ventilator: Do you think its possible to also make a wrapper to use acknex with Java? (Just from the concept point) it for sure is possible. most languages make it possible to wrap c-libraries. writing wrappers by hand often is a lot of work though. i am no java expert and don't know what other tools exist but you could look into SWIG for example.
|
|
|
Re: python wrapper
[Re: Pappenheimer]
#271699
06/14/09 14:39
06/14/09 14:39
|
Joined: May 2002
Posts: 7,441
ventilator
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2002
Posts: 7,441
|
i have compiled the wrapper for python 2.6 so it won't work with python 2.5. drpython needs the wxpython gui toolkit. http://www.wxpython.org/ (download it for python 2.6) IDLE can be started by right clicking on a py file in the explorer and then "edit with IDLE". it also is in the python folder in the start menu.
|
|
|
Re: python wrapper
[Re: ventilator]
#271709
06/14/09 16:07
06/14/09 16:07
|
Joined: May 2002
Posts: 7,441
ventilator
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2002
Posts: 7,441
|
here is knights_on_wheels.py again. i have fixed some bugs i introduced when translating it from lite-c. there also is a simple ai now.  on the city track it drives pretty well but on the canyon track it sometimes tips over after jumps.
# f1 = restart level1
# f2 = restart level2
# cu cr cd cl = control vehicle 1
# page down = reset vehicle 1
# delete = tractor beam vehicle 1
# w d s a = control vehicle 2
# e = reset vehicle 2
# q = tractor beam vehicle 2
from a7_scheduler import *
import default
import sys, os.path, random
# add_folder() works relative to the python.exe but i want it relative to the script
script = sys.argv[0]
folder = os.path.dirname(script)
folder = os.path.join(folder, "knights_on_wheels")
resource = os.path.join(folder, "resource.wrs")
add_folder(folder)
add_resource(resource)
add_folder("C:/Program Files (x86)/GStudio7/projects/carlevel")
camera_distance = 128
camera_tilt = 28
suspension_min = 6
suspension_max = 12
beam_length = 480
beam_force = 50000
vehicle_mass = 16
spring = 22750
damper = 425
motor_speed = 100
motor_power = 100
motor_brake = 180
steering_power = 100
max_laps = 3
energy_start = 100
energy_lap = 50
sd_distance = sd1_distance = 320
sd_threshold = sd1_threshold = 640
sd2_distance = 200
sd2_threshold = 416
second_camera = View()
second_camera.flags |= SHOW
vehicles = []
tires = []
tire_constraints = []
keys = (72, 77, 80, 75, 17, 32, 31, 30, 83, 16)
suspensions = ("frontleft", "frontright", "rearleft", "rearright")
needle = Bitmap("zeiger.tga")
tachometer = Bitmap("tachometer.tga")
huds = []
def set_physics(entity, hull, mhull, group, mass, friction, bounciness, min_speed, linear_damping, angular_damping):
entity.ph_settype(PH_RIGID, hull)
entity.ph_setmass(mass, mhull)
entity.ph_setfriction(friction)
entity.ph_setelasticity(bounciness, min_speed)
entity.ph_setdamping(linear_damping, angular_damping)
entity.ph_setgroup(group)
def reset_vehicle(vehicle):
print "reset", vehicle.name, "| driveline angle:", vehicle.nskills2[1]
for e in vehicle.tires + [vehicle]:
e.ph_enable(0)
v = (e.position - vehicle.position).rotateback(vehicle.orientation)
v = v.rotate((vehicle.nskills2[1], 0, 0)) + vehicle.nposition2
v.z += 64
e.position = v
if e is not vehicle and e.index in (1, 3, 5, 7): # tires of right side
o = 180
else:
o = 0
e.orientation = (vehicle.nskills2[1] - o, 0, 0)
e.ph_clearvelocity()
e.ph_enable(1)
def reset_vehicle_1():
reset_vehicle(vehicles[0])
e.on_pgdn = reset_vehicle_1
def reset_vehicle_2():
reset_vehicle(vehicles[1])
e.on_e = reset_vehicle_2
def toggle_vehicle_1_ai():
vehicles[0].ai = 1 - vehicles[0].ai
e.on_home = toggle_vehicle_1_ai
def toggle_vehicle_2_ai():
vehicles[1].ai = 1 - vehicles[1].ai
e.on_2 = toggle_vehicle_2_ai
#-------------------------------------------------------------------------------
def ang_diff(a1, a2):
a1 = ang(a1)
a2 = ang(a2)
if abs(a1 - a2) > 180: a2 += 360 * sign(a1 - a2)
return a1 - a2
@schedule
def vehicle():
my = e.my
my.index = len(vehicles)
vehicles.append(my)
print "vehicle:", my.name, my.index
my.winner = False
my.ai = False
energy = energy_start
lap = 0
elapsed_time = 0
speed = 0
last_node = 0
distance = 0
message_time = 0
if my.index == 0:
camera = second_camera
group = 2
o = 0
else:
camera = e.camera
group = 4
o = 4
set_physics(my, PH_BOX, PH_BOX, group, vehicle_mass, 40, 25, 10, 20, 20)
my.path_set("driveline")
# count nodes
nodes = 1
while my.path_getnode(nodes):
nodes += 1
print "nodes:", nodes
yield(1) # wait for initialization of all entities
front_left = tire_constraints[0+o]
front_right = tire_constraints[1+o]
rear_left = tire_constraints[2+o]
rear_right = tire_constraints[3+o]
my.tires = tires[0+o:4+o]
opponent = vehicles[1 - my.index]
global huds
if len(huds) == 2: # delete previously created panels after loading a level
for p in huds: p.remove()
huds = []
hud = Panel()
hud.pos_x = e.screen_size.x - 160 - e.screen_size.x / 2 * my.index
hud.pos_y = 10
hud.bmap = tachometer
hud.setneedle(0, 76, 76, needle, 70, 70, 130, 200, 0, lambda: speed)
hud.flags |= SHOW
huds.append(hud)
while 1:
# shortcut detection
if lap < max_laps:
elapsed_time += e.time_step / 16
node = my.path_scan(my.position, my.orientation, (360, 0, sd_distance))
if node:
my.nposition1, my.nskills1 = my.path_getnode(node)
my.nposition2, my.nskills2 = my.path_getnode(node * (last_node == 0) + last_node)
# crossed finish line
if my.nskills1[2] == 1 and my.nskills2[2] == 2:
lap += 1
energy = min(energy + energy_lap, 100)
if lap == max_laps:
if opponent.winner == False:
my.winner = True
# crossed finish line in reverse or shortcut
if (my.nskills1[2] == 2 and my.nskills2[2] == 1)\
or (distance != 0 and distance < (my.nskills1[0] - my.nskills2[0] - sd_threshold)):
message_time = elapsed_time + 3
reset_vehicle(my)
else:
last_node = node
distance = 0
else: # outside of the track
d = my.position.dist(last_position)
if d > 0.1: distance += d
last_position = my.position
# hud
message = ""
if my.winner: message = "winner!"
elif message_time > elapsed_time: message = "invalid shortcut!"
t = (my.index + 1,
elapsed_time / 60,
elapsed_time % 60,
fraction(elapsed_time) * 100,
speed * 1.2,
clamp(lap + 1, 1, max_laps),
energy,
message)
hud_string = "player %d\ntime: %02d:%02d:%02d\nspeed: %dkm/h\nlap: %d\nenergy: %d%%\n\n%s" % t
hud_string_x = e.screen_size.x / 2 + 20 - e.screen_size.x / 2 * my.index
draw_text(hud_string, hud_string_x, 20, (0,0,0))
hud.pos_x = e.screen_size.x - 160 - e.screen_size.x / 2 * my.index
# controls
if my.ai:
# very simple and stupid ai
key_up = key_right = key_down = key_left = 0
n = my.path_getnode(cycle(last_node + 3, 1, nodes))
if n:
p, s = n
draw_point3d(p, (0,255,0), 100, 20)
a = (p - my.position).to_angle().pan
d = ang_diff(my.pan, a)
key_right = clamp(d * 0.01, -1, 1)
else:
reset_vehicle(my)
n = my.path_getnode(cycle(last_node + 9, 1, nodes))
if n:
p, s = n
draw_point3d(p, (0,0,255), 100, 20)
a = s[1]
d = abs(ang_diff(my.pan, a))
target_speed = max(20, 100 - d)
if speed < target_speed:
key_up = 1
if speed - 40 > target_speed:
key_down = 1
c_trace((my.x, my.y, my.z + 100), (my.x, my.y, my.z - 100), IGNORE_ME)
if e.trace_hit:
draw_line3d(e.target, None, 100)
draw_line3d(e.target + e.normal * 100, (0,0,255), 100)
draw_line3d(e.target + e.normal * 100, (0,0,255), 100)
dot = e.normal * Vector(0, 0, 1).rotate(my.orientation)
if dot < 0.95: # brake to prevent tipping over
key_up = 0
key_down = 1
if dot < 0: # tipping over couldn't be prevented
reset_vehicle(my)
else:
# manual control
key_up = key_pressed(keys[0 + 4 * my.index])
key_right = key_pressed(keys[1 + 4 * my.index])
key_down = key_pressed(keys[2 + 4 * my.index])
key_left = key_pressed(keys[3 + 4 * my.index])
key_tractor = key_pressed(keys[8 + my.index])
motor = Vector()
motor.x = motor_speed * key_up * (not key_down)
motor.y = motor_power * key_up * (not key_down) + motor_brake * key_down
rear_left.setmotor(nullvector, motor, nullvector)
rear_right.setmotor(nullvector, motor, nullvector)
steering = Vector()
steering.y = steering_power
p1 = front_left.getposition()
steering.x = (30 * (key_right - key_left)) - p1.x * min(e.time_step, 1)
front_left.setmotor(steering, motor, nullvector)
p2 = front_right.getposition()
steering.x = (30 * (key_right - key_left)) - p2.x * min(e.time_step, 1)
front_right.setmotor(steering, motor, nullvector)
# suspension
my.animate("steering", clamp((p1.x + p2.x) / 2 * (100 / 60.0) + 50, 0, 100), 0)
# camera
if not (default.def_camera and my.index == 1):
offset = Vector(my.pan, -camera_tilt, 0).for_angle() * -camera_distance
camera.position += ((my.position + offset) - camera.position) * min(0.4 * e.time_step, 1)
if abs(my.pan - camera.pan) > 180: # always take the shorter way around
camera.pan += 360 * sign(my.pan - camera.pan)
camera.pan += (my.pan - camera.pan) * min(0.4 * e.time_step, 1)
camera.tilt = -camera_tilt * 0.5
# tractor beam
if key_tractor and energy > 0:
energy = max(energy - e.time_step, 0)
p1 = my.vec_for_vertex(1646)
p2 = p1 + my.orientation.for_angle() * beam_length
c_trace(p1, p2, IGNORE_ME|IGNORE_FLAG2)
if e.trace_hit:
p2 = e.target
if e.you is opponent:
e.you.ph_addforceglobal(-(my.orientation.for_angle() * beam_force), p2)
for i in range(0, int(p1.dist(p2)), 2):
p1 += my.orientation.for_angle() * 2 + Vector(random.random()*0.8-0.4, random.random()*0.8-0.4, random.random()*0.8-0.4)
draw_point3d(p1, (255*(my.index==0), 0, 255*(my.index==1)), 100, 2)
# get speed
v = my.ph_getvelocity(nullvector)
speed = (v.length() / 32) * 60 * 60 / 1000.0
yield(1)
#-------------------------------------------------------------------------------
@schedule
def tire():
my = e.my
my.index = len(tires)
tires.append(my)
print "tire:", my.name, my.index
if my.index < 4:
group = 2
vehicle = vehicles[0]
else:
group = 4
vehicle = vehicles[1]
set_physics(my, PH_SPHERE, PH_SPHERE, group, 30, 80, 50, 10, 20, 20)
if my.index in (0, 1, 4, 5): # front tires
steering_limit_l = -30
steering_limit_r = 30
else:
steering_limit_l = 0
steering_limit_r = 0
c = Constraint(PH_WHEEL, vehicle, my)
c.setparams(my.position, (0, 0, 1), (1, 0, 0), (steering_limit_l, steering_limit_r, 0), nullvector, (spring, damper, 0))
tire_constraints.append(c)
while 1:
# suspension
z = (my.position - vehicle.position).rotateback(vehicle.orientation).z
s = (100.0 / (suspension_max - suspension_min)) * (z - suspension_min) - 30
vehicle.animate(suspensions[my.index % 4], clamp(s, 0, 100), ANM_ADD)
yield(1)
#-------------------------------------------------------------------------------
@schedule
def water():
while 1:
e.my.v += 0.8 * e.time_step
yield(1)
#-------------------------------------------------------------------------------
@schedule
def main():
print "main!"
e.fps_max = 120
e.video_mode = 8
e.video_screen = 2
e.preload_mode = 3
e.time_smooth = 0.9
e.fog_color = 1
e.camera.fog_end = second_camera.fog_end = 75000
global sd_distance, sd_threshold, vehicles, tires, tire_constraints
vehicles = []
tires = []
tire_constraints = []
if not e.key_f2:
sd_distance = sd1_distance
sd_threshold = sd1_threshold
level_load("canyon.wmb", globals()) # pass global namespace so that the entity actions get found
else:
sd_distance = sd2_distance
sd_threshold = sd2_threshold
level_load("city.wmb", globals()) # pass global namespace so that the entity actions get found
e.camera.x = e.camera.y = e.camera.tilt = second_camera.x = second_camera.y = second_camera.tilt = 0
e.camera.pan = e.camera.z = second_camera.pan = second_camera.z = 90
e.sky_cube_level.material = e.mtl_unlit
e.on_f1 = e.on_f2 = main
ph_setgravity((0, 0, -320 * 1.4))
ph_setcorrections(25000, 0.05)
while e.key_f1 or e.key_f2: yield(1)
while not (e.key_f1 or e.key_f2):
e.camera.size_x = second_camera.size_x = second_camera.pos_x = e.screen_size.x / 2
yield(1)
main()
scheduler()
|
|
|
Re: python wrapper
[Re: ventilator]
#276085
07/03/09 11:24
07/03/09 11:24
|
Joined: Sep 2003
Posts: 5,900 Bielefeld, Germany
Pappenheimer
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
|
Thanks for the links, but they are still not basic enough, because even the editor seems to work different to what I know from Lite-C or that what I've seen of C++. What do I have to do, when I get a window called Python Shell with this contend?
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
****************************************************************
Personal firewall software may warn about the connection IDLE
makes to its subprocess using this computer's internal loopback
interface. This connection is not visible on any external
interface and no data is sent to or received from the Internet.
****************************************************************
IDLE 1.2.2
>>>
|
|
|
Re: python wrapper
[Re: Pappenheimer]
#276136
07/03/09 13:38
07/03/09 13:38
|
Joined: Sep 2003
Posts: 5,900 Bielefeld, Germany
Pappenheimer
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
|
I'm quite dumb, i know! :P But now, I got a step further. Although, I don't know what I missed this time. Which dll is it missing?
Traceback (most recent call last):
File "C:/Programme/GStudio7/knightonwheels.py", line 10, in <module>
from a7_scheduler import *
File "C:/Programme/GStudio7\a7_scheduler.py", line 1, in <module>
from a7 import level_load as _level_load
ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden.
>>>
Last edited by Pappenheimer; 07/03/09 14:20.
|
|
|
Re: python wrapper
[Re: ventilator]
#276152
07/03/09 16:04
07/03/09 16:04
|
Joined: Sep 2003
Posts: 5,900 Bielefeld, Germany
Pappenheimer
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
|
 Got it!  Installed Python 2.6.2, extracted the pya7_alpha.exe into the python26 folder and copied the acknex.dll into the same folder. Started IDLE(Python GUI) from the start menu, clicked File --> Open.., opened the knight_on_wheels.py in the python26 folder and hit F5! It works!
|
|
|
Re: python wrapper
[Re: ventilator]
#276743
07/06/09 09:13
07/06/09 09:13
|
Joined: Jul 2009
Posts: 40
enrike
Newbie
|
Newbie
Joined: Jul 2009
Posts: 40
|
this python wrapper sounds really interesting. i have worked few years with python so i could benefit from this because i just started using game studio. Still i find C lite very easy but Python is more powerful because the standard library and hundreds of libraries and modules freely available (although is probably slower).
So far i cannot make it to work, i have python2.6 installed, then uncompressed pyA7 to my hardrive. Then edited the .bat files like this and run it "C:\Program Files\GStudio7\wed.exe" -p c:\python26\python.exe copy c:\python26\acknex.dll C:\Users\Administrator\Desktop\pyA7
at this point i try to run knights_on_wheels.py and I get this DLL error :
IDLE 2.6.2 ==== No Subprocess ==== >>> Traceback (most recent call last): File "C:\Users\Administrator\Desktop\pyA7\knights_on_wheels.py", line 12, in <module> from a7_scheduler import * File "C:\Users\Administrator\Desktop\pyA7\a7_scheduler.py", line 3, in <module> from a7 import level_load as _level_load ImportError: DLL load failed: The specified procedure could not be found.
Could this be because my A7 engine is old? I get SED > Help > About and there it says Version : 7.02.4
I am not sure if this is the right way to run it.
acknex.dll is in the same directory I uncompressed pya7_alpha.exe
I also tried to copy acknex.dll to python2.6 together with a7_scheduler.py and a7.pyd and get the same error.
it would be good to have a step by step explanation of how to set it up. maybe i have not found it?
Last edited by enrike; 07/06/09 09:19.
|
|
|
Re: python wrapper
[Re: ventilator]
#276786
07/06/09 12:27
07/06/09 12:27
|
Joined: Jul 2009
Posts: 40
enrike
Newbie
|
Newbie
Joined: Jul 2009
Posts: 40
|
i downloaded the demo version of the latest A7.77 and now it seems to find the dll, but i fails to run the examples because there are few assets missing, bitmaps like zeiger.tga, ball.pcx or tap.wav. It would be nice to have all included in the package. thanks anyway.
Traceback (most recent call last): File "D:\pyA7\example1.py", line 10, in <module> p_bitmap = Bitmap("ball.pcx") File "a7_types.pyx", line 281, in a7.Bitmap.__cinit__ (a7.cpp:6804) IOError: bitmap file 'ball.pcx' couldn't be opened!
Last edited by enrike; 07/06/09 12:29.
|
|
|
Re: python wrapper
[Re: enrike]
#276787
07/06/09 12:31
07/06/09 12:31
|
Joined: Jul 2009
Posts: 40
enrike
Newbie
|
Newbie
Joined: Jul 2009
Posts: 40
|
ah ok! just realised is looking for them in the 3d game studio folder! i thought they where local files you produced for the examples. sorry. Now it is working thanks!
Last edited by enrike; 07/06/09 12:44.
|
|
|
Re: python wrapper
[Re: enrike]
#276788
07/06/09 12:32
07/06/09 12:32
|
Joined: May 2002
Posts: 7,441
ventilator
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2002
Posts: 7,441
|
there shouldn't be anything missing. i use some assets from the gamestudio folder. maybe you have to adapt some paths like this one: add_folder("C:/Program Files (x86)/GStudio7/projects/carlevel") ...and i think the current version of the wrapper lacks the ang() function. if you need it just define it yourself until i upload the next version.
def ang(x):
return cycle(x, -180, 180)
|
|
|
Re: python wrapper
[Re: enrike]
#276993
07/07/09 10:41
07/07/09 10:41
|
Joined: May 2002
Posts: 7,441
ventilator
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2002
Posts: 7,441
|
they are there but they are methods of the entity class. entity.animate() entity.blend() what's missing is the multiplayer commands and some other stuff like that where i don't have an idea yet how to best wrap it for python. i could upload epydoc api documentation but i didn't really work on it yet. at the moment it's an auto generated mess and i am not sure if it would be more confusing than helpful. 
|
|
|
Re: python wrapper
[Re: enrike]
#277712
07/10/09 10:31
07/10/09 10:31
|
Joined: Jul 2009
Posts: 40
enrike
Newbie
|
Newbie
Joined: Jul 2009
Posts: 40
|
i have been playing around for couple of hours today (after going though a nightame of C-lite problems  and so far looks very nice how this Python wrapper works. At first it took me some time to find out how to do few things but using dir() and help(), and checking the scheduler.py code I found the solutions. Do you have plans to release it? and which license would it have? i can see now that it prints "pya7 alpha" at the bottom, so i assume you might want to sell licenses?
Last edited by enrike; 07/10/09 10:31.
|
|
|
Re: python wrapper
[Re: enrike]
#277763
07/10/09 14:36
07/10/09 14:36
|
Joined: May 2002
Posts: 7,441
ventilator
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2002
Posts: 7,441
|
i wouldn't really rely on it for an important project. it's too early. the wrapper already works nicely but there still are some areas that aren't very tested (like the material system) and some stuff i still have to think about (like game_save()/game_load() - i think saving the script state could probably be done with pickling somehow). i don't know how long it will take me. it would be helpful if more people played around with it and gave feedback about any problems but unfortunately there aren't many python users here.  ... i also prefer python over lite-c in most cases. lite-c isn't that bad but often i find that c forces you to work on a too low level and the debugging features are a bit lacking. debugging can be very annoying with lite-c. there isn't even a stack trace. ... by the way, the wrapper is written in cython. it kind of is a python to c compiler. so you wouldn't have to directly work with c source code but you still need good c knowledge for writing a wrapper. you need to know how pointers and so on work.
|
|
|
Re: python wrapper
[Re: ventilator]
#281398
07/27/09 04:19
07/27/09 04:19
|
Joined: Aug 2005
Posts: 186 Beneath the Surface
alpha12
Member
|
Member
Joined: Aug 2005
Posts: 186
Beneath the Surface
|
This is how to make your games distributable without making your client installing python runtime. Compiling to executable :1.Add python dir "C:\Python26" into your "PATH" environment variables. 2. Download & install py2exe : http://sourceforge.net/projects/py2exe/files/py2exe/0.6.9/py2exe-0.6.9.win32-py2.6.exe/download3. In your working directory : create setup.py with this following code inside
from distutils.core import setup
import py2exe
setup(console=['your_main_python_script.py'])
4.Open cmd go to your working dir and run this command "python setup.py install" 5.And run this command "python setup.py py2exe" 6.Don't forget to add required resource files into dist folder! your distributable exe should be in working_dir\dist have phun! @ventilator GREAT WORK!!hope you gonna finish this wrapper..anyway i test this with 64 bit python26 runtime but cann't run :(,would add compatibility for python 64 bit?
|
|
|
Re: python wrapper
[Re: alpha12]
#310658
02/16/10 11:40
02/16/10 11:40
|
Joined: Jul 2007
Posts: 424 EUROPE
maslone1
Senior Member
|
Senior Member
Joined: Jul 2007
Posts: 424
EUROPE
|
Hi ventilator!
Nochmals danke für den wrapper!
Frage: wo gibts tutorials wie mann wrapper schreibt? Hab mich noch nie über das thema wrapper näher beschäftigt.... (Bin grad dabei python zu lernen und um das wissen in blender nutzen zu können)
A8c, Blender, FlStudio, Unity3d
|
|
|
Re: python wrapper
[Re: ventilator]
#310663
02/16/10 12:19
02/16/10 12:19
|
Joined: Jul 2007
Posts: 424 EUROPE
maslone1
Senior Member
|
Senior Member
Joined: Jul 2007
Posts: 424
EUROPE
|
Danke für die guten tips. Das Cython hab ich mir schon kurz angesehen. Du hast da mein interesse geweckt. Du hast geschrieben, dass dein wrapper noch nicht fertig ist. Ich werde mal python (fertig) lernen und mich dann mal daran versuchen einen wrapper zu schreiben. Gestern hab ich erstmals mit phyton versuche gestartet. Man muss sich etwas an die schreibweise gewöhnen, aber es ist wirklich eine einfache und überschaubare sprache.
Hast du dich schon mal an der ogre-python versucht? Ich habs gestern nur vorab runtergeladen um später versuche zu starten....
Last edited by maslone1; 02/16/10 12:21.
A8c, Blender, FlStudio, Unity3d
|
|
|
Re: python wrapper
[Re: ventilator]
#311093
02/18/10 15:59
02/18/10 15:59
|
Joined: Jul 2007
Posts: 424 EUROPE
maslone1
Senior Member
|
Senior Member
Joined: Jul 2007
Posts: 424
EUROPE
|
Stimmt, interessant wäre es wirklich. Auch interessant ist die blender gameengine. Mit blender hat man alles in einem und python als "skriptsprache". Ne tolle kombination. Ich freu mich schon wieder auf etwas freizeit um weiter python lernen zu können! 
A8c, Blender, FlStudio, Unity3d
|
|
|
Re: python wrapper
[Re: maslone1]
#311175
02/18/10 18:55
02/18/10 18:55
|
Joined: Jul 2007
Posts: 424 EUROPE
maslone1
Senior Member
|
Senior Member
Joined: Jul 2007
Posts: 424
EUROPE
|
hi ventilator!
Ich habe nun deinen wrapper probiert.
Bei mir erscheint nun ein völlig neuer fehler beim start-up-fenster, welcher wie folgt aussieht:
-nc: Unsupported feature - any key to abort
ich habe version 7.82.3 und python 2.6.2 sowie idle installiert. das starup fenster öffnet sich und produziert lediglich den beschriebenen fehler.....?
Einzig funktioniert e-tutorial, wobei auch hier etwas nicht 100% akzeptiert wird, aber das programm an sich läuft....
Woran kann das liegen?
Last edited by maslone1; 02/18/10 18:58.
A8c, Blender, FlStudio, Unity3d
|
|
|
Re: python wrapper
[Re: ventilator]
#311211
02/18/10 21:09
02/18/10 21:09
|
Joined: Jul 2007
Posts: 424 EUROPE
maslone1
Senior Member
|
Senior Member
Joined: Jul 2007
Posts: 424
EUROPE
|
gut, hatte ich nun auch inzwischen gemacht  nun ist der fehler weg.... aber nun schreibt das star-up-window "pythonw.exe damaged"..... ich weiß ich bin ein naturtalent  e_tutorial.py funktioniert weiterhin einwandfrei..... seltsam......
A8c, Blender, FlStudio, Unity3d
|
|
|
Re: python wrapper
[Re: maslone1]
#311224
02/18/10 22:32
02/18/10 22:32
|
Joined: May 2002
Posts: 7,441
ventilator
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2002
Posts: 7,441
|
hm... die engine dll muss ja immer an die ausführende exe gebunden werden und es gibt zwei verschiedene python exes. python.exe ist mit konsole. pythonw.exe ist ohne konsole. vielleicht führst du die beispiele unterschiedlich aus und die engine dll ist dann nicht an die richtige version gebunden? Auch interessant ist die blender gameengine. Mit blender hat man alles in einem und python als "skriptsprache". Ne tolle kombination. http://code.google.com/p/gamekit/interessant ist auch gamekit. ist noch in entwicklung aber der plan ist glaube ich kompatibilität mit der blender game engine. ogre3d/irrlicht wird zum rendern verwendet und in zukunft wird gamekit vielleicht sogar die blender engine ablösen.
|
|
|
Re: python wrapper
[Re: ventilator]
#311254
02/19/10 06:07
02/19/10 06:07
|
Joined: Jul 2007
Posts: 424 EUROPE
maslone1
Senior Member
|
Senior Member
Joined: Jul 2007
Posts: 424
EUROPE
|
..... nein.... ich führe imme mit idle + F5 aus. Wenn ich direkt mit doppelklick starten möchte öffnet sich kurz das start-upfenster und schliesst sich sofort wieder ohne fehlermeldung......
Ich werd mal versuchen mein eigenes kurzes programm zu schreiben, um zu sehen ob auch dann die selben fehlermeldungen auftauchen.
Danke für den link - ne tolle sache!!!
Und was mit ganz besonders gut gefällt -> plattformunabhängig
Da hat man mit gamestudio das nachsehen (wieder mal)
A8c, Blender, FlStudio, Unity3d
|
|
|
Re: python wrapper
[Re: maslone1]
#311515
02/20/10 08:17
02/20/10 08:17
|
Joined: Jul 2007
Posts: 424 EUROPE
maslone1
Senior Member
|
Senior Member
Joined: Jul 2007
Posts: 424
EUROPE
|
hey ventilator! Nutzt du eigentlich eclipse inkl. pydev-plugin für das programmieren mit python? Ich habe es mir installiert und muss sagen, dass es eine sehr gute entwicklungsumgebung ist. Hier ein guter link, in dem ein paar 2d sowie 3d engines für python angeführt sind: http://codeboje.de/2d-and-3d-game-and-rendering-engines-python/
Last edited by maslone1; 02/20/10 10:09.
A8c, Blender, FlStudio, Unity3d
|
|
|
Re: python wrapper
[Re: maslone1]
#311559
02/20/10 16:07
02/20/10 16:07
|
Joined: May 2002
Posts: 7,441
ventilator
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2002
Posts: 7,441
|
bisher habe ich nicht viel mehr gebraucht als einen text editor mit syntax highlighting (ich mag es gerne einfach), aber wenn ich das nächste mal an einem größeren projekt arbeite, werde ich mir eclipse mal ansehen. panda3d ist glaube ich ganz nett, verwendet aber leider ODE als physikengine.  soya3d finde ich interessant, weil es eine in python geschriebene engine ist. der performancekritische kern ist in cython implementiert. und python-ogre ist auch super, weil da nicht nur ogre gewrappt ist sondern auch viele andere libraries. da ließe sich glaube ich ziemlich einfach eine nette game engine zusammenbauen.
|
|
|
Re: python wrapper
[Re: ventilator]
#405074
07/22/12 23:19
07/22/12 23:19
|
Joined: Sep 2007
Posts: 101 Luxembourg
krial057
Member
|
Member
Joined: Sep 2007
Posts: 101
Luxembourg
|
Hey, first of all sorry for digging up such an old thread I really like your work and everything works fine. I am currently working on a project to implement 3dgs in an IDE. That IDE uses python as plugin language. I have no ideas on how to make dll's nor how to bind them to python. So I wrote a server, only for debugging and communicated with it over sockets. But that is pretty tricky. Then I found this wrapper and it would fit perfect for my needs. However, the functions that i need are not yet implemented in your wrapper :'( These are the functions I would need the most important: - engine_debugposition
- engine_debugbreakpoint
- engine_debugstep
And then perhaps the functions for watching the variables Finally, I wanted to ask if you would be so kind to add these functions, or even publish the source  That would be really cool  regards Alain [EDIT]Just tried out to write my own wrapper. I managed to create a pyd and to wrap the engine_open function. However, whenever I try to call engine_fame, the engine and python crash. Here is the c++ code:
void engineOpen(PyObject *settings)
{
engine_open(PyString_AsString(settings));
}
long engineFrame()
{
return engine_frame();
}
void engineClose()
{
engine_close();
}
BOOST_PYTHON_MODULE(gs_ext)
{
using namespace boost::python;
def("engine_open", engineOpen);
def("engine_frame", engineFrame);
def("engine_close", engineClose);
}
Last edited by krial057; 07/24/12 16:46.
|
|
|
|