Inferno #07
31 мая 2005

Gamedev - 3D projection of the floor / road in the games.

<b>Gamedev</b> - 3D projection of the floor / road in the games.
3D projection of the floor / road

   In Wolf'2004 no sex, and existing
on ZX races although he is, but dishonest
(According to him you can not drive across the highway and
the opposite direction). This floor must be
get perspective projection on the
screen images (trace) is sufficiently large
of size.

Newart>

   The game window is, say, 160 pixels, half of the window is 
projected onto the landscape, the length of it, probably before 
projection factor of 3 higher than seen in screen after the 
projection. Explain how you propose to do without rotation ...

 Alone Coder>

   Rotation would be, but in the process of transfer
 graphics chunkmap. Ie 2 pass:

   1. rotate;

  2. output chunks.
Newart>

   A projection will be during the withdrawal
chanok?
 Alone Coder>

    Projection during rotation.

   Let the height of the land = 80 pixels (40
chunks). The distance at which conclusions can be seen
dimye horizontal lines relate to each
other as 40/40, 40/39, 40/38, etc,
The latter line - 40 / 1. Assume that the map
has a size of, well, at least 256x512 pixels.
Let the 4 most rear line of land can not be seen
(Gray), and we see a distance of no more than
1 / 3 card (depending on the height of the observer).
Then, when a chunk 2x4 on the most neighbors is
niyah be distinguishable pixel texture, but
they receive no more than 2 chunks
if I'm not cheated. Ie Very ter pimo ...

   Within each horizontal line is equivalent to
wound, we are moving in texture evenly
equal increments. Before the withdrawal line
only need to calculate it at the top of the tex
tour and a motion vector in texture (and then, and
Both can be figured out by the tables).



   Mathematics there is nothing in itself is not Chairman
 tionally.

   Denote the coordinates of the player through x0,
y0, and its angle - through a. Conditionally
define the z axis from the middle of the screen down
 scale - whatever.

   Then the distance on the map to the point to
toruyu to withdraw in the middle of the horizontal
z, is equal to: d (z) = k1 / z, where k1 - a coefficient
coefficient (it depends on the height of a player over
 surface).

   Coordinates of the point on a map if they
measured from the coordinates of the player are:
 cx (z, a) = d (z) * cos (a); cy (z, a) = d (z) * sin (a).

   Step, which we pass card
