Game Design Document - University of Illinois at Chicago
Download
Report
Transcript Game Design Document - University of Illinois at Chicago
DarkBASIC Matrix Command Set
CS 426 Chautauqua
7 October 2003
Copyright © Nicholas Schwarz, Jia Yin, Litian Zhang
Electronic Visualization Laboratory (EVL)
University of Illinois at Chicago
What does the matrix command set do?
• Provides for the creation and manipulation of 3D
world space matrix landscapes.
• A matrix serves as the floor or terrain of a
DarkBASIC program.
• A matrix is grid of polygons similar to a
checkerboard.
• Each square of the matrix is called a tile.
• Each tile can be painted with a texture, and each of
its four corners can be raised or lowered to create
hills and valleys.
Electronic Visualization Laboratory (EVL)
University of Illinois at Chicago
What does the matrix command set do?
• Can set its position,
transparency, and
representation, and
shift the matrix in
different directions.
• The image to the right
is of a textured matrix
with tile corners of
random height.
Electronic Visualization Laboratory (EVL)
University of Illinois at Chicago
How to use the matrix command set?
A Simple Matrix
• Use the MAKE MATRIX command to create a
matrix.
– MAKE MATRIX MatrixNumber, Width, Depth, XTiles,
ZTiles
– MatrixNumber: number by which a DarkBASIC program
refers to the matrix
– Width: width of the matrix in pixels
– Depth: depth of the matrix in pixels
– XTiles: number of tiles in the x direction
– ZTiles: number of tiles in the z direction
Electronic Visualization Laboratory (EVL)
University of Illinois at Chicago
How to use the matrix command set?
A Simple Matrix
• Changes made to a matrix are not visible until the
UPDATE MATRIX command is issued.
– UPDATE MATRIX MatrixNumber
– MatrixNumber: number of the matrix to update
Electronic Visualization Laboratory (EVL)
University of Illinois at Chicago
How to use the matrix command set?
A Simple Matrix
• MAKE MATRIX 1, 1000, 1000, 10, 10
• UPDATE MATRIX 1
Electronic Visualization Laboratory (EVL)
University of Illinois at Chicago
How to use the matrix command set?
Adding a Texture
• A texture can be added to each tile of the matrix by
using the PREPARE MATRIX TEXTURE command
in combination with the LOAD IMAGE command
from the Image Command Set.
– PREPARE MATRIX TEXTURE MatrixNumber,
ImageNumber, Across, Down
– MatrixNumber: matrix to add a texture to
– ImageNumber: image to use as a texture
– Across: number of tiles across within the texture
– Down: number of tiles in the texture from top to bottom
Electronic Visualization Laboratory (EVL)
University of Illinois at Chicago
How to use the matrix command set?
Adding a Texture
• LOAD IMAGE "marble.bmp", 1
• PREPARE MATRIX TEXTURE 1, 1, 1, 1
Electronic Visualization Laboratory (EVL)
University of Illinois at Chicago
How to use the matrix command set?
Multiple Textures
• DarkBASIC only allows
a single image to serve
as a matrix's texture.
• In order to use multiple
textures with a matrix,
the image file must be
tiled.
• Texture tiles are
numbered starting at 1
from left to right, then
top to bottom.
Electronic Visualization Laboratory (EVL)
University of Illinois at Chicago
How to use the matrix command set?
Multiple Textures
• Load a texture with multiple tiles by specifying the
number of tiles across and down with the Across
and Down parameters of the PREPARE MATRIX
TEXTURE command.
• PREPARE MATRIX TEXTURE 1, 1, 2, 2
• See Demo Program for a better understanding.
Electronic Visualization Laboratory (EVL)
University of Illinois at Chicago
How to use the matrix command set?
Multiple Textures
• Specify which texture to paint a particular tile with
using the SET MATRIX TILE command.
– SET MATRIX TILE MatrixNumber, TileX, TileZ,
TextureTileNumber
– MatrixNumber: specifies the matrix to paint
– TileX, TileZ: identify the tile on the matrix to paint
– TextureTileNumber: refers to the tile in the texture image
to use.
– As an example, to set matrix tile (5,5) with tile 2 from the
texture image use the command SET MATRIX TILE 1, 5,
5, 2.
• See Demo Program for a better understanding.
Electronic Visualization Laboratory (EVL)
University of Illinois at Chicago
How to use the matrix command set?
Manipulating Tile Height
• The easiest way to manipulate the height of tiles in a
matrix is by using the RANDOMIZE MATRIX
command.
• This command sets each tile in the matrix to a random
height between 0 and a specified maximum.
• RANDOMIZE MATRIX MatrixNumber,
MaximumHeight
– MatrixNumber: matrix to manipulate
– MaximumHeight: maximum height in pixels a tile may be
Electronic Visualization Laboratory (EVL)
University of Illinois at Chicago
How to use the matrix command set?
Manipulating Tile Height
• RANDOMIZE MATRIX 1, 50
Electronic Visualization Laboratory (EVL)
University of Illinois at Chicago
How to use the matrix command set?
Manipulating Tile Height
• Another way to manipulate the height of tiles in a
matrix is by using the SET MATRIX HEIGHT
command.
–
–
–
–
SET MATRIX HEIGHT MatrixNumber, TileX, TileZ, Height
MatrixNumber: the matrix to manipulate
TileX, TileZ: identify the tile to manipulate
Height: specifies the tile's height
• This command sets the height of an individual tile to a
specified amount.
• See the demo program for an example of how this
works.
Electronic Visualization Laboratory (EVL)
University of Illinois at Chicago
How to use the matrix command set?
Wireframe Mode
• SET MATRIX WIREFRAME ON displays a wireframe
representation of the specified matrix.
• SET MATRIX WIREFRAME OFF displays the textured
representation of the specified matrix, assuming the
matrix has been assigned a texture.
Electronic Visualization Laboratory (EVL)
University of Illinois at Chicago
How to use the matrix command set?
Matrix Transparency
• GHOST MATRIX ON makes the matrix semitransparent.
• GHOST MATRIX OFF makes the matrix opaque.
• The effects of these commands are only visible when
the textured representation of the matrix is visible.
Electronic Visualization Laboratory (EVL)
University of Illinois at Chicago
How to use the matrix command set?
Shifting the Matrix
• DarkBASIC’s shifting commands allow the
programmer to shift the entire contents of the
matrix one tile up, down, left, and right.
• The height and tile data that represent the matrix
are wrapped around to allow continuous shifting.
• Shifting the entire matrix can be used to emulate
movement. Instead of moving the camera position,
fix the camera position and perform shift
operations. Shifting up emulates forward
movement. Shifting down emulates backwards
movement. Shifting left emulates movement to the
right. Shifting right emulates movement to the left.
Electronic Visualization Laboratory (EVL)
University of Illinois at Chicago
How to use the matrix command set?
Shifting the Matrix
• The shift commands are:
–
–
–
–
SHIFT MATRIX DOWN MatrixNumber
SHIFT MATRIX LEFT MatrixNumber
SHIFT MATRIX RIGHT MatrixNumber
SHIFT MATRIX UP MatrixNumber
• Shifting is better understood when we view the
demo.
Electronic Visualization Laboratory (EVL)
University of Illinois at Chicago
How to use the matrix command set?
Matrix Position
• The command POSITION MATRIX places the
matrix at a position in 3D space.
– POSITION MATRIX MatrixNumber, X, Y, Z
– POSITION MATRIX MatrixNumber, Vector
• DarkBASIC provides commands for getting the
current position of a matrix.
–
–
–
–
float = MATRIX POSITION X(MatrixNumber)
float = 'MATRIX POSITION Y(MatrixNumber)
float = MATRIX POSITION Z(MatrixNumber)
SET VECTOR3 TO MATRIX POSITION Vector,
MatrixNumber
Electronic Visualization Laboratory (EVL)
University of Illinois at Chicago
How to use the matrix command set?
Deleting a Matrix
• The command DELETE MATRIX MatrixNumber
deletes the matrix specified by MatrixNumber.
Electronic Visualization Laboratory (EVL)
University of Illinois at Chicago
Other Matrix Commands
• Other commands exists within the DarkBASIC
Matrix Command Set, but they are beyond the
scope of this presentation…
• Please, feel free to try them yourself.
Electronic Visualization Laboratory (EVL)
University of Illinois at Chicago
Demonstration program
• Run the demo
Electronic Visualization Laboratory (EVL)
University of Illinois at Chicago