G3dControlTestCmdImpl.mesa
Copyright Ó 1988, 1992 by Xerox Corporation. All rights reserved.
Bloomenthal, July 22, 1992 11:35 pm PDT
Heckbert, June 18, 1988 0:35:44 am PDT
DIRECTORY Args, Commander, Controls, G3dBasic, G3dControl, G3dDraw, G3dMatrix, G3dModel, G3dShape, G3dTool, Draw2d, Icons, IO, Rope, ViewerClasses, ViewerOps;
G3dControlTestCmdImpl: CEDAR PROGRAM
IMPORTS Args, Controls, G3dControl, G3dDraw, G3dModel, G3dShape, G3dTool, Draw2d, Icons, Rope, ViewerOps
~ BEGIN
Testing them there 3D Controls
TestData:    TYPE ~ REF TestDataRep;
TestDataRep:   TYPE ~ RECORD [
outerData:     Controls.OuterData,     -- viewing control
view:       G3dMatrix.Matrix ¬ NIL,   -- view transformation
screens:      G3dShape.ScreenSequence ¬ NIL,
shape:       G3dShape.Shape ¬ NIL    -- the polygonal object
];
ControlTest: Commander.CommandProc ~ {
name, all: Args.Arg;
d: TestData ¬ NEW[TestDataRep];
[name, all] ¬ Args.ArgsGet[cmd, "%s-all%b" ! Args.Error => {msg ¬ reason; GOTO Bad}];
d.shape ¬ G3dShape.ShapeFromFile[fileName: name.rope
! G3dShape.Error => {msg ¬ reason; GOTO Bad}];
d.camera ¬ G3dControl.InitCamera[clientData: d];
d.camera.scale.max ¬ 8.0;
Controls.ControlRow[d.camera.par.xMov, 0];
Controls.ControlRow[d.camera.wor.xMov, 1];
Controls.ControlRow[d.camera.eye.xMov, 2];
d.outerData ¬ Controls.OuterViewer[
name: Rope.Concat["ControlTest ", name.rope],
controls: IF all.bool
THEN LIST[
d.camera.par.xMov,
d.camera.par.yMov,
d.camera.par.zMov,
d.camera.par.xRot,
d.camera.par.yRot,
d.camera.par.zRot,
d.camera.fieldOfView,
d.camera.scale,
d.camera.hScreen,
d.camera.vScreen,
d.camera.wor.xMov,
d.camera.wor.yMov,
d.camera.wor.zMov,
d.camera.wor.xRot,
d.camera.wor.yRot,
d.camera.wor.zRot,
d.camera.eye.xMov,
d.camera.eye.yMov,
d.camera.eye.zMov,
d.camera.eye.xRot,
d.camera.eye.yRot,
d.camera.eye.zRot]
ELSE LIST[
d.camera.proxySelect,
d.camera.proxy.xMov,
d.camera.proxy.yMov,
d.camera.proxy.zMov,
d.camera.proxy.xRot,
d.camera.proxy.yRot,
d.camera.proxy.zRot,
d.camera.scale,
d.camera.fieldOfView],
graphicsHeight: 300,
drawProc: TestDraw,
clientData: d,
icon: icon,
noOpen: TRUE];
G3dControl.SetCameraGraphics[d.camera, NARROW[d.outer.data, Controls.OuterData].graphics];
ViewerOps.OpenIcon[d.outerData.parent];
EXITS Bad => RETURN[$Failure, msg];
};
TestDraw: Draw2d.DrawProc ~ {
d: TestData ¬ NARROW[data];
Action: PROC ~ {
d.view ¬ G3dControl.InitContext[context, d.camera, viewer,, d.view];
d.screens ¬ G3dModel.DrawShape[context, d.shape, d.view, d.screens, TRUE];
G3dDraw.DrawAxes[context, d.view];
};
Draw2d.DoWithBuffer[context, Action];
};
Start Code
icon: Icons.IconFlavor ¬ Icons.NewIconFromFile["3dGraphics.icons", 1];
usage: Rope.ROPE ¬ "\nTestControls <shape file> [-all]";
G3dTool.Register["ControlTest", ControlTest, usage];
END.