I tried to put your script into my program (its using magic world to create the matrix), and every way i try to put it in, i always end up with an "object already exists at line 84" or similair. wondering if any of you can help- heres my initial code, looking at the matrix from a predefined point:
#include "magicload1-1.dba"
set display mode 640,480,16
autocam off
sync on
print screen fps()
sync rate 0
set camera view 0,0,640,480
`load world
MagicLoad("4th",1,1,1)
rem Position camera
position camera 0,400,-400: rotate camera 15,0,0
set camera range 1,5000
hide mouse
rem Begin loop
do
rem screen fps
Set Cursor 10,10
print screen fps()
sync
loop
And this is the "magicload" dba file that is needed to run the already created mwdb matrix file from magic world. I'm not sure if the objects are clashing here, and there is some editing to be done.
function MagicLoad(terrain$,firstimage,firstmatrix,firstobject)
path$=get dir$()
if right$(terrain$,5)<>".mwdb" then terrain$=terrain$+".mwdb"
if file exist(terrain$)
`get rid of previous matrices, objects, lights,
`images and objects before calling the function
open to read 1,terrain$
`number of matrices
read word 1,mat
`number of texture images
read word 1,textures
`texture filenames
for a=firstimage to (firstimage+textures)-1
read string 1,tex$
read string 1,tex2$
if path exist(tex2$)=0 then tex2$=path$
if file exist(tex2$+"\"+tex$)
cd tex2$
load image tex$,a
else
get image a,0,0,16,16
endif
next a
cd path$
`for each matrix, twelve dimensions
for a=firstmatrix to (firstmatrix+mat)-1
read word 1,m1
read word 1,m2
read word 1,m3
read word 1,m4
read byte 1,sgn
read word 1,m5
if sgn=1 then m5=0-m5
read byte 1,sgn
read word 1,m6
if sgn=1 then m6=0-m6
read word 1,m7
read word 1,m8
read word 1,m9
read byte 1,m10
read byte 1,m11
read byte 1,m12
`create each matrix not filtered out
if matrix exist(a) then delete matrix a
make matrix a,m1,m2,m3,m4
position matrix a,m5,0,m6
if m9>0 then prepare matrix texture a,(m9-101)+firstimage,m7,m8
`for each grid point in each matrix, a height and tile number
for b=0 to m3
for c=0 to m4
read float 1,height#
set matrix height a,b,c,height#
if b<m3 and c<m4
read word 1,tile
if m9>0 then set matrix tile a,b,c,tile
endif
next c
next b
update matrix a
for c=0 to m4
for b=0 to m3
`no normals
if m12=0
set matrix normal a,b,c,0,1,0
endif
`floor or roof normals
if m12>0
`Get matrix heights
h#=get matrix height(a,b,c)
h2#=get matrix height(a,b,c)
if c=0 then h8#=get matrix height(a,b,c+1) else h8#=get matrix height(a,b,c-1)
if b=0 then h4#=get matrix height(a,b+1,c) else h4#=get matrix height(a,b-1,c)
`Calculate projected angle X using heights
x1#=(b-1)*25.0 : y1#=h#
x2#=(b+0)*25.0 : y2#=h4#
dx#=x2#-x1#
dy#=y2#-y1#
ax#=atanfull(dx#,dy#)
ax#=wrapvalue(90-ax#)
`Calculate projected angle Z using heights
z1#=(c-1)*25.0 : y1#=h2#
z2#=(c+0)*25.0 : y2#=h8#
dz#=z2#-z1#
dy#=y2#-y1#
az#=atanfull(dz#,dy#)
az#=wrapvalue(90-az#)
`Make normal from projected angle
if b=0 then nx#=sin(0-ax#) else nx#=sin(ax#)
ny#=cos(ax#)
if c=0 then nz#=sin(0-az#) else nz#=sin(az#)
`Setting matrix normal for smoothness
if m12=1
set matrix normal a,b,c,nx#,ny#,nz#
endif
if m12=2
set matrix normal a,b,c,0-nx#,0-ny#,0-nz#
endif
endif
next b
next c
update matrix a
if m10=1 then set matrix wireframe off a else set matrix wireframe on a
if m11=1 then ghost matrix off a else ghost matrix on a
next a
`OBJECTS
read word 1,numobj
for a=firstobject to (firstobject+numobj)-1
if object exist(a) then delete object a
read byte 1,OBJECT
read string 1,OBJFILE$
read string 1,OBJFILE2$
read float 1,ox#
read float 1,oy#
read float 1,oz#
read float 1,oxa#
read float 1,oya#
read float 1,oza#
if OBJECT=1 then make object cube a,100
if OBJECT=2 then make object sphere a,100
if OBJECT=3 then make object cylinder a,100
if OBJECT=4 then make object cone a,100
if OBJECT=5 then make object plain a,100,100
if OBJECT=6
if path exist(objfile2$)=0 then objfile2$=PATH$
if file exist(objfile$) then objfile2$=PATH$
if file exist(objfile2$+"\"+objfile$)
cd objfile2$
load object OBJFILE$,a
else
```substitute a cube!!!
make object cube a,100
endif
cd PATH$
endif
position object a,ox#,oy#,oz#
rotate object a,oxa#,oya#,oza#
read float 1,scx#
read float 1,scy#
read float 1,scz#
scale object a,scx#,scy#,scz#
`object texture or color
read byte 1,red
read byte 1,green
read byte 1,blue
read byte 1,op1
read byte 1,op2
read byte 1,op3
read byte 1,op4
read byte 1,op5
read byte 1,op6
read byte 1,op7
read byte 1,op8
read word 1,objtex
for b=1 to 4
read float 1,redundant#
next b
if op1=0 then ghost object on a else ghost object off a
set object a,op2,op3,op4,op5,op6,op7,op8
if OBJTEX=0
color object a,rgb(red,green,blue)
endif
if OBJTEX>100
texture object a,(objtex-101)+firstimage
endif
read byte 1,OBJHISTCOUNT
for b=1 to OBJHISTCOUNT
read float 1,objhist#
read float 1,objhistU#
read float 1,objhistV#
if objhist#=1.0
scroll object texture a,objhistU#,objhistV#
else
scale object texture a,objhistU#,objhistV#
endif
next b
next a
`STATIC OBJECTS
static=firstobject+numobj
if object exist(static) then delete object static
read word 1,numstat
for a=1 to numstat
read byte 1,STATOBJ
read string 1,STATFILE$
read string 1,STATFILE2$
if STATOBJ=1 or STATOBJ=7 then make object cube static,100
if STATOBJ=2 or STATOBJ=8 then make object sphere static,100
if STATOBJ=3 or STATOBJ=9 then make object cylinder static,100
if STATOBJ=4 or STATOBJ=10 then make object cone static,100
if STATOBJ=5 or STATOBJ=11 then make object plain static,100,100
if STATOBJ=6 or STATOBJ=12
if path exist(statfile2$)=0 then statfile2$=PATH$
if file exist(statfile$) then statfile2$=PATH$
if file exist(statfile2$+"\"+statfile$)
cd statfile2$
load object statFILE$,static
else
```substitute a cube!!!
make object cube static,100
endif
cd PATH$
endif
read float 1,sx#
read float 1,sy#
read float 1,sz#
position object static,sx#,sy#,sz#
read float 1,asx#
read float 1,asy#
read float 1,asz#
rotate object static,asx#,asy#,asz#
read float 1,sxsc#
read float 1,sysc#
read float 1,szsc#
scale object static,sxsc#,sysc#,szsc#
read byte 1,sred
read byte 1,sgreen
read byte 1,sblue
read word 1,stattex
if stattex=0
color object static,rgb(sred,sgreen,sblue)
endif
if stattex>100
`textures
texture object static,(stattex-101)+firstimage
endif
read byte 1,stathistcount
for b=1 to stathistcount
read float 1,stathist#
read float 1,stathistU#
read float 1,stathistV#
if stathist#=1.0
scroll object texture static,stathistU#,stathistV#
else
scale object texture static,stathistU#,stathistV#
endif
next b
`make static
if statobj<=6
make static object static
else
make static object static,1
endif
delete object static
next a
`LIGHTS
read word 1,numlight
for a=0 to numlight-1
read byte 1,light
read byte 1,showhide
read float 1,lightposX#
read float 1,lightposY#
read float 1,lightposZ#
read float 1,lightposAX#
read float 1,lightposAY#
read float 1,lightposAZ#
read float 1,lightposI#
read float 1,lightposO#
read byte 1,lred
read byte 1,lgreen
read byte 1,lblue
`make the light
if a>0 then make light a else show light 0
if light=1
set point light a,lightposX#,lightposY#,lightposZ#
endif
if light=2
set spot light a,lightposI#,lightposO#
position light a,lightposX#,lightposY#,lightposZ#
rotate light a,lightposAX#,lightposAY#,lightposAZ#
endif
if light=3
dix#=newxvalue(0,lightposAY#,100)*cos(lightposAX#)
diy#=newyvalue(0,lightposAX#,100)
diz#=newzvalue(0,lightposAY#,100)*cos(lightposAX#)
set directional light a,dix#,diy#,diz#
endif
`color
color light a,lred,lgreen,lblue
next a
`camera details
read float 1,CAMX#
read float 1,CAMY#
read float 1,CAMZ#
read float 1,CAMDX#
read float 1,CAMDY#
read float 1,CAMDZ#
position camera CAMX#,CAMY#,CAMZ#
rotate camera wrapvalue(CAMDX#),wrapvalue(CAMDY#),wrapvalue(CAMDZ#)
`redundant
read byte 1,WIRE
`fog and backdrop
read byte 1,fog
if fog=1 then fog on else fog off
read float 1,fogdist#
fog distance fogdist#
read byte 1,fred
read byte 1,fgreen
read byte 1,fblue
fog color rgb(fred,fgreen,fblue)
read word 1,back
read byte 1,backX
read byte 1,backY
read byte 1,bred
read byte 1,bgreen
read byte 1,bblue
if back=0
color backdrop rgb(bred,bgreen,bblue)
else
`backdrop texture
texture backdrop (back-101)+firstimage
scroll backdrop backX,backY
endif
read byte 1,ambient
set ambient light AMBIENT
`redundant
read byte 1,seas
read float 1,world#
close file 1
endif
endfunction
Thanks for any help.
/Steve.
[/quote]
If you gaze into the abyss long enough, the abyss starts staring back.