home *** CD-ROM | disk | FTP | other *** search
-
- //
- // Description:
- // Export camera animation to a file. Also demonstrates how to use r3File class to
- // enumerate the contents of a layer
- //
- // Super class:
- // myclasses/toolbars/toolbar.js
- //
- // Constructor:
- // toolbar = new myExportTools();
- //
- // Attributes:
- // --
- //
- // Methods:
- // --
- //
-
- include("myclasses/toolbars/mytoolbar.js"); // our super class
-
- include("real/layer/r3prilay.js"); // geometric layer
- include("real/layer/r3animtr.js"); // animator
- include("oops/r3file.js"); // file
-
- // support these geometric objects
- include("real/objects/r3sphere.js");
- include("real/objects/r3camera.js");
-
-
- // This callback function is called for each geometric object
-
- function myExportHook(r3obj, frame)
- {
- // call low level API to fetch the class ID of the object
- iClid = R3Get(r3obj, R3RA_ClassID, R3TID_INTEGER, 0);
-
- if (iClid == R3CLID_CAMERA) {
-
- camera = new r3Camera();
- camera.r3Attach(r3obj);
-
- // fetch position, rotation and viewing angle
- pPos = camera.GetPosition();
- pRot = camera.GetQuaternion();
- fAngle = camera.GetAngle();
-
- // write them out
- this.myFile.PUTS("at time " + frame + "f c.rotation = quat " + pRot.x + " " + pRot.y + " " + pRot.z + " " + pRot.w + "\n");
- this.myFile.PUTS("at time " + frame + "f c.position = [" + pPos.x + "," + pPos.y + "," + pPos.z + "]\n");
- this.myFile.PUTS("at time " + frame + "f c.fov = " + fAngle / (2*Math.PI) * 360.0 + "\n");
-
- delete camera;
- }
- return TRUE;
- }
-
- function myExportGeometrics(button, event, value)
- {
- // create R3D file object
- myFile = new r3File(R3FIA_FileName, "js.out",
- R3FIA_Mode, "wa");
- myExportHook.myFile = myFile;
-
- animator = new r3Animator();
- animator.r3Attach(Get("CurrentProject.Animator"));
-
- iFrames = animator.GetFrames();
-
- myFile.PUTS("-- REALViZ MatchMover exported file\n");
- myFile.PUTS("-- (c) REALViZ 1998\n");
- myFile.PUTS("-- Export tag: $Revision: 1.6 $\n");
- myFile.PUTS("-- Realsoft 3D : scale: 1\n\n");
- myFile.PUTS("-- Creation date : ....\n\n");
- myFile.PUTS("animationRange = interval 0f " + iFrames + "f\n\n");
- myFile.PUTS("-- The camera and its keyframes\n");
- myFile.PUTS("animate on (\n");
- myFile.PUTS("c = freecamera name:\"camera11\"\n\n");
-
- do {
- iCurr = animator.GetCurrentFrame();
-
- // enumerate all geometric objects to 'myExportHook()'
- button.layer.LOCKSHARED(0);
- button.layer.ENUMOBJECTS([R3RA_Hook, myExportHook, R3RA_HookData, iCurr]);
- button.layer.RELEASE(0);
-
- animator.NEXTFRAME();
- } while(iCurr < iFrames-1);
-
- myFile.PUTS(")\n");
-
- // close file
- myExportHook.myFile = 0;
- myFile.r3Detach();
-
- print("Camera animation written to 'js.out' file");
- }
-
- function myExportTools(orientation)
- {
- if(arguments.length == 0)
- return;
-
- // create interface to geometric objects layer
- primLayer = new r3Primlayer();
- primLayer.r3Attach(Get("CurrentProject.Geometrics"));
-
- // call super class constructor
- this.base = myToolBar;
- this.base("Export", orientation, primLayer);
-
- // add tool buttons
- this.AddTool("Export Geometrics", myExportGeometrics);
- }
-
- myExportTools.prototype=new myToolBar;
-