Adventurer #13
31 марта 2002

Exchange of experience - How to write a 3D game such as DOOM.

<b>Exchange of experience</b> - How to write a 3D game such as DOOM.
     (C) Research / Volgasoft


      How to write a 3D game such as DOOM


     In this article I am going to tell
(Well, and show a working example, of course) about how to make 
(as made) three-dimensional din the 3d engine with a pie

organization. At the time, Dr. STS
(Now better known as Dr. Tin Throat:)))) dealt with this issue
and wrote a couple is not much different 3d
engine (code name: ZX Duke Nukem). In
principle of analogues I have not heard, may
someone did something like that, and once
there are none, then we will consider only existing copy. Lest
give izdohnut masterpiece, I've adapted it
in DeMouy, released under the name <Love
Gun>. If you saw it, then realize
what is at stake. Just want to say a huge thanks to another 
well-known <Father> - Darku uncle of the now deceased X-Trade. 
He also greatly involved in the writing of the engine, as well 
as STS. In principle, a bit part in the escalation of materials 
and hardware, and myself. All that is here to be affected, 
based on materials two above-mentioned "three-dads"

electronic publishing magazine "Spectrum Expert". Start with 
it, otherwise no fig do not understand.


     Let's start:


     In early look at what kind of
Sector organization exists.


     By sectors, we understand some
closed three-dimensional shape, from any point that seamlessly 
see other point of this figure. Roughly speaking, these are two

piles, one of which is driven into the floor, and another in 
the ceiling, and all are covered with wallpaper, and we are 
inside the remaining space between the piles. Sector is 
described by the coordinates of points from which it is 
composed of height (Coordinates) of the ceiling height 
(coordinate) floors, the connection diagram points (Walls), and 
of course, numbers of fill each wall (face), floors and ceiling.

Here's a piece of card LoveGun.



     Thus, we have the level, divided into sectors. Look like 
the sector, you've probably already guessed. We look at the 
sector S0. It consists of points with indices

0,1,2,3,4,5,6,7,8,9,0. Points are connected by
clockwise direction and form a wall: 0-9, 98, 08/07, etc. 
Sketched an octahedron, we get an opportunity for him whirl. 
But: there is a problem, as Che's next? On one sector does not 
build the game. Even two or ten. What they were confusing, if 
it is independent from each other premises? After all, they 
somehow have to concatenate. These issues and highlighted in 
the picture thick lines. They are called cross-cutting 
connections. Thus, our sector have a common face - 0-9 to 9-0 
for S0 and S1. And that means a large bucket of nails

in the ass in terms of code and algorithms. Example - when I 
did lift (sector S4-S9), you would like to make it Gorny and

vpindyuril 15 steps. Scorpio is a result of hanging in the ass, 
squeezing emulator Shalaeva 300,000 cycles per frame (at 
Cyrix200) decided that here in the Spectrum mp4 show. Thinking 
that it is still not glitch, I walked five steps.  
explanation of this will be lower. 


     Switch to the source <microcosm>
truncated by a piece of our map
(World5.c).


     Table of pointers to the sectors:

SECTB
 _DW S0, S1, S2, S3, S4, S5, S6, S7, S8, S9


     Pointers located in the same order in which lie the 
sectors themselves. 


     And here is the sector. It took me
some time to rasryuhat which there
STS ponadelal:

 ORG $ ^
 SECTORS
 ; FLOOR'z, CIELING'z
 ; SLOPE FLOOR, SLOPE CIELING
 ; HITAG, LOTAG, EXTRA
 ; FLOORPIC, CIELINGPIC

 ; Example of the sector:
 S0 DW 300, -400,0,0,0,0,0: DB 22,15
 ; Cap sector
 ; DW, ceiling height, sex, and then
 ; Unused field (under any
 ; Special effects), then:
 ; DB pouring floors, ceiling
 , By the way - the ceiling 

 , Followed by a list of nodes that comprise
 Sector
 ; POINT, FIL, NUM, CONNECT, SEC
 ; DW point number: DB die wall <the node -
 , Following it>, the number of this wall,
