Posted: 21st Jun 2003 19:23
Note: This is not finished yet!

This is my first attempt at trying to make a mapping prog, like CShop. I hope I'll be able to finish it!

- 4 views, 3D, XZ, XY, ZY
- Drag out boxes to make level
- 3D navigation (hold dowm mouse on 3d screen for mouselook, arrow keys)
- Save (press space)
- Select box by clicking, delete by pressing delete
- Resize handles

Updated code below
+ Code Snippet
set display mode 800,600,32


sync rate 0
sync on
autocam off

position camera -150,150,0
point camera 0,0,0
set camera range 1,1000000
make matrix 1,10000,10000,100,100
position matrix 1,10000/-2,0,10000/-2


type rect
x1 as integer
x2 as integer
y1 as integer
y2 as integer
z1 as integer
z2 as integer
endtype

dim boxes(100000) as rect

ink rgb(0,0,255),0

xs = 800
ys = 600
xp = 80
yp = 60

`View 1 : XZ
st1x1 = 400
st1y1 = 0
st1x2 = 800
st1y2 = 300

`View 2 : XY
st2x1 = 400
st2y1 = 300
st2x2 = 800
st2y2 = 600

`View 3 : YZ
st3x1 = 0
st3y1 = 300
st3x2 = 400
st3y2 = 600

`View 4 : 3D
st4x1 = 0
st4y1 = 0
st4x2 = 400
st4y2 = 300

` Snap to Grid
ppx# = (xp * 1.0) / (xs * 1.0)
ppy# = (yp * 1.0) / (ys * 1.0)

` Defaults
CurrX1 = 10
CurrX2 = -10
CurrY1 = 10
CurrY2 = 00
CurrZ1 = 10
CurrZ2 = -10

` 3D view : camera
set camera view st4x1,st4y1,st4x2,st4y2

`Grid
grid1 = 65000
grid2 = 65001
make object box grid1,1000000,6,6
make object box grid2,6,6,1000000
color object grid1,rgb(200,0,0)
color object grid2,rgb(200,0,0)

do
  ` cls rgb(200,200,200)
  if mouseclick()=2 and (timer()-exitt) > 500 then goSub Place

  set cursor 0,10

  text 10,10,"FPS: "+str$(screen fps())

  if spacekey() then goSub SaveMap


  goSub Display1
  goSub Display2
  goSub Display3

  ` *-*
  sync

loop


Rem *** Include File: Function.dba ***
Rem Created: 21/06/03 14:27:42

Rem Included in Project: C:Program FilesDark Basic SoftwareDark Basic ProfessionalProjectsMiscdragableedit.dbpro

Function LB(x,y,x2,y2)
  line x,y,x2,y
  line x,y2,x2,y2
  line x,y,x,y2
  line x2,y,x2,y2
endfunction

