Пример #1
0
void MeshExporter::_dumpAnimation(IGameControl * pGameControl, int boneId)
{
	int start = ExportConfig::Instance()->GetFrameRange().x;
	int end = ExportConfig::Instance()->GetFrameRange().y;
	start *= GetTicksPerFrame();
	end *= GetTicksPerFrame();

	if ((pGameControl->IsAnimated(IGAME_POS)) || pGameControl->IsAnimated(IGAME_ROT) || pGameControl->IsAnimated(IGAME_SCALE))
	{
		IGameKeyTab Key;
		if(pGameControl->GetFullSampledKeys(Key, 1, IGAME_TM, true) )
		{
			SkeletonAnimation * skelAnim = new SkeletonAnimation(boneId);

			int count = Key.Count();
			for(int i=0;i<count;i++)
			{
				if (Key[i].t >= start && Key[i].t <= end)
				{
					float time = (float)Key[i].t / (float)GetTicksPerFrame() / (float)GetFrameRate();
					SkeletonAnimation::KeyFrame * kf = skelAnim->CreateKeyFrame(time);

					kf->position = Utility::ToFloat3(Key[i].sampleKey.gval.Translation());
					kf->rotation = Utility::ToQuat(Key[i].sampleKey.gval.Rotation());
					kf->scale = Utility::ToFloat3(Key[i].sampleKey.gval.Scaling());
				}
			}

			skelAnim->Optimize();
			_getAnimation()->AddSkeletonAnimation(skelAnim);
		}
	}
}
Пример #2
0
//called every frame.  Here we set up the target paramters so that they
//can be used by each node passed into the perform function.
void FormationBhvr::InitAtThisTime(TimeValue t)
{

	INode *leaderNode = GetLeader(t);
	if(leaderNode)
	{
	
		if(prevPosTime==TIME_NegInfinity||prevPosTime != t - GetTicksPerFrame())
		{
			//get the right leaderPrevPos.
			leaderPrevPos = GetCurrentMatrix(leaderNode,t-GetTicksPerFrame()).GetTrans();

		}
		leaderPos = GetCurrentMatrix(leaderNode,t).GetTrans();
		leaderVel = leaderPos - leaderPrevPos;//use the preivous position to get the velocity.

		leaderSpeed = leaderVel.FLength();
		//normalize the velocity.
		if(leaderSpeed!=0.0f)
			leaderVel /= leaderSpeed;
		else
		{
			leaderVel.x = leaderVel.y = leaderVel.z = 0.0f;
		}
		//set up the previous for the next time.
		leaderPrevPos = leaderPos;
		prevPosTime = t;
	}
}
Пример #3
0
/*
====================
exportAnimation
====================
*/
void G3DAExport::exportAnimation(NODE* node)
{
	// get the animation 
	if(node->include)
	{
		int first_frame = mStart/GetTicksPerFrame();
		int last_frame = mEnd/GetTicksPerFrame();
		for(int i = first_frame; i <= last_frame; i++)
		{
			// does this node have a max node?
			TimeValue t = i*GetTicksPerFrame();
			Matrix3 m(true);
			if(node->parent)
			{
				m = GetTransform(node, t) * Inverse(GetTransform(node->parent, t));
			}
			else
			{
				m = GetTransform(node, t);
			} 

			// add the transform to the sequence
			node->sequence.push_back(m);
		}
		mNodeCount++;
	}

	// process the child node
	for(int i = 0; i < node->children.size(); i++)
	{
		exportAnimation(node->children[i]);
	}
}
Пример #4
0
bool bgGlobalMax::Initialize(Interface* p3DMax)
{
	m_p3DMax = p3DMax;
	m_pRootNode = p3DMax->GetRootNode();

	if (m_p3DMax == NULL && m_pRootNode == NULL)
		return false;
	if (CheckFile(m_p3DMax) == false)
		return true;

	m_Interval = m_p3DMax->GetAnimRange();

	memset(&m_Scene, 0, sizeof(m_Scene));
	m_Scene.iVersion = 100;
	m_Scene.iFirstFrame = m_Interval.Start() / GetTicksPerFrame();
	m_Scene.iLastFrame = m_Interval.End() / GetTicksPerFrame();
	m_Scene.iFrameSpeed = GetFrameRate();
	m_Scene.iTickPerFrame = GetTicksPerFrame();

	PreProcess(m_pRootNode);

	m_Scene.iNumMesh = m_MatrixMap.Count();
	m_Scene.iMaxWeight = 1;

	return true;
}
Пример #5
0
// Dialog proc
static INT_PTR CALLBACK ExportDlgProc(HWND hWnd, UINT msg,
	WPARAM wParam, LPARAM lParam)
{
	Interval animRange;
	ISpinnerControl  *spin;

	AscOut *exp = (AscOut*)GetWindowLongPtr(hWnd,GWLP_USERDATA); 
	switch (msg) {
	case WM_INITDIALOG:
		exp = (AscOut*)lParam;
		SetWindowLongPtr(hWnd,GWLP_USERDATA,lParam); 
		CenterWindow(hWnd, GetParent(hWnd)); 

		// Setup the spinner controls for the floating point precision 
		spin = GetISpinner(GetDlgItem(hWnd, IDC_PREC_SPIN)); 
		spin->LinkToEdit(GetDlgItem(hWnd,IDC_PREC), EDITTYPE_INT ); 
		spin->SetLimits(1, 10, TRUE); 
		spin->SetScale(1.0f);
		spin->SetValue(exp->GetPrecision() ,FALSE);
		ReleaseISpinner(spin);

		// Setup the spinner control for the static frame#
		// We take the frame 0 as the default value
		animRange = exp->GetInterface()->GetAnimRange();
		spin = GetISpinner(GetDlgItem(hWnd, IDC_STATIC_FRAME_SPIN)); 
		spin->LinkToEdit(GetDlgItem(hWnd,IDC_STATIC_FRAME), EDITTYPE_INT ); 
		spin->SetLimits(animRange.Start() / GetTicksPerFrame(), animRange.End() / GetTicksPerFrame(), TRUE); 
		spin->SetScale(1.0f);
		spin->SetValue(0, FALSE);
		ReleaseISpinner(spin);
		break;

	case CC_SPINNER_CHANGE:
		spin = (ISpinnerControl*)lParam; 
		break;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDOK:
			spin = GetISpinner(GetDlgItem(hWnd, IDC_PREC_SPIN)); 
			exp->SetPrecision(spin->GetIVal());
			ReleaseISpinner(spin);
		
			spin = GetISpinner(GetDlgItem(hWnd, IDC_STATIC_FRAME_SPIN)); 
			exp->SetStaticFrame(spin->GetIVal() * GetTicksPerFrame());
			ReleaseISpinner(spin);
			
			EndDialog(hWnd, 1);
			break;
		case IDCANCEL:
			EndDialog(hWnd, 0);
			break;
		}
		break;
		default:
			return FALSE;
	}
	return TRUE;
}       
Пример #6
0
INT_PTR CALLBACK TrackPropDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
	BlockControl *blk = (BlockControl*)GetWindowLongPtr(hWnd,GWLP_USERDATA);

	ISpinnerControl *spin;
	static TSTR zero = FormatUniverseValue(0.0f);
	Rect rect;

	switch (msg) {
	case WM_INITDIALOG:
		{
		blk = (BlockControl*)lParam;
		SetWindowLongPtr(hWnd,GWLP_USERDATA,lParam);

		Interval range = GetCOREInterface()->GetAnimRange();

		
		spin = GetISpinner(GetDlgItem(hWnd,IDC_STARTSPIN));
		spin->SetLimits(-999999.0f,9999999.0f, FALSE);
		spin->SetAutoScale();
		spin->LinkToEdit(GetDlgItem(hWnd,IDC_START), EDITTYPE_INT);
		spin->SetValue(range.Start()/GetTicksPerFrame(),FALSE);
		ReleaseISpinner(spin);

		blk->propStart = range.Start()/GetTicksPerFrame();
		CenterWindow(hWnd,GetParent(hWnd));
		break;
		}
		
	case CC_SPINNER_CHANGE:
		spin = (ISpinnerControl*)lParam;
		switch (LOWORD(wParam)) {
		case IDC_STARTSPIN: blk->propStart = spin->GetIVal(); break;
		}
		break;



	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDOK:
			{
			EndDialog(hWnd,1);
			blk->NotifyDependents(FOREVER, PART_ALL, REFMSG_CHANGE);

			break;
			}
		case IDCANCEL:
			EndDialog(hWnd,0);
			break;
		}
		break;

	default:
		return FALSE;
	}
	return TRUE;
}
Пример #7
0
// SAMPLENODEMOTION
// sample all the motion on a single node
// intended for use in the context of a full tree traversal
plSampleVec * SampleNodeMotion(INode * node, INode* parent, int sampleRate, TimeValue start, TimeValue end)
{
    plSampleVec *result = new plSampleVec;

    bool done = false;
    
    for(int i = start; ! done; i += sampleRate)
    {
        if (i > end) i = end;
        if (i == end) done = true;

        // Get key time
        TimeValue keyTime = i;
        int frameNum= keyTime / GetTicksPerFrame();

        // get localTM
        nodeTMInfo * nti = new nodeTMInfo;
        nti->fTime = keyTime;
        Matrix3 localTM = node->GetNodeTM(keyTime);

        nti->fMat3 = localTM;
        result->push_back(nti);
    }
    return result;
}
Пример #8
0
//+--------------------------------------------------------------------------+
//|							From IPViewItem									 |
//+--------------------------------------------------------------------------+
bool PFTestGoToRotation::HasDynamicName(TSTR& nameSuffix)
{
	int type = pblock()->GetInt(kGoToRotation_syncBy, 0);
	switch(type) {
	case kGoToRotation_syncBy_time:
		nameSuffix = GetString(IDS_TIME);
		break;
	case kGoToRotation_syncBy_age:
		nameSuffix = GetString(IDS_AGE);
		break;
	case kGoToRotation_syncBy_event:
		nameSuffix = GetString(IDS_EVENT);
		break;
	}
	nameSuffix += _T(" ");
	int tpf = GetTicksPerFrame();
	TimeValue time	= pblock()->GetTimeValue(kGoToRotation_time, 0)/tpf;
	TCHAR buf[32];
	_stprintf(buf, _T("%d"), time);
	nameSuffix += buf;
	TimeValue variation = pblock()->GetTimeValue(kGoToRotation_variation, 0)/tpf;
	if (variation > 0) {
		_tcscpy(buf, GetString(IDS_PLUS_OR_MINUS_CHAR));
		nameSuffix += buf;
		_stprintf(buf, _T("%d"), variation);
		nameSuffix += buf;
	}
	return true;
}
Пример #9
0
int Plate::DoThisFrame(TimeValue t, BOOL fieldRender, TimeValue mapTime) {
	if (!do_nth) return 0;  // only do it once.
	if (nth==1) return 1;   // need every one
	TimeValue del = abs(t - mapTime);
	if (fieldRender) del*=2;
	return  (del>=nth*GetTicksPerFrame())?1:0;
	}