; Room wall shared with adjacent sectors
 , (If 0 - a wall not clear) ()
 ; Number of sectors with which the coupling
 , (-1 - No connection).


         DW 9: DB 1,0,0, -1

         DW 8: DB 14,1,0, -1

         DW 7: DB 6,2,0, -1

         DW 6: DB 12,3,0, -1

         DW 5: DB 20,4,0, -1

         DW 4: DB 12,5,0, -1

         DW 3: DB 6,6,0, -1

         DW 2: DB 14,7,0, -1

         DW 1: DB 1,8,0, -1

         DW 0: DB 25,9,12,1
 ; Connect with the 12-m
 ; Edge of the sector S1


         DW -1; the end of the sector,
 ; Compound 0-th and 9 th node

 ; Example of the second sector
 S1
 _DW 300, -400,0,0,0,0,0: DB 14,19

 _DW 1912: DB 13,10,14,2; unite
 , With a 14-m edge sector S2

         DW 1910: DB 27,11,0, -1
 _DW 9: DB 4,12,9,0; connect with the
 , 9 th rib sector S0


         DW 0: DB 27,13,0, -1

         DW -1; the end of the sector,
 ; Compound 0-th and 12 th nodes


     And here is the points themselves of which are glued 
sector: 

ORG $ ^
 ; DW X, Y; X =- 16384,16383 Y
 , Too, if I am not
 ; Memory
 DOTS DW 5500,4000; 0 S0

         DW 5000,4000

         DW 4000,3000

         DW 4000,1000

         DW 5000,0

         DW 7000,0

         DW 8000,1000

         DW 8000,3000

         DW 7000,4000

         DW 6500,4000; 9


         DW 6500,6500; 10 S1

         DW 5000,6500; 11

         DW 5500,5500; 12 S2

         DW 5000,5500; 13


     As was noted above, such
an idea borrowed from the organization pisyuka
Natural and Improved the opportunity for
Spectrum.


     With all sectors of the device. Now
moved on to how it is poured.


     Now I'll show you a couple of
Images:


     This can be called <viewer's eyes>



     And this <Truth>



     See? Well, what is not shudder?
And the thing that is not our friend Speccy
able to quickly assume. Yes, yes:. Pour
entire wall from floor to ceiling is faster than a cheat site
actually see the audience, and then
fill it, and usually twice.
Ponder this image, STS realized that
principle, to accelerate the engine, fills
take two: the first - the usual (procedure fdrpoly), second - 
fill rectangles, from floor to ceiling - especially Wall 
(procedure filv). By the way it all stack, and accelerate 
virtually no subject. About casting remains to add,

they fill in the columns - it's faster, but the removal of the 
buffer to the screen like this: 

_POP BC: LD (HL), C: INC H: LD (HL), B:
INC H

eating decent performance. This is not

LD HL, # 0000: PUSH HL
 or POP HL: LD (SCREEN), HL

some. On the other hand - this is inevitable. That's why about 
15 steps and did not happen.



      Summing up a little.


     Thus, the handler uses the sectors
the most progressive to date
procedures for calculation (using
logarithms, the approximate calculations, etc.).
In addition, it enabled recursion.
Therefore it is almost not subject to optimization
(Rather, it is subject only dopiske).
Another thing the block fills. Fill as
sort, has always been "Russian field
optimization>. After all, the small detalyushechki
so much is wasted! It would probably be more correct to do, not 
two, but all three or more fills. Now I have hanging up with an 
idea, the current does not know how it is realizable, 
therefore, still silent. 


     There was, remember, the idea of ​​doing this
engine wire. In principle, why
not? The only question is invisible lines
and this again mathematics.


     Lastly, go back to the source.


     Vse I leave as is. STS is usually not
broke the program into logical units
(In the storm to work with them does not hurt a
convenient), and cram as much in
text intermeddle bank. I allowed myself
the audacity to draw a few comments. Deal with the fact that 
there is, it is probably a week (it took me a whole day of 
four). 

     Another toss library GRAFLIB,
STS'om composed of Dark and procedures
their own. It is useful to any
3D .

     Chew on it makes no sense
=> This perhaps all.







Other articles:

From the authors - help: a description of the shell magazine.

From the authors - the contents of the new magazine.

From the authors - Forever young, or the Spectrum in the new millennium. Call Jam / XPJ to save the log ZX Power.

From the authors - The authors of the magazine.

