Пример #1
0
//we need to not only check the expose node and reference node to see if there flags are set, but 
//we also need to check their parents since a call on node->GetNodeTM may call node->parent->UpdateTM
//node->parent->parent->UpdateTM.. etc... So all of the parents need to get checked to.
BOOL BaseExposeControl::AreNodesOrParentsInTMUpdate()
{
	//collect expose node parents.
	if(exposeTransform)
	{
		INode *exposeNode = exposeTransform->GetExposeNode();
		if(exposeNode)
		{
			INodeTab nodes;
			nodes.Append(1,&exposeNode);
			CollectParents(nodes,exposeNode);
	
			//simple check to see if referenceNode isn't exposeNodeParent.. if not.. collect them too
			INode *refNode = exposeTransform->GetReferenceNode();
			if(refNode&&refNode!=exposeNode->GetParentNode())
			{
				nodes.Append(1,&refNode);
				CollectParents(nodes,refNode);
			}

			for(int i=0;i<nodes.Count();++i)
			{
				if(nodes[i]->TestAFlag(A_INODE_IN_UPDATE_TM)==TRUE)
					return TRUE;
			}
		}
	}

	return FALSE;
}
Пример #2
0
void GR2ImportImpl::OrderBones(INodeTab& bones)
{
   if (info.Skeletons.size() == 1)
   {
      NameNodeMap nodes;
      INodeTab rv = ImportSkeleton(*info.Skeletons[0]);
      // Strip out auto-generated bones.  Place in order found in ini file
      for (size_t i = 0, n = rv.Count(); i<n; ++i)
      {
         INode *node = rv[i];

         bool found = false;
         for (stringlist::const_iterator itr=boneMatch.begin(), end=boneMatch.end(); itr != end; ++itr)
         {
            if (wildmatch(*itr, node->GetName())) {
               nodes[*itr].Append(1, &node);
               found = true;
            }
         }
         if (!found)
         {
            node->SetUserPropInt("MDBBoneIndex", int(bones.Count()));
            bones.Append(1, &node);
         }
      }
      for (stringlist::const_iterator itr=boneMatch.begin(), end=boneMatch.end(); itr != end; ++itr)
      {
         INodeTab& map = nodes[*itr];
         for (size_t i = 0, n = map.Count(); i<n; ++i)
         {
            INode *node = map[i];
            node->SetUserPropInt("MDBBoneIndex", int(bones.Count()));
            bones.Append(1, &node);
         }
      }
      // When in face mode, swap the Face Bones for the first N bones in the skeleton.  
      //   Some of the later bones like Head, Neck, Ribcage are still used so we cannot 
      //   discard the whole skeleton.
      if (enableFaceMode)
      {
         size_t curIdx = 0;
         for (size_t i = 0, n = bones.Count(); i<n; ++i)
         {
            INode *node = bones[i];
            for (stringlist::const_iterator itr=faceBoneMatch.begin(), end=faceBoneMatch.end(); itr != end; ++itr)
            {
               if (wildmatch(*itr, node->GetName())) {
                  bones[i] = bones[curIdx];
                  bones[curIdx] = node;
                  node->SetUserPropInt("MDBBoneIndex", int(curIdx));
                  ++curIdx;
                  break;
               }
            }
         }
      }
   }
}
Пример #3
0
void plClickDragComponent::CollectNonDrawables(INodeTab& nonDrawables)
{
    INode* boundsNode = fCompPB->GetINode(kClickDragProxy);
    if(boundsNode && fCompPB->GetInt(kClickDragUseProxy))
        nonDrawables.Append(1, &boundsNode);

    boundsNode = fCompPB->GetINode(kClickDragProxyRegion);
    if(boundsNode )
        nonDrawables.Append(1, &boundsNode);

}
Пример #4
0
void plComponentDlg::SelectComponentTargs(INodeTab& nodes)
{
    // Make an INode tab with all the targets in it
    INodeTab targets;
    for (int i = 0; i < nodes.Count(); i++)
    {
        plComponentBase *comp = ((plMaxNode*)nodes[i])->ConvertToComponent();

        for (int j = 0; j < comp->NumTargets(); j++)
        {
            INode *node = comp->GetTarget(j);
            if (node && !FindNodeInTab(node, targets))
                targets.Append(1, &node);
        }
    }

    // If the user is selecting a single component, make sure it is selected in the rollup too
    if (plComponentUtil::Instance().IsOpen() && nodes.Count() == 1)
        plComponentUtil::Instance().fLastComponent = ((plMaxNode*)nodes[0])->ConvertToComponent();
    
    theHold.Begin();
    fInterface->RedrawViews(fInterface->GetTime(), REDRAW_BEGIN);
    fInterface->ClearNodeSelection(FALSE);              // Deselect current nodes

    // If there is at least one valid target, select it
    if (targets.Count() > 0)
        fInterface->SelectNodeTab(targets, TRUE, FALSE);

    fInterface->RedrawViews(fInterface->GetTime(), REDRAW_END);
    theHold.Accept("Select");
}
Пример #5
0
void plComponentBase::AddTargetsToList(INodeTab& list)
{
    int i;
    for( i = 0; i < NumTargets(); i++ )
    {
        INode* targ = GetTarget(i);
        if( targ )
            list.Append(1, &targ);
    }
}
void plVolumeGadgetComponent::CollectNonDrawables(INodeTab& nonDrawables) 
{ 
    if(fCompPB->GetInt(kUseVolumeNode))
    {
        INode* boundsNode = fCompPB->GetINode(kVolumeNode);
        if( boundsNode )
            nonDrawables.Append(1, &boundsNode);
    }

    AddTargetsToList(nonDrawables); 
}
Пример #7
0
//recursive function to put parents in tab.
static void CollectParents(INodeTab &tab,INode *node)
{
	if(node)
	{
		INode *pNode = node->GetParentNode();
		if(pNode&&pNode!=GetCOREInterface()->GetRootNode())
		{
			tab.Append(1,&pNode);
			CollectParents(tab,pNode);
		}
	}
}
Пример #8
0
// Note: don't return DEP_ENUM_SKIP when we hit a node. From review comments:
// It wants to gather all the dependant particle groups which are base nodes and have a particle group interface.
// This could skip groups that are not direct descendants to the head Particle Flow Object.
// So if you had a Particle Flow object that had a test that referenced another particle group, then that 
// second group had test that referenced another group.  That second particle group would get skipped.  
int MyEnumProc::proc(ReferenceMaker *rmaker) 
{ 
	if ((rmaker != nullptr) && (rmaker->SuperClassID()==BASENODE_CLASS_ID))
	{
		INode* inode = dynamic_cast<INode*>(rmaker);
		if (!Nodes.Contains(inode))
		{
			Nodes.Append(1, (INode **)&rmaker);  
		}
	}
	return DEP_ENUM_CONTINUE;
}
Пример #9
0
Value* ExportCalSkel_cf(Value** arg_list, int count)
{	
	int			i;
	INodeTab	tabnode;
	std::tstring fullpathfilename;
	int			ArraySize		;
	bool		bShowUI			;

	check_arg_count(ExportCalSkel, 3, count);
	type_check(arg_list[0], String, _T("[The first argument of ExportCalSkel should be a string that is a full path name of the file to export]"));
	type_check(arg_list[1], Array , _T("[The 2nd argument of ExportCalSkel should be an array of nodes]"));
	type_check(arg_list[2], Boolean,_T("[The 3rd argument of ExportCalSkel should be a boolean that tells if you want to use the UI or not to select nodes of skeleton]"));
	
	try
	{
		fullpathfilename	= arg_list[0]->to_string();

		//Get Array
		Array* BonesArray	= static_cast<Array*>(arg_list[1]);
		ArraySize			= BonesArray->size;	

		bShowUI				= !!(arg_list[2]->to_bool());

		if (fullpathfilename.length() == 0) return new Integer (1);
		if (! ArraySize)		return new Integer (2);
 
		for (i=0;i<ArraySize;i++)
		{
			if (BonesArray->data[i]->is_kind_of(class_tag(MAXNode)) )
			{
				INode* _node	= 	BonesArray->data[i]->to_node();
				if (! _node)return new Integer (3);

				tabnode.Append(1,&_node);
			}
		}

		//Call the exporter from Maxscript
		if (CMaxSkeletonExport::ExportSkeletonFromMaxscriptCall(fullpathfilename.c_str(), tabnode, bShowUI) )
			return new Integer (0);

		return new Integer (-1);
	}
	catch(...)
	{	
		//MessageBox(NULL,"Exception catched in ExportCalSkel C++ function","Error",MB_OK);
		return new Integer (-2);
	}
}
void TestSplitBySourceDlgProc::SelectSources( HWND hWnd, IParamBlock2* pblock )
{
	if (pblock == NULL) return;
	if (selectionUpdateInProgress) return;

	int allCount = GetPFSystemPool()->NumPFSystems();
	HWND hWndSystem = GetDlgItem(hWnd, IDC_SOURCELIST);
	int listCount = SendMessage(hWndSystem, LB_GETCOUNT, 0, 0);
	if (listCount == LB_ERR) return; // dialog error
	if (allCount != listCount) return; // async

	selectionUpdateInProgress = true;
	
	INodeTab selNodes;
	for(int i=0; i<listCount; i++) {
		int selected = SendMessage(hWndSystem, LB_GETSEL, i, 0);
		if (selected > 0) {
			INode* selNode = GetPFSystemPool()->GetPFSystem(i);
			if (selNode != NULL)
				selNodes.Append(1, &selNode);
		}
	}

	bool resetSelected = ( selNodes.Count() != pblock->Count(kSplitBySource_sources) );
	if (!resetSelected) {
		for(int i=0; i<selNodes.Count(); i++)
			if (!SBSIsSelectedSource(selNodes[i], pblock))
			{ resetSelected = true; break; }
	}
	
	if (resetSelected) {
		macroRec->Disable();
		theHold.Begin();
		pblock->ZeroCount(kSplitBySource_sources);
		if (selNodes.Count() > 0) {
			for(int i=0; i<selNodes.Count(); i++) {
				int nodeHandle = (int)selNodes[i]->GetHandle();
				pblock->Append(kSplitBySource_sources, 1, &nodeHandle);
			}
		}
		theHold.Accept(GetString(IDS_PARAMETERCHANGE));
		macroRec->Enable();
		pblock->NotifyDependents( FOREVER, 0, kSplitBySource_RefMsg_MacrorecSources );
	}

	selectionUpdateInProgress = false;
}
Пример #11
0
void plComponentDlg::IGetComponentsRecur(HWND hTree, HTREEITEM hItem, INodeTab& nodes)
{
    if (hItem)
    {
        INode *node = (INode*)ITreeItemToNode(hTree, hItem);
        if (node)
            nodes.Append(1, &node);
        else
        {
            HTREEITEM hChild = TreeView_GetChild(hTree, hItem);
            IGetComponentsRecur(hTree, hChild, nodes);

            while (hChild = TreeView_GetNextSibling(hTree, hChild))
            {
                IGetComponentsRecur(hTree, hChild, nodes);
            }
        }
    }
}
Пример #12
0
void plComponentDlg::ISelectTreeSelection()
{
    INodeTab nodes;

    INode *curComponent = (INode*)IGetTreeSelection();
    if (curComponent)
    {
        nodes.Append(1, &curComponent);
    }
    else
    {
        HWND hTree = GetDlgItem(fhDlg, IDC_TREE);
        HTREEITEM hRoot = TreeView_GetSelection(hTree);

        IGetComponentsRecur(hTree, hRoot, nodes);
    }

    SelectComponentTargs(nodes);
}
Пример #13
0
void FormationBhvr::PickWhom()
{
   int i;

	// first set the nodetab to equal the existing nodes to flee
	// so that they are selected in the dialog
	if (pblock->Count(follower) > 0)
	{
	    INode *node;
		SelMaxNodes.Resize(pblock->Count(follower));
		SelMaxNodes.SetCount(0);
		for (i=0; i<pblock->Count(follower); i++)
		{
		    pblock->GetValue(follower,0,node,FOREVER,i);
			SelMaxNodes.Append(1,&node);
		}
	}
	else SelMaxNodes.ZeroCount(); 

	// let the user pick
	DoHitObjInMAX.SetSingleSelect(FALSE); // allow multiple selection
	if (!GetCOREInterface()->DoHitByNameDialog(&DoHitObjInMAX)) return;

    // Set follower to the returned nodes
	theHold.Begin();
	pblock->Resize(follower,SelMaxNodes.Count());
	pblock->SetCount(follower,0);
	for (i=0; i<SelMaxNodes.Count(); i++)
		pblock->Append(follower,1,&SelMaxNodes[i]);


	//zero out the formation matrix that's used for saving it out.
	pblock->ZeroCount(follower_matrix1);
	pblock->ZeroCount(follower_matrix2);
	pblock->ZeroCount(follower_matrix3);
	pblock->ZeroCount(follower_matrix4);

    theHold.Accept(GetString(IDS_UN_WHOM));
}
Пример #14
0
bool CollisionImport::ImportPackedNiTriStripsShape(INode *rbody, bhkRigidBodyRef body, bhkPackedNiTriStripsShapeRef shape, INode *parent, Matrix3& tm)
{
	if (hkPackedNiTriStripsDataRef data = shape->GetData())
	{
		Matrix3 ltm(true);
		vector<Vector3> verts = data->GetVertices();
		vector<Triangle> tris = data->GetTriangles();
		vector<Vector3> norms = data->GetNormals();

		vector<Niflib::OblivionSubShape> subshapes = (ni.IsFallout3() || ni.IsSkyrim()) ? shape->GetSubShapes() : data->GetSubShapes();
		if (subshapes.size() == 0)
		{
			// Is this possible?
			INode *inode = ImportCollisionMesh(verts, tris, norms, tm, parent);
			CreatebhkCollisionModifier(inode, bv_type_packed, HavokMaterial(NP_DEFAULT_HVK_MATERIAL), OL_UNIDENTIFIED, 0);
			ImportBase(body, shape, parent, inode, ltm);
			AddShape(rbody, inode);
		}
		else
		{
			unsigned int voff = 0;
			unsigned int toff = 0;

			INodeTab nodes;
			for (int i = 0, n = subshapes.size(); i<n; ++i) {
				Niflib::OblivionSubShape& s = subshapes[i];
				
				vector<Vector3> subverts;
				vector<Triangle> subtris;
				vector<Vector3> subnorms;
				
				subverts.reserve(s.numVertices);
				for (unsigned int v=voff; v < (voff + s.numVertices); ++v) {
					subverts.push_back( verts[v] );
				}
				unsigned int vend = (voff + s.numVertices );

				// TODO: Fix algorithm.  I do not know how to split the triangles here
				//       Basically, greedily take all triangles until next subshape
				//       This is not correct but seems to work with most meshes tested.
				subtris.reserve( s.numVertices / 2 );
				subnorms.reserve( s.numVertices / 2 );
				while ( toff < tris.size() ){
					Triangle t = tris[toff];
					if ( t.v1 >= vend || t.v2 >= vend || t.v3 >= vend )
						break;
					// remove offset for mesh
					t.v1 -= voff; t.v2 -= voff; t.v3 -= voff;
					subtris.push_back( t );	
					subnorms.push_back( norms[toff] );	
					++toff;
				}
				voff += s.numVertices;

				INode *inode = ImportCollisionMesh(subverts, subtris, subnorms, tm, parent);

				CreatebhkCollisionModifier(inode, bv_type_packed, HavokMaterial(s.material), s.layer, s.colFilter);
				ImportBase(body, shape, parent, inode, ltm);

				if (n > 1)
					inode->SetName( FormatText("%s:%d", "OblivionSubShape", i).data() );

				nodes.Append(1, &inode);
			}
			// TODO: Group nodes on import
			if (  nodes.Count() > 1 )
			{
				TSTR shapeName = "bhkPackedNiTriStripsShape";
				INode *group = ni.gi->GroupNodes(&nodes, &shapeName, 0);			
				AddShape(rbody, group);
			}
			else if (  nodes.Count() == 1 )
			{
				AddShape(rbody, nodes[0]);
			}
		}
		return true;
	}

	return false;
}
Пример #15
0
Value* ExportCalSkel_cf(Value** arg_list, int count)
{	
	int			i;
	INodeTab	tabnode;
	char*		fullpathfilename;
	int			ArraySize		;
	bool		bShowUI			;
  bool bUseAxisGL=false; 

  // Cedric Pinson, now we can export in gl coordinates
	check_arg_count_with_keys(ExportCalSkel, 3, count);
	Value* transform= key_arg_or_default(transform, &false_value);
	type_check(transform, Boolean, "[The axisGL argument of ExportCalSkel should be a boolean that is true if you want to export in openGL axis]");

	type_check(arg_list[0], String, "[The first argument of ExportCalSkel should be a string that is a full path name of the file to export]");
	type_check(arg_list[1], Array , "[The 2nd argument of ExportCalSkel should be an array of nodes]");
	type_check(arg_list[2], Boolean,"[The 3rd argument of ExportCalSkel should be a boolean that tells if you want to use the UI or not to select nodes of skeleton]");
	
	try
	{
		fullpathfilename	= arg_list[0]->to_string();
    bUseAxisGL       = (transform->to_bool() != 0);

		//Get Array
		Array* BonesArray	= static_cast<Array*>(arg_list[1]);
		ArraySize			= BonesArray->size;	

		bShowUI				= !!(arg_list[2]->to_bool());

		if (! strcmp(fullpathfilename,"")) return new Integer (1);
		if (! ArraySize)		return new Integer (2);
 
		for (i=0;i<ArraySize;i++)
		{
			if (BonesArray->data[i]->is_kind_of(class_tag(MAXNode)) )
			{
				INode* _node	= 	BonesArray->data[i]->to_node();
				if (! _node)return new Integer (3);

				tabnode.Append(1,&_node);
			}
		}

    theExporter.SetAxisGL(bUseAxisGL);


		//Call the exporter from Maxscript
    if (CMaxSkeletonExport::ExportSkeletonFromMaxscriptCall(fullpathfilename,tabnode, bShowUI) ) {
      // reset axis gl
      theExporter.SetAxisGL(false);
			return new Integer (0);
    }
    theExporter.SetAxisGL(false);
		return new Integer (-1);
	}
	catch(...)
	{	
    theExporter.SetAxisGL(false);

		//MessageBox(NULL,"Exception catched in ExportCalSkel C++ function","Error",MB_OK);
		return new Integer (-2);
	}
}
Пример #16
0
void plComponentDlg::IOpenRightClickMenu()
{
    HWND hTree = GetDlgItem(fhDlg, IDC_TREE);

    // Get the position of the cursor in screen and tree client coords
    POINT point, localPoint;
    GetCursorPos(&point);
    localPoint = point;
    ScreenToClient(hTree, &localPoint);

    // Check if there is a tree item at that point
    TVHITTESTINFO hitTest;
    hitTest.pt = localPoint;
    TreeView_HitTest(hTree, &hitTest);
    if (!(hitTest.flags & TVHT_ONITEMLABEL))
        return;

    // Check if the tree item has an lParam (is a component)
    TVITEM item;
    item.mask = TVIF_PARAM;
    item.hItem = hitTest.hItem;
    TreeView_GetItem(hTree, &item);

    HMENU menu = nil;
    if (IIsComponent(item.lParam))
        menu = fCompMenu;
    else if (IIsType(item.lParam))
        menu = fTypeMenu;
    else
        return;

    // Select the item we're working with, so the user isn't confused
    TreeView_SelectItem(hTree, item.hItem);

    // Create the popup menu and get the option the user selects
    SetForegroundWindow(fhDlg);
    int sel = TrackPopupMenu(menu, TPM_NONOTIFY | TPM_RETURNCMD, point.x, point.y, 0, fhDlg, NULL);
    switch(sel)
    {
    case kMenuDelete:
        IDeleteComponent((plMaxNode*)item.lParam);
        break;

    case kMenuRename:
        TreeView_EditLabel(hTree, hitTest.hItem);
        break;

    case kMenuCopy:
        {
            // Component to copy
            INode *node = (INode*)item.lParam;
            INodeTab tab;
            tab.Append(1, &node);

            // Copy
            INodeTab copy;

            // Make the copy
            fInterface->CloneNodes(tab, Point3(0,0,0), true, NODE_COPY, NULL, &copy);

            // Delete the targets for the copy and add it to the tree
            plMaxNode *newNode = (plMaxNode*)copy[0];
            newNode->ConvertToComponent()->DeleteAllTargets();
            HTREEITEM hItem = IAddComponent(GetDlgItem(fhDlg, IDC_TREE), newNode);
            TreeView_SelectItem(GetDlgItem(fhDlg, IDC_TREE), hItem);
        }
        break;

    case kMenuHide:
        {
            ClassDesc *desc = plComponentMgr::Inst().Get(item.lParam-1);

            std::vector<Class_ID>::iterator it;
            it = std::find(fHiddenComps.begin(), fHiddenComps.end(), desc->ClassID());

            TSTR name = desc->ClassName();
            if (it == fHiddenComps.end())
            {
                fHiddenComps.push_back(desc->ClassID());
                name.Append(" (Hidden)");
            }
            else
                fHiddenComps.erase(it);

            item.mask = TVIF_TEXT;
            item.pszText = name;
            TreeView_SetItem(GetDlgItem(fhDlg, IDC_TREE), &item);

            plComponentUtil::Instance().IUpdateRollups();
        }
        break;
    }

    PostMessage(fhDlg, WM_USER, 0, 0);
}
Пример #17
0
void plSaveSelected()
{
    Interface *ip = GetCOREInterface();

    // Get the Max filename to save to
    char buf[256];
    memset(&buf, 0, sizeof(buf));
    OPENFILENAME ofn = {0};
    ofn.lStructSize = sizeof(OPENFILENAME);
    ofn.hwndOwner = ip->GetMAXHWnd();
    ofn.lpstrFilter = "3ds max (*.max)\0*.max\0\0";
    ofn.nFilterIndex = 1;
    ofn.lpstrFile = buf;
    ofn.nMaxFile = sizeof(buf);
//  ofn.lpstrInitialDir = ip->GetDir(APP_SCENE_DIR);
    ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
    ofn.lpstrDefExt = "max";

    if (GetSaveFileName(&ofn))
    {
        int count = ip->GetSelNodeCount();
        int i;
        
        // Put all the selected nodes in a list
        INodeTab selected;
        for (i = 0; i < count; i++)
        {
            plMaxNode *node = (plMaxNode*)ip->GetSelNode(i);
            selected.Append(1, (INode**)&node);
        }

        // Put all the components attached to those nodes in a list
        INodeTab components;
        for (i = 0; i < count; i++)
        {
            plMaxNode *node = (plMaxNode*)ip->GetSelNode(i);

            uint32_t compCount = node->NumAttachedComponents();
            for (int j = 0; j < compCount; j++)
            {
                INode *compNode = node->GetAttachedComponent(j)->GetINode();//Node(j);

                if (!IIsNodeInTab(components, compNode))
                    components.Append(1, &compNode);
            }
        }

        // Find the objects that the components are reffing that are not part of the selection.
        // Back them up, and delete them out of the components ref list so they won't be saved too.
        std::vector<ComponentRefs> out;
        for (i = 0; i < components.Count(); i++)
        {
            plComponentBase *comp = ((plMaxNode*)components[i])->ConvertToComponent();

            for (int j = comp->NumTargets() - 1; j >= 0; --j)
            {
                plMaxNodeBase *node = comp->GetTarget(j);

                if (!node)
                    continue;
                
                const char *t1 = components[i]->GetName();
                const char *t2 = node->GetName();

                if (!IIsNodeInTab(selected, node))
                {
                    uint32_t idx = -1;
                    for (uint32_t k = 0; k < out.size(); k++)
                    {
                        if (out[k].comp == comp)
                            idx = k;
                    }

                    if (idx == -1)
                    {
                        idx = out.size();
                        out.resize(idx+1);
                        out[idx].comp = comp;
                    }

                    out[idx].refs.Append(1, (INode**)&node);

                    comp->DeleteTarget(node);
                }
            }
        }

        // Save the selected objects and their components
        INodeTab allNodes;
        allNodes.Append(selected.Count(), &selected[0]);
        allNodes.Append(components.Count(), &components[0]);

        ip->FileSaveNodes(&allNodes, buf);

        // Restore the component refs to objects that weren't selected
        for (i = 0; i < out.size(); i++)
        {
            for (int j = 0; j < out[i].refs.Count(); j++)
                out[i].comp->AddTarget((plMaxNode*)out[i].refs[j]);
        }
    }
}
Пример #18
0
Value* ExportCalAnim_cf(Value** arg_list, int count)
{	
	int i								;
	char*	Filefullpathfilename		;
	char*	Skeletonfullpathfilename	;
	Array*	BonesArray					;
	int		StartFrame					;
	int		EndFrame					;
	int		FrameOffset					;
	int		FrameRate					;
  bool   bUseAxisGL=false;

  // Cedric Pinson, now we can export in gl coordinates
	check_arg_count_with_keys(ExportCalAnim, 7, count);
	Value* transform= key_arg_or_default(transform, &false_value);
	type_check(transform, Boolean, "[The axisGL argument of ExportCalAnim should be a boolean that is true if you want to export in openGL axis]");

	type_check(arg_list[0], String	, "[The first argument of ExportCalAnim should be a string that is a full path name of the file to export]");
	type_check(arg_list[1], String	, "[The 2nd argument of ExportCalAnim should be a string that is the fullpath name of the skeleton file]");
	type_check(arg_list[2], Array	, "[The 3rd argument of ExportCalAnim should be an array of nodes to get anim from]");
	type_check(arg_list[3], Integer	, "[The 4th argument of ExportCalAnim should be an integer that is the start frame number]");
	type_check(arg_list[4], Integer	, "[The 5th argument of ExportCalAnim should be an integer that is the end frame number]");
	type_check(arg_list[5], Integer , "[The 6th argument of ExportCalAnim should be an integer that is the frame offset]");
	type_check(arg_list[6], Integer , "[The 7th argument of ExportCalAnim should be an integer that is the framerate]");
	
	try
	{
  bool   bUseAxisGL=false;

  // Cedric Pinson, now we can export in gl coordinates
	check_arg_count_with_keys(ExportCalAnim, 7, count);
	Value* transform= key_arg_or_default(transform, &false_value);
	type_check(transform, Boolean, "[The axisGL argument of ExportCalAnim should be a boolean that is true if you want to export in openGL axis]");
		Filefullpathfilename		= arg_list[0]->to_string();
		Skeletonfullpathfilename	= arg_list[1]->to_string();
		BonesArray					= static_cast<Array*>(arg_list[2]);
		StartFrame					= arg_list[3]->to_int();
		EndFrame					= arg_list[4]->to_int();
		FrameOffset					= arg_list[5]->to_int();
		FrameRate					= arg_list[6]->to_int();

		if (! strcmp(Filefullpathfilename,""))return new Integer(1);

		if (! strcmp(Skeletonfullpathfilename,"")) return new Integer(2);

		//Does skeleton file exist ?
		FILE* _stream;
		_stream = fopen(Skeletonfullpathfilename,"r");
		if (! _stream)return new Integer(3); //Error code number 3
		fclose(_stream);

		//Get the elements of the bones array
		int ArraySize;
    bUseAxisGL       = (transform->to_bool() != 0);

		ArraySize = BonesArray->size;

		if (! ArraySize) return new Integer(4);
		
		if (StartFrame < 0)	return new Integer(5);

		if (EndFrame < 0)return new Integer(6);

		if (StartFrame > EndFrame ) return new Integer(7);

		if (FrameOffset < 0) return new Integer(8);

		if (FrameRate < 0) return new Integer(9);

		INodeTab	tabnode;
		for (i=0;i<ArraySize;i++)
		{
			if (BonesArray->data[i]->is_kind_of(class_tag(MAXNode)) )
			{
				INode* _node	= 	BonesArray->data[i]->to_node();
				if (! _node)return new Integer(10);
				tabnode.Append(1,&_node);
			}
		}		
		
		AnimExportParams param(Skeletonfullpathfilename, tabnode, StartFrame, EndFrame, FrameOffset, FrameRate);

    theExporter.SetAxisGL(bUseAxisGL); // set axis wanted
    if (CMaxAnimationExport::ExportAnimationFromMaxscriptCall(Filefullpathfilename, &param)) {
      //reset to default
      theExporter.SetAxisGL(false);
			return new Integer(0);
    }


    theExporter.SetAxisGL(false);
		return new Integer(-1);
	}


	catch(...)
	{	
    theExporter.SetAxisGL(false);
		//MessageBox(NULL,"Exception catched in ExportCalAnim C++ function","Error",MB_OK);
		return new Integer(-2);
	}
}