Computer Graphics Workshop '97 Lecture Notes | 1/31/97 |
Chess is a networked chess board. Two people can play a game of chess by clicking and dragging the pieces around the board.
The pieces were created by hand using various geometric primitives in Open Inventor. Dragging of the pieces is implemented by setting the geometry of Translate2Draggers to be the pieces' geometry. Every time a piece is dragged, a MotionCallback writes a message to the network containing the piece's new position. In addition, an IdleSensor monitors incoming messages and keeps the local board synchronized with the other player's board.
To start the game, one person must start the chess application first, and
the other must connect to the first one by using the -connect
<machine name>
command line option. The -texture
option turns on texture mapping for the pieces, but this slows down the
game on machines without hardware texture mapping.
Chess was written in C++ and requires the SocketMan networking library in order to compile.
Air Hockey is a networked two-player version of shufflepuck implemented in Scheme. Each player controls one paddle. Moving the mouse in the viewer's window causes the paddle to move on both players' screens.
The game is implemented using a TimerSensor to drive the main loop. At each time step the puck's new position is computed based on its current velocity, and it is constrained to lie within the game region. Then collision tests are performed on the local player's paddle to determine whether the puck should bounce off the paddle with some added velocity. A message is sent over the network to inform the other player of the collision, as well as the position and velocity of the puck after the collision. This allows both machines to maintain synchronization.
To start the game, type "ivyscm hockey.scm" on two different SGIs. The program will ask you whether it should connect to a remote server. On one machine, answer "n"; this will be the server. The other will be a client to the server and should be connected to the server by answering "y", and typing the server's name at the next prompt.
Lightcycles is a 3-D implementation of the game from TRON. Each player controls a biker which drags a trail behind him; the object is to get the other players to run into your trail, without running into a trail yourself. The camera view is a first-person view, pointing straight ahead from your biker. The left and right arrow keys turn your biker by 90 degrees; up and down make you accelerate and decelerate; the Z and X keys let you look left and right while they are held down.
The game is implemented with an IdleSensor driving the main loop. The bikes are hooked up to engines which control their forward motion; key presses cause network messages to be sent out to keep remote machines' view of your bike synchronized. A FaceSet is used to make each biker's trail; the last rectangle in the face set is continually modified to have its last two coordinates be the biker's current position. The geometry for the bikers was made by hand.
Lightcycles uses IP multicasting to perform its network communication, so it can (theoretically) handle any number of players.
To run, just type "ivyscm light-rand.scm".
This is not an easy game. Enemy cones will sometimes hover at the top, sometimes dart at you, and sometimes bounce off of each other.
Run the game with "ivyscm joust.scm".
Gravity is not an object, but just a TimerSensor which accelerates all heavy actors downward.
Collisions are detected by a FieldSensor callback that is executed whenever an Actor moves. Elastic collisions are physically correct, incorporating the masses of the Actors and the angle at which they contact in 3D. Joust could easily be made three-dimensional simply by adding a input key for accelerating along the z-axis.
Tags are used to identify types of Actors. An Actor can check for collisions with the specific Actor types it cares about. Some tags, like egg and enemy, simply identify the class of the Actor. Other tags, like heavy, identify attributes of the Actor. This makes gravity particularly simple: accelerate all heavy Actors. (Barriers are not heavy.) A global table efficiently maps tags into the Actors which hold them.
Run ball.scm for a demo of Actors.
p = v * t + d
.
t is output of an ElapsedTime engine.
v, d are constants.
When the timer runs, p will advance forever in one direction.
Note that setting d = p
and resetting the
timer (t = 0
) produces no visible effect. The VelocityEngine
uses this fact to change its velocity.
See test-ve.scm for a demo of the VelocityEngine. Use the arrow keys to change the velocity of the sphere/cone.
$Id: index.html,v 1.3 1997/02/19 22:51:54 kbrussel Exp $