Presentation - new game from Studio Stall - opener.

Presentation - the new font editor Hewly Font Editor.

Presentation - A new version of the music editor of Sound Tracker Pro.

Presentation - a program for optimization of black and white images skonverchennyh with a PC.

Presentation - ASCII graphics editor for directories in the TR-DOS.

Presentation - "Bard's Tale Merger Programm" - a program to manage shipments of the game Bard's Tale.

Interface - News from: Placebo, Brain- wave, Phantom Family, Volga Soft, Studio Stall, Gogin, Anarchia, Image Crew, Hackerz 'Design Software, Peters +, Fatal Snipe, Ellipse.

Interface - see what tusni are scheduled for Speccy freaks vtechenie year: Forever 3, ASCII ^ 2002, 2nd International Sinclair Sam days, Millenium 1902, Twilight Demoparty 2002, Syndeecate Demoparty 2002, Paradox 2002, CaFe 2002, Chaos Constructions 2002.

Interface - a letter reading rooms: NoViSeT / Brutal Creators, Di / LSg, Moroz1999, Shame / Madness Technology, Cannibal / Techno Lab.

Interface - "for the market to answer!" Russian language is so "Great and powerful", that well use it, unfortunately, is given not for everyone.

Interface - Overview of Windows like shells and systems for ZX Spectrum.

Interface - City of Dzerzhinsk and its Spectrum inhabitants.

Exchange of experience - How to write a 3D game such as DOOM.

Exchange of experience - Floyd-Steinberg method for converting images from a larger number of colors in the least.

Exchange of experience - an unscientific Algorithm for Random Number (RND).

Exchange of experience - Direct Programming General Sound.

Exchange of experience - work with the western disk systems MDOS and MD02.

Chaos Construction 2001 - an interview with Raid.

Chaos Construction 2001 - an interview with Stanly / Studio Stall.

Chaos Construction 2001 - an interview with Gogin (Hacker Smir).

Chaos Construction 2001 - an interview with the Constellation Team: Screamer, Kot, Justinas.

Chaos Construction 2001 - Interview with EYE-Q: Organism, Time Keeper, Mr. Wizard.

Chaos Construction 2001 - an interview with Justionas / Constellation.

Chaos Construction 2001 - an interview with the Moscow encoder Asman / Proxium.

Chaos Construction 2001 - intevyu with Vivid, Megus, Tiggr of Brain-Wave.

Chaos Construction 2001 - an interview with Stingrey and Steep from Izhevsk.

Chaos Construction 2001 - an interview with amizhnikom and organizer CC - Big Black.

Chaos Construction 2001 - an interview with the encoder from Ulyanovsk Faster / TNL.

Chaos Construction 2001 - an interview with Cyberfreak (mooh).

Chaos Construction 2001 - an interview with Ming spektrumistom Equator / PHD.

Chaos Construction 2001 - mini interview with Kano.

Chaos Construction 2001 - an epic dispute: Vivid VS Sairoos, Chanks VS Multicolor, Dogma VS Triptomine Dream.

Chaos Construction 2001 - an interview with Maddy and Drv53b6 of the Phantom Family.

Chaos Construction 2001 - an interview with the Paracels and Sairoos of Placebo.

Chaos Construction 2001 - an interview with Pheel and EA from Antares.

Chaos Construction 2001 - continuation of the epic dispute between megakoderami Vivid and Sairoos.

Chaos Construction 2001 - a detailed report from the CPU.

Promotion - Another shattered dream or a description of the "500 games" - where truth and falsehood.

Promotion - the story creators of the game Star Glider 2 - Steven dunn / Software developement and design.

Promotion - Dizzy in a dungeon or omelette again did not turn out: short story for the game Dizzy Unterground.

Promotion - description of the game "Talisman" - RPG with elements of arcade.

Iron - the modified scheme IDE-HDD adapter.

Ottyag - clean ottyag: Children's self-made newspaper Bird Kar Kar. "

Ottyag - intro: We will not pull the cat by the balls and start with the run ...

Ottyag - Army Suxx or How zakosit from the army, if you are completely healthy.

Ottyag - the depth of a gloomy world outlook Maxima Magnet ...


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

Similar articles:
Echo Conference - My your understand.

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