POV-Ray File Maker
Author
Hagiwara Youichi
Title
POV-Ray File Maker
Description
This package generates POV-Ray scene file. This implements ALL commands of POV-Ray and MORE elementary mathematical functions. This isn't converter of Graphics3D. However, using these commands in this package, you can construct converter package.
Category
Educational Materials
Keywords
URL
http://www.notebookarchive.org/2018-10-10qouxm/
DOI
https://notebookarchive.org/2018-10-10qouxm
Date Added
2018-10-02
Date Last Modified
2018-10-02
File Size
17.31 kilobytes
Supplements
Rights
Redistribution rights reserved




POVFileMaker
Simple Explanation
POVFileMaker
Simple Explanation
Simple Explanation
How to use the
POVFileMaker.m
POVFileMaker.m
by Hagiwara Youichi (HW41)
s945208@ipe.tsukuba.ac..jp
s945208@ipe.tsukuba.ac..jp
Copyright© 1998, Hagiwara Youichi.
All rights reserved.
All rights reserved.
■
POV-Ray and Mathematica
POV-Ray and Mathematica
Do you know POV-Ray ray tracing software? We can generate POV-Ray scene file by POVFileMaker.m.
POV-Ray is FREE but POWERFUL. Description of scene is simple. But I have some inconvenience. For example, it doesn't impliment loop routine (for, while, do, etc), therefore it's a troublesome job to describe many similar objects. And some mathematics functions aren't existence.
This package doesn't implemet loop routine, but Mathematica has many command. Therefore we can repeat operation and use mathematics function. This package impliments ALL POV-Ray commands and some elementary functions!
POV-Ray official home page is http://www.povray.org/. You can get latest version of POV-Ray software from the page.
■
Style
Style
The style is just about the same as POV-Ray's. Command is too. POVFileMaker's command
POVheader[body]
imports POV-Ray's command
header{body}
. If we write string
"Text means Latin texo text- weave."
, output is
TextmeansLatintexotext-weave.
There is usage for all function.
■
Example
Example
The following is simple example. At first, load package.
<<POVFileMaker.m
We use the scene written in POV-Ray(tm) User's Documentation 3.0.10 at section 4.1.6. Comment is written by POVNewLine. String is written in accordance with it. Number (following, 1 in line 5) does output empty n-lines.
povexcomment=POVNewLine "This file was generated by", "Generator : Mathematica", " Package : \"POVFileMaker.m\"", 1,(*make1emptyline*) "Following example program is written in", " Book : POV-Ray(tm) User's Documentation 3.0.10", " Section : 4.1.6";
Include file is "colors.inc". Output is "#include "color.inc"". POVString[string] does output string of POV-Ray style.
povexinclude=POVInclude[POVString["colors.inc"]];
Background is "Cyan".
povexbackground=POVBackground[POVColor["Cyan"]];
Camera is ViewPoint. System is left-hand system. POVParameter[command,parameter] does output "command parameter". POVVecter[x,y,z] is "<x,y,z>".
povexcamera=POVCamera POVParameter["location",POVVector[0,2,-3]], POVParameter["look_at",POVVector[0,1,2]];
Object is one Yellow Sphere. POVNumber[num or func] alters to number or function of POV-Ray style. Enter number or function into POVNumber[] as far as possible.
povexobject=POVSphere POVList[POVVector[0,1,2],POVNumber[2]], POVTexture[POVPigment[POVColor["Yellow"]]];
LightSource is LightSources.
povexlightsource=POVLightSource[POVVector[2,4,-3],POVColor["White"]];
Arrange these data. POVNewLine[] generates one empty line.
povex= povexcomment, POVNewLine[], povexinclude, POVNewLine[], povexbackground, POVNewLine[], povexcamera, POVNewLine[], povexobject, POVNewLine[], povexlightsource;
File named "povex.pov" is made at the same place of Mathematica Kernel. If you want to save into another path, you write FULL path name.
POVMakeFile["povex.pov",povex];
■
More information
More information
POVMakeFile[filename, commandlines] writes commandlines in POV-Ray format to file. The commandline is nested-list of POVcommand[]. POVMakeFile[stream, commandlines] uses stream for output. When you use number or math function, wrap up it in POVNumber[].
POVNumber[number] generates POV-Ray type number. POVNumber can handle following mathematics functions. Abs[x] ArcCos[x] ArcCosh[x] ArcCot[x] ArcCoth[x] ArcCsc[x] ArcCsch[x] ArcSec[x] ArcSech[x] ArcSin[x] ArcSinh[x] ArcTan[x] ArcTan[x, y] ArcTanh[x] Ceiling[x] Cos[x] Cosh[x] Cot[x] Coth[x] Csc[x] Csch[x] Degree Dot[a, b] E Exp[x] Floor[x] GoldenRatio List[e1, e2, ...] Log[x] Log[b, x] Max[x1, x2, ...] Min[x1, x2, ...] Mod[m, n] Pi Power[x, y] Quotient[n, m] Rational[x, y], Sec[x] Sech[x] SeriesData[x, x0, {a0, a1, ...}, nmin, nmax, den] Sign[x] Sin[x] Sinh[x] Sqrt[x] Tan[x] Tanh[x].
POVString["string"] generates POV-Ray type string.
If you forget command, you can write like "command". For example, "pigment{color \"Yellow\"}}" is equivalent to POVPigment[POVColor["Yellow"]]. Or, general command, POVHeader["header"][body], generates POV-Ray header and body, too. Example is POVHeader["pigment"][POVColor["Yellow"]].
There is a difference of output between POVList, POVParameter and POVVector. POVList[a,b,c,...] is a,b,c,... . POVParameter[a,b,c,...] is a b c ... . POVVector[a,b,c,...] is <a,b,c,...>. And POVBracket[a,b,c,...] is [ a b c ... ].
You can use many color type. RGBColor, GrayLevel, POVColor, POVColorRGB, POVColorRGBF, POVColorRGBT, POVColorRGBFT, and POVColorRGBFT[GrayLevel[i],f,t], POVColorRGBFT[RGBColor[r,g,b],f,t], etc.
You can use 2-type comment. POVComment["comment"] outputs c-like /* comment */. POVNewLine["comment"] outputs c++-like // comment .
Other POVFileMaker functions are following.
POVAtmosphere POVHalo POVQuadric
POVBackground POVHeader POVQuartic
POVBicubicPatch POVHeightField POVRadiosity
POVBlob POVIfDef POVRainbow
POVBoundedBy POVIfElse POVRange
POVBox POVIfNDef POVRender
POVBracket POVImageMap POVRotate
POVBumpMap POVInclude POVScale
POVCamera POVIntersection POVSkySphere
POVCase POVIrid POVSlopeMap
POVClippedBy POVJuliaFractal POVSmoothTriangle
POVColor POVLathe POVSOR
POVColorMap POVLightSource POVSphere
POVColorRGB POVList POVStatistics
POVColorRGBF POVMakeFile POVString
POVColorRGBFT POVMaterialMap POVSuperEllipsoid
POVColorRGBT POVMatrix POVSwitch
POVComment POVMerge POVText
POVCone POVMesh POVTexture
POVCubic POVNewLine POVTextureMap
POVCylinder POVNormal POVTorus
POVDebug POVNormalMap POVTransform
POVDeclare POVNumber POVTranslate
POVDefault POVObject POVTriangle
POVDifference POVParameter POVUnion
POVDisc POVPigment POVVector
POVError POVPlane POVVersion
POVFinish POVPoly POVWarning
POVFog POVPolygon POVWarp
POVGlobalSettings POVPrism POVWhile
POVBackground POVHeader POVQuartic
POVBicubicPatch POVHeightField POVRadiosity
POVBlob POVIfDef POVRainbow
POVBoundedBy POVIfElse POVRange
POVBox POVIfNDef POVRender
POVBracket POVImageMap POVRotate
POVBumpMap POVInclude POVScale
POVCamera POVIntersection POVSkySphere
POVCase POVIrid POVSlopeMap
POVClippedBy POVJuliaFractal POVSmoothTriangle
POVColor POVLathe POVSOR
POVColorMap POVLightSource POVSphere
POVColorRGB POVList POVStatistics
POVColorRGBF POVMakeFile POVString
POVColorRGBFT POVMaterialMap POVSuperEllipsoid
POVColorRGBT POVMatrix POVSwitch
POVComment POVMerge POVText
POVCone POVMesh POVTexture
POVCubic POVNewLine POVTextureMap
POVCylinder POVNormal POVTorus
POVDebug POVNormalMap POVTransform
POVDeclare POVNumber POVTranslate
POVDefault POVObject POVTriangle
POVDifference POVParameter POVUnion
POVDisc POVPigment POVVector
POVError POVPlane POVVersion
POVFinish POVPoly POVWarning
POVFog POVPolygon POVWarp
POVGlobalSettings POVPrism POVWhile
■
More Example
More Example
Right-handed-system is set by camera.
povmrexcamera=POVCamera POVParameter["location",POVVector[1.7,1.7,1.7]], POVParameter["direction",POVVector[-1,0,0]], POVParameter["up",POVVector[0,0,1]], POVParameter"right",POVVector0,,0, POVParameter["sky",POVVector[0,0,1]], POVParameter["look_at",POVVector[0.5,0.5,0.5]];
4
3
LightSource is at the same place as viewpoint. Color is White.
povmrexlightsource=POVLightSource[POVVector[1.7,1.7,1.7],POVColorRGB[1,1,1]];
Objects are Balls set at the grids of cubic. Color is RGB of 3-value of position. Number of ball is .
3
11
povmrexobjs=Module{positions}, positions=FlattenTable N[{i,j,k}], i,0,1,,j,0,1,,k,0,1, ,2; MapPOVSphere POVList[POVVector@@#,0.025], POVTexture[POVPigment[POVColorRGB@@#]] &,positions;
1
10
1
10
1
10
Arrange these data.
povmrex= povmrexcamera, POVNewLine[], povmrexlightsource, POVNewLine[], povmrexobjs;
File named "povmrex.pov" is made at the same place of Mathematica Kernel. If you want to save into another path, you write FULL path name.
POVMakeFile["povmrex.pov",povmrex];


Cite this as: Hagiwara Youichi, "POV-Ray File Maker" from the Notebook Archive (2002), https://notebookarchive.org/2018-10-10qouxm

Download

