void SkeletonExporter::dump_material_tracks(Mtl* mtl)
{
  Control *c;
  int size_key;
  Animatable *track;

  if (!mtl) return;
  export_animatable(mtl, 1);

  if (mtl->ClassID() == Class_ID(DMTL_CLASS_ID, 0))
  {
    // opacity track
	track=mtl->SubAnim(2)->SubAnim(0);
    c=GetControlInterface(track);
    if ((c) && (c->NumKeys()>0))
	{
       if (IsTCBControl(c)) size_key=28;
	   else
	   if (IsBezierControl(c)) size_key=16;
	   else size_key=8;
	   fprintf(fTXT, "Material %s:  opacity track present.\n", mtl->GetName());
       write_chunk_header(fA3D, MATERIAL_OPACITY_TRACK_ID,
	                      mtl->GetName(), 1+2+4+c->NumKeys()*size_key);
	   export_float_track(c, 1.0f, fA3D);
	}
  }
  fprintf(fTXT, "\n\n");
}
void SkeletonExporter::export_animatable (Animatable *anim, int blanks)
{
   int w, k;

   if (!anim) return;

   for (k=0; k<blanks; k++) fprintf (fTXT, " ");
   fprintf (fTXT, "SubAnim = %d\n", anim->NumSubs());
   if (anim->NumKeys() > 0)
   {
      for (k=0; k<blanks; k++) fprintf (fTXT, " ");
      fprintf (fTXT, "NumKeys = %d\n", anim->NumKeys());
   }
   for (w=0; w<anim->NumSubs(); w++)
   {
      for (k=0; k<blanks; k++) fprintf (fTXT, " ");
	  fprintf(fTXT, "Anim%d: %s\n", w, anim->SubAnimName(w));
	  if ( (strcmp(anim->SubAnimName(w), "U Offset")==0) ||
           (strcmp(anim->SubAnimName(w), "V Offset")==0) ||
           (strcmp(anim->SubAnimName(w), "U Tiling")==0) ||
           (strcmp(anim->SubAnimName(w), "V Tiling")==0) ||
           (strcmp(anim->SubAnimName(w), "U Angle")==0)  ||
           (strcmp(anim->SubAnimName(w), "V Angle")==0))
	  {
         Control *c=GetControlInterface(anim->SubAnim(w));
         fprintf(fTXT, "Control pointer: %p\n", c);
	  }

      export_animatable(anim->SubAnim(w), blanks+3);
   }
}
Exemple #3
0
	//------------------------------------------------------------
	IPedal::shared_ptr SteerFilter::GetInterface( PEDAL_INTERFACE_TYPE type )
	{
		switch( type )
		{
		case PIT_SCONTROL: return GetControlInterface();
		case PIT_SCALLBACK: return GetCallbackInterface();
		case PIT_SSTATE: return GetStateInterface();
		default: return IPedal::shared_ptr();
		}
	}
