I am trying to write my own 3d level editor using a limb based approach,so i can save the whole model out as well a other eventual info... but the main problem is not being able to position a limb where one already exists, I have this code so far:
Rem Project: my3deditor
Rem Created: Friday, June 14, 2013
Rem ***** Main Source File *****
sync on
sync rate 60
desktopwidth=800
desktopheight=600
set display mode desktopwidth,desktopheight,32,1
SET WINDOW OFF
autocam off
global objectcount=0
global limbnum=0
global cx#,cy#,cz#
global rotvalue=0
global offsetx
global offsetz
global created=0
global c=0
cx#=0
cy#=0.5
cz#=1
global cursoffsetx
global cursoffsety
global cursoffsetz
position camera 50,10,0
position light 0,100,100,100
make matrix 1,100,100,50,50
selector=6657
make object box selector,2,2,2
scale object selector,10,100,100
ghost object on selector
`hide object selector
objectcount=1
`load image "notexture.png",1
`xrotate camera 0,90
xrotate camera 0,45
do
for n=1 to limbnum
if limb exist(objectcount,n)
if limb position x(objectcount,n) = object position x(selector) and limb position y(objectcount,n)= object position y(selector) and limb position z(objectcount,n)= object position z(selector)
c=1
exit
else
c=0
endif
endif
next n
r=object angle y(selector)
t$="poop"
t$=str$(limbnum)
c$=str$(c)
text 0,0,t$
text 0,20,c$
`BirdsEyeCam(object position x(selector),object position y(selector),object position z(selector),5)
`CONTROL CAMERA USING ARROWKEYS 0, 2, 0
BirdsEyeCam(object position x(selector),object position y(selector),object position z(selector),15)
if inkey$()="s"
if object exist(objectcount)
delete file "my_object.dbo"
save object "my_object.dbo",objectcount
print "SAVED!"
sync
wait 3000
Endif
endif
`cx#=object position x(selector)-50
`cy#=object position y(selector)+1
`cz#=object position z(selector)-52.5
if objectcount=1 and created=0
created=1
make object cube objectcount,2
ghost object on objectcount
`scale object objectcount,15,15,15
make mesh from object 1,objectcount
position object objectcount,cx#,cy#,cz#
`hide object objectcount
endif
count=count+1
if count>3
count=0
if inkey$()="r"
rotvalue=rotvalue+90
if rotvalue=270
offsetz=1
offsetx=1
endif
if rotvalue=90
offsetz=0
offsetx=1
endif
if rotvalue=0
offsetx=0
offsetz=0
endif
endif
if rotvalue>= 360
rotvalue=0
endif
if inkey$()="a"
cy#=cy#+2
endif
if inkey$()="z"
cy#=cy#-2
endif
rotate object selector,0,rotvalue,0
endif
if mouseclick()=1 and c=0
inc limbnum
add limb objectcount,limbnum,1
scale limb objectcount,limbnum,10,100,100
rotate limb objectcount,limbnum,0,rotvalue,0
`texture limb objectcount,limbnum,1
link limb objectcount,0,limbnum
count=count+2
offset limb objectcount,limbnum,cx#+offsetx,cy#,cz#+offsetz-1
endif
if upkey()=1
cz#=cz#+2
endif
if downkey()=1
cz#=cz#-2
endif
if leftkey()=1
cx#=cx#-2
endif
if rightkey()=1
cx#=cx#+2
endif
position object selector,cx#+offsetx,cy#,cz#+offsetz
sync
loop
Function BirdsEyeCam(X#,Y#,Z#,Height#)
position camera x#,y#+height#,z#
point camera x#,y#,z#
endfunction
I have tried a for next loop to see if the cursor objects position is equal to an existing limbs position, if so i set the variable c to 1 but only able to place a limb if it is equal to 0, but it doesnt work! As you see displayed the variable limbnum keeps going up in value
Hail to the king, baby!
http://davidjohnwheeler.blogspot.co.uk