Function Trans(value,pp#)
  value = int(value * pp#)*10
EndFunction value

Function Over(x,y,x2,y2)
  if mousex() > x and mousey() > y and mousex() < x2 and mousey() < y2 then over = 1 else over = 0
endfunction overRem *** Include File: Placement.dba ***
Rem Created: 21/06/03 14:27:59

Rem Included in Project: C:Program FilesDark Basic SoftwareDark Basic ProfessionalProjectsMiscdragableedit.dbpro
`---------------------------------------
Place:
  goSub Place1
  goSub Place2
  goSub Place3
  goSub Cam

return

Place1:
  If Over(st1x1,st1y1,st1x2,st1y2)=1
    StartX = Trans(mousex(),ppx#)
    StartY = Trans(mousey(),ppy#)

    goSub Drag

    if StartX = EndX and endy = starty then return

    jx = st1x2 - st1x1
    jy = st1y2 - st1y1

    Boxes(NumPlaced).X1 = StartX - st1x1 - (jx / 2)
    Boxes(NumPlaced).Y1 = CurrY1 * -1
    Boxes(NumPlaced).Z1 = StartY - st1y1 - (jy / 2)
    Boxes(NumPlaced).X2 = EndX - st1x1  - (jx / 2)
    Boxes(NumPlaced).Y2 = CurrY2 * -1
    Boxes(NumPlaced).Z2 = EndY - st1y1  - (jy / 2)

    `   input boxes(numplaced).x1,o
    `   input boxes(numplaced).z1,o
    `  input boxes(numplaced).x2,o
    `  input boxes(numplaced).z2,o

    goSub Add

    Inc NumPlaced


  endif

return

Place2:
  If Over(st2x1,st2y1,st2x2,st2y2)=1
    StartX = Trans(mousex(),ppx#)
    StartY = Trans(mousey(),ppy#)

    goSub Drag

    if StartX = EndX and endy = starty then return

    jx = st2x2 - st2x1
    jy = st2y2 - st2y1

    Boxes(NumPlaced).X1 = StartX - st2x1 - (jx / 2)
    Boxes(NumPlaced).Y1 = StartY - st2y1 - (jy / 2)
    Boxes(NumPlaced).Z1 = CurrZ1 * -1
    Boxes(NumPlaced).X2 = EndX - st2x1  - (jx / 2)
    Boxes(NumPlaced).Y2 = EndY - st2y1  - (jy / 2)
    Boxes(NumPlaced).Z2 = CurrZ2 * -1

    `   input boxes(numplaced).x1,o
    `   input boxes(numplaced).z1,o
    `  input boxes(numplaced).x2,o
    `  input boxes(numplaced).z2,o

    goSub Add

    Inc NumPlaced

  endif

return

Place3:
  If Over(st3x1,st3y1,st3x2,st3y2)=1
    StartX = Trans(mousex(),ppx#)
    StartY = Trans(mousey(),ppy#)

    goSub Drag

    if StartX = EndX and endy = starty then return

    jx = st3x2 - st3x1
    jy = st3y2 - st3y1

    Boxes(NumPlaced).X1 = CurrX1 * -1
    Boxes(NumPlaced).Y1 = StartY - st3y1 - (jy / 2)
    Boxes(NumPlaced).Z1 = StartX - st3x1 - (jx / 2)
    Boxes(NumPlaced).X2 = CurrX2 * -1
    Boxes(NumPlaced).Y2 = EndY - st3y1  - (jy / 2)
    Boxes(NumPlaced).Z2 = EndX - st3x1  - (jx / 2)

    `   input boxes(numplaced).x1,o
    `   input boxes(numplaced).z1,o
    `  input boxes(numplaced).x2,o
    `  input boxes(numplaced).z2,o

    goSub Add

    Inc NumPlaced

  endif

return


Cam:

  rem Control Cam view

  if Over(st4x1,st4y1,st4x2,st4y2)=1

    bx = mousex()
    by = mousey()

    cax = camera angle x()
    cay = camera angle y()

    while mouseclick()<>0

      inc cax,mousemovey()
      inc cay,mousemovex()

      rotate camera cax,cay,0

      position mouse bx,by

      if upkey()=1 then move camera 0.5
      if downkey()=1 then move camera -0.5

      sync

    endwhile

  endif

return

Add:

  width = Boxes(NumPlaced).X2 - Boxes(NumPlaced).X1
  height = Boxes(NumPlaced).Y2 - Boxes(NumPlaced).Y1
  depth = Boxes(NumPlaced).Z2 - Boxes(NumPlaced).Z1

  cls
  set cursor 0,250
  print width
  print height
  print depth
  print "-"
  print Boxes(NumPlaced).X1
  print Boxes(NumPlaced).Y1
  print Boxes(NumPlaced).Z1

  Make object box NumPlaced + 1,depth,height,width
  position object NumPlaced + 1, (Boxes(NumPlaced).Z1 + (0.5 * depth))*-1,(Boxes(NumPlaced).Y1+ (0.5 * height))*-1,(Boxes(NumPlaced).X1 + (0.5 * width))*-1

  set object cull NumPlaced+1,0


return

Drag:

  while mouseclick()<>0
    EndX = Trans(mousex(),ppx#)
    EndY = Trans(mousey(),ppy#)
    `  print endx
    `  print endy

    `cls rgb(200,200,200)

    DrawDotIt(st1x1,st1y1,st1x2,st1y2,"XZ")
    for b = 0 to NumPlaced
      lb(st1x1 + boxes(b).x1+jx,st1y1 + boxes(b).z1+jy,st1x1 + boxes(b).x2+jx,st1y1 + boxes(b).z2+jy)
      line st1x1 + boxes(b).x1+jx,st1y1 + boxes(b).z1+jy,st1x1 + boxes(b).x2+jx,st1y1 + boxes(b).z2+jy
    next b

    goSub display2
    goSub display3

    lb(StartX,StartY,EndX,EndY)


    sync

  endwhile

returnRem *** Include File: DisplayVIews.dba ***
Rem Created: 21/06/03 14:28:12

Rem Included in Project: C:Program FilesDark Basic SoftwareDark Basic ProfessionalProjectsMiscdragableedit.dbpro
Display1:

  DrawDotIt(st1x1,st1y1,st1x2,st1y2,"XZ")

  ink rgb(25,25,255),0

  jx = (st1x2 - st1x1)/2
  jy = (st1y2 - st1y1)/2

  for b = NumPlaced to 0 step -1
    if over(st1x1 + boxes(b).x1+jx,st1y1 + boxes(b).z1+jy,st1x1 + boxes(b).x2+jx,st1y1 + boxes(b).z2+jy)=1
      ink rgb(0,255,0),0
    else
      ink rgb(25,25,255),0
    endif
    lb(st1x1 + boxes(b).x1+jx,st1y1 + boxes(b).z1+jy,st1x1 + boxes(b).x2+jx,st1y1 + boxes(b).z2+jy)
    line st1x1 + boxes(b).x1+jx,st1y1 + boxes(b).z1+jy,st1x1 + boxes(b).x2+jx,st1y1 + boxes(b).z2+jy
    if over(st1x1 + boxes(b).x1+jx,st1y1 + boxes(b).z1+jy,st1x1 + boxes(b).x2+jx,st1y1 + boxes(b).z2+jy)=1 and mouseclick()=1
      Curr = b
      goSub resize1
    endif

  next b

return

Display2:

  DrawDotIt(st2x1,st2y1,st2x2,st2y2,"XY")

  ink rgb(25,25,255),0

  jx = (st1x2 - st1x1)/2
  jy = (st1y2 - st1y1)/2

  for b = NumPlaced to 0 step -1

    if over(st2x1 + boxes(b).x1+jx,st2y1 + boxes(b).y1+jy,st2x1 + boxes(b).x2+jx,st2y1 + boxes(b).y2+jy)=1
      ink rgb(0,255,0),0
    else
      ink rgb(25,25,255),0
    endif

    lb(st2x1 + boxes(b).x1+jx,st2y1 + boxes(b).y1+jy,st2x1 + boxes(b).x2+jx,st2y1 + boxes(b).y2+jy)
    line st2x1 + boxes(b).x1+jx,st2y1 + boxes(b).y1+jy,st2x1 + boxes(b).x2+jx,st2y1 + boxes(b).y2+jy

    if over(st2x1 + boxes(b).x1+jx,st2y1 + boxes(b).y1+jy,st2x1 + boxes(b).x2+jx,st2y1 + boxes(b).y2+jy)=1 and mouseclick()=1
      Curr = b
      goSub resize2
    endif

  next b

return

Display3:

  DrawDotIt(st3x1,st3y1,st3x2,st3y2,"ZY")

 ` ink rgb(25,25,255),0

  jx = (st3x2 - st3x1)/2
  jy = (st3y2 - st3y1)/2

  for b = NumPlaced to 0 step -1

    if over(st3x1 + boxes(b).z1+jx,st3y1 + boxes(b).y1+jy,st3x1 + boxes(b).z2+jx,st3y1 + boxes(b).y2+jy)=1
      ink rgb(0,255,0),0
    else
      ink rgb(25,25,255),0
    endif


    lb(st3x1 + boxes(b).z1+jx,st3y1 + boxes(b).y1+jy,st3x1 + boxes(b).z2+jx,st3y1 + boxes(b).y2+jy)
    line st3x1 + boxes(b).z1+jx,st3y1 + boxes(b).y1+jy,st3x1 + boxes(b).z2+jx,st3y1 + boxes(b).y2+jy


    if over(st3x1 + boxes(b).z1+jx,st3y1 + boxes(b).y1+jy,st3x1 + boxes(b).z2+jx,st3y1 + boxes(b).y2+jy)=1 and mouseclick()=1
      Curr = b
      goSub resize3
    endif

  next b
return


Function DrawDotIt(st1x1,st1y1,st1x2,st1y2,t$)

  rem Background
  ink rgb(200,200,200),0
  box st1x1,st1y1,st1x2,st1y2

  rem Border
  ink 0,0
  lb(st1x1 ,st1y1 ,st1x2 ,st1y2 )

  rem Lines - minor
  ink rgb(255,255,255),0
  for dx = st1x1+10 to st1x2 step 20
    for dy = st1y1+10 to st1y2 step 20
      line dx-10,dy,dx+10,dy
      line dx,dy-10,dx,dy+10
    next dy
  next dx

  rem Dots - minor
  ink rgb(110,110,110),0
  for dx = st1x1+10 to st1x2 step 10
    for dy = st1y1+10 to st1y2 step 10
      dot dx,dy
    next dy
  next dx

  rem Dots - major
  ink rgb(0,0,0),0
  for dx = st1x1+10 to st1x2 step 20
    for dy = st1y1+10 to st1y2 step 20
      dot dx,dy
    next dy
  next dx

  rem Root
  jx = (st1x2 - st1x1)/2
  jy = (st1y2 - st1y1)/2

  ink rgb(200,0,0),0
  line st1x1+jx,st1y1,st1x1+jx,st1y2
  line st1x1,st1y1+jy,st1x2,st1y1+jy

  rem Text Label
  ink rgb(0,0,200),0
  text st1x1+5,st1y1+5,t$

EndFunctionRem *** Include File: Save.dba ***
Rem Created: 21/06/03 16:45:52

Rem Included in Project: C:Program FilesDark Basic SoftwareDark Basic ProfessionalProjectsMiscdragableedit.dbpro
SaveMap:

  cls
  set cursor 10,400

  input "File name: ",n$

  open to write 1,n$

  write string 1,"Saved map from DTEdit"
  write string 1,"---------------------"

  for o = 0 to NumPlaced
    write file 1,Boxes(o).X1
    write file 1,Boxes(o).Y1
    write file 1,Boxes(o).Z1

    write file 1,Boxes(o).X2
    write file 1,Boxes(o).Y2
    write file 1,Boxes(o).Z2
  next o

  close file 1

returnRem *** Include File: Resize.dba ***
Rem Created: 21/06/03 18:46:08

Rem Included in Project: C:Program FilesDark Basic SoftwareDark Basic ProfessionalProjectsMiscdragableedit.dbpro
Resize1:
  ` Draw handles on edges
  x1 = st1x1 + boxes(curr).x1+jx
  y1 = st1y1 + boxes(curr).z1+jy
  x2 = st1x1 + boxes(curr).x2+jx
  y2 = st1y1 + boxes(curr).z2+jy

  do

    goSub updateothers


    if object exist(curr+1) and scancode()=211 then delete object curr+1


    ink rgb(0,200,0),0
    ` TL
    box x1-5,y1-5,x1+5,y1+5
    if over(x1-5,y1-5,x1+5,y1+5)=1 and mouseclick() = 1 then goSub SizeTL1

    ` TR
    box x2-5,y1-5,x2+5,y1+5
    if over(x2-5,y1-5,x2+5,y1+5)=1 and mouseclick() = 1 then goSub SizeTR1

    ` BL
    box x1-5,y2-5,x1+5,y2+5
    if over(x1-5,y2-5,x1+5,y2+5)=1 and mouseclick() = 1 then goSub SizeBL1

    ` BR
    box x2-5,y2-5,x2+5,y2+5
    if over(x2-5,y2-5,x2+5,y2+5)=1 and mouseclick() = 1 then goSub SizeBR1

    if upkey()=1 then dec y1 : dec y2
    if downkey()=1 then inc y1 : inc y2

    if scancode()=211 then array delete element boxes(0),curr : return

    `  set cursor 0,400
    `  print x1;".";y1;".";x2;".";y2
    `   if controlkey()=1 then exit




    if mouseclick() = 1 and over(x1,y1,x2,y2)=0 then exit

    sync

  loop



return

UpdateOthers:
  ` Draw others
  DrawDotIt(st1x1,st1y1,st1x2,st1y2,"XZ")
  for b = 0 to NumPlaced
    lb(st1x1 + boxes(b).x1+jx,st1y1 + boxes(b).z1+jy,st1x1 + boxes(b).x2+jx,st1y1 + boxes(b).z2+jy)
    line st1x1 + boxes(b).x1+jx,st1y1 + boxes(b).z1+jy,st1x1 + boxes(b).x2+jx,st1y1 + boxes(b).z2+jy
  next b

  DrawDotIt(st2x1,st2y1,st2x2,st2y2,"XY")
  ink rgb(25,25,255),0
  for b = 0 to NumPlaced
    lb(st2x1 + boxes(b).x1+jx,st2y1 + boxes(b).y1+jy,st2x1 + boxes(b).x2+jx,st2y1 + boxes(b).y2+jy)
    line st2x1 + boxes(b).x1+jx,st2y1 + boxes(b).y1+jy,st2x1 + boxes(b).x2+jx,st2y1 + boxes(b).y2+jy
  next b

  for b = NumPlaced to 0 step -1
    lb(st3x1 + boxes(b).z1+jx,st3y1 + boxes(b).y1+jy,st3x1 + boxes(b).z2+jx,st3y1 + boxes(b).y2+jy)
    line st3x1 + boxes(b).z1+jx,st3y1 + boxes(b).y1+jy,st3x1 + boxes(b).z2+jx,st3y1 + boxes(b).y2+jy
  next b
return

SizeTR1:
  sy1 = y1
  sx1 = x2
  goSub DragOutTR
  xdiff = rEndX - sx1
  ydiff = rEndY - sy1
  x2 = rEndX
  y1 = rEndY
  inc Boxes(curr).Z1,ydiff
  inc Boxes(curr).X2,xdiff
return

SizeTL1:
  sy1 = y1
  sx1 = x1
  goSub DragOutTL
  xdiff = rEndX - sx1
  ydiff = rEndY - sy1
  x1 = rEndX
  y1 = rEndY
  inc Boxes(curr).Z1,ydiff
  inc Boxes(curr).X1,xdiff
return

SizeBR1:
  sy1 = y2
  sx1 = x2
  goSub DragOutBR
  xdiff = rEndX - sx1
  ydiff = rEndY - sy1
  x2 = rEndX
  y2 = rEndY
  inc Boxes(curr).Z2,ydiff
  inc Boxes(curr).X2,xdiff
return

SizeBL1:
  sy1 = y2
  sx1 = x1
  goSub DragOutBL
  xdiff = rEndX - sx1
  ydiff = rEndY - sy1
  x1 = rEndX
  y2 = rEndY
  inc Boxes(curr).Z2,ydiff
  inc Boxes(curr).X1,xdiff
return

rem Subs for dragging/resizing shapes
DragOutTR:
  do
    rEndX = Trans(mousex(),ppx#)
    rEndY = Trans(mousey(),ppy#)
    goSub updateothers
    LB(x1,y2,rEndX,rEndY)
    if mouseclick()=0 then exit
    sync
  loop
return
DragOutTL:
  do
    rEndX = Trans(mousex(),ppx#)
    rEndY = Trans(mousey(),ppy#)
    goSub updateothers
    LB(x2,y2,rEndX,rEndY)
    if mouseclick()=0 then exit
    sync
  loop
return
DragOutBR:
  do
    rEndX = Trans(mousex(),ppx#)
    rEndY = Trans(mousey(),ppy#)
    goSub updateothers
    LB(x1,y1,rEndX,rEndY)
    if mouseclick()=0 then exit
    sync
  loop
return
DragOutBL:
  do
    rEndX = Trans(mousex(),ppx#)
    rEndY = Trans(mousey(),ppy#)
    goSub updateothers
    LB(x2,y1,rEndX,rEndY)
    if mouseclick()=0 then exit
    sync
  loop
return

rem ---------------------------------------------------------------------------------
rem                                    VIEW 2 RESIZE
rem ---------------------------------------------------------------------------------

Resize2:
  ` Draw handles on edges
  x1 = st2x1 + boxes(curr).x1+jx
  y1 = st2y1 + boxes(curr).y1+jy
  x2 = st2x1 + boxes(curr).x2+jx
  y2 = st2y1 + boxes(curr).y2+jy

  do

    goSub updateothers


    if object exist(curr+1) and scancode()=211 then delete object curr+1


    ink rgb(0,200,0),0
    ` TL
    box x1-5,y1-5,x1+5,y1+5
    if over(x1-5,y1-5,x1+5,y1+5)=1 and mouseclick() = 1 then goSub SizeTL2

    ` TR
    box x2-5,y1-5,x2+5,y1+5
    if over(x2-5,y1-5,x2+5,y1+5)=1 and mouseclick() = 1 then goSub SizeTR2

    ` BL
    box x1-5,y2-5,x1+5,y2+5
    if over(x1-5,y2-5,x1+5,y2+5)=1 and mouseclick() = 1 then goSub SizeBL2

    ` BR
    box x2-5,y2-5,x2+5,y2+5
    if over(x2-5,y2-5,x2+5,y2+5)=1 and mouseclick() = 1 then goSub SizeBR2

    if upkey()=1 then dec y1 : dec y2
    if downkey()=1 then inc y1 : inc y2

    if scancode()=211 then array delete element boxes(0),curr : return
    if mouseclick() = 1 and over(x1,y1,x2,y2)=0 then exit

    sync

  loop

return
REMSTART
---------------------------
HOW TO WORK OUT X/Y CO-ORDS
---------------------------

With X/Y view, X is X and Y is Y, pretty easy to remember.

    Boxes().X1 = StartX
    Boxes().Y1 = StartY
    Boxes().Z1 = n/a
    Boxes().X2 = EndX
    Boxes().Y2 = EndY
    Boxes().Z2 = n/a

REMEND


SizeTR2:
  sy1 = y1
  sx1 = x2
  goSub DragOutTR
  xdiff = rEndX - sx1
  ydiff = rEndY - sy1
  x2 = rEndX
  y1 = rEndY
  inc Boxes(curr).Y1,ydiff
  inc Boxes(curr).X2,xdiff
return

SizeTL2:
  sy1 = y1
  sx1 = x1
  goSub DragOutTL
  xdiff = rEndX - sx1
  ydiff = rEndY - sy1
  x1 = rEndX
  y1 = rEndY
  inc Boxes(curr).Y1,ydiff
  inc Boxes(curr).X1,xdiff
return

SizeBR2:
  sy1 = y2
  sx1 = x2
  goSub DragOutBR
  xdiff = rEndX - sx1
  ydiff = rEndY - sy1
  x2 = rEndX
  y2 = rEndY
  inc Boxes(curr).Y2,ydiff
  inc Boxes(curr).X2,xdiff
return

SizeBL2:
  sy1 = y2
  sx1 = x1
  goSub DragOutBL
  xdiff = rEndX - sx1
  ydiff = rEndY - sy1
  x1 = rEndX
  y2 = rEndY
  inc Boxes(curr).Y2,ydiff
  inc Boxes(curr).X1,xdiff
return

rem ---------------------------------------------------------------------------------
rem                                    VIEW 3 RESIZE
rem ---------------------------------------------------------------------------------

Resize3:
  ` Draw handles on edges
  x1 = st3x1 + boxes(curr).z1+jx
  y1 = st3y1 + boxes(curr).y1+jy
  x2 = st3x1 + boxes(curr).z2+jx
  y2 = st3y1 + boxes(curr).y2+jy

  do

    goSub updateothers


    if object exist(curr+1) and scancode()=211 then delete object curr+1


    ink rgb(0,200,0),0
    ` TL
    box x1-5,y1-5,x1+5,y1+5
    if over(x1-5,y1-5,x1+5,y1+5)=1 and mouseclick() = 1 then goSub SizeTL3

    ` TR
    box x2-5,y1-5,x2+5,y1+5
    if over(x2-5,y1-5,x2+5,y1+5)=1 and mouseclick() = 1 then goSub SizeTR3

    ` BL
    box x1-5,y2-5,x1+5,y2+5
    if over(x1-5,y2-5,x1+5,y2+5)=1 and mouseclick() = 1 then goSub SizeBL3

    ` BR
    box x2-5,y2-5,x2+5,y2+5
    if over(x2-5,y2-5,x2+5,y2+5)=1 and mouseclick() = 1 then goSub SizeBR3

    if upkey()=1 then dec y1 : dec y2
    if downkey()=1 then inc y1 : inc y2

    if scancode()=211 then array delete element boxes(0),curr : return
    if mouseclick() = 1 and over(x1,y1,x2,y2)=0 then exit

    sync

  loop

return
REMSTART
---------------------------
HOW TO WORK OUT Z/Y CO-ORDS
---------------------------

With Z/Y view, X co-ords are Z and Y is Y

    Boxes().X1 = n/a
    Boxes().Y1 = StartY
    Boxes().Z1 = StartX
    Boxes().X2 = n/a
    Boxes().Y2 = EndY
    Boxes().Z2 = EndX

REMEND


SizeTR3:
  sy1 = y1
  sx1 = x2
  goSub DragOutTR
  xdiff = rEndX - sx1
  ydiff = rEndY - sy1
  x2 = rEndX
  y1 = rEndY
  inc Boxes(curr).Y1,ydiff
  inc Boxes(curr).Z2,xdiff
return

SizeTL3:
  sy1 = y1
  sx1 = x1
  goSub DragOutTL
  xdiff = rEndX - sx1
  ydiff = rEndY - sy1
  x1 = rEndX
  y1 = rEndY
  inc Boxes(curr).Y1,ydiff
  inc Boxes(curr).Z1,xdiff
return

SizeBR3:
  sy1 = y2
  sx1 = x2
  goSub DragOutBR
  xdiff = rEndX - sx1
  ydiff = rEndY - sy1
  x2 = rEndX
  y2 = rEndY
  inc Boxes(curr).Y2,ydiff
  inc Boxes(curr).Z2,xdiff
return

SizeBL3:
  sy1 = y2
  sx1 = x1
  goSub DragOutBL
  xdiff = rEndX - sx1
  ydiff = rEndY - sy1
  x1 = rEndX
  y2 = rEndY
  inc Boxes(curr).Y2,ydiff
  inc Boxes(curr).Z1,xdiff
return



Run as 800 x 600. The code should set this. Recommended running in window.


To be put in:
- Moving boxes while being dragged
- Some sort of GUI
- Exporting to a common format
- Texturing


There may be some quirs and bugs, plus some of the source if uncommented and very tricky!

If only I could fit it into 20 lines - I might even win something then!
Posted: 21st Jun 2003 20:28
Nice , this could be really cool when you finish it.

You might want to have a look at the origninal CShop. I think it was made in DB. The source code is available, I had it some where...
Posted: 21st Jun 2003 20:29
David89
this is great
please keep us informed of your progres.

one thing,i only got two views

dave
Posted: 21st Jun 2003 21:13
You might want to have a look at the origninal CShop. I think it was made in DB. The source code is available, I had it some where...


Really? I know CShop was written in Blitz, but I though Josh Klint was licensing out the code (I'll ask on the CS forums).

David89
this is great
please keep us informed of your progres.

one thing,i only got two views

dave


There are actually 3 including the 3D view, only 2 are 2D.

I might be able to upload an updated version source version tonight, with fixed placement and maybe a 3rd view. And resizing if you're really, really lucky!
Posted: 21st Jun 2003 22:23
i'le keep my fingers crosed

dave
Posted: 22nd Jun 2003 0:05
Nice,
I'll be interested to see how it developes and what sort of 'Save and Export' functions it has.. Keep at it,

gbuilder.
Posted: 22nd Jun 2003 0:12
thats a great snippet when the csg commands into play
Posted: 22nd Jun 2003 0:32
Hi all,



Thank for all the comments.

I've just got a 3rd viewport in, plus object selectionj an deleting objects. However, I still can't get the resizing working just right

I'll upload the code later tonight.
Posted: 22nd Jun 2003 1:10
Updated Source - 4 viewports, object selection, save (press space and type name - no load yet), object deletion (press delete when selected, larger resolution, general improvements.

Code below, no media needed.
Posted: 22nd Jun 2003 1:12
Here's a pic of what I've got so far
Posted: 22nd Jun 2003 1:45
Unable to draw boxes now for some reason..

gbuilder.
Posted: 22nd Jun 2003 1:55
same as gbuilder

Unable to draw boxes

dave

just found that if you click both mouse
buttons together then you can now draw
boxes,hope that helps

dave
Posted: 22nd Jun 2003 7:43
Yep, that's it both buttons now (I think I preferred just one).
What would be useful is 'handles' on the box ends for shaping.

gbuilder.
Posted: 22nd Jun 2003 12:37
@David89

I was talking about the very first version of cshop. It's very similar to yours. It exported the collision data to a *.txt file and created a *.asc file which could then be converted to an *.x in a program like 3d exploration.

This was for DBC, so with DBPro you would need to export collision information, just the object file. Are you planning on making it work with any angle, not just 90 degree boxes?

As for the old cshop, you could search for it on google, though I managed to find it along time ago, it might not be there anymore.

Just some ideas
A tool which allows you to carve one object out of another (like in hammer). Though as far as I can see it would be next to impossible.
Some sort of menu. I remember in the old cshop there were lots of commands like Ctrl+S for save and it got confusing.

Good Luck!
Posted: 22nd Jun 2003 16:44
A tool which allows you to carve one object out of another (like in hammer).

patch 5 csg commands will cover that like a charm


Some sort of menu. I remember in the old cshop there were lots of commands like Ctrl+S for save and it got confusing.

make your own or use the brilliant LMS Lightweight menu system by scofflaw? i forget who.
Posted: 25th Jun 2003 0:50
any news David89
i cant contact you,web site down
i wonderd if you could post a comented version of what
you have done with this so far.
thanks

dave
Posted: 28th Jun 2003 12:53
Hi Everybody. I've been away for a week (and forgot to tell you ) but I've been following this thread on my smartphone (Pocket Internet Explorer).

Yep, that's it both buttons now (I think I preferred just one).
What would be useful is 'handles' on the box ends for shaping.


Click on an object to get handles. However resizing isn't in yet.
The reason is is now both buttons is because you can also select a box by clicking the LMB. Having two checks in the same loop causes everthing to get a bit mucked up, so it's either LMB for drawing and RMB for select, or the other way round.

Some sort of menu. I remember in the old cshop there were lots of commands like Ctrl+S for save and it got confusing.

make your own or use the brilliant LMS Lightweight menu system by scofflaw? i forget who.


You may have noticed this is in Code Snippets, not beta announcements because it is a code snippet. I might consider developing it further. I probably will, but it's still a snippet!


i cant contact you,web site down
i wonderd if you could post a comented version of what


I haven't made my email public, so naturally you should have trouble contacting me however my web site shouldn't be down. I'll check right away.
Posted: 28th Jun 2003 15:58
just read the post and can't wait for it to be finished, looks cool m8, BTW RobK has also made a menu system. It's somewhere on the RGT DLL forums but I haven't got a link.
Posted: 28th Jun 2003 16:09
just a suggestion:

You should put it into a window, don't know about you but I can't stand a program that's not in a window.
Posted: 28th Jun 2003 21:03
just a suggestion:

You should put it into a window, don't know about you but I can't stand a program that's not in a window.


Just a suggestion: as this is a code snippet paste it into DBP and put it in a window yourself. I'm sorry if that was a bit abrupt but that is the way to put it in a window, after all


Plus, once again, this is a code snippet! Don't assume it will be finished! I hope to but I've mainly posted it to show people how to create something similar. But knowing all of you you just want a map editor