BOOL SkeletonExporter::material_has_transparency_track(Mtl* mtl)
{
  Control *c;
  Animatable *track;

  if (mtl->ClassID() == Class_ID(DMTL_CLASS_ID, 0))
  {
    track=mtl->SubAnim(2)->SubAnim(0);
    c=GetControlInterface(track);
    if ((c) && (c->NumKeys()>0)) return(TRUE);
  }
  return(FALSE);
}
Exemple #5
0
void RandKeysUtil::Apply()
	{
	BOOL timeMode   = iu->GetMajorMode()==TVMODE_EDITTIME;
	BOOL fcurveMode = iu->GetMajorMode()==TVMODE_EDITFCURVE;
	Interval iv = iu->GetTimeSelection();
	if (!doTime && !doVal) return;

	theHold.Begin();

	// Turn animation on
	SuspendAnimate();
	AnimateOn();

	for (int i=0; i<iu->GetNumTracks(); i++) {
		if ((timeMode||fcurveMode) && !iu->IsSelected(i)) continue;
		
		// Get Interfaces
		Animatable *anim   = iu->GetAnim(i);
		Animatable *client = iu->GetClient(i);
		int subNum         = iu->GetSubNum(i);
		Control *cont      = GetControlInterface(anim);
		IKeyControl *ikc   = GetKeyControlInterface(anim);
		IKey *key          = GetKeyPointer(anim->SuperClassID(),anim->ClassID());				
		if (!ikc || !cont || !key) continue;						
		if (fcurveMode && !anim->IsCurveSelected()) continue;

		// Get the param dim
		float min = negVal, max = posVal;
		ParamDimension *dim = client->GetParamDimension(subNum);
		if (dim) {
			min = dim->UnConvert(min);
			max = dim->UnConvert(max);
			}

		for (int j=0; j<ikc->GetNumKeys(); j++) {
			// Get the key data
			ikc->GetKey(j,key);
			
			// Check if it's selected
			if (timeMode && !iv.InInterval(key->time)) continue;
			if (!timeMode && !(key->flags&IKEY_SELECTED)) continue;			

			// Randomize time
			if (doTime) {
				key->time = (int)CompRand(
					float(key->time-negTime),
					float(key->time+posTime));
				ikc->SetKey(j,key);
				}
			}

		if (doTime) ikc->SortKeys();

		for (j=0; j<ikc->GetNumKeys(); j++) {
			// Get the key data
			ikc->GetKey(j,key);
			
			// Check if it's selected
			if (timeMode && !iv.InInterval(key->time)) continue;
			if (!timeMode && !(key->flags&IKEY_SELECTED)) continue;			

			// Randomize value
			if (doVal) {
				Point3 pt, ang;
				Point4 p4;
				float f;
				Quat q;
				ScaleValue s;				
				BOOL doX, doY, doZ, doW;
				doX = doY = doZ = doW = TRUE;
				if (!fcurveMode) {
					if (!(key->flags&IKEY_XSEL)) doX = FALSE;
					if (!(key->flags&IKEY_YSEL)) doY = FALSE;
					if (!(key->flags&IKEY_ZSEL)) doZ = FALSE;
					if (!(key->flags&IKEY_WSEL)) doW = FALSE;
					}

				switch (anim->SuperClassID()) {
					case CTRL_FLOAT_CLASS_ID:			
						cont->GetValue(key->time,&f,FOREVER);
						f = CompRand(f-min,f+max);
						cont->SetValue(key->time,&f);
						break;

					case CTRL_POSITION_CLASS_ID:
					case CTRL_POINT3_CLASS_ID:
						cont->GetValue(key->time,&pt,FOREVER);
						if (doX) pt.x = CompRand(pt.x-min,pt.x+max);
						if (doY) pt.y = CompRand(pt.y-min,pt.y+max);
						if (doZ) pt.z = CompRand(pt.z-min,pt.z+max);
						cont->SetValue(key->time,&pt);
						break;
					
					case CTRL_POINT4_CLASS_ID:
						cont->GetValue(key->time,&p4,FOREVER);
						if (doX) p4.x = CompRand(p4.x-min,p4.x+max);
						if (doY) p4.y = CompRand(p4.y-min,p4.y+max);
						if (doZ) p4.z = CompRand(p4.z-min,p4.z+max);
						if (doW) p4.w = CompRand(p4.w-min,p4.w+max);
						cont->SetValue(key->time,&p4);
						break;

					case CTRL_ROTATION_CLASS_ID:
						cont->GetValue(key->time,&q,FOREVER);
						QuatToEuler(q, ang);
						ang.x = CompRand(ang.x-min,ang.x+max);
						ang.y = CompRand(ang.y-min,ang.y+max);
						ang.z = CompRand(ang.z-min,ang.z+max);
						EulerToQuat(ang,q);
						cont->SetValue(key->time,&q);
						break;

					case CTRL_SCALE_CLASS_ID:
						cont->GetValue(key->time,&s,FOREVER);
						if (doX) s.s.x = CompRand(s.s.x-min,s.s.x+max);
						if (doY) s.s.y = CompRand(s.s.y-min,s.s.y+max);
						if (doZ) s.s.z = CompRand(s.s.z-min,s.s.z+max);
						cont->SetValue(key->time,&s);
						break;
					}
				}
			}

		
		}

	ResumeAnimate();

	theHold.Accept(GetString(IDS_RB_RANDOMIZEKEYS));
	ip->RedrawViews(ip->GetTime());
	}