void CSkeletonActionExpDlg::OnBnClickedActionAdd()
{
    // TODO: Add your control notification handler code here
    sActionInfo_t action;
    UpdateData();
    action.m_ActionType  = GetActionType();
    action.m_iFirstFrame = m_iStartFrame;
    action.m_iLastFrame  = m_EndFrame;
    action.m_lTime       = m_iDurationTime;
    if(m_iDurationTime == 0)
    {
        int tickt_per_frame = GetTicksPerFrame();
        int iMaxTime = (m_EndFrame - m_iStartFrame + 1 ) * tickt_per_frame;
        float vTime = CMaxEnv::singleton().TicksToSeconds(iMaxTime);
        action.m_lTime       =  vTime * 1000;
        m_iDurationTime = action.m_lTime;
    }
	WGetWndText(&m_ctrlActionName , action.m_Name,32);

    if(wcslen(action.m_Name) == 0)
    {
        ::MessageBoxA(::GetActiveWindow(),"请填写动作名字","错误",MB_OK);
        return ;
    }
    if(m_iDurationTime <= 0)
    {
        ::MessageBoxA(::GetActiveWindow(),"动作时间不能为0","错误",MB_OK);
        return ;
    }
    InsertAction(action, true); 
    
}
Пример #11
0
//+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+
//|							From PFOperatorMaterialStatic						 |
//+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+
PFOperatorMaterialStatic::PFOperatorMaterialStatic()
{
	_dadMgr() = new PFOperatorMaterialStaticDADMgr(this);
	GetClassDesc()->MakeAutoParamBlocks(this);
	// set the initial value for sub-mtls rate to the number of frames per second
	pblock()->SetValue(kMaterialStatic_ratePerSecond, 0, float(TIME_TICKSPERSEC)/GetTicksPerFrame() );
	_material() = NULL;
}
Пример #12
0
void ForceObject::SetUpModifier(TimeValue t,INode *node)
{
    mf->force.obj  = (ForceObject*)(mf->GetWSMObject(t));
    mf->force.node = mf->nodeRef;
    mf->force.tmValid.SetEmpty();
    mf->force.fValid.SetEmpty();
    mf->force.dt = GetTicksPerFrame();
    mf->force.dtsq = mf->force.dt * mf->force.dt;
}
Пример #13
0
ForceField *PinObject::GetForceField(INode *node)
{	PinField *pb = new PinField;	
	pb->obj  = this;
	pb->node = node;
	pb->tmValid.SetEmpty();
	pb->fValid.SetEmpty();
	pb->dt=GetTicksPerFrame();
	pb->dtsq=pb->dt*pb->dt;
	return pb;
}
Пример #14
0
// SAMPLENODEMOTION
// top level function for sampling all the motion on a single node
plSampleVec * SampleNodeMotion(INode* node, INode* parent, int sampleRate, Interface *theInterface)
{
    Interval interval = theInterface->GetAnimRange();
    TimeValue start = interval.Start();                 // in ticks
    TimeValue end = interval.End();

    sampleRate *= GetTicksPerFrame();                   // convert sample rate to ticks

    return SampleNodeMotion(node, parent, sampleRate, start, end);
}
Пример #15
0
void PinMod::ModifyObject(TimeValue t, ModContext &mc, ObjectState *os, INode *node)
{	ParticleObject *obj = GetParticleInterface(os->obj);
	if (obj)
	{	force.obj=(PinObject*)GetWSMObject(t);
		force.node=nodeRef;
		force.tmValid.SetEmpty();
		force.fValid.SetEmpty();
		force.dt=GetTicksPerFrame();
		force.dtsq=force.dt*force.dt;
		obj->ApplyForceField(&force); //ok
	}
}
Пример #16
0
void Import::SetSceneParameters()
{
    Interval range;

    range.SetStart(0);
    range.SetEnd(30);
    SetFrameRate(30);

    SetTicksPerFrame(160);

    range.SetStart(range.Start() * GetTicksPerFrame());
    range.SetEnd(range.End() * GetTicksPerFrame());

    m_ip->SetAnimRange(range);

    Point3 bkColor (0.0f, 0.0f, 0.0f);
    m_impip->SetBackGround(0, bkColor);

    Point3 amColor (0.3f, 0.3f, 0.3f);
    m_impip->SetAmbient(0, amColor);
}
Пример #17
0
BOOL bgAnimMax::CheckForAnimation(INode* pNode, BOOL& bPos, BOOL& bRot, BOOL& bScl)
{
	AffineParts ap;
	Point3 firstPos, firstRotAxis, firstScaleFactor;
	Point3 rotAxis;
	float firstRotAngle;
	float rotAngle;

	GetDecompAffine(m_Interval.Start(), pNode, &ap, &firstRotAxis, &firstRotAngle);
	firstPos = ap.t;
	firstScaleFactor = ap.k;

	TimeValue start = m_Interval.Start() + GetTicksPerFrame();
	TimeValue end = m_Interval.End();

	bPos = bRot = bScl = FALSE;

	for (TimeValue t = start; t <= end; t += m_iDeltaTick)
	{
		GetDecompAffine(t, pNode, &ap, &rotAxis, &rotAngle);

		if (!bPos)
		{
			if (!EqualPoint3(ap.t, firstPos))
			{
				bPos = TRUE;
			}
		}
		if (!bRot)
		{
			if (fabs(rotAngle - firstRotAngle) > ALMOST_ZERO)
			{
				bRot = TRUE;
			}
			else if (!EqualPoint3(rotAxis, firstRotAxis))
			{
				bRot = TRUE;
			}
		}
		if (!bScl)
		{
			if (!EqualPoint3(ap.k, firstScaleFactor))
			{
				bScl = TRUE;
			}
		}

		if (bPos && bRot && bScl)
			break;
	}
	return bPos || bRot || bScl;
}
Пример #18
0
// ###########################################################
// #######   EXPORTERs DI SINGOLE ENTITA' DELLA SCENA  #######
// ###########################################################
void SkeletonExporter::export_general_info(void)
{
	int ff, lf, fs;
	Interval range = ip->GetAnimRange();
	Box3 bbox;

	fprintf(fTXT, "[AD]Turbo ROX as usual !! \n\n");

	INode *root = ip->GetRootNode();
	bbox.pmin.x=bbox.pmin.y=bbox.pmin.z=(float)1E10;
	bbox.pmax.x=bbox.pmax.y=bbox.pmax.z=(float)-1E10;
    GetSceneBoundingBox(root, 0, &bbox);

	ff=range.Start() / GetTicksPerFrame();
	lf=range.End() / GetTicksPerFrame();
	fs=GetFrameRate();

	// Start with a file identifier and format version
	fprintf(fTXT, "First frame : %d\n", ff);
	fprintf(fTXT, "Last frame : %d\n", lf);
	fprintf(fTXT, "Frame speed : %d\n", fs);
	fprintf(fTXT, "Scene Bounding Box at time 0\n");
	fprintf(fTXT, "min : %f, %f, %f\n",
		    bbox.pmin.x, bbox.pmin.y, bbox.pmin.z);
	fprintf(fTXT, "max : %f, %f, %f\n",
		    bbox.pmax.x, bbox.pmax.y, bbox.pmax.z);

	write_chunk_header(fA3D, SCENE_GENERAL_INFO_ID, "Scene Root", 36);
	fwrite(&ff, sizeof(int), 1, fA3D);
	fwrite(&lf, sizeof(int), 1, fA3D);
	fwrite(&fs, sizeof(int), 1, fA3D);
	write_bbox(&bbox, fA3D);

	if (makeRAY) write_chunk_header(fRAY, SCENE_GENERAL_INFO_ID, "Scene Root", 36);
	if (makeRAY) fwrite(&ff, sizeof(int), 1, fRAY);
	if (makeRAY) fwrite(&lf, sizeof(int), 1, fRAY);
	if (makeRAY) fwrite(&fs, sizeof(int), 1, fRAY);
	if (makeRAY) write_bbox(&bbox, fRAY);
}
Пример #19
0
int plLayerTex::ICalcFrame(TimeValue t)
{
    PBBitmap *pbbm = fBitmapPB->GetBitmap(kBmpBitmap);
    if (!pbbm || !pbbm->bi)
        return 0;
    BitmapInfo *bi = pbbm->bi;

    TimeValue tm, dur, td;
    int frameStart = bi->FirstFrame();
    int frameEnd = bi->LastFrame();
    int tpf = GetTicksPerFrame();
    tm = TimeValue(float(t - startTime) * pbRate);
    dur = (fend-fstart+1)*GetTicksPerFrame();

    switch (endCond)
    {
    case END_HOLD:
        if (tm <= 0)
            return frameStart;
        if (tm >= dur)
            return frameEnd;
        return tm/tpf;

    case END_PINGPONG:
        if (((tm >= 0) && ((tm / dur) & 1)) || ((tm < 0) && !(tm / dur)))
        {
            td = modt(tm, dur);
            return frameStart + frameEnd - td / tpf;
        }
    // else fall through
    case END_LOOP:
        td = modt(tm, dur);
        return td / tpf;
    }

    return 0;
}
Пример #20
0
void PBombMod::ModifyObject(
		TimeValue t, ModContext &mc, ObjectState *os, INode *node)
	{
	ParticleObject *obj = GetParticleInterface(os->obj);
	if (obj) {
/*		if (!mc.localdata)
		{ mc.localdata=seed; seed+=5;}	  */
		force.obj  = (PBombObject*)GetWSMObject(t);
		force.node = nodeRef;
		force.tmValid.SetEmpty();
		force.fValid.SetEmpty();
		force.dt=GetTicksPerFrame();
		force.dtsq=force.dt*force.dt;
		obj->ApplyForceField(&force);
		}
	}
