Planet Blender

v2-beta4 'Turning Pages'

... where Blenderheads live. Aggregate of blogs by Blenderheads
  • Blender vehicle physics tutorial
    mike's digital anthology - 2010-04-17 21:14:11

    A long time ago I toyed with the idea of making an entire game by myself. Being a driving game, I spent a long time with the basics stuff like vehicle physics to make sure the driving part is stable, bug-free, and most importantly, fun.

    I never finished it. But ever since I posted the above video, I have been getting a lot of inquiries as to how I did the vehicle physics system in Blender. So here is a quick guide followed by the sample file.

    The key to stable driving dynamics is to use the built-in PhysicsConstraints module within Blender’s game engine. PhysicsConstraints is a python wrapper for the Bullet physics engine. No any homemade setup I’ve seen is as good as what’s already provided by Bullet Physics. So we’ll use that.  Because there isn’t a graphical interface for setting up the vehicle physics yet in Blender, we need to write a few lines of Python script.  The key component is the car body object, which is linked to the 4 wheels through a logic brick connection so that the script would recognize the linked objects as wheels. (As you can see, all the actual driving logic is all happening on the car body, the wheels have no real logic brick attached).

    The entire setup is a bit complex, since there is a mix of logic brick and python. Take a look at the sample file if you are lost.  When one runs the game, the following happens:

    0. World is initialized, but we don’t really care about that here.

    1. The car body is initalized, scripts.carInit() is ran. In this script, it initializes the car as a “vehicle constraint”, aka constraint type11, and stores it as a Python object called vehicle.  The same script then looks for the 4 wheel by access a gamelogic actuator with specific names (in this case, wheel1, wheel3, etc), then the script attaches the wheels to the car body using the settings specified in the script. Variables such as RollInfluence, SuspensionStiffness, and TyreFriction can all be set on a per-tire basis once the vehicle object is created. The job of carInit() is now done.  Our car body is now considered to be a vehicle by the Blender game engine, and it will behave like one.

    2. Every frame, scripts.carHandler() is ran. This script does the actual moving of the car, it applies engine force and steering to the vehicle object. But this script gets the user input (keyboard sensor inputs) from another source. (See #3 below)   Vehicle objects have methods such as applyBreaking(), applyEngineForce(), getWheelRotation(), getNumWheels, which you can all call.

    3. Every time a key is pressed, script.keyHandler() is ran. It figures out which key is pressed and set the intermediate variable so that #2 (i.e. scripts.carHandler) would know how much throttle to apply, where to steer, etc.  This script is separated from scripts.carHandler() not because of technical limitations, but by design so that it’s easier to manage the code.

    That’s all there is to it.  If the script layout is a bit confusing, it’s because it is.  I originally intended it to be a bigger project, thus everything is separated into nice neat functions.  Again, you can DOWNLOAD the whole setup for Blender 2.5 from here.

    Controls:
    Arrow Keys to move the car
    Space bar for handbrake
    R to reset car if it flips over
    number row 1,2,3,4,5 to change camera

    Hope that helped.

  • Call for donations: Vajira Sri Rehabilitation Children’s home
    The lowlander's Weblog - 2010-04-17 20:02:31

    Ayubowan (hello), I mentioned in the previous posts that I had been to Sri Lanka to teach English at the Vajira Sri Rehabilitation Children’s home. What I haven’t mentioned yet, is that this school runs on donations and volunteers, and that they are short on both. But money is a rather pressing issue. So basically [...]
  • This spaceship is getting gnarly
    Starbright Illustrations (blog) - 2010-04-17 14:48:11

    My spaceship illustration is coming on in leaps and bounds, getting more interesting all the time. It has twice as many greebles as the last time we saw it, and of course it was almost completely smooth when I rendered the mesh in Blender.


  • Production changes
    Sintel, the Durian Open Movie Project - 2010-04-17 09:44:21

    The animations provided by the community will be very useful.

  • Another fine spaceship image made with Blender and GIMP
    Starbright Illustrations (blog) - 2010-04-17 01:10:14

    I’ve been modeling spaceships in 3D again, to add to the huge gallery of spaceship art here at Starbright.

    It’s not just about expanding the gallery though, playing around with the capabilities of Blender and GIMP is also a lot of fun. I’m working in a style right now that takes advantage of the 3D capabilities of Blender, but then has a lot of work done in GIMP to produce a 3D image that looks like an illustration.

    In the illustration above the planet in the foreground has had a lot of GIMP work done on it and looks very painterly, and the planet in the background is straight out of Blender. It has that shiny chrome appearance of a render. It’s going to be the very next element to get a working over as I take this image towards being a completed illustration.

    I’m also working on floor plans to go with the spaceship illustration – I know how everyone loves them. I suddenly realised that if I did a screen grab of the top view window in Blender and chose wire mesh as the view option I would have a nice technical drawing of my spaceship without having to do much extra work. So floor plans coming soon, but in the mean time what has been happening with the illustration, well…


    Last time we saw the spaceship illustration it looked like this. Just a mesh with the default skin, and not a very complex mesh either, but it is already beginning to suggest the completed spaceship. It’s a simple cube cut in half and mirrored with a few simple transformations; subdivide, extrude and grab.


    After just a few more extrude operations the spaceship mesh starts to look much more real. I’ve also changed the colour of the skin that the mesh receives when it is rendered.


    Another bump extruded and scaled has been added here to be the cockpit. I’m now very happy with the camera angle and I haven’t fiddled with it for a while, I am still fiddling with the lighting though. I want it a little more dramatic so I added a second light source to brighten up the foreground edges of the spaceship.


    More and more detail and complexity being added to the mesh. Even though there is a lot of complexity, it has almost exclusively been achieved by simply extruding and grabbing surfaces I also added a cylinder right at the front of the spaceship.


    It’s a tiny detail, but like a cherry on a cake it makes all the difference. I had to join it to the original spaceship mesh to get it to mirror properly. With that little touch I was finished with Blender and it was time to move on to GIMP.


    I rendered a nice big jpeg of the finished mesh and dropped it into GIMP. Because I chose a jpeg as the format I had a lot of white background to get rid of, but cutting out a spaceship with hard straight edges is no problem in GIMP. I just held down shift as I used the eraser and GIMP kept my lines nice and straight.


    Once I had my spaceship cut out I started to add some details to it. Abstract spaceship details are called greebles in the business and you need to add an awful lot of them before the spaceship starts to look good.

    This spaceship has only a light dusting of greebles – an airlock and some windows – it’s going to need a few more.

    I also went back to Blender to make a couple of planets – just spheres set smooth with textures chosen from the presets that come with Blender. The foreground planet uses “random noise” and the background planet has the “marble” texture applied.

    I’ve made a good start with this image and I have high hopes that it’s going to be my most professional looking spaceship illustration yet, when I eventually get it done.


<
2010-4
>
 
 
 
1
19
2
4
3
8
4
7
5
7
6
10
7
5
8
12
9
11
10
10
11
11
12
6
13
7
14
6
15
8
16
7
17
6
18
12
19
15
20
8
21
7
22
9
23
9
24
4
25
4
26
14
27
11
28
8
29
7
30
6