home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / demos / gemini / Docs / GeminiSpec < prev   
Encoding:
Text File  |  1996-09-03  |  36.3 KB  |  717 lines

  1. Gemini
  2. ======
  3. version     : 0.99
  4. questions to: Giancarlo Castagno (s64922@galileo.polito.it)
  5. disabled    : this version still doesn't have transparencies
  6.  
  7. © 1996 Sincronia Soluzioni Multimediali, Italy
  8.   It cannot be used without the written permission of Sincronia
  9.  
  10. Here follows a description of Gemini, the new graphic engine that will be used
  11. by TopModel. It is a piece of code to be loaded and shared across all the
  12. applications that need 3D visualisation. It is a module that enables users to
  13. display and navigate in a 3D scene.
  14. Gemini can be run also on older machines (pre RiscPC, without dynamic areas).
  15. Applications that use a certain version of it will work with all the future
  16. versions. Module upgrades will offer automatic file loading and a common wimp
  17. interface, like the Acorn !ColourPicker one.
  18.  
  19. Gemini environment:
  20. ===================
  21.  
  22. Gemini is basically a collection of routines to manage a 3D database and render
  23. it both on the screen or to a memory area (to create a sprite), plus some
  24. tables of precalculated datas (1/x, sin(x), 1/SQR(x) and so on). If you need to
  25. know how to use them not to duplicate informations (i.e. if you need to use
  26. them too), just ask me...
  27. All the relevant informations on how to render the files are stored within the
  28. application using it.That's why it can be shared istantly beetween applications.
  29. Gemini is really simple to use, as it only has three main calls: one for
  30. initialise it, one to set the workarea and one to draw the whole scene. The
  31. tricky part of the system are the memory areas used to make it work. You can
  32. simply set them big enough (read the following instructions), without bother
  33. why they are needed. I prefer to explain you clearly how the whole system works
  34. and what are the main memory areas used...
  35.  
  36. A 3D file is made of 2 separated database, for speed & memory needs: a points
  37. database, which contains all the points used by the model (X,Y,Z of the point
  38. plus some infos) and a primitives database, that contains the description of
  39. each primitive (polygon, sphere or Bezier line/surface) used. For example, this
  40. is a GEO file format which describes a cube that can be used to provide a good
  41. example of how the data bases work:
  42.  
  43. 8                    | total number of points
  44. 0 0 0                | points 0: X Y Z
  45. 1 0 0                | points 1: X Y Z
  46. 1 1 0                | ...
  47. 0 1 0                | ...
  48. 0 0 1                |
  49. 1 0 1                |
  50. 1 1 1                |
  51. 0 1 1                |
  52.                      |
  53. 4 0 1 2 3            | polygon of 4 sides, connecting points 0,1,2,3
  54. 4 7 6 5 4            | polygon of 4 sides, connecting points 7,6,5,4
  55. 4 0 4 5 1            | ...
  56. ...                  | ...
  57.  
  58. Obviousely TopModel files use the ldm of a point instead of its number, but
  59. basically this is the structure. It allows to share points between polygons
  60. (a cube uses 8 points and 6 polygons, instead of 24 points (4 for each poly)
  61. and 6 polygons).
  62. A TopModel file is basically a memory dump of these two TopModel work areas,
  63. plus some other informations (for example the minimum size of each area).
  64. So, before loading a file (looks at the basic program to know how to load a
  65. TopModel file), you have to reserve enough workspace for it. If you want to
  66. speed up things, you can simply reserve a memory area as big as the 3Dfile
  67. size, (plus 2/3 Kbytes for security...). The areas can be stored within your
  68. application workspace or in a dynamic area, and can be two different areas or
  69. only one splitted. Gemini needs only to know where Points and Primitives areas
  70. start in memory.
  71.  
  72. Please note: you must reserve 58 points (32 bytes each, so 58*32 bytes) at the
  73. start of the Points area, used for control (axis, and so on). So, once you have
  74. dimensioning enough workspace for points, starting from an ldm stored in the
  75. variable PointsLDM, you should load the Points informations of the file at
  76. PointsLDM+58*32. Anyway see the Basic program: it will clarify all.
  77. The PROCload_topmodel(PointsLDM [+58*32], PrimitivesLDM) is used to load a
  78. TopModel 3D file. Once you have loaded it, this procedure also tells you which
  79. is the first location, both in the Points and in the Primitives workareas that
  80. is free (i.e. how much memory has been used in each portion of the database).
  81. If you want to merge two 3D files (to add objects to your scene), you have just
  82. to load another file passing to the procedure the first free location of both
  83. the work areas (i.e. you have to append in memory the file to the existing one).
  84. All will work automatically.
  85.  
  86. There are another memory area to store the main resources: a table of presetted
  87. (plus user defined) colours and materials definition plus a table for textures
  88. setup. Both the ASCII files containing the presetted colours and materials are
  89. contained in the same Resource folder of Gemini.
  90.   TopModel (and Gemini) manages 512 colours, (up to 200 presetted and up to 311
  91.   user defined). Each colour uses 16 bytes (0-11 for the name and 12-15 for the
  92.   &BBGGRR00 of the colour palette). So you have to reserve a 512*16 bytes for
  93.   the colour table. In the same way TopModel stores also the 256 materials
  94.   (up to 100 predefined and up to 155 user defined). Each material uses 32 bytes
  95.   (0-11 for the name 12-31 for material definition). Thus you have to reserve
  96.   256*32 bytes for the material table. In this area you should also store the
  97.   texture information table. Gemini manages up to 512 textures and each entry in
  98.   table is 16 bytes long, so you have to reserve another 512*16 bytes.
  99.   Texture 0 is reserved to say "No texture", so its values in the table should
  100.   always remains 0; the first valid texture entry is at the offset +16. The
  101.   entry for each texture are:
  102.     +0 =ldm of the sprite in memory;
  103.     +4 =X dimension of the sprite (pixel);
  104.     +8 =Y dimension of the sprite (pixel);
  105.     +12=2^29 (or colour to be made transparent).
  106.   Finally this buffer holds also group datas. Gemini allows up to 2048 groups to
  107.   be defined, and each of them uses 8 bytes. Thus this area needs 2048*8 bytes.
  108.   When you call Gemini_Initialise for the first time, it should fill this area
  109.   with the predefined materials and colours and zeroes the textures and groups tables.
  110.   So set the bit 1 int the flag word (R4). After these, every file may contain some
  111.   colours or materials created by user. These should be loaded from offset 200 for
  112.   colours and 100 for materials. Look at the PROCload_topmodel() to see how they are
  113.   loaded. The total size of the area is 40960 bytes (512*16+256*32+512*16+2048*8).
  114.  
  115. After that you should create a normal sprite area defined in RiscOS, in which
  116. you have to load the textures used, taking them from inside the Resources
  117. folder. In the file you find the path of each texture used inside the
  118. "!TopRes.texture" directory. Look at the PROCload_topmodel() to see how
  119. textures are loaded. You may need to use !ChangeFSI if the textures aren't
  120. 16bpp RiscOS Sprites, as Gemini can manage only them; once loaded you should
  121. set the corrispondent table entry with the texture ldm and dimensions.).
  122. If you want to discard textures, simply don't load them, leaving the texture
  123. table filled with 0s.
  124.  
  125. Then you have to reserve some memory for the Z buffer. The amount depends upon
  126. the size of the image to be created. Gemini uses 4 bytes for each pixel of the
  127. image. Finally there is the image buffer. You can plot directly on the screen,
  128. and in this case you don't have to dimension nothing, or you may want to plot
  129. to sprite. In this case you need as much memory as the one required to store
  130. a normal RiscOS sprite in that resolution and number of colours (but without
  131. the header).
  132.  
  133. To sum up: you have to set 5or6 work areas:
  134.   1) Points     workarea (the file contains the minimum size)
  135.   2) Primitives workarea (the file contains the minimum size)
  136.   3) Colours+Material+Textures+Groups table (40960 bytes (512*16+256*32+512*16+16384))
  137.   4) Texture sprite area (big enough to load all the 16bpp sprites)
  138.   5) Z buffer (4 bytes for each pixel of the image)
  139.   6) image buffer (if you aren't plotting to the screen): the same size
  140.      of a RiscOS sprite
  141.  
  142. Obviously you can store all of them in a single area or split them on several
  143. segments. Note: ALL THEM MUST BE WORD ALIGNED!
  144.  
  145. Now Gemini is ready to work happily within your application.
  146. There are three main blocks of informations to drive Gemini engine.
  147. I call them TMmemoryblock, TMviewblock, TMcolourblock.
  148.  
  149.   TMmemoryblock (256 bytes)
  150.   -------------------------
  151.     it contains the relevant memory information for Gemini. Some of the
  152.     locations are updated, some other are filled with ldm of tables of
  153.     precalculated datas. These must be filled:
  154.  
  155.     +0  ldm start of Points workspace
  156.     +8  dimension of Points workarea in bytes (but currently unused)
  157.     +12 ldm start of Primitives workspace
  158.     +20 dimension of Primitives workarea in bytes (but currently unused)
  159.     +40 ldm start of Z buffer
  160.     +44 ldm colours+materials+textures+groups table
  161.  
  162.  
  163.     Other relevan values, set by "Gemini_Initialise", when you call it with
  164.     bit 0 (of the flag word) set, are:
  165.  
  166.     +4  first free location in Points workspace (where to load Points from
  167.         file). Updated when loading the file (or editing it).
  168.     +16 first free location in Primitives workspace (where to load Points
  169.         from file). Updated when loading the file (or editing it).
  170.     free location of Primitives and Points workarea. When no object is loaded,
  171.     the default values are: TMmemoryblock!4 =TMmemoryblock!0 +58*32
  172.                             TMmemoryblock!16=TMmemoryblock!12
  173.     +52 ldm texture table
  174.     +64 ldm materials table
  175.     These two are used by Gemini to speed up things. Instead of recalculating each time
  176.     the ldm of the start of each area, Gemini simply calculates them once when a
  177.     "Gemini_Initialise" is called, storing the start ldm of textures, materials and groups
  178.     tables out of the address you pass in +44.
  179.     Simply: +44 colours+materials+textures+groups table; this is also the ldm of
  180.                                             the start of colour area:  512*16 bytes
  181.             +52 texture table:       (previous ldm + 512*16); it uses  256*32 bytes
  182.             +64 materials table:     (previous ldm + 256*32); it uses  512*16 bytes
  183.             +68 groups table:        (previous ldm + 512*16); it uses 2048*8  bytes
  184.  
  185.   TMviewblock (256 bytes)
  186.   -----------------------
  187.     it contains all the relevant parameters to drive the shading process. Some
  188.     locations are updated and some others are filled with some infos about the
  189.     current screen modes and so on. For a full list, ask me. The values
  190.     inside [] are the default values set when you call "Gemini_Initialise"
  191.  
  192.     +0   Z angle of view *16 (so 0 <= Zangle <= 360*16).To rotate around Z
  193.                                                                    [ 0*16]
  194.     +4   Y angle of view *16 (so 0 <= Yangle <= 360*16).To rotate around Y
  195.                                                                    [90*16]
  196.     +8   0 (for the X angle, but currently unused)                 [ 0*16]
  197.     +12  X position of the observer (*2^17) To pan around          [ 0*2^17]
  198.     +16  Y position of the observer (*2^17)                        [ 0*2^17]
  199.     +20  Z position of the observer (*2^17)                        [ 0*2^17]
  200.     +24  current OS version (currently unused)
  201.     +28  zoom factor *2^10 ( 1*2^10 =100%)   Note: (0 <= zoom <= 64*2^10)
  202.                                                                    [ 5*2^10]
  203.     +44  distance observer-plane of projection (*2^17). Used to alter the
  204.          perspective deformation (works just in perspective...)    [10*2^17]
  205.     +100 Linear FOG intensity   (*2^14), to alter the density of the bank of
  206.          fog. (0 <= intensity <= 4*2^14)                           [ 1*2^14]
  207.     +104 Z coordinates at which the fog starts (*2^17). Used to decrease the
  208.          fog with the altitude.                                    [ 0*2^17]
  209.     +108 Z intensity of the fog (*2^14), to alter the Z height of the fog.
  210.          (0 <= height <= 4*2^14)                                   [ 1*2^14]
  211.     +112 Sun light X direction (the X component of the normal giving the
  212.          direction of the sun light)                               [ 0*2^15]
  213.     +116 Sun light Y direction                                     [ 0*2^15]
  214.     +120 Sun light Z direction                                     [ 1*2^15]
  215.     +124 Sun light intensity       (0..1 *2^16)                    [ 1*2^16]
  216.     +128 Sun light colour          (&BBGGRR00)                     [&FFFFFF00]
  217.     +132 Ambiental light intensity (0..1 *2^16)                    [ 0*2^16]
  218.     +136 Ambiental light colour    (&BBGGRR00)                     [&FFFFFF00]
  219.     +140 "Illumination has changed" flag                           [255    ]
  220.     +144 Gemini_version
  221.     +156 "Colours have changed" flag                               [255    ]
  222.     +172 precision in drawing a bezier curve   (1=high...6=low)    [3      ]
  223.     +176 precision in drawing a bezier surface (1=high...6=low)    [5      ]
  224.  
  225.   TMcolourblock (256+1024*4 bytes)
  226.     it contains all the colours used in the Gemini environment. They are stored
  227.     separately, because Gemini recalculates them each time a user change
  228.     graphic mode. The 1024*4 additional bytes are used to store a table of user
  229.     defined lights. See later. Each colour entry uses 8 bytes; 4 for &BBGGRR00
  230.     of the colour and the second 4bytes to store the translated colour for the
  231.     current graphic mode. The values inside [] are the default values set when
  232.     you call "Gemini_Initialise".
  233.     Once Gemini is running, if you want to change a colour (say the fog colour)
  234.     just alter the corrispondent location with the new palette entry and then
  235.     inform Gemini that you have changed colour setting TMviewblock!156 to a
  236.     value different from 0. Gemini will recalculate the new colour table next
  237.     time a "Gemini_Render" call is issued and zeroes this location (+156) on exit.
  238.  
  239.     +0   Background colour (or sky start,for shaded background)    [&AA999900]
  240.     +8   Active plane colour                                       [&00FFFF00]
  241.     +16  Active axis colour                                        [&0000FF00]
  242.     +24  Fog colour                                                [&AA999900]
  243.     +32  Sky end colour      (if user wants a shaded background)   [&FF000000]
  244.     +40  Ground start colour (if user wants a shaded background)   [&BF444400]
  245.     +48  Ground end colour   (if user wants a shaded background)   [&00FF2200]
  246.     +56  Bezier visual-hull lines colour                           [&FFD53B00]
  247.     +64  Polygons' vertices colour                                 [&00FFA000]
  248.     +72  Bezier control-points colour                              [&FF000000]
  249.     +80  Selected points colour                                    [&0000FF00]
  250.  
  251.  
  252. Please note: Gemini, apart from the lights stored within a TopModel file, works
  253.  with two ever present lights: a general sun light and an ambiental one (as you
  254.  see from the structure of TMviewblock). To disable them just set their
  255.  intensity to 0. If you want to light the scene frontally, you should set the
  256.  sun beam direction (TMviewblock!112,116,120) to the values contained in
  257.  TMviewblock!48,52,56 respectively, which hold the current view vector. After
  258.  this you should inform Gemini that illumination has changed, setting
  259.  TMviewblock!140 to a value different from 0. In this way, next time you issue
  260.  a Gemini_Render call, Gemini will recalculate illumination before drawing the
  261.  scene. Gemini will automatically zeroes this location on exit.
  262.  
  263.  
  264. Now let's come to the Gemini calls.
  265. First of all you must initialise your workareas (TMmemory and view blocks):
  266.  
  267. SYS"Gemini_Initialise"
  268. ----------------------
  269. R0 = TMmemoryblock
  270. R1 = TMviewblock
  271. R2 = TMcolourblock
  272. R4 = flag
  273.  
  274. On exit, this call also returns the Gemini version number*100, in TMviewblock!144
  275. The R4 register contains the flag word:
  276.  Bit   Meaning if set   [meaning if not set]
  277. -------------------------------------------------------------------------------------------
  278.    0  | Initialise Points&Primitives workarea and zeroes textures and groups tables [don't]
  279.    1  | Reset colour&material table loading the default colours and materials
  280.    2  | Reset TMviewblock & TMcolourblock entries to their defaul values
  281.  3-31 | reserved - fill with 0
  282.  
  283. The first time you call "Gemini_Initialise" you should set R4 to 7 (set bits 0-2)
  284. This loads the colour and material default definitions and clear the scene, filling
  285. with 0s the texture table and setting the right values in the first 58 points.
  286. It also updates the Point's and Primitive's first free ldm (TMmemory+4 and +16).
  287. In this way, when you issue a Gemini_Render call, after this, Gemini will display
  288. just the axis in the centre of the workarea.
  289. Then you can call "Gemini_Initialise" each time you need to reset your scene (delete
  290. the objects inside) setting R4 to 1.
  291.  
  292.  
  293.  
  294.  
  295. SYS"Gemini_InitScene"
  296. ---------------------
  297. When you have loaded a file you have to adjust all its internal links (i.e. the
  298. ldm of the points used by the polygons); usually you can do it inside the loader
  299. code (the PROCload_topmodel). See the basic code to see how it is implemented.
  300.  
  301. R1 = offset to add to the points
  302.        [(current location at which points are loaded in memory)-(the old location
  303.          from where they were saved, stored in the file)]
  304. R2 = offset to add to the primitives
  305.        [idem]
  306. R3 = location at which points     are loaded (TMmemoryblock!4 , mostly)
  307. R4 = location at which primitives are loaded (TMmemoryblock!16, mostly)
  308.  
  309.  
  310.  
  311.  
  312.  
  313. SYS"Gemini_SetUpLights"
  314. -----------------------
  315. After loading a file, you should compile a light table, to access quickly to
  316. the light informations. The lights (up to 1024 per scene) are memorized in a
  317. table (of 1024*4 bytes) within the TMcolour block. You only have to dimension
  318. correctly the TMcolourblock and call this routine, which scans the Point database
  319. (in which lights are stored) and compile a table of ldm of the lights in memory.
  320. Then recalculates also the illumination of Points and primitives...
  321.  
  322. R0 = TMmemoryblock
  323. R1 = TMviewblock
  324. R2 = TMcolourblock
  325.  
  326. ||| If you want to move your scene in memory, once you have loaded and used it,
  327. ||| just move phisically the memory, update the links within TMmemoryblock
  328. ||| (+0 to +20), call "Gemini_InitScene" with the new parameters and then
  329. ||| call "Gemini_SetUpLights".
  330.  
  331.  
  332.  
  333.  
  334. Then you must specify the dimension of the work area. You must call these
  335. routine every time (1) you want to change the image size or
  336.                    (2) a change of the desktop palette or of the graphic mode
  337.                        has occurred.
  338. There are two routines, which let you specify if you want to work on the screen
  339. or in a memory buffer (you have to call only one of these):
  340.  
  341. (a) SYS"Gemini_SetUpScreen"
  342.     -----------------------
  343.     This allows you to output the scene on the screen.You have to set:
  344.     R0 = TMmemoryblock
  345.     R1 = TMviewblock
  346.     R2 = TMcolourblock
  347.     R3 = X min workarea (OS units, inclusive)
  348.     R4 = Y min workarea (OS units, inclusive)
  349.     R5 = X max workarea (OS units, inclusive)
  350.     R6 = Y max workarea (OS units, inclusive)
  351.     R7 =   0 (for a complete setup, which recalculates also the colour tables for the current palette)
  352.          <>0 (window resize only, much faster)
  353.  
  354. (b) SYS"Gemini_SetUpSprite"
  355.     -----------------------
  356.     Not implemented yet
  357.  
  358.  
  359. On exit, both these calls fill in the TMviewblock with some informations. In
  360. particular (in TMviewblock):
  361.   +72 X min workarea (OS units)
  362.   +76 Y min workarea (OS units)
  363.   +80 X max workarea (OS units)
  364.   +84 Y max workarea (OS units)
  365. these may or may not be equal to those you pass as input. Coordinates are
  366. translated into memory addresses for plotting purposes, which MUST be byte
  367. aligned. In practice, only the X coordinates may be affected from this
  368. readjustament phase. In particular, when in a 4bpp mode, X workarea coordinates
  369. must be multiple of 2 pixels. From 8bpp modes on (and so also 16bpp and 32bpp)
  370. there aren't restrictions.
  371.  
  372. So: call Gemini_SetUpScreen (or _SetUpSprite) specifing your workarea, then
  373.     check which are the settings Gemini assumes to be right and use them
  374.     instead. Please NOTE: Gemini DOESN'T WORK in any 2 or 4 colours mode. If a
  375.     user enters these graphic modes, Gemini fill these addresses (+72 to +84)
  376.     with a particular value: -1. You don't have to check the graphic mode specs
  377.     on a mode change. Just call Gemini_SetUpScreen (or _SetUpSprite) as usual.
  378.     If you get, on exit, the -1 value in the previous locations, then warn the
  379.     user that Gemini doesn't work in this mode and close all the windows you
  380.     need (or fill them with a dummy background or use ChangeFSI to convert the
  381.     last image Gemini produces in one suitable for that graphic mode).
  382. In anycase don't call Gemini_Render while in a "wrong" graphic mode, as the
  383. result will be unpredictable... (but you can try, for while testing it to see
  384. what happens...).
  385.  
  386.  
  387.  
  388.  
  389. And, (at last!), the call to render all the scene on the specify output stream
  390. (video or memory) in the specified size...
  391.  
  392. SYS"Gemini_Render"
  393. ------------------
  394. R0 = TMmemoryblock
  395. R1 = TMviewblock
  396. R2 = TMcolourblock
  397. R3 = screen bank to use (1 or 2; 1 for default)
  398. R4 = mode
  399.  
  400. Gemini enables you to have a full double buffering for smooth animation. Just
  401. redraw the screen with R3 set to 1 or 2 alternatively. (see later)
  402. The R4 register contains the mode word. These are the actual defined bits:
  403.  
  404.  Bit   Meaning if set   [meaning if not set]
  405. --------------------------------------------------------------------------
  406.    0  | Colour [grey-shade]
  407.    1  | Wireframe
  408.    2  | Flat shading
  409.    3  | Gouraud shading
  410.    4  | Phong shading
  411.    5  | Transparency enabled  [always opaque]   ---> not activated yet
  412.    6  | Texture mapping enabled [not enabled]
  413.    7  | Chrome  mapping enabled [not enabled]
  414.    8  | Bump    mapping enabled [not enabled]
  415.  9-11 | reserved - set to 0
  416.    12 | draw primitives [don't draw nothing]
  417.    13 | reserved - set to 0
  418.    14 | perspective view [axonometric]
  419.    15 | normal navigation mode [VR mode: objects behind observer aren't drawn]
  420.    16 | visualize axis [don't]
  421.    17 | recalculate active plane while rotating [don't]
  422.    18 | remove objects with normals against the current view vector [draw all]
  423.    19 | test ESC key to stop redraw [don't]
  424.    20 | fog activated [fog disabled]
  425.    21 | reserved - set to 0
  426.    22 | recalculate light reflections while in flat and Gouraud mode [don't]
  427.    23 | clear the workarea with the current background colour [draw just objects]
  428.    24 | draw bezier-curves/surfaces' visual-hull lines [don't]
  429.    25 | draw polygons' vertices [don't]
  430.    26 | draw control points     [don't]
  431. 27-31 | reserved - set to 0
  432.  
  433.  
  434.  
  435.  
  436. Then there are another two calls, to enable screen buffering
  437.  
  438. SYS"Gemini_StartBuffering"
  439. --------------------------
  440. R1 = TMviewblock
  441.  
  442. This tries to reserve enough video memory to obtain a second bank to enable
  443. screen banking for smooth animation. If it hits the goal, then it copies the
  444. first page into the second, to enable a bank switching also from desktop (the
  445. second page isn't filled with strange colours...)
  446.  
  447. SYS"Gemini_EndBuffering"
  448. ------------------------
  449. R1 = TMviewblock
  450. This ends the bank switching, releasing (if any) the reserved memory and
  451. copying the contents of the second page (if the current page is the second)
  452. into the first.
  453.  
  454. So, to have a working engine with bank switching do this:
  455. "Gemini_StartBuffering":bank%=1
  456. REPEAT
  457.   bank%=bank%EOR3:"Gemini_Render"
  458. UNTIL end
  459. "Gemini_EndBuffering"
  460.  
  461. this work also if there isn't enough memory for bank switching.
  462.  
  463.  
  464.  
  465.  
  466. SYS"Gemini_Select"
  467. ==================
  468. This is a multi-purpose selection command and acts over the loaded database.
  469. Its behaviour depends upon the reason code passed in R4, as follow:
  470.  
  471. R4 values  | action taken
  472. -----------|-------------------------------------------------------------------
  473.     1      |  Select   all
  474.     2      |  Select   only visible objects (the ones inside working area)
  475.     3      |  Select   the specified group of objects
  476.     4      |  Select   all the points inside the specified rectangle
  477.     5      |  Select   the point closest to the passed (X,Y) screen coordinates
  478.     6      |  Select   the primitive closest to the passed (X,Y) screen coordinates
  479.     16     |  Deselect all
  480.     17     |  Deselect only visible objects
  481.     18     |  Deselect the specified group of objects
  482.     19     |  Deselect all the points inside the specified rectangle
  483.  
  484. Not implemented yet
  485.  
  486.  
  487.  
  488.  
  489.  
  490. How to draw the scene in several passes
  491. =======================================
  492. You may need to produce a picture in more than one go, expecially if you want
  493. big resolutions (a 2048*2048 32bpp image, with Zbuffer requires 32Mb free!).
  494. You also may want to draw only a portion of the scene required for example by
  495. a Wimp Redraw Request. I reccommend you to use this tecnique only for file or
  496. sprite output, as it slows down the rendering time a lot; anyway it works also
  497. if you specify the workarea using "Gemini_SetUpScreen". The basic idea is quite
  498. similar to the one used by the wimp scrollbars. When you specify the workarea,
  499. Gemini assumes that the origin is placed in the top left corner, and the Y
  500. coordinate is positive downwards. To place the origin at the centre of the work-
  501. area, Gemini simply adds a fixed amount to each coordinate. These amounts are
  502. the centre of the scene (in pixel); let's call them (fx,fy). They are stored
  503. in TMviewblock+32 and +36, respectively. These locations are filled each time
  504. you issue a "Gemini_SetUpScreen" or "Gemini_SetUpSprite" call. (fx,fy) are set
  505. to the centre of the currently specified workarea on exit (i.e. if you specify
  506. a workarea of (20,20,120,120) OS-Units (with a X and Y scale factor of 2), on
  507. exit from Gemini_SetUpS... you get (fx,fy)=(25,25)).
  508. Let's create a 600x384 pixels image, using 3 strips of 600x128 pixels each.
  509. Let's take a scale factor of 2 on both X and Y (eg. MODE28).
  510. Please note: produce strips starting from the top left one to the bottom
  511. righ. In the following example I consider only 3 horizontal strips, but
  512. once you have understood how it works, you can redraw any portion inside the
  513. "main" (logical) workarea.
  514.  
  515. In OS-Units, here are the 3 workareas to specify:
  516.  
  517.   ________________________________________________________768
  518.   |                                                      |
  519.   |                                                      |
  520.   |                                                      |
  521.   |              Strip #1                                |
  522.   |                                                      |
  523.   |                                                      |
  524.   |                                                      |
  525.   |______________________________________________________|512
  526.   |                                                      |
  527.   |                                                      |
  528.   |                                                      |
  529.   |              Strip #2                                |
  530.   |                                                      |
  531.   |                                                      |
  532.   |                                                      |
  533.   |______________________________________________________|256
  534.   |                                                      |
  535.   |                                                      |
  536.   |                                                      |
  537.   |              Strip #3                                |
  538.   |                                                      |
  539.   |                                                      |
  540.   |______________________________________________________|0
  541.  0                                                   1200
  542.  
  543. So, we have to:
  544. 1) "Gemini_SetUpS..." specifying strip#1
  545. 2)  alter the (fx,fy) settings like using scroll bars (see later)
  546. 3) "Gemini_Render" to draw this strip
  547. 4) "Gemini_SetUpS..." specifying strip#2
  548. 5)  alter the (fx,fy) settings
  549. 6) "Gemini_Render" to draw this strip
  550. 7) "Gemini_SetUpS..." specifying strip#3
  551. 8) alter the (fx,fy) settings
  552. 9) "Gemini_Render" to draw this strip
  553. Each strip, once defined, will have its local coordinate system, starting
  554. from its top-left corner. So, in pixel:
  555.   ________________________________________________________
  556.   |(0,0)                                                 |
  557.   |                                                      |
  558.   |                                                      |
  559.   |              Strip #1                                |
  560.   |                                                      |
  561.   |                                                      |
  562.   |                                            (599,127) |
  563.   |______________________________________________________|
  564.   |(0,0)                                                 |
  565.   |                                                      |
  566.   |                                                      |
  567.   |              Strip #2                                |
  568.   |                                                      |
  569.   |                                                      |
  570.   |                                            (599,127) |
  571.   |______________________________________________________|
  572.   |(0,0)                                                 |
  573.   |                                                      |
  574.   |                                                      |
  575.   |              Strip #3                                |
  576.   |                                                      |
  577.   |                                            (599,127) |
  578.   |______________________________________________________|
  579.  
  580. the centre of the whole scene MUST be EQUAL for all the strips, considering
  581. their relative positions. In OS-Units, considering the global image, (fx,fy)
  582. IS POSITIONED to the middle of the second strip (600,384), but when you specify
  583. and work inside a strip, you have to translate the global position of the
  584. logical centre (OS-Unit) in the current local coordinate system of the strip
  585. (pixel).
  586. So, the strip#1 MUST have (fx,fy) set manually to (300,192)
  587.     the strip#2 MUST have (fx,fy) set manually to (300, 64)
  588.     the strip#3 MUST have (fx,fy) set manually to (300,-64)
  589.  
  590.    ______________________________________________________
  591.   |(0,0)                |                                |
  592.   |      Strip#1        |                                |
  593.   |                     |                                |
  594.   |                     |128+64                          |
  595.   |                     |                                |
  596.   |                     |                                |
  597.   |                     |                      (599,127) |
  598.   |_____________________|________________________________|
  599.   |(0,0)           |    |                                |
  600.   |      Strip#2   |64  |                                |
  601.   |                |    |                                |
  602.   |       300      |    |                                |
  603.   |<---------------------->. (fx,fy)                     |
  604.   |                   |                                  |
  605.   |                   |                        (599,127) |
  606.   |___________________|__________________________________|
  607.   |(0,0)              |-64                               |
  608.   |      Strip#3                                         |
  609.   |                                                      |
  610.   |                                                      |
  611.   |                                                      |
  612.   |                                            (599,127) |
  613.   |______________________________________________________|
  614.  
  615. We are altering only Y position of each strips, so the fx coordinate is
  616. unchanged, equal to half the Xsize of the total image in pixel (i.e. 300).
  617. In general, to generate a portion of the main image, you have to work out
  618. both the coordinates (fx,fy).
  619.  
  620.  
  621.  
  622.  
  623. Restrictions
  624. ============
  625. 1) Gemini DOESN'T WORK in any 2 or 4 colours mode.
  626. 2) Workarea coordinates are translated into memory addresses for plotting purposes, which
  627.    MUST be byte aligned. This involves just the routine that clears the background, not the
  628.    render routine used for objects. Anyway, even if you don't want to redraw background (bit
  629.    23 of R4 in "Gemini_Render" clear), workarea position is moved, so all the objects inside
  630.    are moved accordingly. In practice, only the X coordinates may be affected from this
  631.    readjustament. In particular, when in a 4bpp mode, X workarea coordinates must be multiple
  632.    of 2 pixels. From 8bpp modes on (and so also 16bpp and 32bpp) there aren't restrictions.
  633. 3) ALL MEMORY LOCATIONS (Points&Primitives workarea, Zbuffer, TMmemoryblock, .... etc.) MUST BE
  634.    WORD ALIGNED!
  635. 4) When drawing to screen, the workarea you specify is always clipped to fit into it:
  636.          ________________                            ________________
  637.         |     screen     |                          |     screen     |
  638.      ___|__________      |                          |__________      |
  639.     |   |          |     |                          |          |     |
  640.     |   |          |     |         ====>>>          | workarea |     |
  641.     |   |          |     |                          |          |     |
  642.     |   |__________|_____|                          |__________|_____|
  643.     | workarea     |
  644.     |______________|
  645.  
  646.  
  647.  
  648.  
  649. TopModel 3D scene
  650. =================
  651. In a TopModel 3Dscene (&139) basically you can find (raw by raw)
  652.  
  653. 3DScene                           | Header
  654. 1.00                              | file version number
  655. 27185169                          | mode as described in "Gemini_Render" (in R4)
  656. 48896                             | min size of points     workarea needed (+58*32 always)
  657. 85056                             | min size of primitives workarea needed
  658. 0                                 | min size of group data needed
  659. 24576                             | min size of mats+cols+textures
  660. 122000                            | min size of a standard RiscOS sprite-area to load the textures used
  661. 256                               | size of the portion of TMviewblock saved
  662. 0                                 | reserved, must be 0
  663. 0                                 | reserved, must be 0
  664. 0                                 | reserved, must be 0
  665. 55232                             | ldm of points workarea when it was saved
  666. 333376                            | ldm of primit.workarea when it was saved
  667. 1680832                           | ldm of texture sprite-area when it was saved
  668.  
  669. Then you find a memory dump of points, primitives and groups workareas,
  670. colours+materials+textures table, spritefile containing the texture and TMviewblock area.
  671.  
  672.  
  673.  
  674.  
  675. TopModel 3D file
  676. ================
  677. In a TopModel 3DFile (&B5C) basically you can find (raw by raw)
  678.  
  679. 3DModel                           | Header
  680. 1.07                              | file version number
  681. View1  0,403520,-63204,[...]      | view infos (optional, may be present or not)
  682. Ambiental  255,255,255, 0         | ambiental light infos    (optional)
  683. Solar  255,255,255,    [...]      | standard sun light infos (optional)
  684. Grid  50,4.0000,4.0000 [...]      | grid infos               (optional)
  685. 127392                            | min size of points     workarea needed (+58*32 always)
  686. 284992                            | min size of primitives workarea needed
  687. 0                                 | min size of group data needed
  688. 3980                              | total number of points and lights
  689. 7124                              | total number pf primitives in the file
  690. 3980                              | number of selected points when saved
  691. 7124                              | number of selected primitives when saved
  692. 0                                 | number of selected groups when saved
  693. 0                                 | number of selected lights when saved
  694. 981456                            | ldm of points workarea when it was saved
  695. 1113392                           | ldm of primit.workarea when it was saved
  696. 1                                 | n^ of textures used
  697. 1 -536870912 ,Materiali.ceramic.2 | (text.number) (transparent colour), path
  698. 1 , 1                             | n^ of user defined colours, materials
  699.  Colour1,15658507                 | (colour name),(&BBGGRR00)
  700.  Material1, 194841272,0,0,0       | (material name),mat!12,mat!16,mat!20,mat!24
  701.  
  702. Then the file goes on with a memory dump of the points workarea followed
  703. immediately by a memory dump of the primitives and then odf the groups workareas.
  704.  
  705.  
  706.  
  707.  
  708. Disclaimer
  709. ==========
  710. The module and this documentation are supplied "as is"; neither Sicronia nor
  711. the author of Gemini make any warranty, whether express or implied, as to the
  712. merchantability of the software or its fitness for any purpose.
  713. In no circumstances will Sincronia or the author of Gemini be liable for
  714. any damage, loss of profits, goodwill or for any indirect or inconsequential
  715. loss arising from the use of this software or of this documentation.
  716. Using Gemini is deemed acceptance of these terms.
  717.