Пример #21
0
SWrapObject::SWrapObject()
{ TimeValue tpf=GetTicksPerFrame();
	MakeRefByID(FOREVER, 0, 
		CreateParameterBlock(SWrapdescVer0, PBLOCK_LENGTH, CURRENT_VERSION));
	assert(pblock);	

	cmValid.SetEmpty();
	srand(12345);
	custname=TSTR(_T(" "));
	custnode=NULL;
	cmesh=NULL;
	tm.IdentityMatrix();
	vnorms.ZeroCount();
	fnorms.ZeroCount();
	pblock->SetValue(PB_KIDEFAULT,0,0.0f);
	pblock->SetValue(PB_USESELVERTS,0,0);
	pblock->SetValue(PB_STANDOFF,0,1.0f);
}
Пример #22
0
void AsciiExp::DumpRotSample(INode* node, int indentLevel) 
{	
	TSTR indent = GetIndent(indentLevel);
	
	_ftprintf(pStream, _T("%s\t\t%s {\n"), indent.data(), ID_ROT_TRACK);

	TimeValue start = ip->GetAnimRange().Start();
	TimeValue end = ip->GetAnimRange().End();
	TimeValue t;
	int delta = GetTicksPerFrame() * GetKeyFrameStep();
	Matrix3 tm;
	AffineParts ap;
	Quat prevQ;

	prevQ.Identity();

	for (t=start; t<=end; t+=delta) {
		tm = node->GetNodeTM(t) * Inverse(node->GetParentTM(t));

		decomp_affine(tm, &ap);

		// Rotation keys should be relative, so we need to convert these
		// absolute samples to relative values.

		Quat q = ap.q / prevQ;
		prevQ = ap.q;

		if (q.IsIdentity()) {
			// No point in exporting null keys...
			continue;
		}

		// Output the sample
		_ftprintf(pStream, _T("%s\t\t\t%s %d\t%s\n"),
			indent.data(),
			ID_ROT_SAMPLE,
			t,
			Format(q));
	}

	_ftprintf(pStream, _T("%s\t\t}\n"), indent.data());
}
Пример #23
0
BOOL SmdExportClass::DumpRotations(FILE *pFile, ExpInterface *pexpiface)
{
	// Dump bone-rotation info, for each frame
	// Also dumps root-node translation info (the model's world-position at each frame)
	DumpFrameRotationsTEP procDumpFrameRotations;
	procDumpFrameRotations.m_pfile	= pFile;
	procDumpFrameRotations.m_phec	= this;

	TimeValue m_tvTill = (m_fReferenceFrame) ? m_tvStart : m_tvEnd;

	fprintf(pFile, "skeleton\n" );
	for (TimeValue tv = m_tvStart; tv <= m_tvTill; tv += m_tpf)
	{
		fprintf(pFile, "time %d\n", tv / GetTicksPerFrame() );
		procDumpFrameRotations.m_tvToDump = tv;
		(void) pexpiface->theScene->EnumTree(&procDumpFrameRotations);
	}
	fprintf(pFile, "end\n" );

	return TRUE;
}
Пример #24
0
//from IUnReplaceableControl
Control * EulerExposeControl::GetReplacementClone()
{
	Control *control = NewDefaultRotationController();
	if(control)
	{
		// set key per frame
		Interval range =GetCOREInterface()->GetAnimRange();
		TimeValue tpf = GetTicksPerFrame();	
		SuspendAnimate();
		AnimateOn();
		Quat v;
		for(TimeValue t= range.Start(); t<=range.End();t+=tpf)
		{
			GetValue(t,&v,Interval(t,t));
			control->SetValue(t,&v,1,CTRL_ABSOLUTE);
		}
	
		ResumeAnimate();
	}
	return control;
}
Пример #25
0
/** 
 * This method will check if there is any animation connected to the node.
 * It will run from start to end of animation range and if the position,
 * rotation or scale has been changed during this, it will return true.
 */
