BGE development

It’s been a while since I’ve written anything, so I thought it’s time for an update on what I’ve been working on.

At present I’m working towards building a mouse look actuator for the Blender game engine. Something easily tackled with a Python script, but it serves as a nice and easy introduction to Blender development. Also, the speed in which it takes to set up a logic brick mouse look is so much quicker than trying to remember where I placed the mouse look script I was using. So, it is useful for quickly prototyping ideas in the BGE.

There was some difficulty in deciding the best way to get the screen height/width and for setting/getting the mouse position. But in the end I made a few modifications to KX_Scene and the mouse manager to return what I needed. I’m still not sure if this is the right way to do it, but I can’t see any other way for an actuator to get access to this information. As a side effect of using the mouse manager for the mouse coordinates is that the actuator only actually works with a mouse sensor. Not sure if this is really a problem as I can’t see what other sensor type you’d use it with. I’ve thought about using the SDL library for getting the mouse position, but you can’t use it to centre the mouse again, nor can you get the screen height/width.

Anyway, almost everything is working fine. You can map the mouse’s X and Y motion to any axis of a game object for rotation, as well as the usual rotation capping, inverting and sensitivity control. Obviously, it runs faster than a Python solution. The picture below shows how little is involved in getting mouse look into a game.

There’s still a few issues with capping rotation. Large and wild jumps cause the object to flip around. Nothing major, you really have to move the mouse some to cause it. But I want to make sure there are no problems and I have some ideas for fixing it. After that I’ve got to play with local/world orientation and some code tidy up. Once it’s complete I’ll write part 3 of my creating an actuator series explaining how it’s all done.

Then the final step is to write the python wrappers for it so you can change the settings through scripts. Once that’s all complete I’ll submit a patch and get a build up on graphicall. With a bit of luck perhaps I can get it included in Blender!


~ by Jay on April 17, 2012.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: