
Adobe Acrobat SDK
Creating 3D Annotations
Developing Plug-ins and Applications
Setting the default view 209
Set it as the value of the
OnInstantiate
entry of the 3D stream dictionary. The following code example
specifies a JavaScript script as the value of the
OnInstantiate
entry of the 3D stream dictionary.
CosDictPutKeyString(attrObj, "OnInstantiate", stm3Djscode);
Then some cleanup is done:
ASFileSysReleasePath (ASGetDefaultFileSys(), JsPathName);
ASStmClose(JsFileStm);
Setting the default view
A 3D
view
specifies parameters such as position, orientation, and projection style, which are applied to the
virtual camera
associated with the 3D annotation (see section 9.5.3 in the
PDF Reference
). The
default view
is the view that is chosen when the annotation is activated.
U3D data typically contains a default initial view. This view is used by default if not otherwise specified. In
addition, views can be specified by the entries in a
view dictionary
.
The
VA
entry in the 3D stream dictionary is an array of view dictionaries. One of the views can be chosen as
the default by means of the
3DV
entry in the 3D annotation dictionary or the
DV
entry in a 3D stream
dictionary.
The following code creates a view dictionary and specifies its entries. The code assumes the Cos objects
cosAnnot
for the annotation and
cosDoc
for the document have already been obtained. First, a view
dictionary is created by invoking the
CosNewDict
method:
CosObj cosView = CosNewDict (cosDoc, true, 8);
Next, the code sets the following entries (see Table 9.37 in the
PDF Reference
for more detailed
information):
Type
(optional): If present, must be the name
3DView
.
XN
(required): The name of the view, a string that can be displayed in the user interface.
IN
(optional): The internal name of the view, a string that can be used to refer to the view from other
objects, such as in JavaScript code.
C2W
(optional): A transformation matrix specifying the camera position. To use this, it is also necessary
to set the value of the
MS
entry to
M
.
CO
(optional): A number indicating the distance to the center of orbit for this view.
The following code creates an array of type
double
and specifies values for views:
char* externalViewName = "Default View";
char* internalViewName = "Sample3dView";
double gMatrixVals[12] =
{1.0, 0.0, 0.0, 0.0, 0.0000000000000000612303, -1.0,
0.0, 1.0, 0.0000000000000000612303, 82.9517, -883.324, 115.166};
float gCOvalue = (float) 725.305;
Now the values of the dictionary entries are set:
CosDictPutKeyString(cosView, "Type",
CosNewNameFromString(cosDoc, false,"3DView"));
CosDictPutKeyString(cosView, "XN", CosNewString(cosDoc, false,