DIRECTORY Render3d, TubeDefs, TubeMisc, TubeRender; TubeRenderImpl: CEDAR PROGRAM IMPORTS Render3d, TubeMisc EXPORTS TubeRender ~ BEGIN OPEN TubeDefs; RenderStyle: TYPE ~ Render3d.RenderStyle; Vertex: TYPE ~ Render3d.Vertex; VertexSequence: TYPE ~ Render3d.VertexSequence; ShadingSequence: TYPE ~ Render3d.ShadingSequence; ShadingValue: TYPE ~ Render3d.ShadingValue; NatTable: TYPE ~ Render3d.NatTable; NatSequence: TYPE ~ Render3d.NatSequence; Context3d: TYPE ~ Render3d.Context3d; ObjectFromTube: PROC [tube: Tube, matrix: Matrix _ NIL] RETURNS [ vertices: REF VertexSequence, shades: REF ShadingSequence, textures: TripleSequence, polygons: REF NatTable ] ~ { Point: PointProc ~ { vertices[n].x _ position.x; vertices[n].y _ position.y; vertices[n].z _ position.z; shades[n].xn _ normal.x; shades[n].yn _ normal.y; shades[n].zn _ normal.z; textures[n] _ [u, v, 0.0]; n _ n+1; }; Poly: PolyProc ~ { polygons[id] _ NEW[NatSequence[3]]; polygons[id].length _ 3; polygons[id][0] _ p0; polygons[id][1] _ p1; polygons[id][2] _ p2; }; n: INTEGER _ 0; nPolys: INTEGER _ TubeMisc.NPolys[tube]; nVertices: INTEGER _ TubeMisc.NPoints[tube]; vertices _ NEW[VertexSequence[nVertices]]; shades _ NEW[ShadingSequence[nVertices]]; textures _ NEW[TripleSequenceRep[nVertices]]; polygons _ NEW[NatTable[nPolys]]; polygons.length _ nPolys; FOR n: NAT IN [0..nVertices) DO vertices[n] _ NEW[Vertex]; shades[n] _ NEW[ShadingValue]; ENDLOOP; [] _ TubeMisc.Points[tube, Point, matrix]; [] _ TubeMisc.Polys[tube, Poly]; RETURN[vertices, shades, textures, polygons]; }; AddTube: PUBLIC PROC [ tube: Tube, context3d: Context3d, renderStyle: RenderStyle _ faceted, matrix: Matrix _ NIL] ~ { vertices: REF VertexSequence; shades: REF ShadingSequence; textures: TripleSequence; polygons: REF NatTable; [vertices, shades, textures, polygons] _ ObjectFromTube[tube, matrix]; Render3d.AddObject[ context3d, polygons, vertices, shades, textures, , tube.name, renderStyle, TRUE]; }; END. ฎTubeRenderImpl.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Bloomenthal, February 24, 1987 6:14:47 pm PST Type Declarations Converting from a Tube สฮ˜šœ™Jšœ ฯmœ1™