BOOL OSGExp::hasAnimation(INode* node){
	TimeValue start = _ip->GetAnimRange().Start();
	TimeValue end = _ip->GetAnimRange().End();
	TimeValue t;
	int delta = GetTicksPerFrame();
	Matrix3 tm;
	AffineParts ap;
	Point3 firstPos;
	float rotAngle, firstRotAngle;
	Point3 rotAxis, firstRotAxis;
	Point3 firstScaleFactor;
	//return TRUE;

	for (t=start; t<=end; t+=delta) {

		tm = node->GetNodeTM(t) * Inverse(node->GetParentTM(t));

		decomp_affine(tm, &ap);

		AngAxisFromQ(ap.q, &rotAngle, rotAxis);

		// If any point, rotation or scale in the t'th frame has
		// changes from the start frame then we have an animation.
		if (t != start){
			if(!Util::isPoint3Equal(ap.t, firstPos) ||
				!Util::isPoint3Equal(rotAxis, firstRotAxis) ||
				fabs(rotAngle - firstRotAngle) > ALMOST_ZERO ||
				!Util::isPoint3Equal(ap.k, firstScaleFactor)){
				return TRUE;
			}
		}
		else {
			firstPos = ap.t;
			firstRotAngle = rotAngle;
			firstRotAxis = rotAxis;
			firstScaleFactor = ap.k;
		}
	}
	return FALSE;
}
Пример #26
0
/**
 * This method will sample the node at each frame to get any possible change
 * of position, rotation and scaling. The posible changes is inserted into an
 * OSG AnimationPath and returned.
 */
