Database access and Game Engine

Is it possible to use Python’s database access modules and the Game Engine? I would like to create an interactive 3d program for a product I am developing, where it would take a user’s input and hit the database and return to the plugin to change the object accordingly. Thanks.

rob

I have no idea but you can make a python server . Then have blender and the python server converse data with anonmous ftp access to a certain spot on your site and just upload/read the data file/s.

Its doesn’t even need tobe a python server you can make a php/asp/etc… form and just save that data. and blender read it. And by blender reading it I mean writing simple I/O python script in blender

It might be in your best intrest to try it yourself, make sure the python path is set correctly and the module is imported.

It should work inside of Blender and as a dynamic runtime - I haven’t tried it though. It doesn’t work inside the browser plugin because of the sandboxed environment if you are aiming at this. You don’t need to make a Python server - just use the DB libs of Python (if you just want to connect to a database server and run queries). You would need to set a correct Python path, you would need a complete Python installation for running it inside of Blender - and for a dynamic runtime you would need to give along the Python modules you’re using.

I’m not sure what you mean with changing the object. You could exchange meshes, change vertex colours or similiar things. Probably you couldn’t dynamically create objects or change their geometry that easy (but it’s possible - at least to change them). I’m not sure if you can exchange textures - perhaps someone else has tried it and can tell about his experiences.

The people who have much experience with using extern Python modules are saluk and blenderowl. You could go to #gameblender on irc.freenode.net and ask there, too. Probably they would be even in there.

It’s over my head but don’t databases ,mysql for example, have geometry based tables? Is that what you’re thinking of?

Sorry about checking back so late. You’ve set me down the right path. I’ll let you know where I get. It isn’t so much changing the geometry entirely as it is tweaking certain points locations through transforms. Thanks.

Rob

As far as the database part of it, you can do just about anything you can do in a normal python environment. The only places where you run into issues is with blocking/threading because of how blender runs code in between frames and doesn’t render the frame until all the code has finished. So database access should work fine.

When you look at the blender side of things it gets much trickier. You cannot duplicate objects or create new meshes, or signifigantly alter current meshes, at all, in realtime. Using the Blender.Object, Blender.Mesh etc modules, you can create new meshes or change current ones, adding vertices etc, but for the changes to be applied the scene must be restarted (could work with a scene actuator to apply changes). Although that is not ideal in most cases. Also, it won’t work in a runtime or a plugin.

What you can do in realtime, is change the properties of existing vertices in a mesh, add linked-mesh object copies from the hidden layer, or change the position/rotation of objects in the scene. Keep in mind that if you, say, add 3 balls from a hidden layer, and modify the mesh on one ball, it will do the same modifications on the other 2 balls, as they are all linked to the same mesh. You cannot add or delete vertices on a mesh, but you can change the vertex color, uv coordinates, and position.

Also, it does sound like you are trying to use the blender plugin, I’m not sure how well you can get this to work with database type stuff, but I’m pretty sure you can somehow code the website to handle the database and pass on the object creation etc. commands to the plugin. I’m not sure how this is done though.

Thank you for all the info. I would prefer to use straight Blender, and not the plugin. I may take your advice and do all the database stuff outside of Blender and just use the calculations based upon this to modify the mesh. I would just change the vertex positions, not add or subtract verts. My application is to update a 3d model of a boat based upon a forms input and the background calculations performed on that input. If I can’t somehow use Blender via Python, I am forced to hand code a java app or a c#/.NET application. I was hoping to leverage what could already be done in Blender. I now use it to import my designs for presentation and to output VRML for web viewing. I am scripting a Python program to parse my text files that contain the x,y,z points of the sections, that I would like to loft. I am researching how to make the amount of knot equal for each section without losing the section’s shape. I may be heading down a dead end, but it’s sure a good reason to play with Blender. Also, I would love to place a logo stating: “This site is Blender Powered.”

Regards,

Rob