home *** CD-ROM | disk | FTP | other *** search
/ APDL Public Domain 1 / APDL_PD1A.iso / art_draw / 3d_tutor / 3DText < prev    next >
Encoding:
Text File  |  1991-12-09  |  7.7 KB  |  168 lines

  1. Since the 1980's, several films have been screened that feature 
  2. 3D vision. The effect can be quite fantastic - depending on the 
  3. technique used. Probably the most well known method is using the 
  4. red/green glasses, but this does have the disadvantage that 
  5. colour cannot be used. Another technique is using polarised 
  6. light. This requires two projectors which polarise the beams of 
  7. light differently (90° 'apart'). The glasses then block out one 
  8. of the beams by having polarised lenses. This is debatably the 
  9. most effective method, allowing full colour.
  10. Another form of three dimensional vision is to have a single 
  11. screen that flickers between the display for the left and right 
  12. eyes. The glasses are then synchronised to do the same. The Sega 
  13. system uses this form, but it suffers from a very flickery image.
  14. Because the average user does not have access to polarised light 
  15. projectors or 'flickery' glasses, the first method is a good 
  16. choice to demonstrate the 3D effect.
  17.  
  18. The first thing we must understand before we venture into the 
  19. world of 3D is how the eye perceives 'depth'. Our eyes, 
  20. surprisingly enough, move independently. They move so as to focus 
  21. in on an object.
  22. When an object is close to 'infinity' (as far away as possible) 
  23. our eyes are near parallel, that is point directly ahead and each 
  24. eyes' line of sight converges a long distance away. When our eyes 
  25. point near parallel, our brain assumes the object to be a long 
  26. way away.
  27. When an object is near, the eyes swing towards into other, 
  28. converging at a closer point. This can be seen when somebody 
  29. tries to look at their nose. If the eyes point inwards, our brain 
  30. believes the object to be close.
  31.  
  32. Now, how do we convert that theory onto the screen? Well, under 
  33. normal circumstances, each eyes' line of sight converges at the 
  34. screen. If an object is to be seen behind the monitor (further 
  35. away), we must instruct each eye to swing outwards, towards the 
  36. parallel. This can be expressed as : the left eye's image must be 
  37. further to the left, and the right eye's image must be further to 
  38. the right. From this, we should realise that the image passed to 
  39. the left eye should be on the left, and the image for the right 
  40. eye, on the right. Therefore, we can expect forward projections 
  41. (in front of the monitor) to have the right eye's image at the 
  42. left, and the left image at the right. This will make the lines 
  43. of sight converge before the screen.
  44.  
  45. Note however, that the distance between the left and right images 
  46. should not exceed the distance between each eye, otherwise the 3D 
  47. effect is lost. Indeed, due to the inability to exactly match the 
  48. colour of the glasses, a separation of about 32 OS units is all 
  49. we can expect.
  50.  
  51. Now is where the glasses come in - separating the left eye's 
  52. image and the right eye's. The lenses in each eye are a different 
  53. colour - normally red and green, or red and blue. The glasses I 
  54. used were red in the left eye and blue in the right. The same 
  55. glasses could possibly be obtained from your local cinema, as 
  56. they were used for the film, "Freddy's Dead". Anyway, one lens 
  57. will totally block out the colour of the other. Therefore, by 
  58. making the left image the colour of the left lens, and the right 
  59. image the colour of the right lens, it is possible to separate 
  60. the picture on the screen.
  61.  
  62. Probably the hardest part of creating a 3D image is finding the 
  63. exact colour of each lens. The simplest way of doing this is to 
  64. run listing one (found on the free subscription disc). It will 
  65. initially draw a red circle in the centre of the screen. Place a 
  66. lens over it and alter the colour (which is displayed as three 
  67. figures at the top of the screen) by using the keys as described. 
  68. When the circle appears as dark as possible in one lens, but is 
  69. still bright in the other, note down the colour numbers (and 
  70. which lens it was visible in) and repeat with the other lens. You 
  71. may find all this easier in a dark room.
  72.  
  73. An example of the sort of effect that can be achieved with the 
  74. information described here can be seen with listing two - a three 
  75. dimensional star field. Close all the curtains and doors - the 3D 
  76. effect can best be seen in total darkness - and run the program.
  77.  
  78. If you own a television, you will notice a poor effect, if any. 
  79. The only way to avoid this is to use a good quality PAL encoder, 
  80. or use a monitor. The better the quality of the monitor, the more 
  81. amazing the effect. If you can see 'ghosting', that is seeing 
  82. both red and blue (or whatever colours the lenses are) lines, try 
  83. moving away from the screen more - on a good multisync, it is 
  84. possible to sit normally at the computer and still see a clear 
  85. picture.
  86.  
  87. If you find stars a little boring, take a look at listing three. 
  88. This is the source code to create the module '3DPlotMod'. This 
  89. module provides one SWI that can be accessed from BASIC, or most 
  90. other languages. This function allows 3D vector graphics to be 
  91. produced, by passing the x,y and z coordinates. The appropriate 
  92. red and blue shapes will be drawn. To use it from BASIC, for 
  93. example, you should enter :
  94.  
  95. SYS "3D_Plot",plot action,x,y,z
  96.  
  97. x,y and z are the coordinates of the line, arc or whatever you 
  98. wish to draw. The plot action parameter is the same as for VDU25 
  99. (Plot). For those of you without PRM, here's a summary of the 
  100. codes :
  101.  
  102. All codes can be expressed as "<base> + <action>". the Base 
  103. number tells the computer what shap you wish to draw. Action 
  104. tells the computer how you want to draw it. The base values are 
  105. as follows :
  106.  
  107. 0 - draw a line, or move to the point
  108. 64 - plot a point
  109. 80 - draw a filled triangle
  110. 96 - draw a filled rectangle
  111. 112 - draw a filled parallelogram
  112. 144 - draw a circle outline
  113. 152 - draw a filled circle
  114. 160 - draw an arc
  115. 168 - draw a segment
  116. 176 - draw a sector
  117. 192 - draw an ellipse outline
  118. 200 - draw a filled ellipse
  119.  
  120. The action values that should be added to the above bases are as 
  121. follows :
  122.  
  123. 0 - move relative to the last position visited (MOVE BY)
  124. 1 - draw relative to the last position visited
  125. 4 - move to the given position
  126. 5 - draw at the given position
  127.  
  128. Codes 0 and 1 can be illustrated : If the last point you moved 
  129. (or drew) to was 400,600 and you issued a move by (value 0) 
  130. 100,-200 the new position would be 500,400.
  131.  
  132. As an example, let us draw a line from 300,676,375 to 274,607,374
  133. What you must do is :
  134. Move to one end ...
  135. SYS "3D_Plot",4,300,676,375
  136. And then draw a line to the other ...
  137. SYS "3D_Plot",5,274,607,374
  138.  
  139. To draw a more complex shape, such as a triangle, move to the two 
  140. corners and issue a 85 (ie. 80 + 5) for the final corner.
  141.  
  142. Listing four is a final summary of the ideas described here. It 
  143. contains the start-field from listing two, and adds a spinning 
  144. pyramid bouncing backwards and forwards.
  145. The pyramid is drawn in machine code for speed, and uses the 
  146. 3DPlotMod for the vector graphics. Note that to run this program, 
  147. you must have the Module 3DLines loaded - this can be achieved by 
  148. double-clicking on the 3DPlotMod icon in the desktop.
  149.  
  150. The application !3DSetup is a simple program that defines the 
  151. colours used for the left and right lenses. This can be used to 
  152. adjust the colours to suit you - everyones eyes' see light and 
  153. colour differently. Run the application as normal by double-
  154. clicking on its icon. Then, to change the left lens colour, press 
  155. 'L', or 'R' to change the right one.
  156. Then, follow the instructions on the screen. When you exit from 
  157. the program (not by pressing Escape), the settings you have 
  158. changed will be saved to disc. Note that this will not work if 
  159. you are running !3DSetUp from an archive, ie. follow the 
  160. instructions in the magazine on how to unpack the archive.
  161. From now on, all the programs will use these settings for their 
  162. colours.
  163.  
  164.   Many thanks to Vincent Sanders and the local cinema for their 
  165.   tremendous support for this project and their help with the 
  166.   research into 3D techniques.
  167.  
  168.