osg::AnimationPath* OSGExp::sampleNode(INode* node){

    // Create the animation path.
    osg::AnimationPath* animationPath = new osg::AnimationPath();
    animationPath->setLoopMode(osg::AnimationPath::LOOP);

	TimeValue start = _ip->GetAnimRange().Start();
	TimeValue end = _ip->GetAnimRange().End();
	int val;
	if (node->GetUserPropInt("startFrame",val))
		start= val;
	if (node->GetUserPropInt("endFrame",val))
		end= val;
	TimeValue t;
	int delta = GetTicksPerFrame();
	Matrix3 tm;
	AffineParts ap;

	for (t=start; t<=end; t+=delta) {
		tm = node->GetNodeTM(t) * Inverse(node->GetParentTM(t));
		decomp_affine(tm, &ap);
		Point3 pos = ap.t;
		Point3 sca = ap.k;

		// Note: OSG wants absolute rotations
		Quat rot = ap.q;

		// Convert from Max's left-handed rotation to right-handed
		float ang;
		Point3 axis;
		AngAxisFromQ(rot, &ang, axis);
		ang = -ang;
		rot = QFromAngAxis(ang, axis);
 
		// Insert the sample point into animation path
		addControlPoint(animationPath, (t/(float)TIME_TICKSPERSEC), pos, rot, sca);
	}
	return animationPath;
}
Пример #27
0
void Exporter::ExportCameraObject(INode* node, int indentLevel)
{
	RSCameraObject *pCO=new RSCameraObject;
	pCO->name=new char[strlen(node->GetName())+1];
	strcpy(pCO->name,node->GetName());

	INode* target = node->GetTarget();
	ExportNodeTM(node, indentLevel,&pCO->tm);

	CameraState cs;
	TimeValue t = GetStaticFrame();
	Interval valid = FOREVER;
	// Get animation range
	Interval animRange = ip->GetAnimRange();
	
	ObjectState os = node->EvalWorldState(t);
	CameraObject *cam = (CameraObject *)os.obj;
	
	cam->EvalCameraState(t,valid,&cs);
	pCO->fov=cs.fov;

#define TARGETFPS	60

	TimeValue start = ip->GetAnimRange().Start();
	TimeValue end = ip->GetAnimRange().End();
	int delta = GetTicksPerFrame() * GetFrameRate() / TARGETFPS;
	Matrix3 tm;

	rsm->m_nCameraFrame=(end-start)/delta+1;
	Matrix3 *m=pCO->am=new Matrix3[rsm->m_nCameraFrame];
	for (t=start; t<=end; t+=delta) {
		tm = node->GetNodeTM(t) * Inverse(node->GetParentTM(t));
		*m=tm;
		m++;
	}
	
	rsm->m_CameraList.Add(pCO);

}
Пример #28
0
void UtilTest::SetWAV()
	{
	// Get the current sound object.
	SoundObj *snd = ip->GetSoundObject();
	
	// See if we can get a wave interface
	IWaveSound *iWav = GetWaveSoundInterface(snd);
	if (iWav) {
		// Set the sound file
		if (!iWav->SetSoundFileName(_T("test.wav"))) {
			MessageBox(hPanel,
				_T("Unable to load TEST.WAV"),
				_T("Util Test"),MB_OK);
			return;
			}
		// Set the offset to 10 frames.
		iWav->SetStartTime(GetTicksPerFrame() * 10);
	} else {
		MessageBox(hPanel,
			_T("No IWaveSound interface"),
			_T("Util Test"),MB_OK);
		}
	}
