summaryrefslogtreecommitdiff
path: root/stern.cpp
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2003-09-22 07:43:13 +0000
committerDimitri Sokolyuk <demon@dim13.org>2003-09-22 07:43:13 +0000
commit8ab70c739e68071304b13a629ac083b369eebdeb (patch)
treeb6a91752a95fb4864654bc6bba04971a8e6f15a1 /stern.cpp
parentfaa91c18cdb4dbc17bfd7da977b0e406dc93f165 (diff)
remove LF and add $
Diffstat (limited to 'stern.cpp')
-rw-r--r--stern.cpp253
1 files changed, 127 insertions, 126 deletions
diff --git a/stern.cpp b/stern.cpp
index c94f449..f991ff9 100644
--- a/stern.cpp
+++ b/stern.cpp
@@ -1,126 +1,127 @@
-// STERN.CPP 11.02.2000
-#include <stdio.h>
-#include <conio.h>
-#include <graphics.h>
-#include <process.h>
-#include <math.h>
-
-void InitProgram(void);
-void MainLoop(void);
-void Calc3D(void);
-void Rotation(void);
-void DrawObject(void);
-
-#define COPYRIGHT "Dark Alliance (c) 1996-2000 DreamDemon"
-#define Lines 72
-static int World[Lines][3] = {
- 90, 0, 0, 10, 10, 10, 90, 0, 0, 10, 10,-10,
- 90, 0, 0, 10,-10,-10, 90, 0, 0, 10,-10, 10,
- -90, 0, 0, -10, 10, 10, -90, 0, 0, -10, 10,-10,
- -90, 0, 0, -10,-10,-10, -90, 0, 0, -10,-10, 10,
- 0, 90, 0, 10, 10, 10, 0, 90, 0, -10, 10, 10,
- 0, 90, 0, -10, 10,-10, 0, 90, 0, 10, 10,-10,
- 0,-90, 0, 10,-10, 10, 0,-90, 0, -10,-10, 10,
- 0,-90, 0, -10,-10,-10, 0,-90, 0, 10,-10,-10,
- 0, 0, 90, 10, 10, 10, 0, 0, 90, 10,-10, 10,
- 0, 0, 90, -10,-10, 10, 0, 0, 90, -10, 10, 10,
- 0, 0,-90, 10, 10,-10, 0, 0,-90, 10,-10,-10,
- 0, 0,-90, -10,-10,-10, 0, 0,-90, -10, 10,-10,
- 10, 10, 10, -10, 10, 10, 10,-10, 10, -10,-10, 10,
- 10, 10,-10, -10, 10,-10, 10,-10,-10, -10,-10,-10,
- 10, 10, 10, 10,-10, 10, -10, 10, 10, -10,-10, 10,
- 10, 10,-10, 10,-10,-10, -10, 10,-10, -10,-10,-10,
- 10, 10, 10, 10, 10,-10, 10,-10, 10, 10,-10,-10,
- -10,-10, 10, -10,-10,-10, -10, 10, 10, -10, 10,-10};
-
-float X, Y, Z, sX, sY, Xa, Ya, Za, sXs, sYs, D, Page;
-float R1, R2, R3, Sr1, Sr2, Sr3, Cr1, Cr2, Cr3, mX, mY, mZ;
-
-void main(void)
-{
- InitProgram();
- MainLoop();
- closegraph();
- printf("%s\n",COPYRIGHT);
- getch();
-}
-
-void Calc3D(void)
-{
- X = -1 * X;
- Xa = Cr1 * X - Sr1 * Z;
- Za = Sr1 * X + Cr1 * Z;
- X = Cr2 * Xa + Sr2 * Y;
- Ya = Cr2 * Y - Sr2 * Xa;
- Z = Cr3 * Za - Sr3 * Ya;
- Y = Sr3 * Za + Cr3 * Ya;
- X = X + mX;
- Y = Y + mY;
- Z = Z + mZ;
- sX = 320 + D * X / Z;
- sY = 175 + D * Y / Z;
-}
-
-void DrawObject(void)
-{
- int i;
-
- Rotation();
- for(i=0; i<Lines; i+=2) {
- X = World[i][0];
- Y = World[i][1];
- Z = World[i][2];
- Calc3D();
- sXs = sX;
- sYs = sY;
- X = World[i+1][0];
- Y = World[i+1][1];
- Z = World[i+1][2];
- Calc3D();
- line(sXs, sYs, sX, sY);
- }
-}
-
-void InitProgram(void)
-{
- int gdriver = EGA, gmode = EGAHI, errorcode;
- initgraph(&gdriver, &gmode, "");
- errorcode = graphresult();
- if (errorcode != grOk) {
- printf("Graphics error: %s\n", grapherrormsg(errorcode));
- printf("Press any key to halt:");
- getch();
- exit(1);
- }
- D = 1200; // View point and rotation values
- mZ = -850;
- mX = -5;
- R1 = 0;
- R2 = 0;
- R3 = 0.3;
-}
-
-void MainLoop(void)
-{
- while(!kbhit()) {
- R1 = R1 + 0.1;
- if(R1 > 6.28) R1 = 0;
- R2 = R1;
- R3 = R1;
- clearviewport();
- DrawObject();
- (Page == 0)? Page = 1: Page = 0;
- setactivepage(1-Page);
- setvisualpage(Page);
- }
-}
-
-void Rotation(void)
-{
- Sr1 = sin(R1);
- Sr2 = sin(R2);
- Sr3 = sin(R3);
- Cr1 = cos(R1);
- Cr2 = cos(R2);
- Cr3 = cos(R3);
-}
+/* $Id$ */
+// STERN.CPP 11.02.2000
+#include <stdio.h>
+#include <conio.h>
+#include <graphics.h>
+#include <process.h>
+#include <math.h>
+
+void InitProgram(void);
+void MainLoop(void);
+void Calc3D(void);
+void Rotation(void);
+void DrawObject(void);
+
+#define COPYRIGHT "Dark Alliance (c) 1996-2000 DreamDemon"
+#define Lines 72
+static int World[Lines][3] = {
+ 90, 0, 0, 10, 10, 10, 90, 0, 0, 10, 10,-10,
+ 90, 0, 0, 10,-10,-10, 90, 0, 0, 10,-10, 10,
+ -90, 0, 0, -10, 10, 10, -90, 0, 0, -10, 10,-10,
+ -90, 0, 0, -10,-10,-10, -90, 0, 0, -10,-10, 10,
+ 0, 90, 0, 10, 10, 10, 0, 90, 0, -10, 10, 10,
+ 0, 90, 0, -10, 10,-10, 0, 90, 0, 10, 10,-10,
+ 0,-90, 0, 10,-10, 10, 0,-90, 0, -10,-10, 10,
+ 0,-90, 0, -10,-10,-10, 0,-90, 0, 10,-10,-10,
+ 0, 0, 90, 10, 10, 10, 0, 0, 90, 10,-10, 10,
+ 0, 0, 90, -10,-10, 10, 0, 0, 90, -10, 10, 10,
+ 0, 0,-90, 10, 10,-10, 0, 0,-90, 10,-10,-10,
+ 0, 0,-90, -10,-10,-10, 0, 0,-90, -10, 10,-10,
+ 10, 10, 10, -10, 10, 10, 10,-10, 10, -10,-10, 10,
+ 10, 10,-10, -10, 10,-10, 10,-10,-10, -10,-10,-10,
+ 10, 10, 10, 10,-10, 10, -10, 10, 10, -10,-10, 10,
+ 10, 10,-10, 10,-10,-10, -10, 10,-10, -10,-10,-10,
+ 10, 10, 10, 10, 10,-10, 10,-10, 10, 10,-10,-10,
+ -10,-10, 10, -10,-10,-10, -10, 10, 10, -10, 10,-10};
+
+float X, Y, Z, sX, sY, Xa, Ya, Za, sXs, sYs, D, Page;
+float R1, R2, R3, Sr1, Sr2, Sr3, Cr1, Cr2, Cr3, mX, mY, mZ;
+
+void main(void)
+{
+ InitProgram();
+ MainLoop();
+ closegraph();
+ printf("%s\n",COPYRIGHT);
+ getch();
+}
+
+void Calc3D(void)
+{
+ X = -1 * X;
+ Xa = Cr1 * X - Sr1 * Z;
+ Za = Sr1 * X + Cr1 * Z;
+ X = Cr2 * Xa + Sr2 * Y;
+ Ya = Cr2 * Y - Sr2 * Xa;
+ Z = Cr3 * Za - Sr3 * Ya;
+ Y = Sr3 * Za + Cr3 * Ya;
+ X = X + mX;
+ Y = Y + mY;
+ Z = Z + mZ;
+ sX = 320 + D * X / Z;
+ sY = 175 + D * Y / Z;
+}
+
+void DrawObject(void)
+{
+ int i;
+
+ Rotation();
+ for(i=0; i<Lines; i+=2) {
+ X = World[i][0];
+ Y = World[i][1];
+ Z = World[i][2];
+ Calc3D();
+ sXs = sX;
+ sYs = sY;
+ X = World[i+1][0];
+ Y = World[i+1][1];
+ Z = World[i+1][2];
+ Calc3D();
+ line(sXs, sYs, sX, sY);
+ }
+}
+
+void InitProgram(void)
+{
+ int gdriver = EGA, gmode = EGAHI, errorcode;
+ initgraph(&gdriver, &gmode, "");
+ errorcode = graphresult();
+ if (errorcode != grOk) {
+ printf("Graphics error: %s\n", grapherrormsg(errorcode));
+ printf("Press any key to halt:");
+ getch();
+ exit(1);
+ }
+ D = 1200; // View point and rotation values
+ mZ = -850;
+ mX = -5;
+ R1 = 0;
+ R2 = 0;
+ R3 = 0.3;
+}
+
+void MainLoop(void)
+{
+ while(!kbhit()) {
+ R1 = R1 + 0.1;
+ if(R1 > 6.28) R1 = 0;
+ R2 = R1;
+ R3 = R1;
+ clearviewport();
+ DrawObject();
+ (Page == 0)? Page = 1: Page = 0;
+ setactivepage(1-Page);
+ setvisualpage(Page);
+ }
+}
+
+void Rotation(void)
+{
+ Sr1 = sin(R1);
+ Sr2 = sin(R2);
+ Sr3 = sin(R3);
+ Cr1 = cos(R1);
+ Cr2 = cos(R2);
+ Cr3 = cos(R3);
+}