home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 63 / CDACTUAL63.iso / Aplicaciones / DarkBasic / DemoDarkBasic.exe / help / examples / basic3d / exam04.dba < prev    next >
Encoding:
Text File  |  2000-05-17  |  3.7 KB  |  160 lines

  1. Rem * Title  : Models From Scratch
  2. Rem * Author : DBS-LB
  3. Rem * Date   : 1st Sept 99
  4. rem ===============================================
  5. rem DARK BASIC EXAMPLE PROGRAM 4
  6. rem ===============================================
  7. rem This program makes new models from scratch
  8. rem -----------------------------------------------
  9.  
  10. rem Load a mesh into memory
  11. load mesh "mesh.x",1
  12.  
  13. rem Load image for use as texture
  14. load bitmap "floor1.bmp",1
  15. get image 1,0,0,128,128
  16. delete bitmap 1
  17.  
  18. rem Make object from one mesh and one texture
  19. make object 1,1,1
  20.  
  21. rem Delete mesh from memory
  22. delete mesh 1
  23.  
  24. rem Scale object to make it much bigger
  25. scale object 1,10000,10000,10000
  26.  
  27. rem Position object to one side
  28. position object 1,-250,0,0
  29.  
  30. rem Make and position a sphere object
  31. make object sphere 2,75
  32. position object 2,-150,0,0
  33.  
  34. rem Make and position a cube object
  35. make object cube 3,75
  36. position object 3,-50,0,0
  37.  
  38. rem Replace cube with box and position a box object
  39. delete object 3
  40. make object box 3,75,75,75
  41. position object 3,-50,0,0
  42.  
  43. rem Make and position a cylinder object
  44. make object cylinder 4,75
  45. position object 4,50,0,0
  46.  
  47. rem Make and position a cone object
  48. make object cone 5,75
  49. position object 5,150,0,0
  50.  
  51. rem Make and position a plain object
  52. make object plain 6,75,75
  53. position object 6,250,0,0
  54.  
  55. rem Make and position a triangle object
  56. make object triangle 7,0,0,0,0,100,0,100,0,0
  57. position object 7,350,0,0
  58.  
  59. rem Reposition camera to see them all
  60. position camera 0,200,-500
  61.  
  62. rem Deactivate autobackdrop
  63. backdrop off
  64.  
  65. rem Scroll through object data for each one
  66. for o=1 to 8
  67.  
  68. rem Clear the screen
  69. cls
  70.  
  71. rem Texture each object as view it
  72. if object exist(o)=1 then texture object o,1
  73.  
  74. rem Print information about object
  75. print "Object Information"
  76. print "------------------"
  77. print
  78. print "Object Number:";o
  79. print
  80. if object exist(o)=1
  81.     print "total object frames = ";total object frames(o)
  82.     print "object position x = ";object position x(o)
  83.     print "object position y = ";object position y(o)
  84.     print "object position z = ";object position z(o)
  85.     print "object angle x = ";object angle x(o)
  86.     print "object angle y = ";object angle y(o)
  87.     print "object angle z = ";object angle z(o)
  88.     print "object visible = ";object visible(o)
  89.     print "object playing = ";object playing(o)
  90.     print "object looping = ";object looping(o)
  91.     print "object frame = ";object frame(o)
  92.     print "object speed = ";object speed(o)
  93.     print "object interpolation= ";object interpolation(o)
  94. else
  95.     print "object does not exist!"
  96. endif
  97.  
  98. rem User prompt
  99. print
  100. print "Press any key"
  101. suspend for key
  102.  
  103. Rem Complete next loop
  104. next o
  105.  
  106. rem Delete all six objects
  107. for o=1 to 7 : delete object o : next o
  108.  
  109. rem ** Putting it all together **
  110. backdrop on
  111. color backdrop rgb(255,0,0)
  112.  
  113. rem Make rod mesh
  114. make object box 1,10,100,10
  115. make mesh from object 1,1
  116. delete object 1
  117.  
  118. rem Make robot arm limbs
  119. make object cone 1,100
  120. add limb 1,1,1
  121. add limb 1,2,1
  122. add limb 1,3,1
  123. add limb 1,4,1
  124. add limb 1,5,1
  125.  
  126. rem Place camera
  127. position camera 0,0,-500
  128. point camera 0,0,0
  129.  
  130. rem Link all limbs based on a robotic arm
  131. offset limb 1,1,0,50,0
  132. link limb 1,2,1
  133. offset limb 1,2,0,50,0
  134. link limb 1,3,2
  135. offset limb 1,3,0,50,0
  136. link limb 1,4,3
  137. offset limb 1,4,0,50,0
  138.  
  139. rem The last limb is a magnet block
  140. link limb 1,5,4
  141. scale limb 1,5,200,50,200
  142. offset limb 1,5,0,50,0
  143.  
  144. rem Manual sync loop
  145. sync on
  146. do
  147.  
  148. rem Use mouse position to affect limb rotations
  149. rotate limb 1,0,0,wrapvalue(220-(mousex()/8)),0
  150. rotate limb 1,1,wrapvalue(5+(mousey()/12)),0,0
  151. rotate limb 1,2,wrapvalue(5+(mousey()/12)),0,0
  152. rotate limb 1,3,wrapvalue(5+(mousey()/12)),0,0
  153. rotate limb 1,4,wrapvalue(5+(mousey()/12)),0,0
  154.  
  155. rem Update screen
  156. sync
  157.  
  158. rem End loop
  159. loop
  160.