179 lines
5.8 KiB
C++
179 lines
5.8 KiB
C++
/***********************************************************************************************************************
|
|
*
|
|
* Copyright (c) 2010 - 2022 by Tech Soft 3D, Inc.
|
|
* The information contained herein is confidential and proprietary to Tech Soft 3D, Inc., and considered a trade secret
|
|
* as defined under civil and criminal statutes. Tech Soft 3D shall pursue its civil and criminal remedies in the event
|
|
* of unauthorized use or misappropriation of its trade secrets. Use of this information by anyone other than authorized
|
|
* employees of Tech Soft 3D, Inc. is granted only under a written non-disclosure agreement, expressly prescribing the
|
|
* scope and manner of such use.
|
|
*
|
|
***********************************************************************************************************************/
|
|
/**
|
|
\file AnimDefStep1.cpp
|
|
|
|
Animation for Step 1
|
|
***********************************************************************************************************************/
|
|
|
|
// Do not define INITIALIZE_A3D_API here. It should be only included once in a project.
|
|
#include "AnimDef.hpp"
|
|
|
|
//######################################################################################################################
|
|
|
|
|
|
/*
|
|
Zoom to full extent of the model.
|
|
Make all parts of the model go semi-transparent with the exception of the washer.
|
|
then flash the color of the washer to yellow three times over one second.
|
|
Pause one second
|
|
and then make the model turn back opaque over one second.
|
|
*/
|
|
A3DStatus BuildAnimationStep1(A3DPDFAnimation **ppAnim,
|
|
double dStepInitTimeOffset,
|
|
double& dStepTimeDuration)
|
|
{
|
|
A3DStatus iRet = A3D_SUCCESS;
|
|
|
|
// ANIMATION = set of MOTIONS
|
|
const int INBMOTIONS = 20;
|
|
A3DPDFAnimMotion** ppMotion;
|
|
ppMotion = (A3DPDFAnimMotion**) malloc(INBMOTIONS * A3DUns32(sizeof(A3DPDFAnimMotion*)));
|
|
int idxMotion = 0;
|
|
double dInitTimeOffset = dStepInitTimeOffset;
|
|
double dTimeDuration;
|
|
|
|
// MOTIONS to specify init state
|
|
CreateMotionsInitState(ppMotion, idxMotion, 1,
|
|
dInitTimeOffset,
|
|
dTimeDuration);
|
|
dInitTimeOffset += dTimeDuration;
|
|
|
|
|
|
// MOTION CAMERA
|
|
CreateMotionCameraInit(ppMotion, idxMotion,
|
|
334.117035, 243.555069, 101.844193,
|
|
45.135365, 43.723457, -33.948994,
|
|
-0.311321, -0.183419, 0.932440,
|
|
10, kA3DPDFOrthographicMode, 1.0/(2*106),
|
|
240.637375, -170.123276, 153.468277,
|
|
42.014103, 28.500000, -45.155003,
|
|
-0.408250, 0.408250, 0.816500,
|
|
10, kA3DPDFOrthographicMode, 1.0/(2*137),
|
|
dInitTimeOffset,
|
|
dTimeDuration);
|
|
dInitTimeOffset += dTimeDuration;
|
|
|
|
|
|
// MOTION 1
|
|
// Make all parts of the model go semi-transparent with the exception of the washer.
|
|
{
|
|
A3DPDFAnimMotion* pMotion;
|
|
A3DPDFAnimMotionData2 sMotionData;
|
|
A3D_INITIALIZE_DATA(A3DPDFAnimMotionData2, sMotionData);
|
|
|
|
// --- KEYFRAMES
|
|
|
|
const int INBKEYFRAMESALLOC = 10;
|
|
A3DPDFAnimKeyFrame** ppKeyFrame;
|
|
ppKeyFrame = (A3DPDFAnimKeyFrame**) malloc(INBKEYFRAMESALLOC * A3DUns32(sizeof(A3DPDFAnimKeyFrame*)));
|
|
int idxKeyFrame = 0;
|
|
|
|
AddKeyFrameAppearance(ppKeyFrame, idxKeyFrame, 0.0,
|
|
kA3DPDFInterpolateAppearanceTransparency,
|
|
-1, -1, -1, // RGB
|
|
1.0, // opacity
|
|
kA3DPDFRenderingSolid ); // rendering style
|
|
AddKeyFrameAppearance(ppKeyFrame, idxKeyFrame, 1.0,
|
|
0,//kA3DPDFInterpolateAppearanceTransparency,
|
|
-1, -1, -1, // RGB
|
|
0.1, // opacity
|
|
kA3DPDFRenderingSolid );// rendering style
|
|
|
|
|
|
// --- MOTION CREATION
|
|
|
|
sMotionData.m_bRepeat = false;
|
|
sMotionData.m_dTimeOffset = dInitTimeOffset;
|
|
sMotionData.m_iNumTargets = idxTargetsAllExceptWasher;
|
|
sMotionData.m_ppTargets = ppTargetsAllExceptWasher;
|
|
sMotionData.m_iNumKeyFrames = idxKeyFrame;
|
|
sMotionData.m_ppKeyFrames = ppKeyFrame;
|
|
|
|
A3DPDFAnimMotionCreate2(&sMotionData, &pMotion);
|
|
ppMotion[idxMotion++] = pMotion;
|
|
|
|
dTimeDuration = 1.0; // 1 second motion
|
|
dInitTimeOffset += dTimeDuration;
|
|
}
|
|
|
|
// MOTION 2
|
|
// then flash the color of the washer to yellow three times over one second.
|
|
CreateMotionFlash(ppMotion, idxMotion,
|
|
ppTargetsWasher, idxTargetsWasher,
|
|
1, 1, 0, // color init
|
|
1, 0, 0, // color blink
|
|
kA3DPDFRenderingSolid,
|
|
dInitTimeOffset,
|
|
dTimeDuration);
|
|
dInitTimeOffset += dTimeDuration;
|
|
|
|
|
|
// MOTION 3
|
|
// Pause one second
|
|
// and then make the model turn back opaque over one second.
|
|
{
|
|
A3DPDFAnimMotion* pMotion;
|
|
A3DPDFAnimMotionData2 sMotionData;
|
|
A3D_INITIALIZE_DATA(A3DPDFAnimMotionData2, sMotionData);
|
|
|
|
// --- KEYFRAMES
|
|
|
|
// pause 1 second
|
|
dInitTimeOffset += PAUSE1SEC;
|
|
|
|
const int INBKEYFRAMESALLOC = 10;
|
|
A3DPDFAnimKeyFrame** ppKeyFrame;
|
|
ppKeyFrame = (A3DPDFAnimKeyFrame**) malloc(INBKEYFRAMESALLOC * A3DUns32(sizeof(A3DPDFAnimKeyFrame*)));
|
|
int idxKeyFrame = 0;
|
|
|
|
AddKeyFrameAppearance(ppKeyFrame, idxKeyFrame, 0.0,
|
|
kA3DPDFInterpolateAppearanceTransparency,
|
|
-1, -1, -1, // RGB
|
|
0.1, // opacity
|
|
kA3DPDFRenderingSolid);// rendering style
|
|
AddKeyFrameAppearance(ppKeyFrame, idxKeyFrame, 1.0,
|
|
0,//kA3DPDFInterpolateAppearanceTransparency,
|
|
-1,-1,-1, // RGB
|
|
0.1, // opacity
|
|
kA3DPDFRenderingSolid);// rendering style
|
|
|
|
|
|
// --- MOTION CREATION
|
|
|
|
sMotionData.m_bRepeat = false;
|
|
sMotionData.m_dTimeOffset = dInitTimeOffset;
|
|
sMotionData.m_iNumTargets = idxTargetsAllExceptWasher;
|
|
sMotionData.m_ppTargets = ppTargetsAllExceptWasher;
|
|
sMotionData.m_iNumKeyFrames = idxKeyFrame;
|
|
sMotionData.m_ppKeyFrames = ppKeyFrame;
|
|
|
|
A3DPDFAnimMotionCreate2(&sMotionData, &pMotion);
|
|
ppMotion[idxMotion++] = pMotion;
|
|
|
|
dTimeDuration = 1.0; // 1 second motion
|
|
dInitTimeOffset += dTimeDuration;
|
|
}
|
|
|
|
dStepTimeDuration = dInitTimeOffset - dStepInitTimeOffset;
|
|
|
|
// --- ANIMATION CREATION
|
|
A3DPDFAnimationData sAnimationData;
|
|
A3D_INITIALIZE_DATA(A3DPDFAnimationData, sAnimationData);
|
|
sAnimationData.m_pcName = const_cast<A3DUTF8Char*>("step1");
|
|
sAnimationData.m_iFramesPerSecond = 20;
|
|
sAnimationData.m_iNumAnimationMotions = idxMotion;
|
|
sAnimationData.m_ppAnimationMotions = ppMotion;
|
|
|
|
iRet = A3DPDFAnimationCreate(&sAnimationData, ppAnim);
|
|
return iRet;
|
|
}
|