Π Π°Π·ΡΠ°Π±ΠΎΡΠΊΠ° ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ ΡΠΎΠ·Π΄Π°Π½ΠΈΡ Π²ΠΈΡΡΡΠ°Π»ΡΠ½ΠΎΠΉ ΡΠΎΡΠΎΠ³Π°Π»Π΅ΡΠ΅ΠΈ
Π ΡΠ°ΠΌΠΊΠ°Ρ ΠΊΡΡΡΠΎΠ²ΠΎΠΉ ΡΠ°Π±ΠΎΡΡ ΡΡΠ΅Π΄ΡΡΠ²Π°ΠΌΠΈ ΠΎΠ±ΡΠ΅ΠΊΡΠ½ΠΎ-ΠΎΡΠΈΠ΅Π½ΡΠΈΡΠΎΠ²Π°Π½Π½ΠΎΠ³ΠΎ ΡΠ·ΡΠΊΠ° Object Pascal ΠΈ Π±ΠΈΠ±Π»ΠΈΠΎΡΠ΅ΠΊΠΈ OpenGL ΡΠΎΠ·Π΄Π°Π½ΠΎ ΠΏΠΎΠΌΠ΅ΡΠ΅Π½ΠΈΠ΅ ΡΠΎΡΠΎΠ³Π°Π»Π΅ΡΠ΅ΠΈ ΠΈ ΡΠ°Π·ΡΠ°Π±ΠΎΡΠ°Π½ Π°Π»Π³ΠΎΡΠΈΡΠΌ, ΠΎΡΡΡΠ΅ΡΡΠ²Π»ΡΡΡΠΈΠΉ ΠΏΠ΅ΡΠ΅ΠΌΠ΅ΡΠ΅Π½ΠΈΠ΅ ΠΏΠΎ Π³Π°Π»Π΅ΡΠ΅ΠΈ. ΠΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ Ρ ΠΏΠΎΠΌΠΎΡΡΡ ΠΊΠ»Π°Π²ΠΈΠ°ΡΡΡΡ ΠΈ ΠΌΡΡΠΈ ΠΏΠ΅ΡΠ΅ΠΌΠ΅ΡΠ°ΡΡΡΡ ΠΏΠΎ Π½Π΅ΠΉ ΠΈ ΡΠ°ΡΡΠΌΠ°ΡΡΠΈΠ²Π°ΡΡ ΡΠΎΡΠΎΠ³ΡΠ°ΡΠΈΠΈ. ΠΡΠ΅Π΄ΡΡΠΌΠΎΡΡΠ΅Π½ ΡΠ΅ΠΆΠΈΠΌ ΠΏΡΠΎΡΠΌΠΎΡΡΠ° ΡΠΎΡΠΎΠ³Π°Π»Π΅ΡΠ΅ΠΈ. ΠΡΠΎΡΠ΅Π΄ΡΡΠ° ΠΎΠΏΠΈΡΡΠ²Π°Π΅Ρ ΡΠ΅Π°ΠΊΡΠΈΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ Π½Π° Π½Π°ΠΆΠ°ΡΠΈΠ΅ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Π΅ΠΌ ΠΊΠ»Π°Π²ΠΈΡ… Π§ΠΈΡΠ°ΡΡ Π΅ΡΡ >
Π Π°Π·ΡΠ°Π±ΠΎΡΠΊΠ° ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ ΡΠΎΠ·Π΄Π°Π½ΠΈΡ Π²ΠΈΡΡΡΠ°Π»ΡΠ½ΠΎΠΉ ΡΠΎΡΠΎΠ³Π°Π»Π΅ΡΠ΅ΠΈ (ΡΠ΅ΡΠ΅ΡΠ°Ρ, ΠΊΡΡΡΠΎΠ²Π°Ρ, Π΄ΠΈΠΏΠ»ΠΎΠΌ, ΠΊΠΎΠ½ΡΡΠΎΠ»ΡΠ½Π°Ρ)
Π€Π΅Π΄Π΅ΡΠ°Π»ΡΠ½ΠΎΠ΅ Π°Π³Π΅Π½ΡΡΡΠ²ΠΎ ΠΏΠΎ ΠΎΠ±ΡΠ°Π·ΠΎΠ²Π°Π½ΠΈΡ Π ΡΠ·Π°Π½ΡΠΊΠΈΠΉ ΠΠΎΡΡΠ΄Π°ΡΡΡΠ²Π΅Π½Π½ΡΠΉ Π Π°Π΄ΠΈΠΎΡΠ΅Ρ Π½ΠΈΡΠ΅ΡΠΊΠΈΠΉ Π£Π½ΠΈΠ²Π΅ΡΡΠΈΡΠ΅Ρ ΠΠ°ΡΠ΅Π΄ΡΠ° ΠΠΠ
ΠΠΎΡΡΠ½ΠΈΡΠ΅Π»ΡΠ½Π°Ρ Π·Π°ΠΏΠΈΡΠΊΠ°
ΠΊ ΠΊΡΡΡΠΎΠ²ΠΎΠΉ ΡΠ°Π±ΠΎΡΠ΅ Π½Π° ΡΠ΅ΠΌΡ
«Π Π°Π·ΡΠ°Π±ΠΎΡΠΊΠ° ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ ΡΠΎΠ·Π΄Π°Π½ΠΈΡ Π²ΠΈΡΡΡΠ°Π»ΡΠ½ΠΎΠΉ ΡΠΎΡΠΎΠ³Π°Π»Π΅ΡΠ΅ΠΈ»
ΠΡΠΏΠΎΠ»Π½ΠΈΠ»
ΡΡΡΠ΄Π΅Π½Ρ Π³ΡΡΠΏΠΏΡ 541
ΠΡΠ΄ΠΊΠΎΠ² ΠΠ»Π΅ΠΊΡΠ°Π½Π΄Ρ
ΠΠΎΠ²Π΅ΡΠΈΠ»
Π§ΠΈΡΠΈΠΊΠΈΠ½ Π. Π
Π ΡΠ·Π°Π½Ρ 2008 Π³.
Π ΡΠ°ΠΌΠΊΠ°Ρ ΠΊΡΡΡΠΎΠ²ΠΎΠΉ ΡΠ°Π±ΠΎΡΡ ΡΡΠ΅Π΄ΡΡΠ²Π°ΠΌΠΈ ΠΎΠ±ΡΠ΅ΠΊΡΠ½ΠΎ-ΠΎΡΠΈΠ΅Π½ΡΠΈΡΠΎΠ²Π°Π½Π½ΠΎΠ³ΠΎ ΡΠ·ΡΠΊΠ° Object Pascal ΠΈ Π±ΠΈΠ±Π»ΠΈΠΎΡΠ΅ΠΊΠΈ OpenGL ΡΠΎΠ·Π΄Π°Π½ΠΎ ΠΏΠΎΠΌΠ΅ΡΠ΅Π½ΠΈΠ΅ ΡΠΎΡΠΎΠ³Π°Π»Π΅ΡΠ΅ΠΈ ΠΈ ΡΠ°Π·ΡΠ°Π±ΠΎΡΠ°Π½ Π°Π»Π³ΠΎΡΠΈΡΠΌ, ΠΎΡΡΡΠ΅ΡΡΠ²Π»ΡΡΡΠΈΠΉ ΠΏΠ΅ΡΠ΅ΠΌΠ΅ΡΠ΅Π½ΠΈΠ΅ ΠΏΠΎ Π³Π°Π»Π΅ΡΠ΅ΠΈ. ΠΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ Ρ ΠΏΠΎΠΌΠΎΡΡΡ ΠΊΠ»Π°Π²ΠΈΠ°ΡΡΡΡ ΠΈ ΠΌΡΡΠΈ ΠΏΠ΅ΡΠ΅ΠΌΠ΅ΡΠ°ΡΡΡΡ ΠΏΠΎ Π½Π΅ΠΉ ΠΈ ΡΠ°ΡΡΠΌΠ°ΡΡΠΈΠ²Π°ΡΡ ΡΠΎΡΠΎΠ³ΡΠ°ΡΠΈΠΈ. ΠΡΠ΅Π΄ΡΡΠΌΠΎΡΡΠ΅Π½ ΡΠ΅ΠΆΠΈΠΌ ΠΏΡΠΎΡΠΌΠΎΡΡΠ° ΡΠΎΡΠΎΠ³Π°Π»Π΅ΡΠ΅ΠΈ.
1. Π’Π΅ΠΎΡΠ΅ΡΠΈΡΠ΅ΡΠΊΠ°Ρ ΡΠ°ΡΡΡ
ΠΡΡΡΠΎΠ²ΠΎΠΉ ΠΏΡΠΎΠ΅ΠΊΡ Π²ΠΊΠ»ΡΡΠ°Π΅Ρ Π΄Π²Π° ΡΡΠ°ΠΏΠ°:
1. Π Π°Π·ΡΠ°Π±ΠΎΡΠΊΠ° Π°Π»Π³ΠΎΡΠΈΡΠΌΠ° ΠΏΠ΅ΡΠ΅ΠΌΠ΅ΡΠ΅Π½ΠΈΡ ΠΏΠΎ ΡΠΎΡΠΎΠ³Π°Π»Π΅ΡΠ΅ΠΈ;
2. Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ ΠΏΠΎΠΌΠ΅ΡΠ΅Π½ΠΈΡ Π³Π°Π»Π΅ΡΠ΅ΠΈ.
1.1 Π Π°Π·ΡΠ°Π±ΠΎΡΠΊΠ° Π°Π»Π³ΠΎΡΠΈΡΠΌΠ° ΠΏΠ΅ΡΠ΅ΠΌΠ΅ΡΠ΅Π½ΠΈΡ ΠΏΠΎ ΡΠΎΡΠΎΠ³Π°Π»Π΅ΡΠ΅ΠΈ
ΠΠ΄Π½Π° ΠΈΠ· Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡΠ΅ΠΉ ΠΎΡΡΡΠ΅ΡΡΠ²ΠΈΡΡ ΠΏΠ΅ΡΠ΅ΠΌΠ΅ΡΠ΅Π½ΠΈΠ΅ ΠΏΠΎ ΡΠΎΡΠΎΠ³Π°Π»Π΅ΡΠ΅ΠΈ — ΡΡΠΎ ΠΏΠ΅ΡΠ΅ΠΌΠ΅ΡΠ°ΡΡ ΠΊΠ°ΠΌΠ΅ΡΡ ΠΈ ΠΏΠ΅ΡΠ΅ΡΠΈΡΠΎΠ²ΡΠ²Π°ΡΡ 3D ΡΡΠ΅Π΄Ρ ΠΎΡΠ½ΠΎΡΠΈΡΠ΅Π»ΡΠ½ΠΎ Π΅Ρ ΠΏΠΎΠ»ΠΎΠΆΠ΅Π½ΠΈΡ. ΠΡΠΎ ΠΌΠΎΠΆΠ½ΠΎ ΠΎΡΡΡΠ΅ΡΡΠ²ΠΈΡΡ ΡΠ»Π΅Π΄ΡΡΡΠΈΠΌ ΠΎΠ±ΡΠ°Π·ΠΎΠΌ:
Β· ΠΡΠ°ΡΠ°ΡΡ ΠΈ ΠΏΡΠΎΠ΅ΡΠΈΡΠΎΠ²Π°ΡΡ ΠΏΠΎΠ·ΠΈΡΠΈΡ ΠΊΠ°ΠΌΠ΅ΡΡ ΡΠ»Π΅Π΄ΡΡ ΠΊΠΎΠΌΠ°Π½Π΄Π°ΠΌ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ;
Β· ΠΡΠ°ΡΠ°ΡΡ ΠΌΠΈΡ Π²ΠΎΠΊΡΡΠ³ Π½Π°ΡΠ°Π»Π° ΠΊΠΎΠΎΡΠ΄ΠΈΠ½Π°Ρ ΠΏΡΠΎΡΠΈΠ²ΠΎΠΏΠΎΠ»ΠΎΠΆΠ΅Π½ΠΎ Π²ΡΠ°ΡΠ΅Π½ΠΈΡ ΠΊΠ°ΠΌΠ΅ΡΡ (ΡΡΠΎ Π΄Π°ΡΡ ΠΈΠ»Π»ΡΠ·ΠΈΡ ΡΠΎΠ³ΠΎ, ΡΡΠΎ ΠΏΠΎΠ²Π΅ΡΠ½ΡΠ»Π°ΡΡ ΠΊΠ°ΠΌΠ΅ΡΠ°);
Β· ΠΠ΅ΡΠ΅ΠΌΠ΅ΡΡΠΈΡΡ ΠΌΠΈΡ ΡΠΏΠΎΡΠΎΠ±ΠΎΠΌ, ΠΏΡΠΎΡΠΈΠ²ΠΎΠΏΠΎΠ»ΠΎΠΆΠ½ΡΠΌ ΠΏΠ΅ΡΠ΅ΠΌΠ΅ΡΠ΅Π½ΠΈΡ ΠΊΠ°ΠΌΠ΅ΡΡ (ΡΡΠΎ Π΄Π°ΡΡ ΠΈΠ»Π»ΡΠ·ΠΈΡ ΡΠΎΠ³ΠΎ, ΡΡΠΎ ΠΏΠ΅ΡΠ΅ΠΌΠ΅ΡΡΠΈΠ»Π°ΡΡ ΠΊΠ°ΠΌΠ΅ΡΠ°)
Π ΠΈΡ 1. ΠΡΠ°ΡΠ΅Π½ΠΈΠ΅ ΠΊΠΎΠΎΡΠ΄ΠΈΠ½Π°Ρ
ΠΠ° ΠΈΡΡ ΠΎΠ΄Π½ΠΎΠ΅ ΠΏΡΠΈΠΌΠ΅ΠΌ ΠΏΠΎΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅, Π² ΠΊΠΎΡΠΎΡΠΎΠΌ Π³ΠΎΠ»ΠΎΠ²Π° ΡΠΌΠΎΡΡΠΈΡ Π»ΠΈΡΠΎΠΌ ΠΏΠΎ Π½Π°ΠΏΡΠ°Π²Π»Π΅Π½ΠΈΡ ΠΎΡΠΈ Y, Π° Π²Π²Π΅ΡΡ ΡΠΌΠΎΡΡΠΈΡ ΠΏΠΎ Π½Π°ΠΏΡΠ°Π²Π»Π΅Π½ΠΈΡ ΠΎΡΠΈ Z. Π‘Π»Π΅Π²Π° Π½Π°ΠΏΡΠ°Π²ΠΎ ΠΏΡΠΎΡ ΠΎΠ΄ΠΈΡ ΠΎΡΡ X. ΠΠ»ΡΠ΄Ρ Π² ΡΡΠΎΠΌ ΠΆΠ΅ Π½Π°ΠΏΡΠ°Π²Π»Π΅Π½ΠΈΠΈ ΠΌΠΎΠΆΠ½ΠΎ Π²ΡΠ°ΡΠ°ΡΡ Π³ΠΎΠ»ΠΎΠ²Ρ Π²ΠΎΠΊΡΡΠ³ ΠΎΡΠΈ Z.
Π§ΡΠΎΠ±Ρ ΠΏΠΎΠ²Π΅ΡΠ½ΡΡΡ ΠΊΠ°ΠΌΠ΅ΡΡ Π²ΠΎΠΊΡΡΠ³ ΠΎΡΠΈ Z ΠΏΡΠΈΠΌΠ΅Π½ΡΠ΅ΡΡΡ ΠΎΠΏΠ΅ΡΠ°ΡΠΎΡ Π²ΡΠ°ΡΠ΅Π½ΠΈΡ ΠΌΠΈΡΠ°
glRotate (f, 0, 0, 1),
Π³Π΄Π΅ f — ΡΠ³ΠΎΠ», Π²ΡΠ°ΡΠ°ΡΡΠΈΠΉ ΠΌΠΈΡ Π½Π°Π²
Π§ΡΠΎΠ±Ρ ΠΏΠ΅ΡΠ΅ΠΌΠ΅ΡΡΠΈΡΡΡΡ Π²Π΄ΠΎΠ»Ρ ΠΎΡΠ΅ΠΉ X, Y ΠΏΡΠΈΠΌΠ΅Π½ΡΠ΅ΡΡΡ ΠΎΠΏΠ΅ΡΠ°ΡΠΎΡ
glTranslatef (tx, ty, 0),
Π³Π΄Π΅
ty := ty + sin (f*pi/180)/2;
tx := tx + cos (f*pi/180)/2;
ΠΈΠ»ΠΈ
ty := ty — sin (f*pi/180)/2;
tx := tx — cos (f*pi/180)/2;
Π Π·Π°Π²ΠΈΡΠΈΠΌΠΎΡΡΠΈ ΠΎΡ Π½Π°ΠΏΡΠ°Π²Π»Π΅Π½ΠΈΡ Π΄Π²ΠΈΠΆΠ΅Π½ΠΈΡ:
ΠΠ°ΠΆΠ°ΡΠ° ΡΡΡΠ΅Π»ΠΊΠ° «Π²Π»Π΅Π²ΠΎ» (ΠΏΠ΅ΡΠ΅ΠΌΠ΅ΡΠ΅Π½ΠΈΠ΅ ΠΏΠΎ ΠΎΡΠΈ X):
ty := ty — sin (f*pi/180)/2;
tx := tx + cos (f*pi/180)/2;
ΠΠ°ΠΆΠ°ΡΠ° ΡΡΡΠ΅Π»ΠΊΠ° «Π²ΠΏΡΠ°Π²ΠΎ»:
ty := ty + sin (f*pi/180)/2;
tx := tx — cos (f*pi/180)/2;
ΠΠ°ΠΆΠ°ΡΠ° ΡΡΡΠ΅Π»ΠΊΠ° «Π²Π²Π΅ΡΡ » (ΠΏΠ΅ΡΠ΅ΠΌΠ΅ΡΠ΅Π½ΠΈΠ΅ ΠΏΠΎ ΠΎΡΠΈ Y):
ty := ty + sin ((f+90)*pi/180)/2;
tx:= tx — cos ((f+90)*pi/180)/2;
ΠΠ°ΠΆΠ°ΡΠ° ΡΡΡΠ΅Π»ΠΊΠ° «Π²Π½ΠΈΠ·»:
ty := ty — sin ((f+90)*pi/180)/2;
tx := tx + cos ((f+90)*pi/180)/2;
Π€ΠΎΡΠΎΠ³Π°Π»Π΅ΡΠ΅Ρ ΡΠΎΡΡΠΎΠΈΡ ΠΈΠ· Π΄Π²ΡΡ ΠΎΡΠ½ΠΎΠ²Π½ΡΡ ΠΊΠΎΠΌΠ½Π°Ρ, ΠΊΠ°ΠΆΠ΄Π°Ρ ΠΈΠ· ΠΊΠΎΡΠΎΡΡΡ ΠΈΠΌΠ΅Π΅Ρ ΡΠ°Π·ΠΌΠ΅Ρ 12?12.
Π ΠΈΡ 2. Π‘ΡΡΡΠΊΡΡΡΠ° ΡΠΎΡΠΎΠ³Π°Π»Π΅ΡΠ΅ΠΈ
2. ΠΠΏΠΈΡΠ°Π½ΠΈΠ΅ ΠΌΠΎΠ΄ΡΠ»Ρ Gallery. pas
2.1 ΠΠ±ΡΠΈΠ΅ ΡΠ²Π΅Π΄Π΅Π½ΠΈΡ
ΠΡΠΎΠ³ΡΠ°ΠΌΠΌΠ½Π°Ρ Π΅Π΄ΠΈΠ½ΠΈΡΠ° ΠΏΡΠ΅Π΄ΡΡΠ°Π²Π»ΡΠ΅Ρ ΡΠΎΠ±ΠΎΠΉ ΡΡΠ°ΡΠΈΡΠ΅ΡΠΊΡΡ Π±ΠΈΠ±Π»ΠΈΠΎΡΠ΅ΠΊΡ, ΠΏΠΎΠ΄ΠΊΠ»ΡΡΠ°Π΅ΠΌΡΡ ΠΊ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ΅ Π½Π° ΡΡΠ°ΠΏΠ΅ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΠΈ.
ΠΠ°ΠΈΠΌΠ΅Π½ΠΎΠ²Π°Π½ΠΈΠ΅ ΠΌΠΎΠ΄ΡΠ»Ρ Gallery.pas.
ΠΠΎΠ΄ΡΠ»Ρ ΡΠΎΠ·Π΄Π°Π½ Π½Π° ΡΠ·ΡΠΊΠ΅ Delphi Π² ΡΡΠ΅Π΄Π΅ ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ Delphi 7.0
2.2 Π€ΡΠ½ΠΊΡΠΈΠΎΠ½Π°Π»ΡΠ½ΠΎΠ΅ Π½Π°Π·Π½Π°ΡΠ΅Π½ΠΈΠ΅
Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ ΠΈ ΠΏΠ΅ΡΠ΅ΠΌΠ΅ΡΠ΅Π½ΠΈΠ΅ ΠΏΠΎ Π²ΠΈΡΡΡΠ°Π»ΡΠ½ΠΎΠΉ ΡΠΎΡΠΎΠ³Π°Π»Π΅ΡΠ΅ΠΈ Π² ΡΠΎΠΎΡΠ²Π΅ΡΡΡΠ²ΠΈΠΈ Ρ ΠΊΠΎΠΌΠ°Π½Π΄Π°ΠΌΠΈ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ.
2.3 ΠΠΏΠΈΡΠ°Π½ΠΈΠ΅ ΡΡΡΡΠΊΡΡΡΡ ΠΌΠΎΠ΄ΡΠ»Ρ Gallery.pas.
ΠΠΎΠ΄ΡΠ»Ρ ΡΠΎΠ΄Π΅ΡΠΆΠΈΡ 13 ΠΏΡΠΎΡΠ΅Π΄ΡΡ, ΡΠ΅Π°Π»ΠΈΠ·ΡΡΡΠΈΡ ΡΠΎΠ·Π΄Π°Π½ΠΈΠ΅ Π³Π°Π»Π΅ΡΠ΅ΠΈ ΠΈ ΠΏΠ΅ΡΠ΅ΠΌΠ΅ΡΠ΅Π½ΠΈΠ΅ ΠΏΠΎ Π½Π΅ΠΉ.
procedure TfrmGL. FormPaint (Sender: TObject)
ΠΡΠΎΡΠ΅Π΄ΡΡΠ° ΠΎΠ±Π΅ΡΠΏΠ΅ΡΠΈΠ²Π°Π΅Ρ ΡΡΡΠ°Π½ΠΎΠ²ΠΊΡ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡΠΎΠ² Π³ΡΠ°ΡΠΈΡΠ΅ΡΠΊΠΈΡ ΠΎΠ±ΡΠ΅ΠΊΡΠΎΠ² ΠΈ Π²ΡΠ²ΠΎΠ΄ Π½Π° ΡΠΊΡΠ°Π½ ΠΊΠΎΠΌΠ½Π°Ρ ΡΠΎΡΠΎΠ³Π°Π»Π΅ΡΠ΅ΠΈ, Π° ΡΠ°ΠΊΠΆΠ΅ ΠΎΡΡΡΠ΅ΡΡΠ²Π»Π΅Π½ΠΈΠ΅ ΠΏΡΠΎΡΠΌΠΎΡΡΠ° Π³Π°Π»Π΅ΡΠ΅ΠΈ Π² Π°Π²ΡΠΎΠΌΠ°ΡΠΈΡΠ΅ΡΠΊΠΎΠΌ ΡΠ΅ΠΆΠΈΠΌΠ΅.
procedure TfrmGL. FormMouseMove (Sender: TObject; Shift: TShiftState; X,
Y: Integer);
ΠΡΠΎΡΠ΅Π΄ΡΡΠ° ΠΎΠΏΠΈΡΡΠ²Π°Π΅Ρ ΡΠ΅Π°ΠΊΡΠΈΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ ΠΏΡΠΈ ΠΈΠ·ΠΌΠ΅Π½Π΅Π½ΠΈΠΈ ΠΏΠΎΠ»ΠΎΠΆΠ΅Π½ΠΈΡ ΠΌΡΡΠΈ.
procedure TfrmGL. FormKeyDown (Sender: TObject; var Key: Word;
Shift: TShiftState);
ΠΡΠΎΡΠ΅Π΄ΡΡΠ° ΠΎΠΏΠΈΡΡΠ²Π°Π΅Ρ ΡΠ΅Π°ΠΊΡΠΈΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ Π½Π° Π½Π°ΠΆΠ°ΡΠΈΠ΅ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Π΅ΠΌ ΠΊΠ»Π°Π²ΠΈΡ ΡΠΏΡΠ°Π²Π»Π΅Π½ΠΈΡ Π΄Π»Ρ ΠΏΠ΅ΡΠ΅Π΄Π²ΠΈΠΆΠ΅Π½ΠΈΡ ΠΏΠΎ ΡΠΎΡΠΎΠ³Π°Π»Π΅ΡΠ΅ΠΈ ΠΈ ΡΡΡΠ°Π½ΠΎΠ²ΠΊΠΈ ΠΎΠ³ΡΠ°Π½ΠΈΡΠ΅Π½ΠΈΠΉ Π²ΡΡ ΠΎΠ΄Π° ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ Π·Π° ΠΏΡΠ΅Π΄Π΅Π»Ρ ΠΊΠΎΠΌΠ½Π°Ρ ΡΠΎΡΠΎΠ³Π°Π»Π΅ΡΠ΅ΠΈ, Π° ΡΠ°ΠΊΠΆΠ΅ ΡΡΡΠ°Π½ΠΎΠ²Π»Π΅Π½ΠΈΡ Π΄Π΅ΠΌΠΎΠ½ΡΡΡΠ°ΡΠΈΠΎΠ½Π½ΠΎΠ³ΠΎ ΡΠ΅ΠΆΠΈΠΌ ΠΈ ΠΏΡΠΎΡΠΌΠΎΡΡΠ° ΡΠΎΡΠΎΠ³ΡΠ°ΡΠΈΠΉ.
procedure TfrmGL. FormCreate (Sender: TObject);
ΠΡΠΎΡΠ΅Π΄ΡΡΠ° ΠΈΠ½ΠΈΡΠΈΠ°Π»ΠΈΠ·ΠΈΡΡΠ΅Ρ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΠ΅ ΠΈ ΡΠΎΠ·Π΄Π°Π΅Ρ ΡΡΡΠ»ΠΊΡ Π½Π° ΠΎΠΊΠ½ΠΎ Π΄Π»Ρ OpenGL
procedure TfrmGL. FormDestroy (Sender: TObject);
ΠΡΠΎΡΠ΅Π΄ΡΡΠ° ΡΠ΄Π°Π»ΡΠ΅Ρ Π²ΡΠ΅ ΠΎΠ±ΡΠ΅ΠΊΡΡ OpenGl, Π²ΡΡΠ²ΠΎΠ±ΠΎΠΆΠ΄Π°Ρ ΠΏΠ°ΠΌΡΡΡ
procedure TfrmGL. FormResize (Sender: TObject);
ΠΡΠΎΡΠ΅Π΄ΡΡΠ° ΠΏΠ΅ΡΠ΅ΡΠΈΡΠΎΠ²ΡΠ²Π°Π΅Ρ ΠΎΠΊΠ½ΠΎ ΠΈ ΡΠΎΠ·Π΄Π°Π΅Ρ ΠΏΠ΅ΡΡΠΏΠ΅ΠΊΡΠΈΠ²Ρ
procedure SetDCPixelFormat (hdc: HDC);
ΠΡΠΎΡΠ΅Π΄ΡΡΠ° Π·Π°Π΄Π°Π΅Ρ ΡΠΎΡΠΌΠ°Ρ ΠΏΠΈΠΊΡΠ΅Π»Π΅ΠΉ Π΄Π»Ρ ΡΠ°Π±ΠΎΡΡ c Π±ΠΈΠ±Π»ΠΈΠΎΡΠ΅ΠΊΠΎΠΉ OpenGl.
Procedure zal1;
ΠΡΠΎΡΠ΅Π΄ΡΡΠ° ΠΏΡΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ ΡΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ ΠΎΠ±ΡΡΠ°Π½ΠΎΠ²ΠΊΠΈ ΠΏΠ΅ΡΠ²ΠΎΠΉ ΠΊΠΎΠΌΠ½Π°ΡΡ ΡΠΎΡΠΎΠ³Π°Π»Π΅ΡΠ΅ΠΈ
Procedure zal2;
ΠΡΠΎΡΠ΅Π΄ΡΡΠ° ΠΏΡΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ ΡΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ ΠΎΠ±ΡΡΠ°Π½ΠΎΠ²ΠΊΠΈ Π²ΡΠΎΡΠΎΠΉ ΠΊΠΎΠΌΠ½Π°ΡΡ ΡΠΎΡΠΎΠ³Π°Π»Π΅ΡΠ΅ΠΈ.
Procedure zal0;
ΠΡΠΎΡΠ΅Π΄ΡΡΠ° ΠΏΡΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ ΡΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ ΠΎΠ±ΡΡΠ°Π½ΠΎΠ²ΠΊΠΈ ΡΡΠ΅ΡΡΠ΅ΠΉ ΠΈ ΡΠ΅ΡΠ²Π΅ΡΡΠΎΠΉ ΠΊΠΎΠΌΠ½Π°ΡΡ ΡΠΎΡΠΎΠ³Π°Π»Π΅ΡΠ΅ΠΈ. ΠΠΎΡΡΠ΄ΠΎΠΊ ΠΏΠΎΡΡΡΠΎΠ΅Π½ΠΈΡ Π²ΡΠΎΡΠΎΠΉ, ΡΡΠ΅ΡΡΠ΅ΠΉ ΠΈ ΡΠ΅ΡΠ²Π΅ΡΡΠΎΠΉ ΠΊΠΎΠΌΠ½Π°Ρ ΡΠΎΡΠΎΠ³Π°Π»Π΅ΡΠ΅ΠΈ ΡΡ ΠΎΠ΄Π΅Π½ Ρ ΠΏΠ΅ΡΠ²ΠΎΠΉ.
procedure BmpTexture (name:string; k: boolean);
ΠΡΠΎΡΠ΅Π΄ΡΡΠ° ΠΏΡΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ ΡΡΠ΅Π½ΠΈΠ΅ Π³ΡΠ°ΡΠΈΡΠ΅ΡΠΊΠΎΠ³ΠΎ ΡΠ°ΠΉΠ»Π° `name', ΠΊΠΎΡΠΎΡΡΠΉ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΡΡ Π² ΠΊΠ°ΡΠ΅ΡΡΠ²Π΅ ΡΠ΅ΠΊΡΡΡΡΡ Π² ΠΏΠΎΠΌΠ΅ΡΠ΅Π½ΠΈΠΈ ΡΠΎΡΠΎΠ³Π°Π»Π΅ΡΠ΅ΠΈ.
Procedure kartina;
ΠΡΠΎΡΠ΅Π΄ΡΡΠ° ΠΏΡΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ ΡΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ ΡΠ°ΠΌΡ Π΄Π»Ρ ΠΊΠ°ΡΡΠΈΠ½Ρ ΠΈ Π·Π°Π³ΡΡΠ·ΠΊΡ ΠΈΠ·ΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΡ ΠΊΠ°ΡΡΠΈΠ½Ρ.
2.4 ΠΡΠ·ΠΎΠ² ΠΈ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠ΅ ΠΌΠΎΠ΄ΡΠ»Ρ
ΠΠ»Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΡ ΠΏΡΠΎΡΠ΅Π΄ΡΡ ΠΌΠΎΠ΄ΡΠ»Ρ Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΠΎ Π½Π° ΡΡΠ°ΠΏΠ΅ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΠΈ ΠΏΠΎΠ΄ΠΊΠ»ΡΡΠΈΡΡ ΠΌΠΎΠ΄ΡΠ»Ρ ΠΊ ΠΏΡΠΎΠ΅ΠΊΡΡ, Π²Π²Π΅Π΄Ρ Π½Π°Π·Π²Π°Π½ΠΈΠ΅ ΠΌΠΎΠ΄ΡΠ»Ρ Gallery Π² ΡΠΏΠΈΡΠΎΠΊ ΠΌΠΎΠ΄ΡΠ»Π΅ΠΉ, ΠΏΠ΅ΡΠ΅ΡΠΈΡΠ»Π΅Π½Π½ΡΡ Π² ΠΏΡΠ΅Π΄Π»ΠΎΠΆΠ΅Π½ΠΈΠΈ uses. ΠΠΎΡΠ»Π΅ ΡΡΠΎΠ³ΠΎ ΠΌΠΎΠΆΠ½ΠΎ ΠΎΠ±ΡΠ°ΡΠΈΡΡΡΡ ΠΊ Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΠΎΠΉ ΠΏΡΠΎΡΠ΅Π΄ΡΡΠ΅.
3. ΠΠΏΠΈΡΠ°Π½ΠΈΠ΅ ΠΏΡΠΈΠΌΠ΅Π½Π΅Π½ΠΈΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ½ΠΎΠΉ Π΅Π΄ΠΈΠ½ΠΈΡΡ
ΠΡΠΎΡΠ΅Π΄ΡΡΡ Π±ΠΈΠ±Π»ΠΈΠΎΡΠ΅ΠΊΠΈ Gallery. pas ΠΌΠΎΠ³ΡΡ ΠΏΡΠΈΠΌΠ΅Π½ΡΡΡΡΡ ΠΏΡΠΈ ΠΏΡΠΎΠ΅ΠΊΡΠΈΡΠΎΠ²Π°Π½ΠΈΠΈ Π»ΡΠ±ΡΡ ΠΏΡΠΎΠ΅ΠΊΡΠΎΠ² Π² ΡΡΠ΅Π΄Π΅ ΡΠ°Π·ΡΠ°Π±ΠΎΡΠΊΠΈ Delphi, ΠΏΡΡΠ΅ΠΌ ΠΏΠΎΠ΄ΠΊΠ»ΡΡΠ΅Π½ΠΈΡ ΠΌΠΎΠ΄ΡΠ»Ρ Π½Π° ΡΡΠ°ΠΏΠ΅ ΠΊΠΎΠΌΠΏΠΈΠ»ΡΡΠΈΠΈ.
4. Π‘ΠΏΠΈΡΠΎΠΊ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½Π½ΠΎΠΉ Π»ΠΈΡΠ΅ΡΠ°ΡΡΡΡ
1. ΠΠ‘ΠΠ ΠΠΠ‘Π’Ρ 19.101, 19.105, 19,401.
2. M. B. ΠΡΠ°ΡΠ½ΠΎΠ² OpenGL. ΠΡΠ°ΡΠΈΠΊΠ° Π² ΠΏΡΠΎΠ΅ΠΊΡΠ°Ρ Delphi. Π. 2000.
Π’Π΅ΠΊΡΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ½ΠΎΠ³ΠΎ ΠΌΠΎΠ΄ΡΠ»Ρ Gallery. pas
unit Gallery. pas;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
OpenGL, ExtDlgs;
type
TfrmGL = class (TForm)
OpenPictureDialog1: TOpenPictureDialog;
procedure FormCreate (Sender: TObject);
procedure FormPaint (Sender: TObject);
procedure FormDestroy (Sender: TObject);
procedure FormKeyDown (Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FormResize (Sender: TObject);
procedure FormMouseMove (Sender: TObject; Shift: TShiftState; X,
Y: Integer);
private
DC: HDC;
hrc: HGLRC;
tx, ty, tz, f, t: GLfloat;
quadObj: GLUquadricObj;
lock, zal, kadr: boolean;
wrkx, wrky: Glint;
mode, demonstr: boolean;
time0, time1, FrameTime: GLInt;
count: GLint;
end;
var
frmGL: TfrmGL;
mode: (POINT, LINE, FILL, SILHOUETTE) = FILL;
gluobj: (SPHERE, CONE, CYLINDER, DISK) = SPHERE;
Position1:array [0.3] of GlFloat;
Position:array [0.2] of GlFloat=(0.5,0.5,0.5);
heading, lookupdown: GlFloat;
mpos: TPoint;
float:GlFloat;
Bitmap:TBitmap;
getpict:boolean;
room, pict: byte;
p:0.18;
implementation
uses Unit3, Unit2;
{$R *.DFM}
{====================================================================
ΠΡΠΎΡΠ΅Π΄ΡΡΠ° ΡΡΠ΅Π½ΠΈΠ΅ Π³ΡΠ°ΡΠΈΡΠ΅ΡΠΊΠΎΠ³ΠΎ ΡΠ°ΠΉΠ»Π°, ΠΊΠΎΡΠΎΡΡΠΉ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΡΡ Π² ΠΊΠ°ΡΠ΅ΡΡΠ²Π΅ ΡΠ΅ΠΊΡΡΡΡΡ}
procedure BmpTexture (name:string; k: boolean);
var
// ΠΌΠ°ΡΡΠΈΠ² ΠΎΠ±ΡΠ°Π·Π°, 64×64
i, j: Integer;
bits1:array [0.63,0.63,0.2] of Glbyte;
bits2:array [0.31,0.31,0.2] of Glbyte;
begin
Bitmap := TBitmap. Create;
Bitmap.LoadFromFile ('image/'+name); // Π·Π°Π³ΡΡΠ·ΠΊΠ° ΡΠ΅ΠΊΡΡΡΡΡ ΠΈΠ· ΡΠ°ΠΉΠ»Π°
if k then
begin
For i := 0 to 63 do
For j := 0 to 63 do
begin
bits1 [i, j, 0] := GetRValue (Bitmap.Canvas.Pixels [i, j]);
bits1 [i, j, 1] := GetGValue (Bitmap.Canvas.Pixels[i, j]);
bits1 [i, j, 2] := GetBValue (bitmap.Canvas.Pixels[i, j]);
end;
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA,
64,64, // Π·Π΄Π΅ΡΡ Π·Π°Π΄Π°Π΅ΡΡΡ ΡΠ°Π·ΠΌΠ΅Ρ ΡΠ΅ΠΊΡΡΡΡΡ
0, GL_RGB, GL_UNSIGNED_BYTE, @Bits1);
end
else begin
For i := 0 to 31 do
For j := 0 to 31 do
begin
bits2 [i, j, 0] := GetRValue (Bitmap.Canvas.Pixels [i, j]);
bits2 [i, j, 1] := GetGValue (Bitmap.Canvas.Pixels[i, j]);
bits2 [i, j, 2] := GetBValue (bitmap.Canvas.Pixels[i, j]);
end;
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA,
31,31, // Π·Π΄Π΅ΡΡ Π·Π°Π΄Π°Π΅ΡΡΡ ΡΠ°Π·ΠΌΠ΅Ρ ΡΠ΅ΠΊΡΡΡΡΡ
0, GL_RGB, GL_UNSIGNED_BYTE, @Bits2);
end;
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_Mag_FILTER, GL_LINEAR);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
end;
{==============================================================
Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ ΡΠ°ΠΌΡ Π΄Π»Ρ ΠΊΠ°ΡΡΠΈΠ½, Π° ΡΠ°ΠΊΠΆΠ΅ Π²ΡΠ²ΠΎΠ΄Π° ΠΈΠ·ΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΡ ΠΊΠ°ΡΡΠΈΠ½}
Procedure rama;
var
i:byte;
Begin
if (form2.colpic[p]=true)
then
For i:=1 to 4 do
begin
glColor3f (0.72,0.31,0.05);
glNormal3f (0,1,0);
glBegin (Gl_Quads);
glTexCoord2d (0.5,0); glVertex3f (0,0,0);
glTexCoord2d (0.5,2); glVertex3f (0,0,2);
glTexCoord2d (0, 2); glVertex3f (0.2,0.1,1.78);
glTexCoord2d (0, 0); glVertex3f (0.2,0.1,0.18);
glEnd;
glColor3f (0.491,0.25,0.1);
glBegin (Gl_Quads);
glTexCoord2d (0.2, 0); glVertex3f (0.2,0.1,0.18);
glTexCoord2d (0.2, 2); glVertex3f (0.2,0.1,1.78);
glTexCoord2d (0, 2); glVertex3f (0.3,0.05,1.78);
glTexCoord2d (0, 0); glVertex3f (0.3,0.05,0.18);
glEnd;
if getpict
then begin
frmGL.Visible:=true;
frmGL.Enabled:=true;
BMPPIC (p);
glEnable (GL_TEXTURE_2D);
end;
glColor3f (0.9,0.9,0.8);
glBegin (Gl_Quads);
glTexCoord2d (0, 1);
glVertex3f (0.3,0.05,0.3);
glTexCoord2d (1, 1);
glVertex3f (0.3,0.05,1.7);
glTexCoord2d (1, 0);
glVertex3f (1.7,0.05,1.7);
glTexCoord2d (0, 0);
glVertex3f (1.7,0.05,0.3);
glEnd;
glDisable (GL_TEXTURE_2D);
glTranslatef (2,0,0);
glRotatef (-90,0,1,0);
end;
End;
{=============================================================
ΠΡΠΎΡΠ΅Π΄ΡΡΠ° ΡΠΎΠ·Π΄Π°Π½ΠΈΡ 3 ΠΈ 4 ΠΊΠΎΠΌΠ½Π°ΡΡ ΡΠΎΡΠΎΠ³Π°Π»Π΅ΡΠ΅ΠΈ}
Procedure zal0;
var
i, k, j:integer;
quadObj: GLUquadricObj;
Begin
glPushMatrix;
quadObj := gluNewQuadric;
glColor3f (0.9, 0.9, 1); //ΡΡΠ΅Π½Ρ
if (room>=3)
then begin
glBegin (GL_QUADS);
glNormal3f (1, 0, 1); //Π»Π΅Π²Π°Ρ ΡΡΠ΅Π½Π°
glTexCoord2d (2.0, 0.0); glVertex3f (-12, 12.0, 0);
glTexCoord2d (2.0, 5.0); glVertex3f (-12.0, 12.0, 5);
glTexCoord2d (0.0, 5.0); glVertex3f (-12.0, 11.0, 5);
glTexCoord2d (0.0, 0.0); glVertex3f (-12.0, 11.0, 0);
glEnd;
ΡΠΎΡΠΎΠ³Π°Π»Π΅ΡΠ΅Ρ Π°Π»Π³ΠΎΡΠΈΡΠΌ ΠΏΡΠΎΡΠΌΠΎΡΡ Π³ΡΠ°ΡΠΈΡΠ΅ΡΠΊΠΈΠΉ
glBegin (GL_QUADS);
glNormal3f (1, 0, 1); //Π»Π΅Π²Π°Ρ ΡΡΠ΅Π½Π°
glTexCoord2d (4.0, 0.0); glVertex3f (-12, 11.0, 0);
glTexCoord2d (4.0, 1.0); glVertex3f (-12.0, 11.0, 1);
glTexCoord2d (0.0, 1.0); glVertex3f (-12.0, 7.0, 1);
glTexCoord2d (0.0, 0.0); glVertex3f (-12.0, 7.0, 0);
glEnd;
glBegin (GL_QUADS);
glNormal3f (1, 0, 1); //Π»Π΅Π²Π°Ρ ΡΡΠ΅Π½Π°
glTexCoord2d (18.0, 0.0); glVertex3f (-12, 7.0, 0);
glTexCoord2d (18.0, 5.0); glVertex3f (-12.0, 7.0, 5);
glTexCoord2d (0.0, 5.0); glVertex3f (-12.0, -12.0, 5);
glTexCoord2d (0.0, 0.0); glVertex3f (-12.0, -12.0, 0);
glEnd;
glBegin (GL_QUADS);
glNormal3f (0, -1, 1); // ΡΡΠ΅Π½Π°
glVertex3f (-12, 11.0, 1);
glVertex3f (-12, 7.0, 1);
glVertex3f (-12.2, 7.0, 1);
glVertex3f (-12.2, 11.0, 1);
glEnd;
end
else begin
glBegin (GL_QUADS);
glNormal3f (1, 0, 1); //Π»Π΅Π²Π°Ρ ΡΡΠ΅Π½Π°
glTexCoord2d (24.0, 0.0); glVertex3f (-12, 12.0, 0);
glTexCoord2d (24.0, 5.0); glVertex3f (-12.0, 12.0, 5);
glTexCoord2d (0.0, 5.0); glVertex3f (-12.0, -12.0, 5);
glTexCoord2d (0.0, 0.0); glVertex3f (-12.0, -12.0, 0);
glEnd;
end;
glBegin (GL_QUADS);
glNormal3f (0, 1, 1);//Π΄Π°Π»ΡΠ½ΡΡ
glTexCoord2d (12.0, 0.0); glVertex3f (-12, -12.0, 0);
glTexCoord2d (12.0, 5.0); glVertex3f (-12, -12.0, 5);
glTexCoord2d (0.0, 5.0); glVertex3f (12, -12.0, 5);
glTexCoord2d (0.0, 0.0); glVertex3f (12, -12.0, 0);
glEnd;
glBegin (GL_QUADS);
glNormal3f (0, -1, 1); //Π±Π»ΠΈΠΆΠ½ΡΡ
glTexCoord2d (24.0, 0.0); glVertex3f (12, 12.0, 0);
glTexCoord2d (24.0, 5.0); glVertex3f (12.0, 12.0, 5);
glTexCoord2d (0.0, 5.0); glVertex3f (-12.0, 12.0, 5);
glTexCoord2d (0.0, 0.0); glVertex3f (-12.0, 12.0, 0);
glEnd;
glBegin (GL_QUADS);
glNormal3f (-1, 0, 1); //ΠΏΡΠ°Π²Π°Ρ ΡΡΠ΅Π½Π°
glTexCoord2d (24.0, 0.0); glVertex3f (12, 12.0, 0);
glTexCoord2d (24.0, 5.0); glVertex3f (12.0, 12.0, 5);
glTexCoord2d (0.0, 5.0); glVertex3f (12.0, -12.0, 5);
glTexCoord2d (0.0, 0.0); glVertex3f (12.0, -12.0, 0);
glEnd;
BmpTexture ('WOOD30.bmp', true);
glEnable (GL_TEXTURE_2D);
glTranslatef (0.0, 0.0, 5);
glBegin (GL_QUADS);
glNormal (1,0,-1);
glTexCoord2d (12.0, 0.0); glVertex3f (12, 12.0, 0.0);
glTexCoord2d (12.0, 12.0); glVertex3f (-12.2, 12.0, 0.0);
glTexCoord2d (0.0, 12.0); glVertex3f (-12.2, -12.0, 0.0);
glTexCoord2d (0.0, 0.0); glVertex3f (12.0, -12.0, 0.0);
glEnd;
glDisable (GL_TEXTURE_2D);
glTranslatef (0.0, 0.0, -5);
BmpTexture ('w.bmp', true);
glEnable (GL_TEXTURE_2D);
glBegin (GL_QUADS);
glNormal3f (1,0,1);
glTexCoord2d (12.0, 0.0); glVertex3f (12, 12.0, 0.0);
glTexCoord2d (12.0, 12.0); glVertex3f (-12.0, 12.0, 0.0);
glTexCoord2d (0.0, 12.0); glVertex3f (-12.0, -12.0, 0.0);
glTexCoord2d (0.0, 0.0); glVertex3f (12.0, -12.0, 0.0);
glEnd;
glDisable (GL_TEXTURE_2D);
glpopMatrix;
glPushMatrix;
glTranslatef (-1.5,-11.9,0.5);
if pict=1 then
begin
//ΠΏΡΠΎΡΠΈΡΠΎΠ²ΠΊΠ° ΡΠ°ΠΌ Π΄Π»Ρ ΠΊΠ°ΡΡΠΈΠ½
glPushMatrix;
glScalef (1.5,1.5,1.5);
p:=9;
rama;
glPopmatrix ;
glTranslatef (13.4,4,0.5);
glRotatef (90,0,0,1);
p:=12;
for j:=1 to 3 do
begin
inc (p);
rama;
glTranslatef (6,0,0);
end;
glTranslatef (1.8,6.9,-0.5);
glRotatef (90,0,0,1);
p:=18;
for j:=1 to 2 do
begin
glPushMatrix;
glScalef (1.5,1.5,1.5);
dec (p);
rama;
glPopmatrix ;
glTranslatef (7,0,0);
end;
glTranslatef (2.7,9,0.5);
glRotatef (90,0,0,1);
p:=13;
for j:=1 to 3do
begin
dec (p);
rama;
glTranslatef (4.5,0,0);
end;
end;
glPopMatrix;
glPushMatrix;
//ΠΡΠΎΡΠΈΡΠΎΠ²ΠΊΠ° ΠΎΠ³ΡΠ°Π½ΠΈΡΠΈΡΠ΅Π»Π΅ΠΉ ΠΊ ΠΊΠ°ΡΡΠΈΠ½Π°ΠΌ
glTranslatef (-12, 15, 1);
for k:=1 to 2 do
begin
glTranslatef (0, -4.0, 0.0);
glColor3f (0.7, 0.7, 0.4);
gluCylinder (quadObj, 0.4, 0.4, 4, 20, 1);
for i:=1 to 10 do
begin
glPushMatrix;
glTranslatef (0.4, 0.0, 0);
gluCylinder (quadObj, 0.01, 0.01, 4, 5,1);
glPopMatrix;
glRotatef (36, 0.0, 0.0, 1.0);
end;
glPushMatrix;
gluCylinder (quadObj, 0.8, 0.4, 0.4, 4, 1);
glPopMatrix;
end;
glTranslatef (6, 0, 0);
glPopMatrix;
glPushMatrix;
glTranslatef (11.5, -9.0, 3.5);
For j:=1 to 2 do
Begin
glColor3f (0.7,0.3,0.1);
GlTranslatef (0,2,0);
For i:=1 to 4 do
begin
gluCylinder (quadObj, 0.07, 0.07,1.5, 6, 1);
gluDisk (quadObj, 0, 0.08, 10, 1);
GlTranslatef (0,5,0);
end;
glColor3f (1,0,0);
glBegin (GL_QUADS);
glNormal3f (1,1,0);
glVertex3f (0, -20.0, 0.0);
glVertex3f (0, -20.0, 0.2);
glVertex3f (0, -5, 0.2);
glVertex3f (0, -5, 0.0);
glEnd;
glTranslatef (-23, -25.5, 0.1);
end;
glPopMatrix;
glPushMatrix;
glTranslatef (-7.5, 11.5, 3.5);
For k:=1 to 2 do
begin
glColor3f (0.7,0.3,0.1);
For i:=1 to 4 do
begin
gluCylinder (quadObj, 0.07, 0.07,1.5, 6, 1);
gluDisk (quadObj, 0, 0.08, 10, 1);
GlTranslatef (5,0,0);
end;
glColor3f (1,0,0);
glTranslatef (0, 0, 0.1);
glBegin (GL_QUADS);
glNormal3f (1,1,0);
glVertex3f (-5, 0, 0.0);
glVertex3f (-5.0, 0, 0.2);
glVertex3f (-20.0, 0, 0.2);
glVertex3f (-20.0, 0, 0.0);
glEnd;
glTranslatef (-20, -47, -0.1);
end;
GlPopMatrix;
glPushMatrix;
GlTranslatef (-4,-11.5,3.5);
glColor3f (0.7,0.3,0.1);
For i:=1 to 3 do
begin
gluCylinder (quadObj, 0.07, 0.07,1.5, 6, 1);
gluDisk (quadObj, 0, 0.08, 10, 1);
GlTranslatef (4,0,0);
end;
glColor3f (1,0,0);
glTranslatef (0, 0, 0.1);
glBegin (GL_QUADS);
glNormal3f (1,1,0);
glVertex3f (-4, 0, 0.0);
glVertex3f (-4.0, 0, 0.2);
glVertex3f (-12.0, 0, 0.2);
glVertex3f (-12.0, 0, 0.0);
glEnd;
glPopMatrix;
End;
{=============================================================
ΠΡΠΎΡΠ΅Π΄ΡΡΠ° ΠΏΡΠΎΡΠΈΡΠΎΠ²ΠΊΠΈ ΠΏΠ΅ΡΠ²ΠΎΠΉ ΠΊΠΎΠΌΠ½Π°ΡΡ}
Procedure zal1;
var
i, k, j:integer;
quadObj: GLUquadricObj;
Begin
glPushMatrix;
quadObj := gluNewQuadric;
glColor3f (0.9, 0.9, 1); //ΡΠ²Π΅Ρ ΡΡΠ΅Π½
BmpTexture ('w.bmp', true);
glEnable (GL_TEXTURE_2D);
if room>=4
then begin
glBegin (GL_QUADS);
glNormal3f (1, 0, 1); //Π»Π΅Π²Π°Ρ ΡΡΠ΅Π½Π°
glTexCoord2d (19.0, 0.0); glVertex3f (-12, 12.0, 0);
glTexCoord2d (19.0, 5.0); glVertex3f (-12.0, 12.0, 5);
glTexCoord2d (0.0, 5.0); glVertex3f (-12.0, -7.0, 5);
glTexCoord2d (0.0, 0.0); glVertex3f (-12.0, -7.0, 0);
glEnd;
glBegin (GL_QUADS);
glNormal3f (1, 0, 1); //Π»Π΅Π²Π°Ρ ΡΡΠ΅Π½Π°
glTexCoord2d (4.0, 0.0); glVertex3f (-12, -7.0, 0);
glTexCoord2d (4.0, 1.0); glVertex3f (-12.0, -7.0, 1);
glTexCoord2d (0.0, 1.0); glVertex3f (-12.0, -11.0, 1);
glTexCoord2d (0.0, 0.0); glVertex3f (-12.0, -11.0, 0);
glEnd;
glBegin (GL_QUADS);
glNormal3f (1, 0, 1); //Π»Π΅Π²Π°Ρ ΡΡΠ΅Π½Π°
glTexCoord2d (1.0, 0.0); glVertex3f (-12, -11.0, 0);
glTexCoord2d (1.0, 5.0); glVertex3f (-12.0, -11.0, 5);
glTexCoord2d (0.0, 5.0); glVertex3f (-12.0, -12.0, 5);
glTexCoord2d (0.0, 0.0); glVertex3f (-12.0, -12.0, 0);
glEnd;
end
else begin
glBegin (GL_QUADS);
glNormal3f (1, 0, 1); //Π»Π΅Π²Π°Ρ ΡΡΠ΅Π½Π°
glTexCoord2d (24.0, 0.0); glVertex3f (-12, 12.0, 0);
glTexCoord2d (24.0, 5.0); glVertex3f (-12.0, 12.0, 5);
glTexCoord2d (0.0, 5.0); glVertex3f (-12.0, -12.0, 5);
glTexCoord2d (0.0, 0.0); glVertex3f (-12.0, -12.0, 0);
glEnd;
end;
glBegin (GL_QUADS);
glNormal3f (0, 1, 1);//Π΄Π°Π»ΡΠ½ΡΡ
glTexCoord2d (3.0, 0.0); glVertex3f (-12, -12.0, 0);
glTexCoord2d (3.0, 5.0); glVertex3f (-12, -12.0, 5);
glTexCoord2d (0.0, 5.0); glVertex3f (-9.0, -12.0, 5);
glTexCoord2d (0.0, 0.0); glVertex3f (-9.0, -12.0, 0);
glEnd;
glBegin (GL_QUADS);
glNormal3f (0, 1, 1);
glTexCoord2d (4.0, 0.0); glVertex3f (-9, -12.0, 0);
glTexCoord2d (4.0, 1); glVertex3f (-9, -12.0, 1);
glTexCoord2d (0.0, 1); glVertex3f (-5, -12.0, 1);
glTexCoord2d (0.0, 0.0); glVertex3f (-5, -12.0, 0);
glEnd;
glBegin (GL_QUADS);
glNormal3f (0, 1, 1);//Π΄Π°Π»ΡΠ½ΡΡ
glTexCoord2d (10, 0.0); glVertex3f (-5, -12.0, 0);
glTexCoord2d (10, 5.0); glVertex3f (-5, -12.0, 5);
glTexCoord2d (0.0, 5.0); glVertex3f (5.0, -12.0, 5);
glTexCoord2d (0.0, 0.0); glVertex3f (5.0, -12.0, 0);
glEnd;
glBegin (GL_QUADS);
glNormal3f (0, 1, 1);
glTexCoord2d (4.0, 0.0); glVertex3f (5, -12.0, 0);
glTexCoord2d (4.0, 1); glVertex3f (5, -12.0, 1);
glTexCoord2d (0.0, 1); glVertex3f (9, -12.0, 1);
glTexCoord2d (0.0, 0.0); glVertex3f (9, -12.0, 0);
glEnd;
glBegin (GL_QUADS);
glNormal3f (0, 1, 1);//Π΄Π°Π»ΡΠ½ΡΡ
glTexCoord2d (3.0, 0.0); glVertex3f (9, -12.0, 0);
glTexCoord2d (3.0, 5.0); glVertex3f (9.0, -12.0, 5);
glTexCoord2d (0.0, 5.0); glVertex3f (12.0, -12.0, 5);
glTexCoord2d (0.0, 0.0); glVertex3f (12.0, -12.0, 0);
glEnd;
glBegin (GL_QUADS);
glNormal3f (0, -1, 1); //Π±Π»ΠΈΠΆΠ½ΡΡ
glTexCoord2d (24.0, 0.0); glVertex3f (12, 12.0, 0);
glTexCoord2d (24.0, 5.0); glVertex3f (12.0, 12.0, 5);
glTexCoord2d (0.0, 5.0); glVertex3f (-12.0, 12.0, 5);
glTexCoord2d (0.0, 0.0); glVertex3f (-12.0, 12.0, 0);
glEnd;
if room>=3 //ΠΡΠΎΡΠΈΡΠΎΠ²ΠΊΠ° ΠΏΡΠΎΡ ΠΎΠ΄Π° Π² ΡΡΠ΅ΡΡΡ ΠΊΠΎΠΌΠ½Π°ΡΡ, Π΅ΡΠ»ΠΈ ΠΎΠ½Π° ΠΏΠΎΠ΄ΠΊΠ»ΡΡΠ΅Π½Π°
then begin
glBegin (GL_QUADS);
glNormal3f (-1, 0, 1); //ΠΏΡΠ°Π²Π°Ρ ΡΡΠ΅Π½Π°
glTexCoord2d (1.0, 0.0); glVertex3f (12, 12.0, 0);
glTexCoord2d (1.0, 5.0); glVertex3f (12.0, 12.0, 5);
glTexCoord2d (0.0, 5.0); glVertex3f (12.0, 11.0, 5);
glTexCoord2d (0.0, 0.0); glVertex3f (12.0, 11.0, 0);
glEnd;
glBegin (GL_QUADS);
glNormal3f (-1, 0, 1); //Π»Π΅Π²Π°Ρ ΡΡΠ΅Π½Π°
glTexCoord2d (4.0, 0.0); glVertex3f (12, 11.0, 0);
glTexCoord2d (4.0, 1.0); glVertex3f (12.0, 11.0, 1);
glTexCoord2d (0.0, 1.0); glVertex3f (12.0, 7.0, 1);
glTexCoord2d (0.0, 0.0); glVertex3f (12.0, 7.0, 0);
glEnd;
glBegin (GL_QUADS);
glNormal3f (-1, 0, 1); //ΠΏΡΠ°Π²Π°Ρ ΡΡΠ΅Π½Π°
glTexCoord2d (19.0, 0.0); glVertex3f (12, 7.0, 0);
glTexCoord2d (19.0, 5.0); glVertex3f (12.0, 7.0, 5);
glTexCoord2d (0.0, 5.0); glVertex3f (12.0, -12.0, 5);
glTexCoord2d (0.0, 0.0); glVertex3f (12.0, -12.0, 0);
glEnd;
end
else begin
glBegin (GL_QUADS);
glNormal3f (-1, 0, 1); //ΠΏΡΠ°Π²Π°Ρ ΡΡΠ΅Π½Π°
glTexCoord2d (24.0, 0.0); glVertex3f (12, 12.0, 0);
glTexCoord2d (24.0, 5.0); glVertex3f (12.0, 12.0, 5);
glTexCoord2d (0.0, 5.0); glVertex3f (12.0, -12.0, 5);
glTexCoord2d (0.0, 0.0); glVertex3f (12.0, -12.0, 0);
glEnd;
end;
//ΠΏΠΎΠ» ΠΈ ΠΏΠΎΡΠΎΠ»ΠΎΠΊ
glTranslatef (0.0, 0.0, 5);
glBegin (GL_QUADS);
glNormal (1,0,-1);
glTexCoord2d (12.0, 0.0); glVertex3f (12, 12.0, 0.0);
glTexCoord2d (12.0, 12.0); glVertex3f (-12.0, 12.0, 0.0);
glTexCoord2d (0.0, 12.0); glVertex3f (-12.0, -12.0, 0.0);
glTexCoord2d (0.0, 0.0); glVertex3f (12.0, -12.0, 0.0);
glEnd;
glDisable (GL_TEXTURE_2D);
glTranslatef (0.0, 0.0, -5);
BmpTexture ('blue.bmp', true);
glEnable (GL_TEXTURE_2D);
glBegin (GL_QUADS);
glNormal3f (1,0,1);
glTexCoord2d (12.0, 0.0); glVertex3f (12, 12.0, 0.0);
glTexCoord2d (12.0, 12.0); glVertex3f (-12.0, 12.0, 0.0);
glTexCoord2d (0.0, 12.0); glVertex3f (-12.0, -12.0, 0.0);
glTexCoord2d (0.0, 0.0); glVertex3f (12.0, -12.0, 0.0);
glEnd;
glDisable (GL_TEXTURE_2D);
glpopMatrix;
glPushMatrix;
glTranslatef (-1.5,-11.9,0.5);
if pict=1 then
begin
//ΡΠ°ΠΌΡ Π΄Π»Ρ ΠΊΠ°ΡΡΠΈΠ½
glPushMatrix;
glScalef (1.5,1.5,1.5);
p:=9;
rama;
glPopmatrix ;
glTranslatef (13.4,4,0.5);
glRotatef (90,0,0,1);
p:=12;
for j:=1 to 3 do
begin
inc (p);
rama;
glTranslatef (6,0,0);
end;
glTranslatef (1.8,6.9,-0.5);
glRotatef (90,0,0,1);
p:=18;
for j:=1 to 2 do
begin
glPushMatrix;
glScalef (1.5,1.5,1.5);
dec (p);
rama;
glPopmatrix ;
glTranslatef (7,0,0);
end;
glTranslatef (2.7,4.1,0.5);
glRotatef (90,0,0,1);
p:=13;
for j:=1 to 3do
begin
dec (p);
rama;
glTranslatef (6,0,0);
end;
end;
//ΠΡΠΎΡΠΈΡΠΎΠ²ΠΊΠ° ΠΎΠ³ΡΠ°Π½ΠΈΡΠΈΡΠ΅Π»Π΅ΠΉ ΠΊ ΠΊΠ°ΡΡΠΈΠ½Π°ΠΌ
glPopMatrix;
glPushMatrix;
glTranslatef (-13, -12, 1);
For j:=1 to 2 do
begin
for k:=1 to 2 do
begin
glTranslatef (4, 0.0, 0.0);
glColor3f (0.7, 0.7, 0.4);
gluCylinder (quadObj, 0.4, 0.4, 4, 20, 1);
for i:=1 to 10 do
begin
glPushMatrix;
glTranslatef (0.4, 0.0, 0);
gluCylinder (quadObj, 0.01, 0.01, 4, 5,1);
glPopMatrix;
glRotatef (36, 0.0, 0.0, 1.0);
end;
glPushMatrix;
gluCylinder (quadObj, 0.8, 0.4, 0.4, 4, 1);
glPopMatrix;
end;
glTranslatef (6, 0, 0);
end;
glPopMatrix;
glPushMatrix;
glTranslatef (11.5, -10.0, 3.5);
For k:=1 to 2 do
Begin
For j:=1 to 2 do
Begin
glColor3f (0.7,0.3,0.1);
For i:=1 to 5 do
begin
gluCylinder (quadObj, 0.07, 0.07,1.5, 6, 1);
// glTranslatef (0, 0, -1);
gluDisk (quadObj, 0, 0.08, 10, 1);
GlTranslatef (0,4,0);
end;
glColor3f (1,0,0);
glBegin (GL_QUADS);
glNormal3f (1,1,0);
glVertex3f (0, -4.0, 0.0);
glVertex3f (0, -4.0, 0.2);
glVertex3f (0, -20, 0.2);
glVertex3f (0, -20, 0.0);
glEnd;
glTranslatef (0, -43, 0);
end;
glNormal3f (-1,1,0);
glTranslatef (-23, 50, 0);
end;
glPopMatrix;
glPushMatrix;
glTranslatef (-7.5, 11.5, 3.5);
For k:=1 to 2 do
begin
glColor3f (0.7,0.3,0.1);
For i:=1 to 4 do
begin
gluCylinder (quadObj, 0.07, 0.07,1.5, 6, 1);
gluDisk (quadObj, 0, 0.08, 10, 1);
GlTranslatef (5,0,0);
end;
glColor3f (1,0,0);
glTranslatef (0, 0, 0.1);
glBegin (GL_QUADS);
glNormal3f (1,1,0);
glVertex3f (-5, 0, 0.0);
glVertex3f (-5.0, 0, 0.2);
glVertex3f (-20.0, 0, 0.2);
glVertex3f (-20.0, 0, 0.0);
glEnd;
glTranslatef (-18, -47, -0.1);
end;
GlPopMatrix;
glPushMatrix;
GlTranslatef (-4,-11.5,3.5);
glColor3f (0.7,0.3,0.1);
For i:=1 to 3 do
begin
gluCylinder (quadObj, 0.07, 0.07,1.5, 6, 1);
gluDisk (quadObj, 0, 0.08, 10, 1);
GlTranslatef (4,0,0);
end;
glColor3f (1,0,0);
glTranslatef (0, 0, 0.1);
glBegin (GL_QUADS);
glNormal3f (1,1,0);
glVertex3f (-4, 0, 0.0);
glVertex3f (-4.0, 0, 0.2);
glVertex3f (-12.0, 0, 0.2);
glVertex3f (-12.0, 0, 0.0);
glEnd;
glPopMatrix;
End;
{=============================================================
ΠΡΠΎΡΠ΅Π΄ΡΡΠ° ΠΏΡΠΎΡΠΈΡΠΎΠ²ΠΊΠΈ ΠΏΠ΅ΡΠ²ΠΎΠΉ ΠΊΠΎΠΌΠ½Π°ΡΡ}
Procedure zal2;
var
i, j: integer;
quadObj: GLUquadricObj;
Begin
quadObj := gluNewQuadric;
glPushMatrix;
glColor3f (0.9,0.9,0.8);
glBegin (GL_QUADS);
glNormal3f (1, 0, 1); //Π»Π΅Π²Π°Ρ ΡΡΠ΅Π½Π°
glVertex3f (-12, 12.0, 0);
glVertex3f (-12.0, 12.0, 5);
glVertex3f (-12.0, -12.0, 5);
glVertex3f (-12.0, -12.0, 0);
glEnd;
glBegin (GL_QUADS);
glNormal3f (0, 1, 1); //Π΄Π°Π»ΡΠ½ΡΡ ΡΡΠ΅Π½Π°
glVertex3f (12, -12.0, 0);
glVertex3f (12.0, -12.0, 5);
glVertex3f (-12.0, -12.0, 5);
glVertex3f (-12.0, -12.0, 0);
glEnd;
glBegin (GL_QUADS);
glNormal3f (-1,0, 1); // ΠΏΡΠ°Π²Π°Ρ ΡΡΠ΅Π½Π°
glVertex3f (12, 12.0, 0);
glVertex3f (12.0, 12.0, 5);
glVertex3f (12.0, -12.0, 5);
glVertex3f (12.0, -12.0, 0);
glEnd;
glBegin (GL_QUADS);
glNormal3f (0, -1, 1);//Π±Π»ΠΈΠΆΠ½ΡΡ
glVertex3f (-12, 11.8, 0);
glVertex3f (-12, 11.8, 5);
glVertex3f (-9.0, 11.8, 5);
glVertex3f (-9.0, 11.8, 0);
glEnd;
glBegin (GL_QUADS);
glNormal3f (0, -1, 1);
glVertex3f (-9, 11.8, 0);
glVertex3f (-9, 11.8, 1);
glVertex3f (-5, 11.8, 1);
glVertex3f (-5, 11.8, 0);
glEnd;
glBegin (GL_QUADS);
glNormal3f (1, 0, 1);
glVertex3f (-9, 11.8, 1);
glVertex3f (-9, 12, 1);
glVertex3f (-5, 12, 1);
glVertex3f (-5, 11.8, 1);
glEnd;
glBegin (GL_QUADS);
glNormal3f (0, -1, 1);//Π±Π»ΠΈΠΆΠ½ΡΡ
glVertex3f (-5, 11.8, 0);
glVertex3f (-5, 11.8, 5);
glVertex3f (5.0, 11.8, 5);
glVertex3f (5.0, 11.8, 0);
glEnd;
glBegin (GL_QUADS);
glNormal3f (0, -1, 1);
glVertex3f (5, 11.8, 0);
glVertex3f (5, 11.8, 1);
glVertex3f (9, 11.8, 1);
glVertex3f (9, 11.8, 0);
glEnd;
glBegin (GL_QUADS);
glNormal3f (1, 0, 1);
glVertex3f (5, 11.8, 1);
glVertex3f (5, 12, 1);
glVertex3f (9, 12, 1);
glVertex3f (9, 11.8, 1);
glEnd;
glBegin (GL_QUADS);
glNormal3f (0, -1, 1);//Π±Π»ΠΈΠΆΠ½ΡΡ
glVertex3f (9, 11.8, 0);
glVertex3f (9.0, 11.8, 5);
glVertex3f (12.0, 11.8, 5);
glVertex3f (12.0, 11.8, 0);
glEnd;
glBegin (GL_QUADS);
glNormal3f (0, -1, 1); // ΡΡΠ΅Π½Π°
glVertex3f (-0.25, -4.0, 0);
glVertex3f (-0.25, -4.0, 5);
glVertex3f (0.25, -4.0, 5);
glVertex3f (0.25, -4.0, 0);
glEnd;
glPushMatrix;
glTranslatef (-0.75,0,0);
glNormal3f (-1,0, 1); // ΠΏΠ΅ΡΠ΅Π³ΠΎΡΠΎΠ΄ΠΊΠ° ΠΏΡΠ°Π²Π°Ρ ΡΡΠ΅Π½Π°
For i:=1 to 2 do
begin
glTranslatef (0.5,0,0);
glBegin (GL_QUADS);
glVertex3f (0, 12.0, 0);
glVertex3f (0, 12.0, 5);
glVertex3f (0, -4.0, 5);
glVertex3f (0, -4.0, 0);
glEnd;
glNormal3f (1,0, 1); // ΠΏΠ΅ΡΠ΅Π³ΠΎΡΠΎΠ΄ΠΊΠ° Π»Π΅Π²Π°Ρ ΡΡΠ΅Π½Π°
end ;
glpopMatrix;
BmpTexture ('Roof.bmp', true);
glEnable (GL_TEXTURE_2D);
glBegin (GL_QUADS); //ΠΏΠΎΠ» ΠΈ ΠΏΠΎΡΠΎΠ»ΠΎΠΊ
glNormal3f (0,0, 1);
glTexCoord2d (12.0, 0.0); glVertex3f (12, 12.0, 0.0);
glTexCoord2d (12.0, 12.0); glVertex3f (-12.0, 12.0, 0.0);
glTexCoord2d (0.0, 12.0); glVertex3f (-12.0, -12.0, 0.0);
glTexCoord2d (0.0, 0.0); glVertex3f (12.0, -12.0, 0.0);
glEnd;
glDisable (GL_TEXTURE_2D);
glTranslatef (0.0, 0.0, 5);
BmpTexture ('ΠΏΠ°ΡΠΊΠ΅Ρ.bmp', true);
glColor3f (1,1,1);
glEnable (GL_TEXTURE_2D);
glNormal (0,0,1);
glBegin (GL_QUADS); //ΠΏΠΎΠ» ΠΈ ΠΏΠΎΡΠΎΠ»ΠΎΠΊ
glTexCoord2d (12.0, 0.0); glVertex3f (12, 12.0, 0.0);
glTexCoord2d (12.0, 12.0); glVertex3f (-12.0, 12.0, 0.0);
glTexCoord2d (0.0, 12.0); glVertex3f (-12.0, -12.0, 0.0);
glTexCoord2d (0.0, 0.0); glVertex3f (12.0, -12.0, 0.0);
glEnd;
glEnable (GL_COLOR_Material);
glDisable (GL_TEXTURE_2D);
glTranslatef (0.0, 0.0, 5);
glPopMatrix;
glPushMatrix;
if pict=2 then
begin
glTranslatef (-5,-11.8,0.5);
p:=0;
for j:=1 to 2 do //ΡΠ°ΠΌΡ Π΄Π»Ρ ΠΊΠ°ΡΡΠΈΠ½
begin
glPushmatrix;
glScalef (1.5,1.5,1.5);
inc (p);
rama;
glPopMatrix ;
glTranslatef (7,0,0);
end;
glTranslatef (2.9,4,0.5);
glRotatef (90,0,0,1);
p:=2;
for j:=1 to 3 do
begin
inc (p);
rama;
glTranslatef (6,0,0);
end;
glTranslatef (1.8,6,0);
glRotatef (90,0,0,1);
glTranslatef (17.7,4.1,0);
glRotatef (90,0,0,1);
p:=9;
for j:=1 to 3 do
begin
dec (p);
rama;
glTranslatef (6,0,0);
end;
end;
//ΠΡΠΎΡΠΈΡΠΎΠ²ΠΊΠ° ΠΎΠ³ΡΠ°Π½ΠΈΡΠΈΡΠ΅Π»Π΅ΠΉ ΠΊ ΠΊΠ°ΡΡΠΈΠ½Π°ΠΌ
glPopMatrix;
glPushMatrix;
GlTranslatef (0.8,0,3.5);
For j:=1 to 2 do
begin
For i:=1 to 3 do
begin
glColor3f (0.7,0.3,0.1);
gluCylinder (quadObj, 0.07, 0.07,1.5, 6, 1);
gluDisk (quadObj, 0, 0.08, 10, 1);
GlTranslatef (0,4.5,0);
end;
glColor3f (1,0,0);
glTranslatef (0, -4.5, 0.1);
glBegin (GL_QUADS);
glVertex3f (0, 0, 0.0);
glVertex3f (0, 0, 0.2);
glVertex3f (0, -9, 0.2);
glVertex3f (0, -9, 0.0);
glEnd;
GlTranslatef (-1.6,-9,-0.1);
end;
glPopMatrix;
glTranslatef (-7.3, -11.9, 1);
End;
{=======================================================================
ΠΠ΅ΡΠ΅ΡΠΈΡΠΎΠ²ΠΊΠ° ΠΎΠΊΠ½Π°}
procedure TfrmGL. FormPaint (Sender: TObject);
begin
Position1 [0]: =0; //Π£ΡΡΠ°Π½ΠΎΠ²ΠΊΠ°
Position1 [1]: =3; //ΠΏΠΎΠ»ΠΎΠΆΠ΅Π½ΠΈΡ
Position1 [2]: =4; //ΠΈΡΡΠΎΡΠ½ΠΈΠΊΠΎΠ²
Position1 [3]: =12; //ΡΠ²Π΅ΡΠ°
glClear (GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);// ΠΎΡΠΈΡΡΠΊΠ° Π±ΡΡΠ΅ΡΠ° ΡΠ²Π΅ΡΠ°
glLightfv (GL_LIGHT0,GL_PosiTion, @position1); //ΠΠ°Π³ΡΡΠ·ΠΊΠ° ΠΈΡΡΠΎΡΠ½ΠΈΠΊΠΎΠ² ΡΠ²Π΅ΡΠ°
glMaterialfv (GL_FRONT, GL_SPECULAR, @Position); //ΡΡΡΠ°Π½ΠΎΠ²ΠΊΠ° ΡΠ²ΠΎΠΉΡΡΠ² ΠΌΠ°ΡΠ΅ΡΠΈΠ°Π»Π°
if Lock //ΠΡΠΎΠ²Π΅ΡΠΊΠ° Π±Π»ΠΎΠΊΠΈΡΠΎΠ²ΠΊΠΈ ΡΠΊΠ°Π·Π°ΡΠ΅Π»Ρ
then SetCursorPos (wrkX, wrkY);
if not mode
then glPolygonMode (GL_FRONT_AND_BACK, GL_LINE) //Π£ΡΡΠ°Π½ΠΎΠ²ΠΊΠ° ΡΡΠΈΠ»Ρ ΡΠΈΡΠΎΠ²Π°Π½ΠΈΡ Π»ΠΈΠ½ΠΈΡΠΌΠΈ
else glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); //Π£ΡΡΠ°Π½ΠΎΠ²ΠΊΠ° ΡΡΠΈΠ»Ρ ΡΠΈΡΠΎΠ²Π°Π½ΠΈΡ Ρ Π·Π°ΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ΠΌ
glPushMatrix; //Π‘ΠΎΡ ΡΠ°Π½Π΅Π½ΠΈΠ΅ ΠΈΡΡ ΠΎΠ΄Π½ΠΎΠ³ΠΎ ΡΠΎΡΡΠΎΡΠ½ΠΈΡ ΠΌΠ°ΡΡΠΈΡΡ
glRotate (f, 0, 0, 1); //ΠΏΠΎΠ²ΠΎΡΠΎΡ «ΠΌΠΈΡΠ°» Π½Π° ΡΠ³ΠΎΠ» f
glTranslatef (tx, ty, tz); //ΠΠ΅ΡΠ΅ΠΌΠ΅ΡΠ΅Π½ΠΈΠ΅ ΠΏΠΎ Π³Π°Π»Π΅ΡΠ΅ΠΈ
glPushMatrix;
zal1; // Π²ΡΠ·ΠΎΠ² ΠΏΡΠΎΡΠ΅Π΄ΡΡΡ ΡΠΈΡΠΎΠ²Π°Π½ΠΈΡ ΠΏΠ΅ΡΠ²ΠΎΠΉ ΠΊΠΎΠΌΠ½Π°ΡΡ
glPopMatrix;
glPushMatrix;
glTranslatef (0,-24,0);
zal2; //Π²ΡΠ·ΠΎΠ² ΠΏΡΠΎΡΠ΅Π΄ΡΡΡ ΡΠΈΡΠΎΠ²Π°Π½ΠΈΡ Π²ΡΠΎΡΠΎΠΉ ΠΊΠΎΠΌΠ½Π°ΡΡ
glPopMatrix;
if room>=3 then
begin
glTranslatef (24.2,0,0);
glPushMatrix;
zal0; //Π²ΡΠ·ΠΎΠ² ΠΏΡΠΎΡΠ΅Π΄ΡΡΡ ΡΠΈΡΠΎΠ²Π°Π½ΠΈΡ ΡΡΠ΅ΡΡΠ΅ΠΉ ΠΊΠΎΠΌΠ½Π°ΡΡ
glPopMatrix;
end;
if room>=4 then
begin
glTranslatef (-48.4,0,0);
glRotatef (180,0,0,1);
glPushMatrix;
zal0; //Π²ΡΠ·ΠΎΠ² ΠΏΡΠΎΡΠ΅Π΄ΡΡΡ ΡΠΈΡΠΎΠ²Π°Π½ΠΈΡ ΡΠ΅ΡΠ²Π΅ΡΡΠΎΠΉ ΠΊΠΎΠΌΠ½Π°ΡΡ
glPopMatrix;
end;
glPopMatrix;
if demonstr
then //ΠΠ°ΠΏΡΡΠΊ ΡΠ΅ΠΆΠΈΠΌΠ° Π΄Π΅ΠΌΠΎΠ½ΡΡΡΠ°ΡΠΈΠΈ
begin
count:= count+1;
tx:=0;
ty:=0;
case count of
2:begin
f:=0;
pict:=1;
end;
3.61:f:=f+6;
62.78:ty:=(count-62)*0.5;
79.92:begin
ty:=8;
tx:=tx+(count-78)*0.5;
f:=f+6;
end;
93.133:begin
ty:=-(count-93)*0.4+8;
tx:=7;
end;
134.150:begin
ty:=-8;
tx:=7;
f:=f+6
end;
151.177:begin
ty:=-7.5;
tx:=-(count-151)*0.5+7;
end;
178.193:begin
ty:=-7.5;
tx:=-6;
f:=f+6;
end;
194.223:begin
ty:=(count-193)*0.5−7.5;
tx:=-6.5;
end;
224.229:begin
tx:=-6.5;
ty:=7.5;
f:=f+6;
end;
230.236:begin
pict:=2;
tx:=-6.5;
ty:=7.5;
f:=f+6;
end;
237.256:begin
pict:=2;
tx:=-6.5;
ty:=(count-236)*0.5+7.5;
end;
257.265:begin
tx:=-6.5;
ty:=14.5;
f:=f-6;
end;
266.296:begin
ty:=(count-265)*0.5+14.5;
tx:=-6.5;
end;
297.307:begin
tx:=-6.5;
ty:=29.5;
f:=f+6;
end;
308.332:begin
tx:=(count-308)*0.5−6.5;
ty:=29.5;
end;
333.345:begin
tx:=6.5;
ty:=29.5;
f:=f+6;
end;
346.374:begin
ty:=-(count-346)*0.5+29.5;
tx:=6.5;
end;
375.380:begin
tx:=6.5;
ty:=15.5;
f:=f+6;
end;
381.406:begin
pict:=1;
tx:=6.5;
ty:=15.5;
f:=f+6;
end;
407.420:begin
pict:=2;
tx:=6.5;
ty:=15.5;
f:=f+6;
end;
else begin
tX:=0;
tY:=-10;
f:=0;
demonstr:=false;
count:=1;
end
end;
end;
if kadr
then begin //ΠΠ°ΠΏΡΡΠΊ ΡΠ΅ΠΆΠΈΠΌΠ° ΠΎΡΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΡ Π²ΡΠ΅ΠΌΠ΅Π½ΠΈ ΠΏΠΎΡΡΡΠΎΠ΅Π½ΠΈΡ 1 ΠΊΠ°Π΄ΡΠ°
time0:= GetTickCount;
FrameTime:=time0 — time1;
time1:=time0;
FRMGL.Caption :=inttostr (count)+'ΠΊΠ°Π΄Ρ 3Π° '+ inttostr (Frametime)+'ΠΌΡ ';
end
else
FRMGL.Caption :='Gallery ';
SwapBuffers (DC);
end;
{=======================================================================
Π€ΠΎΡΠΌΠ°Ρ ΠΏΠΈΠΊΡΠ΅Π»Ρ}
procedure SetDCPixelFormat (hdc: HDC);
var
pfd: TPixelFormatDescriptor;
nPixelFormat: Integer;
begin
FillChar (pfd, SizeOf (pfd), 0);
pfd.dwFlags := PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL or PFD_DOUBLEBUFFER;
nPixelFormat := ChoosePixelFormat (hdc, @pfd);
SetPixelFormat (hdc, nPixelFormat, @pfd);
end;
{=======================================================================
Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ ΡΠΎΡΠΌΡ}
procedure TfrmGL. FormCreate (Sender: TObject);
begin
room:=2;
DC := GetDC (Handle);
SetDCPixelFormat (DC);
hrc := wglCreateContext (DC);
wglMakeCurrent (DC, hrc);
glClearColor (1, 1, 0.9, 1.0); // ΡΠ²Π΅Ρ ΡΠΎΠ½Π°
glLineWidth (1.5);
glEnable (GL_LIGHTING);
glEnable (GL_LIGHT0);
glEnable (GL_DEPTH_TEST);
glEnable (GL_COLOR_MATERIAL);
quadObj := gluNewQuadric;
tX:=0;
tY:=-10;
tZ:=-2;
demonstr:=false;
count:=1;
lock:=true;
pict:=1;
zal:=false;
mode:=true;
form2.prosmotr:=false;
getpict:=true;
p:=0;
t:=0;
f:=0;
ShowCursor (false);
wrkX:=Left+round (Width/2);
wrkY:=Top+round (Height/2);
SetCursorPos (wrkx, wrky);
end;
{=======================================================================
ΠΠΎΠ½Π΅Ρ ΡΠ°Π±ΠΎΡΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ}
procedure TfrmGL. FormDestroy (Sender: TObject);
begin
gluDeleteQuadric (quadObj);
wglMakeCurrent (0, 0);
wglDeleteContext (hrc);
ReleaseDC (Handle, DC);
DeleteDC (DC);
end;
procedure showimage (number:byte);
begin
Form3.Visible:=true;
Form3.Image1.Center:=true;
Form3.Image1.AutoSize:=true;
if fileexists (form2.nameimage[number]) then
begin
form3.Image1.Picture.LoadFromFile (form2.nameimage[number]);
form3.deleteimage.Enabled:=true;
form3.rotate90.Enabled:=true;
form3.Rotate180.Enabled:=true;
end
else
begin
form3.Image1.Picture:=nil;
form3.rotate90.Enabled:=false;
form3.Rotate180.Enabled:=false;
form3.deleteimage.Enabled:=false;
end;
Form3.Height:=Form3.Image1.Height+60;
Form3.Width:=Form3.Image1.Width+35;
frmGl.Visible:=false;
ShowCursor (true);
frmgl.hide;
showcursor (true)
end;
{==============================================================
ΠΡΠΎΡΠ΅Π΄ΡΡΠ° ΡΠ΅Π°ΠΊΡΠΈΠΈ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ Π½Π° Π½Π°ΠΆΠ°ΡΠΈΠ΅ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Π΅ΠΌ ΠΊΠ»Π°Π²ΠΈΡ ΡΠΏΡΠ°Π²Π»Π΅Π½ΠΈΡ}
procedure TfrmGL. FormKeyDown (Sender: TObject; var Key: Word;
Shift: TShiftState);
var
tx0,ty0:Glfloat;
var
kolfile:byte;
begin
If Key = VK_ESCAPE then
begin
ShowCursor (true);
form2.Visible:=true;
form2.DirectoryListBox1.Directory:=form2.directory+'/download';
form2.FilterComboBox1.Filelist.Mask:='*.bmp';
for kolfile:=1 to 17 do
begin
if fileexists (form2.directory+'/download/fotogallery'+inttostr (kolfile)+'.bmp') then
if deletefile (form2.directory+'/download/fotogallery'+inttostr (kolfile)+'.bmp') then
form2.FileListBox1.DeleteSelected;
Form2.colpic[kolfile]: =false;
end ;
form2.DirectoryListBox1.Directory:=form2.directory;
form2.FilterComboBox1.Filelist.Mask:=form2.mask;
frmgl.close;
end;
if Key=VK_Return
then
begin
if (ty<-6) and (ty>-12) and (tx>0) and (tx<8)
then begin form3. number:=16; showimage (form3.number); end;
if (ty>-9) and (ty<-3) and (tx>3) and (tx<12)
then begin form3. number:=12; showimage (form3.number); end;
if (ty>-3) and (ty<4) and (tx>3) and (tx<12)
then begin form3. number:=11; showimage (form3.number); end;
if (ty>4) and (ty<12) and (tx>3) and (tx<12)
then begin form3. number:=10; showimage (form3.number); end;
if (ty<-6) and (ty>-12) and (tx>-8) and (tx<0)
then begin form3. number:=17; showimage (form3.number); end;
if (ty>-9) and (ty<-3) and (tx>-12) and (tx<-3)
then begin form3. number:=15; showimage (form3.number); end;
if (ty>-3) and (ty<4) and (tx>-12) and (tx<-3)
then begin form3. number:=14; showimage (form3.number); end;
if (ty>4) and (ty<12) and (tx>-12) and (tx<-3)
then begin form3. number:=13; showimage (form3.number); end;
if (ty>2) and (ty<12) and (tx>-6) and (tx<6)
then begin form3. number:=9; showimage (form3.number); end;
if (ty>12) and (ty<20) and (tx>1) and (tx<12)
then begin form3. number:=8; showimage (form3.number); end;
if (ty>20) and (ty<28) and (tx>1) and (tx<12)
then begin form3. number:=7; showimage (form3.number); end;
if (ty>28) and (ty<36) and (tx>1) and (tx<12)
then begin form3. number:=6; showimage (form3.number); end;
if (ty>12) and (ty<20) and (tx>-11) and (tx<-1)
then begin form3. number:=5; showimage (form3.number); end;
if (ty>20) and (ty<28) and (tx>-11) and (tx<-1)
then begin form3. number:=4; showimage (form3.number); end;
if (ty>28) and (ty<35) and (tx>-11) and (tx<-1)
then begin form3. number:=3; showimage (form3.number); end;
if (ty>30) and (ty<35) and (tx>0) and (tx<8)
then begin form3. number:=1; showimage (form3.number); end;
if (ty>30) and (ty<35) and (tx>-8) and (tx<0)
then begin form3. number:=2; showimage (form3.number); end;
end;
if Key=VK_F1
then begin
lock:=false;
Application.HelpFile:='HelpHelp.hlp';
Application.HelpCommand (HELP_FINDER, 0);
end;
if Key=VK_F2
then begin
if lock
then ShowCursor (true)
else ShowCursor (false);
lock:=not lock;
end;
if Key=VK_F3
then begin
demonstr:=not demonstr;
count:=1;
end;
If Key = VK_F4
then kadr:=not kadr;
if Key=VK_F5
then getpict:=not getpict;
if Key=VK_F8
then begin
zal:=true;
room:=room+1;
end;
if not demonstr
then begin
If Key = VK_Left then
begin
ty0:=ty;
tx0:=tx;
ty := ty — sin (f*pi/180)/2;
tX := tX + cos (f*pi/180)/2;
end;
If Key = VK_Right then
begin
ty0:=ty;
tx0:=tx;
ty := ty + sin (f*pi/180)/2;
tX := tX — cos (f*pi/180)/2;
end;
If Key = VK_up then
begin
ty0:=ty;
tx0:=tx;
ty := ty + sin ((f+90)*pi/180)/2;
tX := tX — cos ((f+90)*pi/180)/2;
end;
If Key = VK_down then
begin
ty0:=ty;
tx0:=tx;
ty := ty — sin ((f+90)*pi/180)/5;
tX := tX + cos ((f+90)*pi/180)/5;
end;
If Key = VK_delete then
tz:=tz-0.5;
If Key = VK_insert then
tz:=tz+0.5;
if room=2
then
begin
if (tx<=-11) and (tx>=-12)
then
tx:=-11;
end
else begin
if (tx<=-11)and (tx>=-12)and (((ty>-12) and (ty<-10.5))or ((ty>-6.5) and (ty<36)))
then
tx:=-11;
if (tx>=-13)and (tx<=-12)and (((ty>-12) and (ty<-10.5))or ((ty>-6.5) and (ty<36)))
then
tx:=-13;
end;
if room>=4
then begin
if (tx>=11)and (tx<=12)and (((ty>-12) and (ty<6.5))or ((ty>10.5) and (ty<36)))
then
tx:=11;
if (tx<=13)and (tx>=12)and (((ty>-12) and (ty<6.5))or ((ty>10.5) and (ty<36)))
then
tx:=13;
end
else if tx>=11
then tx:=11;
if (ty<=-11)
then ty:=-11;
if (ty>=35)
then ty:=35;
if (ty>11.4) and (ty<12.4) and ((tx>8) or (tx<-8) or ((tx<5) and (tx>-5)))
then begin
ty:=ty0;
end;
if (ty>12) and (ty<28.4) and (tx>-0.8) and (tx<0.8)
then
tx:=tx0;
if (tx>-0.8) and (tx<0.8) and (ty<28.4) and (ty>27)
then
ty:=ty0;
if (ty<12)// and (tx<12) and (tx>-12)
then pict:=1
else begin
{if tx<-12
then pict:=1 ;
if tx>12
then pict:=1
else }pict:=2
end;
end;
InvalidateRect (Handle, nil, False);
end;
{======================================================================
ΠΡΠΎΡΠ΅Π΄ΡΡΠ° ΠΏΠ΅ΡΠ΅ΡΠΈΡΠΎΠ²ΠΊΠΈ Π³Π°Π»Π΅ΡΠ΅ΠΈ}
procedure TfrmGL. FormResize (Sender: TObject);
begin
glViewport (0, 0, ClientWidth, ClientHeight);
glMatrixMode (GL_PROJECTION);
glLoadIdentity;
gluPerspective (50, Width/Height, 0.1, 48.2);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity;
glRotatef (90.0, 1.0, 0.0, 0.0); // ΠΏΠΎΠ²ΠΎΡΠΎΡ ΠΎΠ±ΡΠ΅ΠΊΡΠ° — ΠΎΡΡ Y
InvalidateRect (Handle, nil, False);
end;
{====================================================================
ΠΡΠΎΡΠ΅Π΄ΡΡΠ° ΡΠ΅Π°ΠΊΡΠΈΠΈ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ Π½Π° ΠΏΠ΅ΡΠ΅ΠΌΠ΅ΡΠ΅Π½Π΅ ΠΌΡΡΠΈ}
procedure TfrmGL. FormMouseMove (Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if Lock
then
begin
GetCursorPos (mpos);
if not demonstr
then begin
f:=f-(mpos.x-(wrkX))/8;
t:=t+(mpos.y-(wrkY))/8;
end;
InvalidateRect (Handle, nil, False);
end