Download presentation
Presentation is loading. Please wait.
Published byJonas Joel Miles Modified over 9 years ago
1
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) DarkBASIC Matrix Command Set CS 426 Chautauqua 7 October 2003 Copyright © Nicholas Schwarz, Jia Yin, Litian Zhang
2
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) 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.
3
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) 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.
4
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) 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
5
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) 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
6
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) How to use the matrix command set? A Simple Matrix MAKE MATRIX 1, 1000, 1000, 10, 10 UPDATE MATRIX 1
7
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) 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
8
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) How to use the matrix command set? Adding a Texture LOAD IMAGE "marble.bmp", 1 PREPARE MATRIX TEXTURE 1, 1, 1, 1
9
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) 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.
10
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) 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.
11
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) 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.
12
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) 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
13
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) How to use the matrix command set? Manipulating Tile Height RANDOMIZE MATRIX 1, 50
14
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) 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.
15
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) 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.
16
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) How to use the matrix command set? Matrix Transparency GHOST MATRIX ON makes the matrix semi- transparent. GHOST MATRIX OFF makes the matrix opaque. The effects of these commands are only visible when the textured representation of the matrix is visible.
17
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) 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.
18
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) 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.
19
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) 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
20
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) How to use the matrix command set? Deleting a Matrix The command DELETE MATRIX MatrixNumber deletes the matrix specified by MatrixNumber.
21
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) 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.
22
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) Demonstration program Run the demo
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.