Пример #29
0
void AsciiExp::DumpPosSample(INode* node, int indentLevel) 
{	
	TSTR indent = GetIndent(indentLevel);
	
	_ftprintf(pStream, _T("%s\t\t%s {\n"), indent.data(), ID_POS_TRACK);

	TimeValue start = ip->GetAnimRange().Start();
	TimeValue end = ip->GetAnimRange().End();
	TimeValue t;
	int delta = GetTicksPerFrame() * GetKeyFrameStep();
	Matrix3 tm;
	AffineParts ap;
	Point3	prevPos;

	for (t=start; t<=end; t+=delta) {
		tm = node->GetNodeTM(t) * Inverse(node->GetParentTM(t));
		decomp_affine(tm, &ap);

		Point3 pos = ap.t;

		if (t!= start && EqualPoint3(pos, prevPos)) {
			// Skip identical keys 
			continue;
		}

		prevPos = pos;

		// Output the sample
		_ftprintf(pStream, _T("%s\t\t\t%s %d\t%s\n"),
			indent.data(),
			ID_POS_SAMPLE,
			t,
			Format(pos));
	}

	_ftprintf(pStream, _T("%s\t\t}\n"), indent.data());
}
Пример #30
0
//+--------------------------------------------------------------------------+
//|							From IPViewItem									 |
//+--------------------------------------------------------------------------+
bool PFTestDuration::HasDynamicName(TSTR& nameSuffix)
{
	int testType	= pblock()->GetInt(kDuration_testType, 0);
	switch(testType) {
	case kDuration_testType_time:
//		nameSuffix = GetString(IDS_ABSOLUTE_ABBR);
		nameSuffix = GetString(IDS_TIME);
		break;
	case kDuration_testType_age:
		nameSuffix = GetString(IDS_AGE);
		break;
	case kDuration_testType_event:
		nameSuffix = GetString(IDS_EVENT);
		break;
	}
	int condType	= pblock()->GetInt(kDuration_conditionType, 0);
	if (condType == kDuration_conditionType_less)
		nameSuffix += _T("<");
	else
		nameSuffix += _T(">");
	TimeValue testValue	= pblock()->GetTimeValue(kDuration_testValue, 0);
	int tpf = GetTicksPerFrame();
	testValue /= tpf;
	TCHAR buf[32];
	_stprintf(buf, _T("%d"), testValue);
	nameSuffix += buf;
	TimeValue variation = pblock()->GetTimeValue(kDuration_variation, 0);
	variation /= tpf;
	if (variation > 0) {
		_tcscpy(buf, GetString(IDS_PLUS_OR_MINUS_CHAR));
		nameSuffix += buf;
		_stprintf(buf, _T("%d"), variation);
		nameSuffix += buf;
	}
	return true;
}