DIRECTORY AtomButtonsTypes, Imager, IO, Rope, SV2d, SV3d, SVBasicTypes, SVModelTypes, SVSceneTypes, ViewerClasses; SVScene: CEDAR DEFINITIONS = BEGIN versionRope: Rope.ROPE; version: REAL; Artwork: TYPE = SVModelTypes.Artwork; BoundBlock: TYPE = SVBasicTypes.BoundBlock; BoundBox: TYPE = SVBasicTypes.BoundBox; BoundHedron: TYPE = SVBasicTypes.BoundHedron; Camera: TYPE = SVModelTypes.Camera; Classification: TYPE = SVSceneTypes.Classification; Color: TYPE = Imager.Color; CoordSystem: TYPE = SVModelTypes.CoordSystem; CSGTree: TYPE = SVSceneTypes.CSGTree; Database: TYPE = SVSceneTypes.Database; DrawStyle: TYPE = SVModelTypes.DrawStyle; -- {wire, shaded, rayCast, normals} FeedbackData: TYPE = AtomButtonsTypes.FeedbackData; FileCamera: TYPE = SVSceneTypes.FileCamera; FileCameraList: TYPE = SVSceneTypes.FileCameraList; FrameBlock: TYPE = SVSceneTypes.FrameBlock; FrameBox: TYPE = SVModelTypes.FrameBox; LightSource: TYPE = SVModelTypes.LightSource; LightSourceList: TYPE = SVSceneTypes.LightSourceList; MasterObject: TYPE = SVSceneTypes.MasterObject; MasterObjectClass: TYPE = SVSceneTypes.MasterObjectClass; MasterObjectClassList: TYPE = SVSceneTypes.MasterObjectClassList; MasterObjectList: TYPE = SVSceneTypes.MasterObjectList; Matrix4by4: TYPE = SV3d.Matrix4by4; Plane: TYPE = SV3d.Plane; Point2d: TYPE = SV2d.Point2d; Point3d: TYPE = SV3d.Point3d; PointSetOp: TYPE = SVSceneTypes.PointSetOp; -- {union, intersection, difference} Poly3d: TYPE = SV3d.Poly3d; Primitive: TYPE = SVSceneTypes.Primitive; Projection: TYPE = SVModelTypes.Projection; Ray: TYPE = SVSceneTypes.Ray; Scene: TYPE = SVSceneTypes.Scene; SelectionClass: TYPE = SVSceneTypes.SelectionClass; Shape: TYPE = SVSceneTypes.Shape; ShowAsType: TYPE = SVSceneTypes.ShowAsType; Slice: TYPE = SVSceneTypes.Slice; SliceList: TYPE = SVSceneTypes.SliceList; ToolData: TYPE = SVSceneTypes.ToolData; Vector3d: TYPE = SV3d.Vector3d; Viewer: TYPE = ViewerClasses.Viewer; CreateScene: PROC [name: Rope.ROPE] RETURNS [scene: Scene]; CreateEmptyScene: PROC [name: Rope.ROPE] RETURNS [scene: Scene]; CreateMasterObject: PROC [ name: Rope.ROPE, class: MasterObjectClass, mainBody: REF ANY, lineBody: REF ANY, shadeBody: REF ANY, rayCastBody: REF ANY] RETURNS [mo: MasterObject]; CopyMasterObject: PROC [mo: MasterObject] RETURNS [copy: MasterObject]; CreateSceneAssembly: PROC [name: Rope.ROPE, pointSetOp: PointSetOp, coordSys: CoordSystem, isTool: BOOL _ FALSE, toolData: ToolData _ NIL] RETURNS [assembly: Slice]; CreateToolData: PROC [loX, hiX, loY, hiY, loZ, hiZ: REAL, plane: NAT, infinite: BOOL _ FALSE, clientData: REF ANY _ NIL] RETURNS [toolData: ToolData]; CreateAmbientLightSource: PROC [name: Rope.ROPE, color: Color] RETURNS [ls: LightSource]; CreateLightSource: PROC [name: Rope.ROPE, position: Point3d, color: Color] RETURNS [ls: LightSource]; CreateFileCamera: PROC [ name: Rope.ROPE, origin: Point3d, focusPoint: Point3d, slant: REAL, resolution: REAL, focalLength: REAL, projection: Projection, frame: FrameBox, clippingPlanes: LIST OF Plane, visibleAssemblies: LIST OF Rope.ROPE] RETURNS [fileCamera: FileCamera]; CreateCamera: PROC [worldCS: CoordSystem, screenCS: CoordSystem, style: DrawStyle] RETURNS [camera: Camera]; StuffCameraFromFileCamera: PROC [camera: Camera, fileCamera: FileCamera, style: DrawStyle, scene: Scene]; InitialCameraList: PROC [] RETURNS [cameras: FileCameraList]; GetEyepoint: PROC [camera: Camera] RETURNS [eyePointWORLD: Point3d]; NameAlreadyPresent: SAFE SIGNAL; AddMasterObjectToScene: PROC [mo: MasterObject, scene: Scene]; AddLightSourceToScene: PROC [ls: LightSource, scene: Scene]; AddCameraToScene: PROC [fileCamera: FileCamera, scene: Scene]; AddCameraOrderNameToScene: PROC [name: Rope.ROPE, scene: Scene]; AddOrResizeToolToAssembly: PROC [assembly: Slice, scene: Scene]; UniqueAssemblyNameFrom: PROC [name: Rope.ROPE, scene: Scene] RETURNS [unique: Rope.ROPE]; RenameAssembly: PROC [assem: Slice, newName: Rope.ROPE, scene: Scene]; CopyAssemblyAndSonsRename: PROC [assembly: Slice, scene: Scene, prefix: Rope.ROPE, parent: Slice, feedback: FeedbackData] RETURNS [copy: Slice]; CopyAssemblyAndSonsNoRename: PROC [assembly: Slice, newScene: Scene, parent: Slice, feedback: FeedbackData] RETURNS [copy: Slice]; CopyAssemblyAndSonsUniqueNames: PROC [assembly: Slice, oldScene: Scene, newScene: Scene, parent: Slice, feedback: FeedbackData] RETURNS [copy: Slice]; MoveSubassembly: PROC [assem: Slice, to: Slice, scene: Scene]; MoveToFrontOfAssembly: PROC [subassembly: Slice, assembly: Slice, scene: Scene]; MergeAssemblyIntoScene: PROC [originalAssembly: Slice, fromScene: Scene, parentAssembly: Slice, toScene: Scene, feedback: FeedbackData] RETURNS [copyAssembly: Slice]; MergeSceneIntoScene: PROC [fromScene: Scene, toScene: Scene, feedback: FeedbackData] RETURNS [success: BOOL]; SetArtworkAssembly: PROC [assembly: Slice, artwork: Artwork, scene: Scene]; FindSceneFromName: PROC [name: Rope.ROPE] RETURNS [scene: Scene]; DatabaseEmpty: SIGNAL; SceneNotFound: SIGNAL; FindAssemblyFromName: PROC [name: Rope.ROPE, scene: Scene] RETURNS [assembly: Slice, superAssembly: Slice, success: BOOL]; AssemblyNotFound: SIGNAL; AssemblyNameIsPresent: PROC [name: Rope.ROPE, scene: Scene] RETURNS [BOOL]; AnyNamesAlreadyPresent: PROC [assembly: Slice, scene: Scene] RETURNS [BOOL]; NewNamesAlreadyPresent: PROC [assembly: Slice, scene: Scene, prefix: Rope.ROPE] RETURNS [BOOL]; FindObjectFromName: PROC [name: Rope.ROPE, scene: Scene] RETURNS [object: MasterObject, success: BOOL]; ObjectNameIsPresent: PROC [name: Rope.ROPE, scene: Scene] RETURNS [BOOL]; CoordSysNameIsPresent: PROC [name: Rope.ROPE, scene: Scene] RETURNS [BOOL]; FindLightFromName: PROC [name: Rope.ROPE, scene: Scene] RETURNS [light: LightSource, success: BOOL]; LightSourceNameIsPresent: PROC [name: Rope.ROPE, scene: Scene] RETURNS [BOOL]; FindFileCameraFromName: PROC [name: Rope.ROPE, scene: Scene] RETURNS [fileCamera: FileCamera, success: BOOL]; FileCameraNameIsPresent: PROC [name: Rope.ROPE, scene: Scene] RETURNS [BOOL]; UniqueObjectNameFrom: PROC [name: Rope.ROPE, scene: Scene] RETURNS [unique: Rope.ROPE]; GetSceneGenerator: PROC RETURNS [g: SceneGenerator]; SceneGenerator: TYPE = REF SceneGeneratorObj; SceneGeneratorObj: TYPE = RECORD [currentPtr: LIST OF Scene]; NextScene: PROC [g: SceneGenerator] RETURNS [scene: Scene]; GetCoordSysGenerator: PROC [scene: Scene] RETURNS [g: CoordSysGenerator]; CoordSysGenerator: TYPE = REF CoordSysGeneratorObj; CoordSysGeneratorObj: TYPE = RECORD[currentPtr: LIST OF CoordSystem]; NextCoordSys: PROC [g: CoordSysGenerator] RETURNS [cs: CoordSystem]; GetAssemblyGenerator: PROC [scene: Scene] RETURNS [g: AssemblyGenerator]; PrimAssembliesInScene: PROC [scene: Scene] RETURNS [g: AssemblyGenerator]; AssemblyGenerator: TYPE = REF AssemblyGeneratorObj; AssemblyGeneratorObj: TYPE = RECORD[currentPtr: LIST OF Slice]; NextAssembly: PROC [g: AssemblyGenerator] RETURNS [a: Slice]; ListOfPrimAssemblies: PROC [assembly: Slice, scene: Scene] RETURNS [primList: LIST OF Slice]; GetLightSourceGenerator: PROC [scene: Scene] RETURNS [g: LightSourceGenerator]; LightSourceGenerator: TYPE = REF LightSourceGeneratorObj; LightSourceGeneratorObj: TYPE = RECORD [currentPtr: LightSourceList]; NextLight: PROC [g: LightSourceGenerator] RETURNS [ls: LightSource]; GetMasterObjectClassGenerator: PROC [scene: Scene] RETURNS [g: MasterObjectClassGenerator]; MasterObjectClassGenerator: TYPE = REF MasterObjectClassGeneratorObj; MasterObjectClassGeneratorObj: TYPE = RECORD [ currentPtr: MasterObjectClassList]; NextClass: PROC [g: MasterObjectClassGenerator] RETURNS [moClass: MasterObjectClass]; MasterObjectsOfScene: PROC [scene: Scene] RETURNS [l: MasterObjectList]; MasterObjectsOfAssembly: PROC [assembly: Slice, scene: Scene] RETURNS [l: MasterObjectList]; DeleteMasterObjectNamed: PROC [moName: Rope.ROPE, scene: Scene] RETURNS [found: BOOL]; MasterObjectIsUsed: PROC [mo: MasterObject, scene: Scene] RETURNS [used: BOOL]; DeleteCoordSysAndChildren: PROC [cs: CoordSystem, scene: Scene]; DeleteLightSourceNamed: PROC [lsName: Rope.ROPE, scene: Scene]; ClearScene: PROC [scene: Scene]; ClearCoordSystems: PROC [scene: Scene]; ClearMasterObjects: PUBLIC PROC [scene: Scene]; DeleteSubassemblyFromAssembly: PROC [subassembly: Slice, assembly: Slice, scene: Scene _ NIL] RETURNS [success: BOOL]; DeleteAllPrimitivesOfClass: PROC [className: Rope.ROPE, scene: Scene, feedback: FeedbackData]; DeleteAllAssembliesSittingOn: PROC [chair: Slice, scene: Scene]; DeleteAllSelected: PROC [scene: Scene, camera: Camera] RETURNS [bBox: BoundBox]; DeleteSlice: PROC [scene: Scene, slice: Slice]; -- doesn't deselect slice from the normal selected list DrawScene: PROC [dc: Imager.Context, scene: Scene, camera: Camera, except: Slice _ NIL]; SaveSelections: PROC [scene: Scene]; RestoreSelections: PROC [scene: Scene]; SelectInBlock: PROC [scene: Scene, block: BoundBlock, selectClass: SelectionClass _ normal]; SelectPartsInBlock: PROC [scene: Scene, block: BoundBlock, selectClass: SelectionClass _ normal]; END. SVScene.mesa Copyright c 1984 by Xerox Corporation. All rights reserved. Last edited by Bier on September 11, 1987 2:38:56 pm PDT Used for version stamps and initial greeting. Exported by SVSceneImplA. Introduction Contents: The Solidviews System is involved with the creation and manipulation of three dimensional scenes. A scene is a list of lightsources, a list of cameras, and a tree of assemblies. Intermediate nodes in this tree are cluster assemblies. The leaves of this tree are primitive assemblies. Each cluster assembly specifies a point set operation describing how its children should be combined. Each primitive assembly refers to a master object (a shape) and a triplet of scalars describing how this master object should be scaled before being displayed. All assemblies (cluster or primitive) refer to a coordinate system which describes how the object should be positioned and oriented with respect to its parent coordinate system (from which we can derive how it will be positioned in the scene's master coordinate system known as WORLD). Each master object is an instance of a class of shapes called a master object class. This interface provides procedures which: Set Up the System The set of master object classes is established at load time. It is independent of scene, since it is assumed that each artist will want to have all available classes at his disposal for all scenes. Thus, each program which implements a master object class must register it at load time. Those classes which have only one instance (such as spheres, cylinders, blocks, and cones) should register these at load time as well. Create Entities Scenes, Master Objects, Primitive Assemblies, Cluster Assemblies, Light Sources. Build the Scene Tree Add Master Objects, Light Sources, Coordinate Systems, and Assemblies to the scene. Add assemblies as children of other assemblies. Restructure the Tree Rename assemblies. Copy assemblies. Move assemblies to other nodes. Change the order of assemblies within nodes. Add assemblies from other scenes. Add entire other scenes. Change the surface appearance of a Primitive Slice. Delete Parts of the Scene Tree Delete Master Objects, Coordinate Systems, and Light Sources from the scene. Delete Assemblies from their parents. Delete all assemblies from the scene. Delete all Coordinate Systems from the scene. Find Scene Entities from their Names Find scenes from the global scene database. In scenes find: Assemblies, Master Objects, Master Object Classes, Light Sources from their names. Also some facilities for generate a unique assembly name by adding a number to a given assembly name. Get Generators of Scene Entities GetGenerator and Next procedures for Scenes, Coordinate Systems, Assemblies, Light Sources, Master Object Classes, Master Objects. Also a procedure which returns a list of primitive assemblies. Draw Parts of the Scene Tree Draw the entire scene. Draw an assembly and all of its children. Imported Types Create Entities In SVSceneImplA Creates scene and adds scene to database. Includes default coordinate systems (WORLD, CAMERA, and SCENE), one default point light source, one ambient light source, five default master objects (cube, sphere, cone, cylinder, and torus) and seven default cameras (Top, Bottom, Left, Right, Front, UpLeft, and UpRight). Like create scene, but includes only the 3 default coordinate systems. No light sources, master objects or cameras. The scene assembly is the only assembly which has no parent. This procedure creates an assembly and doesn't try to wire it up to a parent. plane = 1, 2, 3 corresponds to the x=0, y=0, and z=0 planes respectively. plane = 4 means all three of them. ToolDatas are needed by CreatePrimitiveAssembly and CreateClusterAssembly above if the assembly is to be a tool. Must be done whenever a new scene is to be viewed (including whenever a solidviewer is created. Adding the camera to the scene tree is probably one of the first acts after creating a new coordinate system tree. A conversion from the viewer-independent to the viewer-dependent type of camera. Must be done whenever camera name (Front, Top, etc) or changes (and thus whenever the scene changes). An initial list of cameras provided with a new scene (or an old scene which was made before named file cameras were introduced). Build the Scene Tree In SVSceneImplA Any of the procedures below may signal NameAlreadyPresent. Adds the named object to the scene's master object list. Add LightSource "ls" to the given scene. Add FileCamera "fileCamera" to the given scene. The names of those cameras which should open automatically with the pic file is loaded are added to the scene in order. Restructure the Tree In SVSceneImplA Takes name, breaks it up into 3 parts: the base rope, a ".", and a trailing number. Increments the number to make the name unique, and reconcatenates the three parts. In SVSceneImplB Creates a new assembly tree with copied master objects at the leaves May SIGNAL NameAlreadyPresent or AttemptToAddSubassemblyToPrimitive if there is a failure for either of these reasons. Soon to be obsolete. Use CopyAssemblyAndSonsUniqueNames. Not used anymore. An attempt to do it right. For assembly and all of its successors, we find an integer a just high enough so that if name.# becomes name.a then all names will be unique. We copy the assembly and its successors and rename them this way. Moves subassembly to the first position of assembly's assemblylist. Makes a list of all of the masterobjects needed. Compares this list to the list of masterobjects available in the new scene, subtracting any that are available. Copies those that are still needed and adds them to the new scene. Makes a copy of the newAssembly tree (without changing names) but refering to master objects in the new scene. Wires up the new assembly to its parent. Takes all of the assemblies from fromScene which are directly under sceneAssembly and adds them to the sceneAssembly of toScene. Makes sure that all assemblies in fromScene have names unique in toScene first. Find Scene Entities from their Names In SVSceneImplA Looks for named scene in the global database Finds the named assembly and its immediate superior in current scene. superAssembly is NIL if assembly is top level Is an assembly with this name present in current scene? Returns TRUE iff one or more of: assembly's name or the names of all of assembly's children is currently found in scene. In SVSceneImplB Like AnyNamesAlreadyPresent except that assembly's name and the name of each of assembly's children is concatenated with prefix before being tested for presence in the scene. In SVSceneImplA Takes name and appends an integer which is greater than the integer for any other master object in the scene. Generators of Scene Entities Scene Generator gets a generator of the scenes in the database CoordSystem Generator gets a generator of the assemblies in the current scene Slice Generator Returns a list of the leaves of the tree whose root is the given assembly. A good start for any function interested in modifying all of the primitive assemblies of a given subassembly of the scene (including the whole scene, of course). LightSource Generator gets a generator of the lightsources in the current scene. MasterObjectClass Generator MasterObject Generator Delete Parts of the Scene Tree In SVSceneImplB Removes all assemblies from scene. Leaves light sources for now. Removes all but WORLD, and SCREEN from current scene. Removes all but "block", "sphere", "cone", and "cylinder" from current scene. Deletes subAssembly from assembly. If subassembly is not a son of assembly, returns FALSE and does nothing className must be a master object class, e.g. "sphere" or "jack". All primitive (leaf) assemblies refering to shapes of this class will be deleted. All assemblies A such that A.sittingOn = chair.name will be deleted along with their children. Draw Parts of the Scene Tree In SVSceneImplB.mesa Draw given scene. Selections Select all slices that are completely contained within or on the surface of block. Select all slice parts that are completely contained within or on the surface of block. ʃ– "Cedar" style˜Ihead1– "Cedar" stylešœ ™ Jšœ Ïmœ1™Jšžœ˜Jš¢œžœ žœ"˜JJšžœ˜š¢œžœ˜Jš£œžœ˜Jš£œ ˜Jš£ œ ˜Jš£œžœ˜ Jš£ œžœ˜Jš£ œžœ˜Jš£ œ ˜Jš£œ ˜Jš£œžœžœ˜Jš £œžœžœžœžœ˜H—š¢ œžœAžœ˜lJ™ÓJ™—š¢œžœJ˜iJ™·—J™š¢œžœžœ˜=J™€J™—Jš¢ œžœžœ Ïuœ ˜D—– "Cedar" stylešœ™L– "Cedar" style™– "Cedar" stylešœ:™:J– "Cedar" styleš£œžœžœ˜!—– "Cedar" styleš¢œžœ"˜>J– "Cedar" stylešœ9™9—– "Cedar" styleš¢œžœ!˜J– "Cedar" stylešœ0™0—– "Cedar" styleš¢œžœ žœ˜@J– "Cedar" style™x—J– "Cedar" styleš¢œžœ!˜@—– "Cedar" stylešœ™J– "Cedar" style™J– "Cedar" style˜– "Cedar" styleš ¢œžœ žœžœžœ˜YJ– "Cedar" stylešœ§™§—J– "Cedar" styleš¢œžœžœ˜FJ˜J™J™Jš¢œžœ.žœ(˜yšžœ˜J– "Cedar" stylešœö™ö—š¢œžœKžœ˜‚J™—š¢œžœ\žœ˜–J™ì—J– "Cedar" style˜J– "Cedar" styleš¢œžœ)˜>– "Cedar" styleš¢œžœ5˜PJ– "Cedar" stylešœC™C—š¢œžœlžœ˜¦J™ÿ—J– "Cedar" styleš¢œžœ;˜Tšžœ žœ˜J– "Cedar" stylešœÑ™Ñ—J– "Cedar" styleš¢œžœ3˜K—– "Cedar" stylešœ$™$J– "Cedar" stylešœ™J– "Cedar" style˜– "Cedar" styleš¢œžœ žœžœ˜AJ– "Cedar" stylešœ,™,J– "Cedar" styleš£ œžœ˜J– "Cedar" styleš£ œžœ˜—J– "Cedar" styleš¢œžœ žœ˜:šžœ2žœ˜?J– "Cedar" stylešœs™sJ– "Cedar" styleš£œžœ˜—– "Cedar" styleš ¢œžœ žœžœžœ˜KJ– "Cedar" stylešœ7™7—– "Cedar" styleš¢œžœ!žœžœ˜LJšœx™x—J™J™š ¢œžœ.žœžœžœ˜_Jšœ¯™¯—J™JšÐbnœžœ žœ˜8Jšžœ!žœ˜.J– "Cedar" styleš ¢œžœ žœžœžœ˜JJ– "Cedar" style˜Jš ¢œžœ žœžœžœ˜LJš¢œžœ žœ˜7Jšžœžœ˜,Jš ¢œžœ žœžœžœ˜OJš ¢œžœ žœžœ#žœ˜mJš ¢œžœ žœžœžœ˜N– "Cedar" styleš ¢œžœ žœžœžœ˜WJ– "Cedar" stylešœR£ œ™m—J– "Cedar" style˜—– "Cedar" stylešœ™head2– "Cedar" stylešœ™J– "Cedar" styleš¢œžœžœ˜4Jšœ.™.Jšœžœžœ˜-Jš œžœžœžœžœ˜=J– "Cedar" styleš¢ œžœžœ˜;—– "Cedar" stylešœ™J– "Cedar" styleš¢œžœžœ˜IJšœ7™7Jšœžœžœ˜3Jš œžœžœ žœžœ˜EJ– "Cedar" styleš¢ œžœžœ˜D—– "Cedar" stylešœ™J– "Cedar" styleš¢œžœžœ˜IJ– "Cedar" styleš¢œžœžœ˜JJšœžœžœ˜3Jš œžœžœ žœžœ˜?J– "Cedar" styleš¢ œžœžœ ˜=– "Cedar" styleš ¢œžœ!žœ žœžœ˜]J– "Cedar" stylešœí™í——– "Cedar" stylešœ™J– "Cedar" styleš¢œžœžœ˜OJšœ:™:Jšœžœžœ˜9Jšœžœžœ˜EJ– "Cedar" styleš¢ œžœžœ˜D—– "Cedar" stylešœ™J– "Cedar" styleš¢œžœžœ"˜\Jšœžœžœ˜Ešœžœžœ˜.Jšœ#˜#—J– "Cedar" styleš¢ œžœ ˜/Jšžœ˜%—– "Cedar" stylešœ™J– "Cedar" styleš¢œžœ˜)Jšžœ˜Jš¢œžœ!žœ˜\——– "Cedar" stylešœ™J– "Cedar" style™J– "Cedar" style˜J– "Cedar" styleš ¢œžœžœžœ žœ˜VJš¢œžœ!žœžœ˜OJš¢œžœ!˜@Jš¢œžœžœ˜?š¢ œžœ˜ J– "Cedar" stylešœA™A—– "Cedar" styleš¢œžœ˜'J– "Cedar" stylešœ5™5—– "Cedar" styleš¢œžœžœ˜/JšœM™M—š ¢œžœ6žœžœ žœ˜vJšœk™k—š¢œžœžœ(˜^Jšœ”™”—š¢œžœ˜@Jšœ^™^—Jš¢œžœ žœ˜PJš¢ œžœ¡7˜g—– "Cedar" stylešœ™J– "Cedar" stylešœ™J– "Cedar" style˜– "Cedar" styleš¢ œžœDžœ˜XJ– "Cedar" stylešœ™——– "Cedar" stylešœ ™ Icodeš¢œžœ˜$Oš¢œžœ˜'š¢ œžœI˜\O™R—š¢œžœI˜aO™W——J– "Cedar" style˜J– "Cedar" stylešžœ˜—…—#XWû