It dawned on me how to make what seems like a GIGANTIC matrix. UV data describes how a texture is stretched across the faces of a 3d object. If the limits are between 0 and 1, the texture maps to the faces in percentages so that the object is covered completely by a single image more or less. If you increase the UV values past 1, it starts to tile... that is, the image repeats itself in portions or in whole.
So I ran with that premise and created a floor function that creates a PLAIN OBJECT that uses a tiled texture. What this means is you could create a PLAIN that is 200000 by 200000 units for example, and divide it into as many tiles as you want based on the texture scaling. So a 2000 x 2000 tiled plain would take up, let me do the calculations here... ok, carry the 1...
4 POLYGONS.
(note: for my wall function it's 24 polygons per wall)
Useful applications of these functions would be for floors, and walls mostly for interiors. The floor will be flat, though it can be rotated and therefore made into an incline. The walls could be used as walls or other square type objects. You could effectively create the interior floor plan of a whole building without taking a performance hit because the polys are so low.
I'm including 2 functions:
make_floor(obj,width#,height#,posx#,posy#,posz#,texture,across#,down#)
make_wall(obj,width#,height#,depth#,posx#,posy#,posz#,texture,across#,down#)
The parameter descriptions are as follows:
Obj = integer - Object number you want to create
Width# = float - x dimension
Height# = float - y dimension
Depth# = float - (Wall Only) z dimension
posx# = float - the x position of where to place the object
posy# = float - the y position of where to place the object
posz# = float - the z position of where to place the object
texture = integer - the image number to assign to object
across# = float - tile UV texture across by number
down# = float - tile UV texture down by number
The functions return the actual object number that was used to create the object. The functions check to make sure the object doesn't exist before a floor or wall is created.
I've included a little example. The textures stink because I just quickly whipped them up with the BOX command. With well made textures, everything looks pretty good!
rem floor and wall functions
rem latch grapple
rem nov 2 2006
set display mode 800,600,16
sync on
sync rate 60
autocam off
rem make floor texture
ink rgb(255,255,255),0
box 0,0,127,127
ink rgb(90,90,90),0
box 4,4,127,127
ink rgb(100,192,200),0
box 4,4,123,123
get image 1,0,0,128,128
cls 0
rem make wall texture
ink rgb(64,64,64),0
box 33,4,100,33
box 0,37,67,70
get image 2,0,0,71,71
rem call make_floor function
groundfloor = make_floor(1,20000.0,10000.0,0.0,0.0,0.0,1,200.0,100.0)
wall = make_wall(1,50.0,200.0,1000.0,500.0,100.0,50.0,2,20.0,5.0)
wall2 = make_wall(1,3000.0,2000.0,200.0,0.0,1000.0,2000.0,2,2.0,5.0)
set object wall2,1,0,0
sync
rem position camera
position camera 0,100,0
ink rgb(255,0,0),0
do
set cursor 0,0
print screen fps()
rem move camera around
if upkey()=1 then move camera 5
if downkey()=1 then move camera -5
rem rotate camera
if rightkey()=1 then ang#=wrapvalue(ang#+1)
if leftkey()=1 then ang#=wrapvalue(ang#-1)
yrotate camera ang#
sync
loop
end
rem ******************** FUNCTIONS *******************************************
function make_floor(obj,width#,height#,posx#,posy#,posz#,texture,across#,down#)
rem check for exisiting objects
while object exist(obj)=1
inc obj
endwhile
rem make the actual plain object and rotate it flat
make object plain obj,width#,height#
xrotate object obj,90
fix object pivot obj
rem texture and scale the texture to tile it or not
texture object obj,texture
scale object texture obj,across#,down#
rem set the initial position of the floor
position object obj,posx#,posy#,posz#
endfunction obj
function make_wall(obj,width#,height#,depth#,posx#,posy#,posz#,texture,across#,down#)
rem check for exisiting objects
while object exist(obj)=1
inc obj
endwhile
rem make the actual box object to become a wall
make object box obj,width#,height#,depth#
rem texture and scale the texture to tile it or not
texture object obj,texture
scale object texture obj,across#,down#
rem set the initial position of the floor
position object obj,posx#,posy#,posz#
endfunction obj
Enjoy your day.