Standard Actions

HOOPS Publish supports the connection of standard actions to buttons or links within the PDF document.

Standard actions are predefined and avoid the developer to write some JavaScript code to control actions. Standard actions are of following types:

  • LaunchURL: to launch a URL in a browser window

  • StartAnimation: to start an animation on a 3D annotation

  • PauseAnimation: to pause the current animation on a 3D annotation

  • ResumeAnimation: to resume the current animation on a 3D annotation

  • SetRenderingStyle: to set the default rendering type for all objects in the scene on a 3D annotation.

  • SetView: to activate a view in a 3D annotation

Playing a U3D Animation

The U3DWithAnimation sample shows how to play a pre-defined animation stored within a U3D file.

Note that the first seven seconds of the animation stored in the U3D file don’t do anything so the animation is set to start at 8 seconds. The start animation button launches the animation for the 3D Annotation context. The pause and the resume buttons stop and play this animation:

// button start
iRet = A3DPDFPageGetField(pPage, "Button1", &pButStart);
iRet = A3DPDFPageFieldButtonSetLabel(pPage, "Button1", "Play");
if (pButStart)
    iRet = A3DPDFButtonSetLabel(pButStart, "Start");
    A3DPDFAction* pAction = NULL;
    A3DPDFActionStartAnimationData sActionData;
    A3D_INITIALIZE_DATA(A3DPDFActionStartAnimationData, sActionData);
    sActionData.m_p3DAnnot = p3DAnnot;
    sActionData.m_bIsNativeAnimation = TRUE;
    // Note: with the car.u3d sample, the animation really starts at 8 secs.
    sActionData.m_dStartTime = 8.0;
    sActionData.m_dEndTime = -1.0;
    iRet = A3DPDFActionStartAnimationCreate(&sActionData, &pAction);
    iRet = A3DPDFButtonAddAction(pButStart, pAction);
// button pause
A3DPDFButton* pButPause = NULL;
A3DPDFPageGetField(pPage, "Button2", &pButPause);
if (pButPause)
    iRet = A3DPDFButtonSetLabel(pButPause, "Pause");
    A3DPDFAction* pAction = NULL;
    A3DPDFActionPauseAnimationData sActionData;
    A3D_INITIALIZE_DATA(A3DPDFActionPauseAnimationData, sActionData);
    sActionData.m_p3DAnnot = p3DAnnot;
    iRet = A3DPDFActionPauseAnimationCreate(&sActionData, &pAction);
    iRet = A3DPDFButtonAddAction(pButPause, pAction);
// button Resume
A3DPDFButton* pButResume = NULL;
A3DPDFPageGetField(pPage, "Button3", &pButResume);
if (pButResume)
    iRet = A3DPDFButtonSetLabel(pButResume, "Resume");
    A3DPDFAction* pAction = NULL;
    A3DPDFActionResumeAnimationData sActionData;
    A3D_INITIALIZE_DATA(A3DPDFActionResumeAnimationData, sActionData);
    sActionData.m_p3DAnnot = p3DAnnot;
    iRet = A3DPDFActionResumeAnimationCreate(&sActionData, &pAction);
    iRet = A3DPDFButtonAddAction(pButResume, pAction);