//---------------------------------------------------------------------------
static bool IsNodeRenderable( INode *pnode, Object *pobj )
{
	if(!pobj || !pobj->CanConvertToType(Class_ID(TRIOBJ_CLASS_ID, 0)))
		return false;

	if (pobj->ClassID() == Class_ID(DUMMY_CLASS_ID, 0)) 
		return false;
	
	if (pobj->ClassID() == Class_ID(BONE_CLASS_ID, 0)) 
		return false;

#if MAX_RELEASE >= 4000
	if( pobj->ClassID() == BONE_OBJ_CLASSID )
		return false;
#endif

	// check for biped node
	Control *pControl = pnode->GetTMController();
	if( (pControl->ClassID() == BIPSLAVE_CONTROL_CLASS_ID) || 
		(pControl->ClassID() == BIPBODY_CONTROL_CLASS_ID) || 
		(pControl->ClassID() == FOOTPRINT_CLASS_ID) )
	{
		return false;
	}

	return true;
}
bool SGP_MaxInterface::IsBone(INode *pNode)
{
	// check for root node
	if(pNode->IsRootNode()) 
		return false;

	// check for bone node
	ObjectState os;
	os = pNode->EvalWorldState(0);
	if(os.obj->ClassID() == Class_ID(BONE_CLASS_ID, 0)) 
		return true;

#if MAX_RELEASE >= 4000
	if(os.obj->ClassID() == BONE_OBJ_CLASSID) 
		return true;
#endif

	if(os.obj->ClassID() == Class_ID(DUMMY_CLASS_ID, 0)) 
		return false;

	// check for biped node
	Control *pControl;
	pControl = pNode->GetTMController();
	if((pControl->ClassID() == BIPSLAVE_CONTROL_CLASS_ID) || (pControl->ClassID() == BIPBODY_CONTROL_CLASS_ID)) 
		return true;

	return false;
}
// ============================================================================
bool IsNodeBipedBone(INode *pNode)
{
	if(pNode == NULL || pNode->IsRootNode())
		return false;

	Control *cont = pNode->GetTMController();
	if(cont->ClassID() == BIPSLAVE_CONTROL_CLASS_ID ||
		cont->ClassID() == BIPBODY_CONTROL_CLASS_ID
	) return true;

	return false;
}
Beispiel #4
0
// HASBIPCONTROLLER
bool HasBipController(INode* node)
{
    if (!node)
        return false;
    Control* c = node->GetTMController();
    if (c && ((c->ClassID()== BIPSLAVE_CONTROL_CLASS_ID) ||
        (c->ClassID()== BIPBODY_CONTROL_CLASS_ID) || 
        (c->ClassID()== FOOTPRINT_CLASS_ID)) )
        return true;
    return false;

}
Beispiel #5
0
// EXPORTABLEANIMATIONCONTROLLER
bool ExportableAnimationController(INode* node)
{
    bool result = false;

    if(node)
    {
        Control *c = node->GetTMController();
        if(c)
        {
            Class_ID id = c->ClassID();
            if(id == Class_ID(LININTERP_ROTATION_CLASS_ID, 0)
                || id == Class_ID(PRS_CONTROL_CLASS_ID, 0)
                || id == Class_ID(LININTERP_POSITION_CLASS_ID, 0)
                || id == Class_ID(TCBINTERP_FLOAT_CLASS_ID, 0)
                || id == Class_ID(TCBINTERP_POSITION_CLASS_ID, 0)
                || id == Class_ID(TCBINTERP_ROTATION_CLASS_ID, 0)
                || id == Class_ID(TCBINTERP_POINT3_CLASS_ID, 0)
                || id == Class_ID(TCBINTERP_SCALE_CLASS_ID, 0))
            {
                result = true;
            }
        }
    }
    return result;
}
Beispiel #6
0
bool BipedUtil::isBiped( INode* node )
{
	require( node );
	Control* c = node->GetTMController();
	return c &&
		c->ClassID() == BIPSLAVE_CONTROL_CLASS_ID ||
		c->ClassID() == BIPBODY_CONTROL_CLASS_ID;
}
Beispiel #7
0
Interval AnimExportUtil::getKeyFramedRotationRange( INode* node3ds, Interval animRange )
{
	require( node3ds->GetTMController() );

	TimeValue start = animRange.Start();
	TimeValue end = animRange.End();

	// target defines rotation
	if ( node3ds->GetTarget() )
		return Interval( start, start );

	Control* cont = node3ds->GetTMController()->GetRotationController();
	IKeyControl* ikeys = cont ? GetKeyControlInterface( cont ) : 0;
	if ( ikeys )
	{
		ITCBRotKey key1;
		IBezQuatKey key2;
		ILinRotKey key3;
		IKey* keyp = 0;

		if ( cont->ClassID() == Class_ID(TCBINTERP_ROTATION_CLASS_ID, 0) )
			keyp = &key1;
		else if ( cont->ClassID() == Class_ID(HYBRIDINTERP_ROTATION_CLASS_ID, 0) )
			keyp = &key2;
		else if ( cont->ClassID() == Class_ID(LININTERP_ROTATION_CLASS_ID, 0) )
			keyp = &key3;

		if ( keyp )
		{
			if ( 0 == ikeys->GetNumKeys() )
				return Interval( start, start );

			ikeys->GetKey( 0, keyp );
			start = keyp->time;
			ikeys->GetKey( ikeys->GetNumKeys()-1, keyp );
			end = keyp->time;
		}
	}

	return Interval( start, end );
}
// ============================================================================
bool IsNodeBone(INode *pNode)
{
	if(pNode == NULL || pNode->IsRootNode())
		return false;

	ObjectState os = pNode->EvalWorldState(0);
	if(os.obj->ClassID() == Class_ID(BONE_CLASS_ID, 0))
		return true;

	// we don't want biped end effectors
	if(os.obj->ClassID() == Class_ID(DUMMY_CLASS_ID, 0))
		return false;

	Control *cont = pNode->GetTMController();
	if(cont->ClassID() == BIPSLAVE_CONTROL_CLASS_ID ||
		cont->ClassID() == BIPBODY_CONTROL_CLASS_ID ||
		cont->ClassID() == FOOTPRINT_CLASS_ID
	) return true;

	return false;
}
bool SGP_MaxInterface::IsBipedBone( INode* pNode )
{
	// check for invalid nodes
	if(pNode == NULL) 
		return false;

	// check for root node
	if(pNode->IsRootNode())
		return false;

	// check for bone node
	ObjectState os;
	os = pNode->EvalWorldState(0);
	if(os.obj->ClassID() == Class_ID(DUMMY_CLASS_ID, 0)) 
		return false;

	// check for biped node
	Control *pControl;
	pControl = pNode->GetTMController();
	if((pControl->ClassID() == BIPSLAVE_CONTROL_CLASS_ID) || (pControl->ClassID() == BIPBODY_CONTROL_CLASS_ID))
		return true;

	return false;
}
Mesh* CExporter::getMeshPtr(INode* node, Object* object)
{
	assert(object != NULL);

	while (GEN_DERIVOB_CLASS_ID == object->SuperClassID())
	{
		object = ((IDerivedObject*)object)->GetObjRef();
	}

	if (GEOMOBJECT_CLASS_ID != object->SuperClassID())
	{
		return NULL;
	}

	Control* pCtrl = node->GetTMController();
	Class_ID id = pCtrl->ClassID();
	if (id == BIPSLAVE_CONTROL_CLASS_ID
		|| id == BIPBODY_CONTROL_CLASS_ID
		|| id == FOOTPRINT_CLASS_ID)
	{
		return NULL;
	}

	if (!object->CanConvertToType(Class_ID(TRIOBJ_CLASS_ID, 0)))
	{
		return NULL;
	}
	assert(m_interface != NULL);
	TriObject* pTriObj = (TriObject*)(object->ConvertToType(m_interface->GetTime(),
															Class_ID(TRIOBJ_CLASS_ID, 0)));
	if (NULL == pTriObj)
	{
		return NULL;
	}
	return &(pTriObj->mesh);
}
Beispiel #11
0
void SGMExporter::CollectProperties(Scene3DMesh *mesh, IGameMesh *gMesh)
{
	IPropertyContainer *propsContainer = gMesh->GetIPropertyContainer();
	if (propsContainer == NULL || propsContainer->GetNumberOfProperties() == 0)
	{
		Log::LogT("Mesh %s has no properties", mesh->name.c_str());
		return;
	}
	
	Log::LogT("properties count: %d", propsContainer->GetNumberOfProperties());

	for (int i = 0; i < propsContainer->GetNumberOfProperties(); i++)
	{
		IGameProperty *gProp = propsContainer->GetProperty(i);
		if (gProp == NULL)
			continue;

		int propType = gProp->GetType();
		std::string propName = StringUtils::ToNarrow(gProp->GetName());

		Log::LogT("eporting %s with type %d", propName.c_str(), propType);

		if (propType == IGAME_UNKNOWN_PROP)
		{
			Log::LogT("property %s has unknown type", propName.c_str());
			continue;
		}

		Property::AnimationType propAnimType = Property::AnimationType_None;

		Property *prop = NULL; 

		if (!gProp->IsPropAnimated())
		{
			Log::LogT("property %s has no animation", propName.c_str());

			prop = new Property(propName, PropTypeConv(propType), Property::AnimationType_None);
			switch (propType)
			{
			case IGAME_FLOAT_PROP:
				{
					float val;	
					gProp->GetPropertyValue(val);
					prop->SetValue(val);
				}
				break;

			case IGAME_INT_PROP:
				{
					int val;
					gProp->GetPropertyValue(val);
					prop->SetValue(val);
				}
				break;

			case IGAME_POINT3_PROP:
				{
					Point3 val;
					gProp->GetPropertyValue(val);
					prop->SetValue(sm::Vec3(val.x, val.y, val.z));
				}
				break;
			}
		}
		else
		{
			IGameControl *ctrl = gProp->GetIGameControl();

			if (ctrl == NULL)
			{
				Log::LogT("%s IGameControl is NULL", propName.c_str());
				continue;
			}

			switch (propType)
			{
			case IGAME_FLOAT_PROP:
				{
					Control *maxControl = ctrl->GetMaxControl(IGAME_FLOAT);
					if (maxControl != NULL && maxControl->IsAnimated())
					{
						if (maxControl->ClassID() == Class_ID(LININTERP_FLOAT_CLASS_ID, 0))
						{	
							Log::LogT("%s float liniowe scierwo", propName.c_str());
							prop = new Property(propName, Property::PropertyType_Float, Property::AnimationType_Linear);
							IGameKeyTab keys;
							if (ctrl->GetLinearKeys(keys, IGAME_FLOAT))
							{
								for (int j = 0; j < keys.Count(); j++)
								{
									prop->SetValue(keys[j].linearKey.fval, TicksToSec(keys[j].t));
								}
							}
						}
						if (maxControl->ClassID() == Class_ID(TCBINTERP_FLOAT_CLASS_ID, 0))
						{
							Log::LogT("%s float tcb scierwo", propName.c_str());
							prop = new Property(propName, Property::PropertyType_Float, Property::AnimationType_TCB);
							IGameKeyTab keys;
							if (ctrl->GetTCBKeys(keys, IGAME_FLOAT))
							{
								for (int j = 0; j < keys.Count(); j++)
								{
									prop->SetValue(keys[j].tcbKey.fval, TicksToSec(keys[j].t));
								}
							}
						}
					}
				}

				break;

			case IGAME_INT_PROP:
				{
					Control *maxControl = ctrl->GetMaxControl(IGAME_FLOAT);
					if (maxControl != NULL && maxControl->IsAnimated())
					{
						if (maxControl->ClassID() == Class_ID(LININTERP_FLOAT_CLASS_ID, 0))
						{
							Log::LogT("%s int liniowe scierwo", propName.c_str());
							//prop = new Property(propName, Property::PropertyType_Int, Property::AnimationType_Linear);
							// it should be always state interpolator for int
							prop = new Property(propName, Property::PropertyType_Int, Property::AnimationType_State);
							IGameKeyTab keys;
							if (ctrl->GetLinearKeys(keys, IGAME_FLOAT))
							{
								Log::LogT("eksportowanie %d keyframow", keys.Count());
								for (int j = 0; j < keys.Count(); j++)
								{
									prop->SetValue((int)keys[j].linearKey.fval, TicksToSec(keys[j].t));
								}
							}
						}
						if (maxControl->ClassID() == Class_ID(TCBINTERP_FLOAT_CLASS_ID, 0))
						{
							Log::LogT("%s int tcb scierwo", propName.c_str());
							//prop = new Property(propName, Property::PropertyType_Int, Property::AnimationType_TCB);
							// it should be always state interpolator for int
							prop = new Property(propName, Property::PropertyType_Int, Property::AnimationType_State);
							IGameKeyTab keys;
							if (ctrl->GetTCBKeys(keys, IGAME_FLOAT))
							{
								for (int j = 0; j < keys.Count(); j++)
								{
									prop->SetValue((int)keys[j].linearKey.fval, TicksToSec(keys[j].t));
								}
							}
						}
					}
					else
					{
					}
				}

				break;
			}
		}

		if (prop != NULL)
			mesh->properties.push_back(prop);
	}
}
Beispiel #12
0
Control* BlockControl::BuildSlave(TrackViewPick res,Control* list, BOOL createdList)
{
int count = list->NumSubs()-2;
Control *slave = NULL;
for (int i = 0; i < count; i++)
   {
   if (res.anim->SuperClassID() == CTRL_FLOAT_CLASS_ID) 
      {
      slave = (Control*)list->SubAnim(i);
      if (slave->ClassID() == SLAVEFLOAT_CONTROL_CLASS_ID)
         {
         return slave;
         }
      }
   else if (res.anim->SuperClassID() == CTRL_POSITION_CLASS_ID) 
      {
      slave = (Control*)list->SubAnim(i);
      if (slave->ClassID() == SLAVEPOS_CONTROL_CLASS_ID)
         {
         return slave;
         }
      }
   else if (res.anim->SuperClassID() == CTRL_ROTATION_CLASS_ID) 
      {
      slave = (Control*)list->SubAnim(i);
      if (slave->ClassID() == SLAVEROTATION_CONTROL_CLASS_ID)
         {
         return slave;
         }
      }
   else if (res.anim->SuperClassID() == CTRL_SCALE_CLASS_ID) 
      {
      slave = (Control*)list->SubAnim(i);
      if (slave->ClassID() == SLAVESCALE_CONTROL_CLASS_ID)
         {
         return slave;
         }
      }
   }
BOOL isRotation = FALSE;
if (res.anim->SuperClassID() == CTRL_FLOAT_CLASS_ID) 
   slave = (Control*)new SlaveFloatControl;
#ifndef NO_CONTROLLER_SLAVE_POSITION
else if (res.anim->SuperClassID() == CTRL_POSITION_CLASS_ID) 
   slave = (Control*)new SlavePosControl;
#endif
#ifndef NO_CONTROLLER_SLAVE_ROTATION
else if (res.anim->SuperClassID() == CTRL_ROTATION_CLASS_ID) 
   {
   slave = (Control*)new SlaveRotationControl;
   isRotation = TRUE;
   }
#endif
#ifndef NO_CONTROLLER_SLAVE_SCALE
else if (res.anim->SuperClassID() == CTRL_SCALE_CLASS_ID) 
   slave = (Control*)new SlaveScaleControl;
#endif
if (createdList)
   {
      list->AssignController(CloneRefHierarchy(res.anim),count);
      list->AssignController(slave,count+1);
      }  
else
   {
   list->AssignController(slave,count);
   }
return slave;
}
Beispiel #13
0
void XsiExp::DumpScaleKeys( INode * node, int indentLevel) 
{
  Control * cont = node->GetTMController()->GetScaleController();
	IKeyControl * ikc = GetKeyControlInterface(cont);
	INode * parent = node->GetParentNode();
	if (!cont || !parent || (parent && parent->IsRootNode()) || !ikc)
  {
    // no controller or root node
		return;
  }
	int numKeys = ikc->GetNumKeys();
	if (numKeys <= 1)
  {  
    return;
  }
	Object * obj = node->EvalWorldState(0).obj;
  BOOL isBone = obj && obj->ClassID() == Class_ID(BONE_CLASS_ID, 0) ? TRUE : FALSE;

  // anim keys header
  TSTR indent = GetIndent(indentLevel);
	fprintf(pStream,"%s\tSI_AnimationKey {\n", indent.data()); 
	fprintf(pStream,"%s\t\t1;\n", indent.data());     // 1 means scale keys
	fprintf(pStream,"%s\t\t%d;\n", indent.data(), numKeys);

	int t, delta = GetTicksPerFrame();
 	Matrix3 matrix;
  AffineParts ap;
	for (int i = 0; i < numKeys; i++)
  {  
    // get the key's time
	  if (cont->ClassID() == Class_ID(TCBINTERP_SCALE_CLASS_ID, 0))
    {
  	  ITCBRotKey key;
			ikc->GetKey(i, &key);
      t = key.time;
    }
    else if (cont->ClassID() == Class_ID(HYBRIDINTERP_SCALE_CLASS_ID, 0))
	  {
		  IBezQuatKey key;
		  ikc->GetKey(i, &key);
      t = key.time;
    }
	  else if (cont->ClassID() == Class_ID(LININTERP_SCALE_CLASS_ID, 0))
    {
  	  ILinRotKey key;
		  ikc->GetKey(i, &key);
      t = key.time;
    }
    // sample the node's matrix
    matrix = node->GetNodeTM(t) * Inverse(node->GetParentTM(t));
    if (!isBone)
    {
      matrix = matrix * topMatrix;
    }
    decomp_affine(matrix, &ap);

		fprintf(pStream, "%s\t\t%d; 3; %.6f, %.6f, %.6f;;%s\n", 
			indent.data(),
			t / delta,
			ap.k.x, ap.k.z, ap.k.y,
      i == numKeys - 1 ? ";\n" : ",");
	}
  // anim keys close
	fprintf(pStream,"%s\t}\n\n", indent.data());
}
void KeyTest() 
{
	int i, numKeys;
	INode *         n;
	Control *       c;
	Quat            newQuat, prevQuat;
	IKeyControl*    ikeys;
	ITCBPoint3Key   tcbPosKey;
	ITCBRotKey      tcbRotKey;
	ITCBScaleKey    tcbScaleKey;
	IBezPoint3Key   bezPosKey;
	IBezQuatKey     bezRotKey;
	IBezScaleKey    bezScaleKey;
	ILinPoint3Key   linPosKey;
	ILinRotKey      linRotKey;
	ILinScaleKey    linScaleKey;

	// Get the first node in the selection set
	if (!CMaxEnv::singleton().m_pInterace->GetSelNodeCount()) 
		return;
	n = CMaxEnv::singleton().m_pInterace->GetSelNode(0); 

	// --- Process the position keys ---
	c = n->GetTMController()->GetPositionController();
	ikeys = GetKeyControlInterface(c);

	if (!ikeys) 
	{
		// No interface available to access the keys...
		// Just sample the controller to get the position
		// data at each key...
		SampleController(n, c);
		return; 
	}

	numKeys = ikeys->GetNumKeys();
	DebugPrint(_T("\nThere are %d position key(s)"), numKeys);
	if (c->ClassID() == Class_ID(TCBINTERP_POSITION_CLASS_ID, 0)) 
	{
		for (i = 0; i < numKeys; i++) 
		{
			ikeys->GetKey(i, &tcbPosKey);
			//DebugPrint(_T("\nTCB Position Key: %d=(%.1f, %.1f, %.1f)"), 
			//	i, tcbPosKey.val.x, tcbPosKey.val.y, tcbPosKey.val.z);
		}
	}
	else if (c->ClassID() == Class_ID(HYBRIDINTERP_POSITION_CLASS_ID, 0)) 
	{
		for (i = 0; i < numKeys; i++) 
		{
			ikeys->GetKey(i, &bezPosKey);
			//DebugPrint(_T("\nBezier Position Key: %d=(%.1f, %.1f, %.1f)"), 
			//	i, bezPosKey.val.x, bezPosKey.val.y, bezPosKey.val.z);

		}
	}
	else if (c->ClassID() == Class_ID(LININTERP_POSITION_CLASS_ID, 0)) 
	{
		for (i = 0; i < numKeys; i++) 
		{
			ikeys->GetKey(i, &linPosKey);
			//DebugPrint(_T("\nLinear Position Key: %d=(%.1f, %.1f, %.1f)"), 
			//	i, linPosKey.val.x, linPosKey.val.y, linPosKey.val.z);
		}
	}
	// --- Process the rotation keys ---

	c = n->GetTMController()->GetRotationController();
	ikeys = GetKeyControlInterface(c);
	if (!ikeys) return;
	numKeys = ikeys->GetNumKeys();
	//DebugPrint(_T("\nThere are %d rotation key(s)"), numKeys);
	if (c->ClassID() == Class_ID(TCBINTERP_ROTATION_CLASS_ID, 0)) 
	{
		for (i = 0; i < numKeys; i++) 
		{
			ikeys->GetKey(i, &tcbRotKey);
			newQuat = QFromAngAxis(tcbRotKey.val.angle, tcbRotKey.val.axis);
			if (i) newQuat = prevQuat * newQuat;
			prevQuat = newQuat;
			//DebugPrint(_T("\nTCB Rotation Key: %d=(%.1f, %.1f, %.1f, %.1f)"), 
			//	i, newQuat.x, newQuat.y, newQuat.z, newQuat.w);
		}
	}
	else if (c->ClassID() == Class_ID(HYBRIDINTERP_ROTATION_CLASS_ID, 0)) 
	{
		for (i = 0; i < numKeys; i++) 
		{
			ikeys->GetKey(i, &bezRotKey);
			newQuat = bezRotKey.val;
			if (i) 
				newQuat = prevQuat * newQuat;

			prevQuat = newQuat;
			//DebugPrint(_T("\nBezier Rotation Key: %d=(%.1f, %.1f, %.1f, %.1f)"), 
			//	i, newQuat.x, newQuat.y, newQuat.z, newQuat.w);
		}
	}
	else if (c->ClassID() == Class_ID(LININTERP_ROTATION_CLASS_ID, 0)) 
	{
		for (i = 0; i < numKeys; i++) 
		{
			ikeys->GetKey(i, &linRotKey);
			newQuat = linRotKey.val;
			if (i) 
				newQuat = prevQuat * newQuat;

			prevQuat = newQuat;
			//DebugPrint(_T("\nLinear Rotation Key: %d=(%.1f, %.1f, %.1f, %.1f)"), 
			//	i, newQuat.x, newQuat.y, newQuat.z, newQuat.w);
		}
	}

	// --- Process the scale keys ---
	c = n->GetTMController()->GetScaleController();
	ikeys = GetKeyControlInterface(c);

	if (!ikeys) return;

	numKeys = ikeys->GetNumKeys();
	
	//DebugPrint(_T("\nThere are %d scale key(s)"), numKeys);



	if (c->ClassID() == Class_ID(TCBINTERP_SCALE_CLASS_ID, 0)) 
	{

		for (i = 0; i < numKeys; i++) 
		{
			ikeys->GetKey(i, &tcbScaleKey);
			//DebugPrint(_T("\nTCB Scale Key: %2d=(%.1f, %.1f, %.1f)"), 
			//	i, tcbScaleKey.val.s.x, tcbScaleKey.val.s.y, 
			//	tcbScaleKey.val.s.z);
		}
	}
	else if (c->ClassID() == Class_ID(HYBRIDINTERP_SCALE_CLASS_ID, 0)) 
	{
		for (i = 0; i < numKeys; i++) 
		{
			ikeys->GetKey(i, &bezScaleKey);
			//DebugPrint(_T("\nBezier Scale Key: %2d=(%.1f, %.1f, %.1f)"), 
			//	i, bezScaleKey.val.s.x, bezScaleKey.val.s.y, 
			//	bezScaleKey.val.s.z);
		}
	}
	else if (c->ClassID() == Class_ID(LININTERP_SCALE_CLASS_ID, 0)) 
	{
		for (i = 0; i < numKeys; i++) 
		{
			ikeys->GetKey(i, &linScaleKey);
			DebugPrint(_T("\nLinear Scale Key: %2d=(%.1f, %.1f, %.1f)"), 
				i, linScaleKey.val.s.x, linScaleKey.val.s.y, 
				linScaleKey.val.s.z);
		}
	}
}