Archive for the ‘Programming’ Category

h1

The Level Production Pipeline

October 19, 2009

After one week of testing and writing scripts for the level production pipeline, we finally come to a first version that is working well. We use Maya 2008 as level editor and created some scripts to make editing easier and more efficient. The Editor is split in two parts:

The Block Editor

The block editor is use two create so call blocks for the track editor.

Shelf_BlockEditorThe picture shows the shelf for the block editor. The left two buttons will be explained in another post. The other buttons are to insert platforms in different sizes into the scene. The shelf is automatically filled with buttons by scanning a define folder for maya files with this different sized platforms in it.

global proc TheBallBlock() {
 global string $gBuffStr;
 global string $gBuffStr0;
 global string $gBuffStr1;

 string $tempDir = "D:/WS09_The_Ball/Production/Model/Element/Boxes//";
 string $blocks[] = `getFileList -folder $tempDir -filespec "*.mb"`;

 for ($i in $blocks)
  {
  string $block = `substitute ".mb" $i ""`;
  string $short[];
  $numTokens = `tokenize $block "_" $short`;

  if($short[0] == "Box")
   {
   shelfButton
    -enableCommandRepeat 1
    -enable 1
    -width 34
    -height 34
    -manage 1
    -visible 1
    -preventOverride 0
    -align "center"
    -label $block
    -labelOffset 0
    -font "smallFixedWidthFont"
    -imageOverlayLabel $short[1]
    -image "commandButton.xpm"
    -image1 "commandButton.xpm"
    -style "iconOnly"
    -marginWidth 1
    -marginHeight 1
    -command [Here has to be the command to import maya files]
    -sourceType "mel"
    -actionIsSubstitute 0;
  }
 }
}

This is a part of the script to fill the shelfs with buttons. The next picture shows a “turn block”.

BlockEditor

The Track Editor

The track editor uses the blocks out of the block editor to create a track.

Shelf_TrackEditor

The picture shows the shelf for the track editor. The three buttons on the right show block elements that can be inserted currently. This shelf is also automatically filled with buttons by scanning a folder for the blocks created before. It also loads a picture of the block into the button, but this pictures have to be made by hand. In difference to the block editor the elements of the track editor are imported by reference ad instance. This makes it possible to make slight changes in the blocks without having to build all the tracks new to update the block elements. The next pictures shows a simple track created with our current block elements.

TrackEditor

An in-game movie coming soon, with a new texture design.

h1

Panda3D following camera

October 7, 2009

After posting all these screenshots and videos, we thought it would be nice to go a little bit deeper and share some code. What you see below is how we are making the camera follow the ball (don’t worry, some explanation will follow!):

camvec = self.ball.getPos() - base.camera.getPos()
camheight = camvec.getZ()
camvec.setZ(0)
camdist = camvec.length()
camvec.normalize()

if (camdist > 20.0):
    base.camera.setPos(base.camera.getPos() + camvec * (camdist - 20))
elif (camdist < 15.0):
    base.camera.setPos(base.camera.getPos() - camvec * (15 - camdist))

if (camheight > 0):
    base.camera.setPos(base.camera.getPos() + Vec3(0, 0, camheight - 0))
elif (camheight < -3):
    base.camera.setPos(base.camera.getPos() + Vec3(0, 0, camheight + 3))

self.ballPosHprDummy.setPos(self.ball.getPos())
self.ballPosHprDummy.setH(self.ball.getH())
dirVec = self.desiredCamPosDummy.getPos(render) - base.camera.getPos()
dirVec.setZ(0)
turnRate = 0.1
base.camera.setPos(base.camera.getPos() + dirVec * turnRate)
base.camera.lookAt(self.ball)

So what’s this mumbo-jumbo all about?

Let’s have a look at it step by step:

  • First we get the vector pointing from the camera to the ball and store the difference in height between those two in camheight and camdist.
  • The next part of the posted code is responsible for the camera following the player with a distance of at least 15 and 20 units at max (first if…elif statement). The second part makes the camera follow the ball on the z axis (which is up and down in Panda3D). What’s important here is that the camera is not directly set to the player’s height, which would give it an unnatural feeling – instead it starts matching the height when the given threshholds are surpassed.
  • In the last part, we are using the ballPosHprDummy and desiredCamPosDummy NodePath objects to adjust the camera rotation with a slight delay. The desiredCamPosDummy is parented to ballPosHprDummy and (in our case) always 15 units behind ballPosHprDummy (the code to setup this hierarchy is not shown here). This can be used to get a vector from the camera’s current position to its desired position, which is then used to bump it a small part along this vector (influenced by turnRate) to get closer to the desired position. You may need to tweak the turnRate variable to adjust it to the turning speed of your game character!

Closing thoughts and notes:

This way to handle the camera may be a little hacky and will most definitely see some changes (just think of problems like the camera intersecting / getting occluded by objects) on our journey to the final version of the game, but as a drop-in solution for quickly testing our basic gameplay, it worked like a charm!

Also note that there may no need for something like the ballPosHprDummy in other kinds of games. We just were not able to parent desiredCamPosDummy directly to the ball, because it is spinning most of the time (Well, there was a short moment where we didn’t mind this that got us a little dizzy when starting the game…).

h1

Physic Test October 2009

October 5, 2009

This is the actual game version. It’s using the PhysX integration and pygame for gamepad support.

h1

Physics Test September 2009

October 5, 2009

This version was created with Panda3D using the integrated ODE module

h1

Technical Information

October 2, 2009
  • The project is going to be developed with Panda3D.
  • The graphical assets are made with Maya2008.
  • Controls are Keyboard and a small set of Gamepads.
  • Local multiplayer mode (up to 4 players).