@ Dmitry K,
I seem to be having difficulty with DK Pick Limb in U6.2b... program crashes.... will submit code shortly if nothing occurs to you about why this is happening...
[edit]
ok - here's my code - i've doctored the stuff about startBlue for obvious reasons.... excuse the terrible inefficient and tardy coding...
Rem Project: Limb Jointer
Rem Created: 09/07/2006 22:19:25
Rem ***** Main Source File *****
set display mode 1024,768,32
startBlue "XX","YYY"
load sound "clickerx.wav",1
ink rgb(255,255,255),1
set window on
maximize window
set window title "Limb Jointer"
show window
resetMainWindow
autocam off
make camera 1
set camera range 1,0,5000
set camera view 1,1,1,1024,768
position camera 1,0,0,0
point camera 1,0,0,5000
set current camera 1
backdrop on 1
color backdrop 1,1
sync on
sync rate 0
draw sprites first
draw to front
set global collision off
set ambient light 40
set text font "Times New Roman"
set text size 16
type textbutton
name as string
topx as integer
topy as integer
botx as integer
boty as integer
width as integer
height as integer
state as integer
colour as integer
endtype
global dim commands(40) as textbutton
global dim limbbuttons(400) as textbutton
type limbdata
number as integer
name as string
endtype
global dim limbs(400)as limbdata
global totallimbs as integer
global parentlimb as integer
global childlimb as integer
global selectedlimb as integer
global commandcovered as integer
global limbdisplaymode as integer
global axis as string
global focuson as string
global limbbuttoncovered as integer
limbbuttoncovered = 0
focuson = "object"
axis = "x"
limbdisplaymode = 0
commandcovered = 0
totallimbs = 0
parentlimb = 0
childlimb = 0
selectedlimb = 0
commands(1).name = "Open 3D Object"
commands(2).name = "Save 3D Object"
commands(3).name = "----------------------------"
commands(4).name = "Reset 3D Object"
commands(5).name = "----------------------------"
commands(6).name = "Load In Jointing File"
commands(7).name = "Save Out Jointing File"
commands(8).name = "----------------------------"
commands(9).name = "Reset Focus on Object"
commands(10).name = "Select Limb to Focus On"
commands(11).name = "Focus on Selected Limb"
commands(12).name = "----------------------------"
commands(13).name = "Select Parent Limb"
commands(14).name = "Select Child Limb"
commands(15).name = "----------------------------"
commands(16).name = "Join Parent & Child Limbs"
commands(17).name = "----------------------------"
commands(18).name = "Test Selected Limb"
commands(19).name = "Test Parent Limb"
commands(20).name = "Test Child Limb"
commands(21).name = "----------------------------"
commands(22).name = "Undo Jointing Stage"
commands(23).name = "----------------------------"
commands(24).name = "Exit Program"
commands(25).name = "----------------------------"
commands(26).name = "----------------------------"
commands(27).name = "Select X Axis"
commands(28).name = "Select Y Axis"
commands(29).name = "Select Z Axis"
commands(30).name = "----------------------------"
commands(31).name = "Use Up/Down Keys to move in and out of focus"
commands(32).name = "Use Left/Right Keys to rotate around axis"
commands(33).name = "Press 'Z' to normalise zoom"
commands(34).name = "Press 'R' to normalise rotate"
commands(35).name = "Press 'N' to normalise all"
yy = 140
for r = 1 to 35
commands(r).width = text width(commands(r).name)
commands(r).height = text height(commands(r).name)
commands(r).topx = 4
commands(r).topy = yy
commands(r).botx = 0 + commands(r).width
commands(r).boty = yy + commands(r).height
commands(r).state = 1
commands(r).colour = rgb(255,255,255)
yy = yy + 17
next r
xv = 0
do
i$ = upper$(inkey$())
pl$ = "No limb covered currently by mouse..."
pl = -1
xx = mousex()
yy = mousey()
commandcovered = 0
limbbuttoncovered = 0
ink rgb(255,255,255),0
text 1,1,"Screen Frames Per Second = " + str$(screen fps())
text 1,21,"Polygons On Screen = " + str$(statistic(1))
if object exist(1) > 0
text 1,41,"3D Object Loaded"
text 1,61,"Total Number of Limbs in Object = " + str$(totallimbs)
else
text 1,41,"No 3D Object Loaded"
text 1,61,"Therefore no Limbs on Screen either.."
endif
if object exist(1) > 0
if totallimbs > 0
pl = dk pick limb(1,xx,yy,1,1,totallimbs)
if pl > 0
pl$ = "(" + str$(pl) + ") " + limb name$(1,pl)
pl$ = "Limb covered by mouse = " + pl$
endif
endif
endif
text 300,21,pl$
if object exist(1) > 0
if limb exist(1,selectedlimb) > 0
if limb name$(1,selectedlimb) <> ""
text 1,81,"Selected Limb = " + limb name$(1,selectedlimb)
else
text 1,81,"No Selected Limb"
endif
endif
if limb exist(1,parentlimb) > 0
if limb name$(1,parentlimb) <> ""
text 1,101,"Parent Limb = " + limb name$(1,parentlimb)
endif
endif
if limb exist(1,childlimb) > 0
if limb name$(1,childlimb) <> ""
text 1,101,"Child Limb = " + limb name$(1,childlimb)
endif
endif
endif
if limbdisplaymode = 0 or object exist(1) < 1
for r = 1 to 35
commands(r).colour = rgb(255,255,255)
if xx >= commands(r).topx
if xx <= commands(r).botx
if yy >= commands(r).topy
if yy <= commands(r).boty
if r < 30
if commands(r).name <> "----------------------------"
a = mouseclick()
commandcovered = r
if a > 0
commands(r).colour = rgb(255,255,0)
else
commands(r).colour = rgb(0,0,255)
endif
endif
endif
endif
endif
endif
endif
ink commands(r).colour,0
text commands(r).topx,commands(r).topy,commands(r).name
next r
endif
if limbdisplaymode > 0 and object exist(1) > 0
if limbdisplaymode = 1
cc = rgb(160,160,160)
ink cc,0
text 1,81,"Selected Limb Mode"
endif
if limbdisplaymode = 2
cc = rgb(255,0,0)
ink cc,0
text 1,81,"Parent Limb Mode"
endif
if limbdisplaymode = 3
cc = rgb(0,255,0)
ink cc,0
text 1,81,"Child Limb Mode"
endif
for r = 1 to totallimbs
limbbuttons(r).colour = cc
if xx >= limbbuttons(r).topx
if xx <= limbbuttons(r).botx
if yy >= limbbuttons(r).topy
if yy <= limbbuttons(r).boty
if r < 30
if limbbuttons(r).name <> "----------------------------"
a = mouseclick()
limbbuttoncovered = r
if a > 0
limbbuttons(r).colour = rgb(255,255,0)
else
limbbuttons(r).colour = rgb(0,0,255)
endif
endif
endif
endif
endif
endif
endif
ink limbbuttons(r).colour,0
text limbbuttons(r).topx,limbbuttons(r).topy,limbbuttons(r).name
next r
endif
if mouseclick() > 0 and limbdisplaymode < 1
if commandcovered > 0 and commandcovered < 30
xv = xv + 1
if xv > 3
xv = 0
play sound 1
wait 200
if commandcovered = 1
loadobject()
endif
if commandcovered = 2
saveobject()
endif
if commandcovered = 10
if object exist(1) > 0
limbdisplaymode = 1
limbdatarefill()
endif
endif
if commandcovered = 24
end
endif
if commandcovered = 27
axis = "x"
endif
if commandcovered = 28
axis = "y"
endif
if commandcovered = 29
axis = "z"
endif
endif
endif
endif
if mouseclick() > 0 and limbdisplaymode > 0
if limbbuttoncovered > 0
xv = xv + 1
if xv > 3
xv = 0
play sound 1
wait 200
limbdisplaymode = 0
selectedlimb = limbbuttoncovered
if limbdisplaymode = 1
if object exist(1) > 0
if limb exist(1,limbbuttoncovered) > 0
for r = 1 to totalimbs
if limb exist(1,r) > 0
color limb 1,r,rgb(180,180,180)
endif
next r
color limb 1,limbbuttoncovered,rgb(160,160,160)
endif
endif
endif
if limbdisplaymode = 2
parentlimb = limbbuttoncovered
if object exist(1) > 0
if limb exist(1,limbbuttoncovered) > 0
for r = 1 to totalimbs
if limb exist(1,r) > 0
color limb 1,r,rgb(180,180,180)
endif
next r
color limb 1,limbbuttoncovered,rgb(255,0,0)
endif
endif
endif
if limbdisplaymode = 3
childlimb = limbbuttoncovered
if object exist(1) > 0
if limb exist(1,limbbuttoncovered) > 0
for r = 1 to totalimbs
if limb exist(1,r) > 0
color limb 1,r,rgb(180,180,180)
endif
next r
color limb 1,limbbuttoncovered,rgb(0,255,0)
endif
endif
endif
endif
endif
endif
if upkey() > 0
if focuson = "object"
point camera 1,0,0,0
move camera 1,(object size(1) * 0.5)
endif
if focuson = "limb"
if limb exist(1,selectedlimb) > 0
point camera 1,limb position x(1,selectedlimb),limb position y(1,selectedlimb),limb position y(1,selectedlimb)
if object exist(2) > 0
delete object 2
endif
make object from limb 2,1,selectedlimb
aa# = object size(2)
aa# = aa# * 0.05
delete object 2
move camera 1,aa#
endif
endif
endif
if downkey() > 0
if focuson = "object"
point camera 1,0,0,0
move camera 1,-1 * (object size(1) * 0.01)
endif
if focuson = "limb"
if limb exist(1,selectedlimb) > 0
point camera 1,limb position x(1,selectedlimb),limb position y(1,selectedlimb),limb position y(1,selectedlimb)
if object exist(2) > 0
delete object 2
endif
make object from limb 2,1,selectedlimb
aa# = object size(2)
aa# = -1 * aa# * 0.01
delete object 2
move camera 1,aa#
endif
endif
endif
if i$ = "X"
axis = "x"
endif
if i$ = "Y"
axis = "y"
endif
if i$ = "Z"
axis = "z"
endif
sync
loop
end
function loadobject()
if object exist(1) = 1
q = questionMessage("Do you want to save out your existing object before loading in a new one?","Save Current Object?")
if q = 1
saveobject()
endif
endif
a$ = openDialog("Open 3D Object File","DirectX Object (*.x)|*.x|DBO Object (*.dbo)|*.dbo|All Files (*.*)|*.*")
if file exist(a$) = 0
errorMessage "File does not exist!"
exitfunction
endif
load object a$,1
hide object 1
position object 1,0,0,0
a# = object size(1)
b# = object size x(1)
if b# > a#
a# = b#
endif
b# = object size y(1)
if b# > a#
a# = b#
endif
b# = object size z(1)
if b# > a#
a# = b#
endif
a# = a# * 1.5
if object size z(1) > object size y(1)
rotate object 1,-90,0,0
fix object pivot 1
position object 1,0,-1*object size y(1)/2,0
endif
position camera 1,0,0,0
point camera 1,0,0,-3000
move camera 1,a#
point camera 1,0,0,0
totallimbs = 0
while limb exist(1,totallimbs) = 1
totallimbs = totallimbs + 1
endwhile
show object 1
endfunction
function saveobject()
if object exist(1) = 0
errormessage "No Object Loaded Yet...!"
exitfunction
endif
a$ = saveDialog("Save 3D Object File","DBO Object (*.dbo)|*.dbo|All Files (*.*)|*.*")
if file exist(a$) = 1
delete file a$
endif
save object a$,1
message "DBO Object Saved!"
endfunction
function limbdatarefill()
if object exist(1) < 1
exitfunction
endif
for r = 1 to 400
if limb exist(1,r) > 0
if r <= totallimbs
limbbuttons(r).name = "{" + str$(r) + ") " + limb name$(1,r)
limbs(r).name = limb name$(1,r)
limbs(r).number = r
else
limbbuttons(r).name = ""
limbs(r).name = ""
limbs(r).number = -1
endif
limbbuttons(r).width = text width(limb name$(1,r))
limbbuttons(r).height = text height(limb name$(1,r))
endif
next r
y = 101
n = 1
for r = 1 to totallimbs
if r < 41
limbbuttons(r).topx = 1
limbbuttons(r).botx = limbbuttons(r).width + 1
endif
if r > 40 and r < 81
limbbuttons(r).topx = 60
limbbuttons(r).botx = limbbuttons(r).width + 1
endif
if r > 80 and r < 121
limbbuttons(r).topx = 120
limbbuttons(r).botx = limbbuttons(r).width + 1
endif
if r > 120 and r < 161
limbbuttons(r).topx = 180
limbbuttons(r).botx = limbbuttons(r).width + 1
endif
if r > 160 and r < 201
limbbuttons(r).topx = 240
limbbuttons(r).botx = limbbuttons(r).width + 1
endif
if r > 240 and r < 281
limbbuttons(r).topx = 300
limbbuttons(r).botx = limbbuttons(r).width + 1
endif
limbbuttons(r).topy = y
limbbuttons(r).boty = y + limbbuttons(r).height
y = y + 17
n = n + 1
if n > 40
n = 1
y = 101
endif
next r
endfunction
the problem comes at lines 138-146 - principally line 140.... why?
am I misusing the dk pick limb command???
a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...