drawing a horizontal line z, is: step (z) = k2 / z,
where k2 - some other factor (the ratio
of k1/k2 defines a rectangular "elongated
 nutost "image).

   Components of this step, the x and y are:
stepx (z, a) = step (z) * sin (a);
 stepy (z, a) =- step (z) * cos (a).

   Then it is clear that the left point of our Does
Institute of z on the map will have the coordinates:
leftx (z, a) = cx (z)-width * stepx (z, a);
 lefty (z, a) = cy (z)-width * stepy (z, a).

   That is, instead of mathematics can be
just a table of values ​​stepx, stepy, leftx,
lefty size 36 * 64 (the remaining 192 of the angle a
can be reduced to these 64 simple corners of
replacements coordinates and change their signs). Poes
Kolka, these numbers are 16-bit, then the table Zai
met 18 kilobytes (can be expanded in countries
prone - a special rate is not needed). A
all calculations on the fly will be reduced to simple
addition to adding coordinates of the player (x0, y0)
 to read coordinates from a table.

   Importantly - the partition maps "znakomes
ta "(tiles). We assume that the tile is
1916 (Y) * 8 (X) texels (texture elements,
pixels). They will be stored at the addresses
% 0110yyyyxxxttttt, where yyyy, xxxx - coordinates within the 
tile, ttttt - number of the tile. Then the map will be 16 * 128 
= 2048 (Y) 8 * 256 =  = 2048 (X).


   Projection is a chankovy buffer
(Then it will be possible to impose the sprites).

 width = 24; CHRS

       (DUP width)

         ADD IX, DE; Y

         EXX

         ADD HL, BC; X

         LD E, H; X

         LD D, HX; Y

        (Set 7, d); not to zashkal.za map

         LD A, (DE); room tile, standing in the

                          ; This place cards

         XOR L; ml.bayt X (inside the tile)

         AND # 1F

         XOR L; A =% xxxttttt

         EXX

         LD L, A

         LD A, LX; ml.bayt Y (within the tile)

         RRA

         SCF

         RRA

         SCF

         RRA

         OR A

         RRA; A =% 0110yyyy

         LD H, A; HL = address of a texel tile

        LD B, (HL); color chunk
 , And again:

         ADD IX, DE; Y

         EXX

         ADD HL, BC; X

         LD E, H; X

         LD D, HX; Y

        (Set 7, d); not to zashkal.za map

        LD A, (DE); room tile, standing in the

                          ; This place cards

         XOR L; ml.bayt X (inside the tile)

         AND # 1F

         XOR L; A =% xxxttttt

         EXX

         LD L, A

         LD A, LX; ml.bayt Y (within the tile)

         RRA

         SCF

         RRA

         SCF

         RRA

         OR A

         RRA; A =% 0110yyyy

         LD H, A; HL = address of a texel tile

         LD C, (HL); color chunk

         PUSH BC; put two chunks in chankmep

      (EDUP)



    The accuracy of calculations = 1 / 8 texels.

    Conclusion chunks on the screen:

       (DUP width)

         POP HL; colors of the two chunks:

                       ;% 1111aaa1,% 1111bbb1

         LD A, (HL)

         LD (BC), A

         LDD; DE = BC +256 (or vice versa)

      (EDUP)



   You can rotate the output chunks with proetsi
the fore after each line of the picture -
but then no sprites on ekrane.Hotya can
 bring them cleverly, too, on line.

   Size chankmepa (including the upper half
guilt, where the card is not drawn):
 48 (2 * width) * 80 (hgt) = 3840.

   No memory left, so you can ISPO
lzovat 2 nd screen, and can reduce the map
the Y twice (to the size of pages) -
add SET 6, D. In fact, these SET -
a matter of taste, you can simply give the player
approaching the border of the map.

A. Coder




Other articles:

Classics - Almanashnik. Alexander Pushkin.

For Coderz - Recognition and computation of arithmetic expressions on their character record.

Inferno - The authors of the magazine.

For Coderz - the discipline to create large projects.

Interview - Questions Konstantin Sviridov (Conan) on the site zxnext.narod.ru.

Likbez - The principles of converting graphics PC-ZX.

For Coderz - Programming disc changer / drive in Scorpio.

Softinka - DNA_OS v0.431 - package of utilities for working with hard drives, RAM-drives and floppy disks.

For Coderz - Programming under DNA_OS ZET-9, a package of tools to work with storage devices.

Softinka - The problems and shortcomings package of tools to work with storage devices DNA_OS.

Likbez - details about disk formats that are FAT.

Inferno - Entered from the editor.

Inferno - Errors in the previous numbers.

For Coderz - Small programmers' tricks.

Gameland - On the new games: Oneyroid, Dizzy forever, Dridlock.

For Coderz - Writing archive. Practical principles LZ packaging.

Gameland - Passage of new shipments for the game "Black Crow".

For Coderz - Programming for the video mode 384x304.

Inferno - Letters to the Editor.

Sound - Eden Megus'a about the tracker for the AY / YM.

Inferno - On the shell.

For Coderz - Fundamentals of optimization for the processor Z80.

Likbez - The location of partitions on your hard drive.

Gamedev - 3D projection of the floor / road in the games.

Sound - Wild ideas for AY trackers.

Advertising - Ads by Roman Chuunin.

Advertising - Ads by V. Bogdanovich

For Coderz - How a large Flexible Program.

Repair - Faults Pentagon 128 + and their repair.

Inferno - Content.

Miscellaneous - Thoughts on the contest for the best software.

Others - Transfer software on ZX Spectrum with a PC.

Video - On packaging for a video ZX Spectrum.


Темы: Игры, Программное обеспечение, Пресса, Аппаратное обеспечение, Сеть, Демосцена, Люди, Программирование

Similar articles:
AMIGA vs PC - What can you say about the Amiga?
Game room - Novella and the description of the game "DEMON'S REVENGE".
Scribble brain - One day at school (continued).
Platform hallucinations - events, facts and announcements: Porting Star Heritage on Gameboy, and Raver preparing English translation of the game, is preparing a new number Deja VU and Adventurer, Kristof row with Himik'om, Judge Black Crow under General Sound, etc.

В этот день...   2 May