// Pentagon.cc // Ray Tracer 4 Sphers + small 2 Sphers + Triangle + ppm Image // Read image from and output to or // Copyright (C) 1997,1998,1999 Y.Nagatani #include #include "raytrace.h" void Pentagon (int nFrame, int nMaxFrames, PPMRawImage & ppm) { Real rTime = (Real) nFrame / nMaxFrames; List LS; // Vein Real rSep0 = 4.2, rRad0 = 5.1; Vector vR1 (rRad0,0,+rSep0), vR2 (rRad0,0,-rSep0); Line lAxis (0,0,0, 0,0,1); // Sphers Real rSphersRadius = 4.0; Real rRefrac = 1.15; Spher S; int nSphers = 3; for (int n = 0 ; n < nSphers ; n ++) { Vector vRa = vR1.GetRotateAxesLine (lAxis, (2.0*M_PI) * (+rTime+n)/nSphers), vRb = vR2.GetRotateAxesLine (lAxis, (2.0*M_PI) * (-rTime+n)/nSphers); S = Spher (vRa, rSphersRadius); S.setRGB (RGB(.03,.06,.03), RGB(.8,.8,.8), RGB(.9,.9,.9)); S.setRefraction (rRefrac); LS.add (S); S = Spher (vRb, rSphersRadius); S.setRGB (RGB(.06,.03,.03), RGB(.8,.8,.8), RGB(.9,.9,.9)); S.setRefraction (rRefrac); LS.add (S); } // Rotate & Translate Objects LS.RotateAxesLine (Line(Vector (0,0,0), Vector (0,0,1)), +132.0*M_PI/180); LS.RotateAxesLine (Line(Vector (0,0,0), Vector (1,0,0)), -51.0*M_PI/180); LS.RotateAxesLine (Line(Vector (0,0,0), Vector (0,1,0)), +33.8*M_PI/180); LS += Vector (0,0,0); // Add Small New 2 Sphers Real rT; rT = 10; S = Spher (Vector (1.25*rT,0,-rT), 1.5); S.setRGB (RGB(.03,.01,.01), RGB(1,1,1), RGB(0.6,0.6,0.6)); S.setRefraction (rRefrac); LS.add (S); S = Spher (Vector (-1.25*rT,0,-rT), 1.5); S.setRGB (RGB(.01,.01,.03), RGB(1,1,1), RGB(0.6,0.6,0.6)); S.setRefraction (rRefrac); LS.add (S); // Quadrilateral Pic Image rT = 150; Real rAngle = 0; Real rX = rT * cos (rAngle), rY = rT / 1.25, rZ = rT * sin (rAngle); QuadrilateralImag Quad (0,0,0, rX,0,rZ, 0,rY,0, ppm); Quad += Vector (-rX*0.5, -rY*0.2, -rZ*0.5); Quad.setNoTranspareceWithoutBlack (True); // set black is transp. Quad.setRGB (0, RGB(.1,.1,.1), RGB(1,1,1)); Quad += Vector (0, 0, +50); LS.add (Quad); // Back Ground Light LS.setBackGround (RGB ( .0, .0, .0)); LS.setBackGroundDir (Vector (2,-1,-1), RGB (.5,.6,.7), 10); int nMatrixSize = 256; Real rAspect = 1.25; rAngle = 2.0 * M_PI * 0.0; rX = sin (rAngle); rZ = cos (rAngle); PostScript PS (Line (40*rX,0,40*rZ, 0,0,0), // center view line Vector (12*rZ, 0, -12*rX) * rAspect, // x direction (width) Vector ( 0, 12, 0), // y direction (height) (int)(rAspect*nMatrixSize), nMatrixSize); // Matrix Size PS.setRecursiveLevel (7); // 0 is most simple case PS.setEps (); // as EPS PS.setShowStatus (); // show calculating status PS.setPPM (True); // as PPM not (ps / eps) char szFileNameHead [128]; sprintf (szFileNameHead, "x%03d", nFrame); PS.putImagFile (LS, szFileNameHead); } int main (int nArgc, char *pszArgv[]) { Check_rRand (); PPMRawImage ppm ("in.ppm"); int nMax = 32; for (int n = 0 ; n < nMax ; n++) Pentagon (n, nMax, ppm); return 0; }