Skip to content
Masoug edited this page Oct 24, 2013 · 5 revisions

Dynamics objects are things that interact with Bullet (i.e. the walls, players, balls, etc...). The DynamicObject class encapsulates the Bullet RigidBody and Irrlicht's SceneNode under one package.

Things to note for while perusing the code:

  • applyTransform() copies the Bullet-calculated position and orientation of the object to Irrlicht. Pretty simple.
  • onCollision() handles any collision that this object will be concerned with (i.e. hit the ground, hit the player, etc...)
  • throwBall() for the DodgeballNode just applies the given impulse to the rigid body. It also ACTIVEates the ball.
  • WallNodes are just boxes with a really skinny thickness. They have no mass (don't move) and I have yet to give them a suitable texture...
  • AvatarNodes are objects that represent the other players in the game. They will be controlled by the network module later on as a networked game. Currently, the class itself is just a "shell" of sorts that loads the provided model in the constructor. Each player is also required to be on a team; RED or BLUE. This determines which direction they're facing on the court. The placement of the players still need to be hardcoded. Player Models has more information about preparing models in Blender to use in dodgeball.
    • Players are moved through Bullet; that is, when the user pushes the W key, a force is applied to the model (same for A, S and D, etc...). The velocity of the model is controlled with a simple proportional controller (see PID Controller for more info about control loops) that applies the necessary force to the player rigidbody to get it going at the right speed.
      • The setForward(), setLateral() and stop() functions are convenience methods sets the speed of the front-back, left-right (and no movement) motions of the player (respectively).
    • The CameraAvatar is a special AvatarNode in that its scene node is a camera. It does not have a model; rather it is a camera inside a Bullet rigidbody (AvatarNodes are btCapsules btw). This presents a minor issue; when a ball is thrown by the player, it immediately collides with the capsule rigidbody. To mitigate this, the dodgeball's initial position upon spawning is ~1 meter in front of the camera. This avoids the problem for most cases, but if the player aims below ~45 degrees, the ball will still register a collision with the player. So this is a future issue to be addressed.

Clone this wiki locally