<<>> <> <> <> <> <> <> DIRECTORY CedarProcess, ColorFns, G3dBasic, G3dLight, G3dMatrix, G3dRender, G3dShape, G3dVector, G3dView, Imager, ImagerColor, ImagerSample, NamedColors, Rope; G3dRenderImpl: CEDAR MONITOR IMPORTS ColorFns, G3dMatrix, G3dView, NamedColors, Rope EXPORTS G3dRender ~ BEGIN <> Error: PUBLIC SIGNAL [code: ATOM, reason: ROPE] = CODE; <> Process: TYPE ~ CedarProcess.Process; Pair: TYPE ~ G3dBasic.Pair; Triple: TYPE ~ G3dBasic.Triple; Light: TYPE ~ G3dLight.Light; LightSequence: TYPE ~ G3dLight.LightSequence; Matrix: TYPE ~ G3dMatrix.Matrix; Context3d: TYPE ~ G3dRender.Context3d; Context3dRep: TYPE ~ G3dRender.Context3dRep; DisplayMode: TYPE ~ G3dRender.DisplayMode; RenderData: TYPE ~ G3dRender.RenderData; RenderStyle: TYPE ~ G3dRender.RenderStyle; TextureMap: TYPE ~ G3dRender.TextureMap; TextureStyle: TYPE ~ G3dRender.TextureStyle; Shape: TYPE ~ G3dShape.Shape; ShapeRep: TYPE ~ G3dShape.ShapeRep; ShapeSequence: TYPE ~ G3dShape.ShapeSequence; Vertex: TYPE ~ G3dShape.Vertex; VertexRep: TYPE ~ G3dShape.VertexRep; VertexSequenceRep: TYPE ~ G3dShape.VertexSequenceRep; Rectangle: TYPE ~ Imager.Rectangle; RGB: TYPE ~ ImagerColor.RGB; SampleMap: TYPE ~ ImagerSample.SampleMap; ROPE: TYPE ~ Rope.ROPE; <> Create: PUBLIC PROC RETURNS [c: Context3d] ~ { c ¬ NEW[Context3dRep ¬ [view: G3dMatrix.Identity[]]]; SetBackgroundColor[c, [0.2, 0.2, 0.7]]; }; <> SetViewFromParameters: PUBLIC PROC [ context3d: Context3d, fieldOfView: REAL ¬ 40.0, scale: REAL ¬ 1.0, moves, rotates: Triple ¬ []] ~ { fov: REAL ¬ IF fieldOfView = 0.0 THEN 40.0 ELSE fieldOfView; eyePoint, lookAt, upDirection: Triple; [eyePoint, lookAt, upDirection] ¬ G3dView.FromScaleMovesRots[scale, moves, rotates]; SetView[context3d, eyePoint, lookAt, fov, 0.0, upDirection]; }; SetView: PUBLIC PROC [ context3d: Context3d, eyePoint: Triple, lookAt: Triple, fieldOfView: REAL ¬ 40.0, rollAngle: REAL ¬ 0.0, upDirection: Triple ¬ [0., 0., 1.], hitherLimit: REAL ¬ .01, yonLimit: REAL ¬ 1000.0] ~ { context3d.eyePoint ¬ eyePoint; context3d.lookAt ¬ lookAt; context3d.fieldOfView ¬ fieldOfView; context3d.rollAngle ¬ rollAngle; context3d.upDirection ¬ upDirection; context3d.hitherLimit ¬ hitherLimit; context3d.yonLimit ¬ yonLimit; }; SetViewport: PUBLIC PROC [context3d: Context3d, size: Rectangle] ~{ IF size.w <= 0.0 OR size.h <= 0.0 THEN SIGNAL Error[$MisMatch, "Null rectangle"]; context3d.viewport ¬ size; }; SetWindow: PUBLIC PROC [context3d: Context3d, size: Rectangle] ~ { <> }; <> NameBackgroundColor: PUBLIC PROC [context3d: Context3d, color: ROPE] ~ { <> bkgrdColor: RGB ¬ ColorFns.RGBFromHSL[NamedColors.RopeToHSL[color]]; SetBackgroundColor[context3d, bkgrdColor]; -- set color }; SetBackgroundColor: PUBLIC PROC [context3d: Context3d, color: RGB] ~ { IF context3d # NIL THEN context3d.backgroundColor ¬ color; }; SetBackgroundImage: PUBLIC PROC [context3d: Context3d, name: ROPE] ~ { GetImage: PROC [name: ROPE] RETURNS [map: SampleMap] ~ {}; context3d.backgroundImage ¬ GetImage[context3d.backgroundName ¬ name]; }; EnableClear: PUBLIC PROC [context3d: Context3d, on: BOOL] ~ { IF context3d # NIL THEN context3d.clear ¬ on; }; MatteBackground: PUBLIC PROC [context3d: Context3d, matte: BOOL] ~ { IF context3d # NIL THEN context3d.matteBackground ¬ matte; }; <> RenderDataFrom: PUBLIC PROC [shape: Shape] RETURNS [data: RenderData] ~ { IF shape = NIL THEN RETURN[NIL]; IF shape.renderData = NIL THEN shape.renderData ¬ NEW[G3dRender.RenderDataRep]; data ¬ NARROW[shape.renderData]; }; SetRenderStyle: PUBLIC PROC [shape: Shape, renderStyle: RenderStyle] ~ { RenderDataFrom[shape].renderStyle ¬ renderStyle; }; SetColor: PUBLIC PROC [shape: Shape, color: RGB] ~ { RenderDataFrom[shape].color ¬ color; }; <<>> SetDiffuse: PUBLIC PROC [shape: Shape, diffuseReflectivity: REAL] ~ { RenderDataFrom[shape].diffuseReflectivity¬ diffuseReflectivity; }; SetSpecular: PUBLIC PROC [shape: Shape, specularReflectivity: REAL] ~ { RenderDataFrom[shape].specularReflectivity¬ specularReflectivity; }; SetMetallicity: PUBLIC PROC [shape: Shape, metallicity: REAL] ~ { RenderDataFrom[shape].metallicity¬ metallicity; }; SetShininess: PUBLIC PROC [shape: Shape, shininess: REAL] ~ { RenderDataFrom[shape].shininess¬ shininess; }; SetTransmittance: PUBLIC PROC [shape: Shape, transmittance: REAL] ~ { RenderDataFrom[shape].transmittance ¬ transmittance; }; SetInvisible: PUBLIC PROC [shape: Shape] ~ {IF shape # NIL THEN shape.visible ¬ FALSE}; SetVisible: PUBLIC PROC [shape: Shape] ~ {IF shape # NIL THEN shape.visible ¬ TRUE}; ShowBackfaces: PUBLIC PROC [shape: Shape] ~ { IF shape # NIL THEN shape.showBackfaces ¬ TRUE; }; HideBackfaces: PUBLIC PROC [shape: Shape] ~ { IF shape # NIL THEN shape.showBackfaces ¬ FALSE; }; AddAxes: PUBLIC PROC [ context3d: Context3d, origin: Triple ¬ [0, 0, 0], size: REAL ¬ 1.0, scale: Triple ¬ [1, 1, 1], nReticles: NAT ¬ 20] ~ {}; <> <> <> <> <> <> <<};>> <> <> <> <> <> <> <> <<};>> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <<};>> <> <> <> <<};>> <> SetTextureMap: PUBLIC PROC [ shape: Shape, fileName: ROPE, textureStyle: TextureStyle ¬ intensity, textureFiltering: BOOL ¬ FALSE] RETURNS [error: ROPE] ~ { }; GetTextureMap: PUBLIC PROC [shape: Shape, textureName: ROPE] RETURNS [t: TextureMap] ~ { FOR l: LIST OF TextureMap ¬ RenderDataFrom[shape].textures, l.rest WHILE l # NIL DO IF Rope.Equal[l.first.name, textureName, FALSE] THEN RETURN[l.first]; ENDLOOP; }; OffsetTextureCoords: PUBLIC PROC [shape: Shape, offset: Pair] ~ { FOR n: NAT IN [0..shape.vertices.length) DO v: Vertex ¬ shape.vertices[n]; v.texture ¬ [v.texture.x+offset.x, v.texture.y+offset.y]; ENDLOOP; }; SetTextureScale: PUBLIC PROC [shape: Shape, textureName: ROPE, scale: Pair ¬ [1.0, 1.0]] ~ { map: TextureMap ¬ GetTextureMap[shape, textureName]; IF map # NIL THEN map.scale ¬ scale; }; SetTextureRange: PUBLIC PROC [shape: Shape, textureName: ROPE, range: Pair] ~ { map: TextureMap ¬ GetTextureMap[shape, textureName]; IF map # NIL THEN map.range ¬ range; }; SetTextureFiltering: PUBLIC PROC [shape: Shape, textureName: ROPE, on: BOOL] ~ { map: TextureMap ¬ GetTextureMap[shape, textureName]; IF map # NIL THEN map.filter ¬ on; }; SetBumpHeight: PUBLIC PROC [shape: Shape, textureName: ROPE, height: REAL ¬ 1.0] ~ { map: TextureMap ¬ GetTextureMap[shape, textureName]; IF map # NIL THEN map.bumpHeight ¬ height; }; <> renderDone: CONDITION; ReallyRenderData: TYPE ~ RECORD [context3d: Context3d, image: REF ANY, error: ROPE ¬ NIL]; Render: PUBLIC PROC [context3d: Context3d, image: REF ANY, fork: BOOL ¬ TRUE] RETURNS [error: ROPE] ~ { <> <> <> <> <> }; RenderToFile: PUBLIC PROC [ context3d: Context3d, fileName: ROPE, fork: BOOL ¬ TRUE, abekas: BOOL ¬ FALSE] ~ { <> <> <> <> }; WaitTilRenderDone: PUBLIC ENTRY PROC ~ { ENABLE UNWIND => NULL; WAIT renderDone; }; IsRendering: PUBLIC PROC [context3d: Context3d] RETURNS [b: BOOL ¬ TRUE] ~ { <> }; <> <> <<};>> <<>> <> <> <> <> <> <> <<};>> <> <<};>> <<>> AbortRender: PUBLIC PROC [context3d: Context3d] ~ { <> }; SetAntiAliasing: PUBLIC PROC [context3d: Context3d, on: BOOL ¬ TRUE] ~ { <> <> }; AntiAliasingNeeded: PUBLIC PROC [context3d: Context3d] RETURNS [b: BOOL ¬ FALSE] ~ { <> <> <> <> <> <> <> <> < 0.0 THEN RETURN[TRUE];>> <> <<};>> }; GetBuffer: PUBLIC PROC [context3d: Context3d, type: ATOM] RETURNS [s: SampleMap] ~ { }; <> AtomFromTextureStyle: PUBLIC PROC [textureStyle: TextureStyle] RETURNS [a: ATOM] ~ { a ¬ SELECT textureStyle FROM bump => $Bump, color => $Color, ENDCASE => $Intensity; }; AtomFromDisplayMode: PUBLIC PROC [displayMode: DisplayMode] RETURNS [a: ATOM] ~ { a ¬ SELECT displayMode FROM fullColor=>$FullColor, dither=>$PseudoColor, ENDCASE=>$Gray; }; RopeFromDisplayMode: PUBLIC PROC [displayMode: DisplayMode] RETURNS [ROPE] ~ { RETURN[SELECT displayMode FROM gray => "Gray", dither => "Dither", fullColor => "FullColor", ENDCASE => NIL]; }; RopeFromRenderStyle: PUBLIC PROC [renderStyle: RenderStyle] RETURNS [ROPE] ~ { RETURN[SELECT renderStyle FROM faceted => "constant", ENDCASE => "smooth"]; < "Lines",>> < "ShadedLines",>> < "HiddenLines",>> < NIL];>> }; RopeFromTextureStyle: PUBLIC PROC [textureStyle: TextureStyle] RETURNS [ROPE] ~ { RETURN[SELECT textureStyle FROM intensity => "Intensity", color => "Color", bump => "Bump", ENDCASE => "None"]; }; END.