Пример #1
0
void BaseExposeControl::PopupErrorMessage()
{
	if(exposeTransform) //should exist if not and this message is popping up then we're scewed.
	{
		INode *expNode = exposeTransform->GetExposeNode();
		INode *node = exposeTransform->GetMyNode();
		if(expNode&&node)
		{
			TSTR msg; msg.printf(GetString(IDS_ILLEGAL_SELF_REFERENCE),expNode->GetName(),node->GetName(),node->GetName()); 
			if (GetCOREInterface()->GetQuietMode()) 
			{
				 GetCOREInterface()->Log()->LogEntry(SYSLOG_WARN,NO_DIALOG,GetString(IDS_ILLEGAL_CYCLE),msg);
			}	
			else
			{
				// beep or no??MessageBeep(MB_ICONEXCLAMATION); 
				MessageBox(GetCOREInterface()->GetMAXHWnd(),msg,GetString(IDS_ILLEGAL_CYCLE), 
				MB_ICONEXCLAMATION | MB_APPLMODAL | MB_OK);
			}

		}
		//suspend the hold
		BOOL resume =FALSE;
		if(theHold.Holding())
		{
			theHold.Suspend();
			resume =TRUE;
		}
		exposeTransform->SetExposeNode(NULL);
		if(resume)
			theHold.Resume();
	}
}
Пример #2
0
static float CalcScale(INode *bone, NiNodeRef node, vector<NiNodeRef>& children)
{
   int n = bone->NumberOfChildren();
   if (n > 0) 
   {
      float len1 = 0.0f;
      float len2 = 0.0f;
      Matrix3 m = bone->GetNodeTM(0);
      Matrix3 m2 = TOMATRIX3(node->GetWorldTransform());
      for (int i = 0; i<n; i++)
      {
         INode *child = bone->GetChildNode(i);
         LPCTSTR name = child->GetName();
         if (HasBipedPosDOF(name))
            continue;

         Matrix3 cm = child->GetObjectTM(0);
         len1 += Length(m.GetTrans()-cm.GetTrans());

         if (NiNodeRef child2 = FindNodeByName(children, string(child->GetName()))){
            Matrix3 cm2 = TOMATRIX3(child2->GetWorldTransform());
            len2 += Length(m2.GetTrans()-cm2.GetTrans());
         }
      }
      return (len2 != 0.0f && len1 != 0.0f) ? (len2/len1) : 1.0f;
   }
   return 1.0f;
}
Пример #3
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;
               }
            }
         }
      }
   }
}
BOOL plFootstepSoundComponentProc::DlgProc(TimeValue t, IParamMap2 *pm, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    IParamBlock2 *pb = pm->GetParamBlock();
    HWND hSurface = GetDlgItem(hWnd, IDC_COMP_FOOTSTEP_SOUND_SURFACE);
    HWND hPick = GetDlgItem(hWnd, IDC_COMP_FOOTSTEP_SOUND_PICK);
    INode *curPick = nil;
    int curSurface = 0;

    switch (msg)
    {
    case WM_INITDIALOG:
        {
            int i;
            for (i = 0; i < plArmatureEffectsMgr::kMaxSurface; i++)
                ComboBox_AddString(hSurface, plArmatureEffectsMgr::SurfaceStrings[i]);

            curSurface = pb->GetInt(ParamID(plFootstepSoundComponent::kSurface));
            ComboBox_SetCurSel(hSurface, curSurface);

            curPick = pb->GetINode(ParamID(plFootstepSoundComponent::kSurfaceList), 0, curSurface);
            Button_SetText(hPick, (curPick == nil ? "None" : curPick->GetName()));
        }
        return TRUE;


    case WM_COMMAND:
        if (HIWORD(wParam) == BN_CLICKED)
        {
            if (LOWORD(wParam) == IDC_COMP_FOOTSTEP_SOUND_PICK)
            {
                std::vector<Class_ID> cids;
                cids.push_back(RANDOM_SOUND_COMPONENT_ID);
                if (plPick::NodeRefKludge(pb, plFootstepSoundComponent::kNodePicker, &cids, true, false))           
                {
                    curPick = pb->GetINode(ParamID(plFootstepSoundComponent::kNodePicker));
                    curSurface = pb->GetInt(ParamID(plFootstepSoundComponent::kSurface));
                    pb->SetValue(ParamID(plFootstepSoundComponent::kSurfaceList), 0, curPick, curSurface); 
                    Button_SetText(hPick, (curPick == nil ? "None" : curPick->GetName()));
                }
            
                return TRUE;
            }
        }
        else if (LOWORD(wParam) == IDC_COMP_FOOTSTEP_SOUND_SURFACE)
        {
            curSurface = ComboBox_GetCurSel(hSurface);
            curPick = pb->GetINode(ParamID(plFootstepSoundComponent::kSurfaceList), 0, curSurface);
            pb->SetValue(ParamID(plFootstepSoundComponent::kSurface), 0, curSurface);
            Button_SetText(hPick, (curPick == nil ? "None" : curPick->GetName()));
        }
    }

    return FALSE;
}
Пример #5
0
BOOL    plPlasmaAnimSelectDlgProc::DlgProc( TimeValue t, IParamMap2 *pmap, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
    switch ( msg )
    {
        case WM_INITDIALOG:
            {
                IParamBlock2 *pb = pmap->GetParamBlock();

                INode *node = pb->GetINode( fParamID );
                TSTR newName( node ? node->GetName() : "Pick" );
                ::SetWindowText( ::GetDlgItem( hWnd, fDlgItem ), newName );

                IUpdateNodeBtn( hWnd, pb );
            }
            break;

        case WM_COMMAND:
            if( ( HIWORD( wParam ) == BN_CLICKED ) )
            {
                if( LOWORD( wParam ) == fDlgItem )
                {
                    IParamBlock2 *pb = pmap->GetParamBlock();
                    plPlasmaAnimHitCallback hitCB( pb, fParamID, fTitle );
                    GetCOREInterface()->DoHitByNameDialog( &hitCB );

                    INode *node = pb->GetINode( fParamID );
                    TSTR newName( node ? node->GetName() : "Pick" );
                    ::SetWindowText( ::GetDlgItem(hWnd, fDlgItem ), newName );
                    pmap->Invalidate( fParamID );
                    ::InvalidateRect( hWnd, NULL, TRUE );

                    IUpdateNodeBtn( hWnd, pb );
                    return true;
                }
                else if( fUseNode && LOWORD( wParam ) == fNodeDlgItem )
                {
                    IParamBlock2 *pb = pmap->GetParamBlock();

                    plAnimObjInterface *iface = plAnimComponentBase::GetAnimInterface( pb->GetINode( fParamID ) );
                    iface->PickTargetNode( pb, fNodeParamID, fTypeParamID );

                    IUpdateNodeBtn( hWnd, pb );
                    return true;
                }
            }
            break;
    }

    if( fChain != nil )
        return fChain->DlgProc( t, pmap, hWnd, msg, wParam, lParam );

    return false;
}
Пример #6
0
void MeshExporter::_dumpSkinInfo(IGameSkin * skin)
{
	d_assert (skin->GetNumOfSkinnedVerts() == mMeshData.P.Size());

	for (int i = 0; i < skin->GetNumOfSkinnedVerts(); i++)
	{
		int type = skin->GetVertexType(i);

		Exporter::BlendIndex bi;
		Exporter::BlendWeight bw;

		if (type==IGameSkin::IGAME_RIGID_BLENDED)
		{
			for (int b = 0; b < skin->GetNumberOfBones(i) && b < 4; b++)
			{
				INode * bone = skin->GetBone(i, b);
				float weight = skin->GetWeight(i, b);

				if (bone)
				{
					const char * bname = bone->GetName();
					int boneId = _getJointId(bname);

					bi.i[b] = boneId;
					bw.w[b] = weight;
				}
			}
		}
		else if (type == IGameSkin::IGAME_RIGID)
		{
			INode * bone = skin->GetBone(i, 0);
			if (bone)
			{
				const char * bname = bone->GetName();
				int boneId = _getJointId(bname);

				bi.i[0] = boneId;
				bw.w[0] = 1;
			}
		}

		bw.normalize();

		mMeshData.BI.PushBack(bi);
		mMeshData.BW.PushBack(bw);
	}

	mMeshData.VertexElems |= MeshSerializer::VE_BONEINDEX;
	mMeshData.VertexElems |= MeshSerializer::VE_BONEWEIGHT;
}
Пример #7
0
RefResult SWrapObject::NotifyRefChanged( 
		Interval changeInt,
		RefTargetHandle hTarget, 
		PartID& partID, 
		RefMessage message )
	{				
	switch (message) {		
		case REFMSG_CHANGE:	
			{ if (hTarget==custnode) cmValid.SetEmpty();
			  if (hTarget==pblock) InvalidateUI();
			SimpleWSMObject::NotifyRefChanged(changeInt,hTarget,partID,message);
			}
			break;
		case REFMSG_TARGET_DELETED:	
			{ if (hTarget==custnode) custnode=NULL;
			}
			break;
		case REFMSG_NODE_NAMECHANGE:
			{ if (hTarget==custnode) 
			  { custname = TSTR(custnode->GetName());
			    ShowName();
				}
			  break;
			}
		default: SimpleWSMObject::NotifyRefChanged(changeInt,hTarget,partID,message);
		}
	return REF_SUCCEED;
	}
Пример #8
0
//=================================================================
// Methods for CollectNodesTEP
//
int CollectNodesTEP::callback(INode *node)
{
	INode *pnode = node; // Hungarian

	ASSERT_MBOX(!(pnode)->IsRootNode(), "Encountered a root node!");

	if (::FNodeMarkedToSkip(pnode))
		return TREE_CONTINUE;

	// Get pre-stored "index"
	int iNode = ::GetIndexOfINode(pnode);
	ASSERT_MBOX(iNode >= 0 && iNode <= m_phec->m_imaxnodeMac-1, "Bogus iNode");
	
	// Get name, store name in array
	TSTR strNodeName(pnode->GetName());
	strcpy(m_phec->m_rgmaxnode[iNode].szNodeName, (char*)strNodeName);

	// Get Node's time-zero Transformation Matrices
	m_phec->m_rgmaxnode[iNode].mat3NodeTM		= pnode->GetNodeTM(0/*TimeValue*/);
	m_phec->m_rgmaxnode[iNode].mat3ObjectTM		= pnode->GetObjectTM(0/*TimeValue*/);

	// I'll calculate this later
	m_phec->m_rgmaxnode[iNode].imaxnodeParent	= SmdExportClass::UNDESIRABLE_NODE_MARKER;

	return TREE_CONTINUE;
}
Пример #9
0
BOOL PickProtTarget::Pick (IObjParam *ip, ViewExp *vpt) 
{
   if ( ! vpt || ! vpt->IsAlive() )
	{
		// why are we here
		DbgAssert(!_T("Invalid viewport!"));
		return FALSE;
	}
	 INode *node = vpt->GetClosestHit();
   assert(node);
   int res = TRUE;

   ph->ReplaceReference(which,node);
   ph->NotifyDependents(FOREVER,PART_ALL,REFMSG_CHANGE);
   ph->Invalidate();
   SetDlgItemText(hDlg, which ? IDC_PROT_TARGET2_NAME : IDC_PROT_TARGET1_NAME, 
         ph->refNode[which] ? node->GetName() : _T(""));

   if(creating) {
      ph->BeginEditParams(ip, BEGIN_EDIT_CREATE, NULL);
      ip->SetCommandMode(cm);
      ip->RedrawViews(ip->GetTime());
      return FALSE;
   }
   return TRUE;
}
Пример #10
0
/*===========================================================================*\
 | Dialog Procs and related functions
\*===========================================================================*/
void FormatObjectDisplay(int i, ReferenceMaker* rm, bool showaddress, TSTR& buf) {
   TSTR str;
   if (rm) {
      rm->GetClassName(str);
      buf.printf(_T("%d: %s (0x%08x) "), i, str.data(), rm->SuperClassID());
      if (str == _T("Node")) 
			{
         INode* node = (INode*)rm;
         str = buf;
         buf.printf(_T("%s \"%s\""), str.data(), node->GetName());
      }
			else 
			{
				str = buf;
				if (rm->ClassID() == Class_ID(0,0))
					buf.printf(_T("%s (0,0)"), str.data());
				else
					buf.printf(_T("%s (0x%08x, 0x%08x)"), str.data(), rm->ClassID().PartA(), rm->ClassID().PartB());
			}
      if (showaddress) {
         str = buf;
         buf.printf(_T("%s at 0x%08x"), str.data(), rm);
      }
   }
   else
      buf.printf(_T("%d: NULL"), i);
}
Пример #11
0
void CreateMorphMode::Begin(INode *n,IObjParam *i) 
   {
   ReplaceReference(0,n);
   svNode = node;
   assert(node);
   ip = i;
   proc.Init(ip);

   theHold.Begin();
   theHold.Put(new CreateMorphRestore);

   obj = new MorphObject;
   
   theHold.Put(new CreateMorphNotify(obj,1));

   TSTR name = TSTR(_T("M_")) + node->GetName();
   SetMorphTargetPacket pckt(node->GetObjectRef(),name);
   obj->morphCont->SetValue(0,&pckt);
   
   node->SetObjectRef(obj);
   
   theHold.Put(new CreateMorphNotify(obj,0));

   theHold.Accept(IDS_DS_CREATE);

   obj->BeginEditParams(i,BEGIN_EDIT_CREATE,NULL);
   }
Пример #12
0
void MeshExporter::_dumpJoint(IGameNode * node)
{
	IGameObject * obj = node->GetIGameObject();
	IGameObject::MaxType T = obj->GetMaxType();
	IGameObject::ObjectTypes type = obj->GetIGameType();
	const char * name = node->GetName();
		
	switch(type)
	{
	case IGameObject::IGAME_BONE:
	case IGameObject::IGAME_HELPER:
		{
			joint * bone = mMeshSource->NewJoint(node->GetName());
			int parent = -1;

			if (node->GetNodeParent())
			{
				parent = _getJointId(node->GetNodeParent()->GetName());

				mMeshSource->SetJointLink(parent, mMeshSource->GetJointCount() - 1);
			}
			else
			{
				INode* pNode = node->GetMaxNode()->GetParentNode();
				if (pNode)
					parent = _getJointId(pNode->GetName());
			}
				
			IGameControl * pGameControl = node->GetIGameControl();
			// base matrix
			{
				GMatrix matWorld = node->GetLocalTM();
				bone->position = Utility::ToFloat3(matWorld.Translation());
				bone->rotation = Utility::ToQuat(matWorld.Rotation());
				bone->scale = Utility::ToFloat3(matWorld.Scaling());

				/*
				if (node->GetNodeParent())
				{
					int parentId = _getBoneId(node->GetNodeParent()->GetName());

					if (parentId != -1)
					{
						xBone * parentBn = GetBone(parentId);

						bone->position = bone->position - parentBn->position;
						bone->orientation = parentBn->orientation.Inverse() * bone->orientation;
						bone->scale = bone->scale / parentBn->scale;
					}
				}
				*/
			}

			_dumpAnimation(pGameControl, mMeshSource->GetJointCount() - 1);
		}

		break;
	}
}
void plBridgeProc::ILoadList(IParamBlock2* pb, HWND hDlg)
{
    HWND hList = GetDlgItem(hDlg, IDC_SECT_LIST);
    for (int i = 0; i < pb->Count(plPhysBridgeComponent::kSections); i++)
    {
        INode* node = pb->GetINode(plPhysBridgeComponent::kSections, 0, i);
        ListBox_AddString(hList, node->GetName());
    }
}
Пример #14
0
// PROCESSBIPNODERECURSE
// When we find a Biped-controlled node in our hierarchy, we need to find one non-biped
// child and promote it to the place of the biped node in the hierarchy. The siblings
// of the promoted node will become its children, as will the original children from the
// biped node.
void ProcessBipedNodeRecurse(INode *bipNode, INode *parent, Interface *theInterface)
{
    int numChildren = bipNode->NumberOfChildren();
    char *bipName = bipNode ? bipNode->GetName() : nil;
    INode *replacement = nil;

    for (int i = 0; i < numChildren; i++)
    {
        INode *child = bipNode->GetChildNode(i);
        char *childName = child ? child->GetName() : nil;

        if( ! HasBipController(child) )
        {
            replacement = child;                    // this child is going to be our replacement for this bipnode

            // sample the animation (into global space)
            plSampleVec *samples = SampleNodeMotion(replacement, bipNode, 1, theInterface);

            // detach from the parent (this blows away the animation)
            replacement->Detach(0);

            // attach the node to the biped's parent.
            parent->AttachChild(replacement);   

            ReapplyAnimation(child, samples);
            FreeMotionSamples(samples);

            // we only need one replacement for the bip node
            break;
        }
    }
    
    if(replacement)
    {
        // reparent the siblings to the newly promoted replacement node
        numChildren = bipNode->NumberOfChildren();
        for (int i = 0; i < numChildren; i++)
        {
            INode *child = bipNode->GetChildNode(i);

            if( HasBipController(child) )
            {
                ProcessBipedNodeRecurse(child, replacement, theInterface);
            } else {
                child->Detach(0);                   // remove the (non-bip) child from the bip node
                replacement->AttachChild(child);    // attach it to the non-bip parent

                ProcessNonBipedNodeRecurse(child, replacement, theInterface);
            }
        }
    } else {
        // this is an error condition: we've got a bip node that has no non-bip child for us to promote
        char buf[256];
        sprintf(buf, "Couldn't find non-bip node to transfer motion to for bip node %s\n", bipNode->GetName());
        hsStatusMessage(buf);
    }
}
bool CExporter::generateSkinBone(grp::SkinnedMeshExporter* skinnedMesh, INode* node, ISkin* skin)
{
	Matrix3 mSkinOffset;
	if (!skin->GetSkinInitTM(node, mSkinOffset, true))
	{
		setLastError("获取Skin偏移矩阵失败");
		return false;
	}

	int iNumBone = skin->GetNumBones();
	skinnedMesh->m_boneNames.resize(iNumBone);
	skinnedMesh->m_offsetMatrices.resize(iNumBone);
	for (int i = 0; i < iNumBone; ++i)
	{
		//mbs only
		INode* pBone = skin->GetBone(i);
		if (NULL == pBone)
		{
			setLastError("找不到skin依赖的骨骼");
			return false;
		}
		if (ENUM_NODE_DUMMY == checkNodeType(pBone))
		{
			char szError[1024];
			::StringCchPrintf(szError, sizeof(szError), "发现绑定到虚拟体[%s]的顶点", pBone->GetName());
			setLastError(szError);
			return false;
		}

		wchar_t unicodeString[256];
		mbstowcs(unicodeString, pBone->GetName(), 255);
		skinnedMesh->m_boneNames[i] = unicodeString;

		Matrix3 mBoneOffset;
		skin->GetBoneInitTM(pBone, mBoneOffset);
		mBoneOffset.Invert();
		Matrix3 meshOffset = node->GetObjectTM(0);
		mBoneOffset = meshOffset * mBoneOffset;
		//mBoneOffset = mSkinOffset * mBoneOffset;
		grp::Matrix& mCore = skinnedMesh->m_offsetMatrices[i];
		::MatrixFromMatrix3(mCore, mBoneOffset);
	}
	return true;
}
Пример #16
0
/*
this function takes a char string. if the string begins
with a / it will perceive it as a relative path otherwise it will
take take the entire path as a name. trailing / may be
present or omitted.
*/
INode* UserNodeImpl::GetChild(const char* name)
{
	if((NULL == name)||(NULL == m_children))
		return NULL;

	INode* child;
	char *szname;
	int j;
	if('/' == name[0])
	{
		szname = strdup(name);

		int len = strlen(name);

		for(j = 1; j < len; j++)
		{
			if('/' == szname[j])
			{
				szname[j] = 0;
				break;
			}
		}

		child = GetChild(szname);

		if(NULL == child)
		{
			free(szname);
			return NULL;
		}

		if(j < len)
		{
			child = child->GetChild(&szname[j+1]);
		}

		free(szname);

		return child;
	}else
	{
		for(int i = 0; i < m_children->size(); i++)
		{
			child = m_children->at(i);
			if(0 == strcmp(name, child->GetName()))
			{
				return child;
			}
		}
		
		return NULL;
	}

	//should never reach here
	return NULL;
}
Пример #17
0
    void IUpdateNode(TimeValue t, IParamBlock2* pb, HWND hWnd, ParamID buttonID, int button)
    {
        INode* node = pb->GetINode(buttonID, t);
        HWND hButton = GetDlgItem(hWnd, button);

        if (node)
            SetWindowText(hButton, node->GetName());
        else
            SetWindowText(hButton, "<none>");
    }
Пример #18
0
void plMtlAnimProc::ISetNodeButtonText(HWND hWnd, IParamBlock2* pb)
{
    HWND hNode = GetDlgItem(hWnd, fNodeButtonID);

    INode* node = pb->GetINode(fNodeParamID);
    if (node)
        SetWindowText(hNode, node->GetName());
    else
        SetWindowText(hNode, kUserTypeAll);
}
	//------------------------------
	bool MaterialCreator::createAndAssingMaxMaterial( const DocumentImporter::NodeMaterialBindingsPair& materialBindingPair )
	{
		const DocumentImporter::MaterialBindingVector& materialBindings = materialBindingPair.materialBindings;
		INode* maxNode = materialBindingPair.maxNode;

		if ( materialBindings.size() == 0 )
			return true;

		const COLLADAFW::UniqueId& geometryUniqueId = getUniqueIdByObjectINode( maxNode );
		assert( geometryUniqueId.isValid() );

		// calculate largest material id
		int largestMaterialId = 0;
		DocumentImporter::MaterialBindingVector::const_iterator it = materialBindings.begin();

		for ( ; it != materialBindings.end(); ++it)
		{
			int materialId = (int)it->getMaterialId();
			largestMaterialId = materialId;
		}

		if ( !materialBindings.empty() )
		{
			if ( materialBindings.size() == 1 )
			{
				const COLLADAFW::MaterialBinding& materialBinding = materialBindings[0];
				const COLLADAFW::Effect* effect = getEffect(materialBinding);
				if ( !effect )
					return true;
				Mtl* newMaterial = getMaxMaterial(*effect, materialBinding, geometryUniqueId);
				maxNode->SetMtl( newMaterial );
			}
			else
			{
				MultiMtl * multiMaterial = NewDefaultMultiMtl();
				multiMaterial->SetNumSubMtls( largestMaterialId + 1 );
				String multiMaterialName = String(maxNode->GetName()) + "-MultiMaterial";
				multiMaterial->SetName(multiMaterialName.c_str());

				it = materialBindings.begin();
				for ( ; it != materialBindings.end(); ++it)
				{
					const COLLADAFW::MaterialBinding& materialBinding = *it;
					const COLLADAFW::Effect* effect = getEffect(materialBinding);
					if ( !effect )
						continue;
					Mtl* newMaterial = getMaxMaterial(*effect, materialBinding, geometryUniqueId);
					multiMaterial->SetSubMtl( materialBinding.getMaterialId(), newMaterial);
				}
				maxNode->SetMtl( multiMaterial );
			}
		}
		return true;
	}
Пример #20
0
void FormationBhvr::SetLeaderNodeText()
{

	if (!editing) return;
    IParamMap2 *pmap = pblock->GetMap();
	if (!pmap) return;
	INode *node;
    node = pblock->GetINode(leader,0,0);
	if(node)
		pmap->SetText(leader,node->GetName());
	else
		pmap->SetText(leader,GetString(IDS_NONE));
}
Пример #21
0
static AngAxis CalcTransform(INode *bone, NiNodeRef node, vector<NiNodeRef>& children)
{
   Matrix3 mr(TRUE);
   int n = bone->NumberOfChildren();
   if (n > 0) 
   {
      int c = 0;
      Point3 vs(0.0f, 0.0f, 0.0f), vf(0.0f, 0.0f, 0.0f);
      Matrix3 m = bone->GetNodeTM(0);
      Matrix3 m2 = TOMATRIX3(node->GetWorldTransform());
      for (int i = 0; i<n; i++)
      {
         INode *child = bone->GetChildNode(i);
         LPCTSTR name = child->GetName();
         if (HasBipedPosDOF(name))
            continue;

         Matrix3 cm = child->GetObjectTM(0);
         vs += (m.GetTrans()-cm.GetTrans());

         if (NiNodeRef child2 = FindNodeByName(children, string(child->GetName()))){
            Matrix3 cm2 = TOMATRIX3(child2->GetWorldTransform());
            vf += (m2.GetTrans()-cm2.GetTrans());
         }
         ++c;
      }
      vs = FNormalize(vs); 
      vf = FNormalize(vf);
      Point3 cross = CrossProd(vs, vf);
      if (fabs(cross.x) < 0.01 && fabs(cross.y) < 0.01 && fabs(cross.z) < 0.01)
         return AngAxis(Point3(0.0f, 0.0f, 0.0f), 0.0f);
      float dot = DotProd(vs, vf);
      return AngAxis( cross, acos( dot ) );
   }
   return mr;
}
Пример #22
0
void FormationBhvr::SetFollowerNodeText()
{
	if (!editing) return;
    IParamMap2 *pmap = pblock->GetMap();
	if (!pmap) return;
	if (pblock->Count(follower) == 0)
         pmap->SetText(follower_single,GetString(IDS_NONE));
	else if (pblock->Count(follower) == 1)
	     {
	          INode *node;
              node = pblock->GetINode(follower,0,0);
    	      if (node) pmap->SetText(follower_single,node->GetName());
         }
	     else pmap->SetText(follower_single,GetString(IDS_MULTIPLE));
}
void TestSplitBySourceDlgProc::UpdateSourceDlg( IParamMap2* map )
{
	if (map == NULL) return;
	IParamBlock2* pblock = map->GetParamBlock();
	if (pblock == NULL) return;
	HWND hWnd = map->GetHWnd();

	HWND hWndSystem = GetDlgItem(hWnd, IDC_SOURCELIST);
	SendMessage(hWndSystem, LB_RESETCONTENT, 0, 0);
	IPFSystemPool* pool = GetPFSystemPool();
	for(int i=0; i<pool->NumPFSystems(); i++) {
		INode* pSystem = pool->GetPFSystem(i);
		SendMessage(hWndSystem, LB_ADDSTRING, 0, (LPARAM)(TCHAR*)(pSystem->GetName()) );
		if (SBSIsSelectedSource(pSystem, pblock))
			SendMessage(hWndSystem, LB_SETSEL, TRUE, i);
	}
}
Пример #24
0
/**
*  @brief
*    Writes a target rotation scene node modifier
*/
void PLSceneNode::WriteTargetRotationModifier(XmlElement &cSceneElement, INode &cTarget, bool bFlip) const
{
	// Get the PL scene node
	String sTarget;
	PLSceneNode *pSceneNode = GetScene().GetPLSceneNode(cTarget);
	if (pSceneNode) {
		// Same container?
		if (pSceneNode->GetContainer() == GetContainer()) {
			// Yeah, that was easy!
			sTarget = pSceneNode->GetName();
		} else {
			// The exported supports only 'one' cell level, else this would be a bit more complex...
			if (pSceneNode->GetContainer() == &GetScene()) {
				sTarget += "Parent.";
				sTarget += pSceneNode->GetName();
			} else {
				sTarget += "Parent.";
				sTarget += pSceneNode->GetContainer()->GetName();
				sTarget += '.';
				sTarget += pSceneNode->GetName();
			}
		}

	// Fallback: Use the 3ds Max node name
	} else {
		sTarget = cTarget.GetName();
		g_pLog->LogFLine(PLLog::Warning, "'%s' target node: There's no PL scene node with the name '%s'", m_sName.GetASCII(), sTarget.GetASCII());
	}

	// Add scene node modifier
	XmlElement *pModifierElement = new XmlElement("Modifier");
	pModifierElement->SetAttribute("Class",  "PLScene::SNMRotationTarget");
	pModifierElement->SetAttribute("Target", sTarget);
	if (bFlip)
		pModifierElement->SetAttribute("Offset", "0 180 0");

	// Link modifier element
	cSceneElement.LinkEndChild(*pModifierElement);
}
Пример #25
0
void PFTestSplitBySource::macrorecSources()
{
	if (pblock() == NULL) return;
	TSTR selItemNames = _T("(");
	int numItems = pblock()->Count(kSplitBySource_sources);
	bool nonFirst = false;
	Interface* ip = GetCOREInterface();
	for(int i=0; i<numItems; i++) {
		INode* selNode = ip->GetINodeByHandle(ULONG(pblock()->GetInt(kSplitBySource_sources, 0, i)));
		if (selNode == NULL) continue;
		if (nonFirst) selItemNames = selItemNames + _T(", ");
		selItemNames = selItemNames + _T("$'");
		selItemNames = selItemNames + selNode->GetName();
		selItemNames = selItemNames + _T("'.handle");
		nonFirst = true;
	}
	selItemNames = selItemNames + _T(")");
	TCHAR selNames[3000];
	sprintf(selNames,"%s", selItemNames);
	macroRec->EmitScript();
	macroRec->SetProperty(this, _T("Selected_Sources"), mr_name, selNames);
}
Пример #26
0
void    plPlasmaAnimSelectDlgProc::IUpdateNodeBtn( HWND hWnd, IParamBlock2 *pb )
{
    if( fUseNode )
    {
        int type = pb->GetInt( fTypeParamID );
        if( type == plAnimObjInterface::kUseOwnerNode )
            ::SetWindowText( ::GetDlgItem( hWnd, fNodeDlgItem ), kUseOwnerNodeString );
        else
        {
            INode *node = pb->GetINode( fNodeParamID );
            TSTR newName( node ? node->GetName() : kUseParamBlockNodeString );
            ::SetWindowText( ::GetDlgItem( hWnd, fNodeDlgItem ), newName );
        }

        plAnimObjInterface *iface = plAnimComponentBase::GetAnimInterface( pb->GetINode( fParamID ) );
        if( iface == nil || !iface->IsNodeRestricted() )
            ::EnableWindow( ::GetDlgItem( hWnd, fNodeDlgItem ), false );
        else
        {
            ::EnableWindow( ::GetDlgItem( hWnd, fNodeDlgItem ), true );
        }
    }
}
Пример #27
0
//+--------------------------------------------------------------------------+
//|							From IPViewItem									 |
//+--------------------------------------------------------------------------+
bool PFOperatorForceSpaceWarp::HasDynamicName(TSTR& nameSuffix)
{
	int num = pblock()->Count(kForceSpaceWarp_ForceNodeList);
	int count=0, firstIndex=-1;
	for(int i=0; i<num; i++) {
		if (pblock()->GetINode(kForceSpaceWarp_ForceNodeList, 0, i) != NULL) {
			count++;
			if (firstIndex < 0) firstIndex = i;
		}
	}
	if (count > 0) {
		INode* force = pblock()->GetINode(kForceSpaceWarp_ForceNodeList, 0, firstIndex);
		nameSuffix = force->GetName();
		if (count > 1) {
			TCHAR buf[32];
			_stprintf(buf, _T(" +%d"), count-1);
			nameSuffix += buf;
		}
	} else {
		nameSuffix = GetString(IDS_NONE);
	}
	return true;
}
Пример #28
0
BOOL SWrapPickOperand::Pick(IObjParam *ip,ViewExp *vpt)
	{
	INode *node = vpt->GetClosestHit();
	assert(node);
	INodeTab nodes;
	nodes.SetCount(1);nodes[0]=node;
	ip->FlashNodes(&nodes);
	if (po->custnode) po->ReplaceReference(CUSTNODE,node,TRUE);
	else po->MakeRefByID(FOREVER,CUSTNODE,node);	
	po->custname = TSTR(node->GetName());
	// Automatically check show result and do one update
	po->cmValid.SetEmpty();
	po->pmapParam->Invalidate();
	po->ShowName();	
	po->NotifyDependents(FOREVER, PART_ALL, REFMSG_CHANGE);
	if (po->creating) {
		theCreateSWrapObjectMode.JumpStart(ip,po);
		ip->SetCommandMode(&theCreateSWrapObjectMode);
		ip->RedrawViews(ip->GetTime());
		return FALSE;
	} else {
		return TRUE;
		}
	}
Пример #29
0
    void UpdateBoneDisplay(IParamMap2 *pm)
    {
        HWND hWnd = pm->GetHWnd();
        HWND hList = GetDlgItem(hWnd, IDC_COMP_LOD_AVATAR_BONELIST);
        IParamBlock2 *pb = pm->GetParamBlock();
            
        ListBox_ResetContent(hList);
        int group = fComp->GetCurGroupIdx();
        int startIdx = fComp->GetStartIndex(group);
        int endIdx = fComp->GetEndIndex(group);

        while (startIdx < endIdx)
        {
            INode *curNode = pb->GetINode(ParamID(plLODAvatarComponent::kBoneList), 0, startIdx);
            if (curNode == nil)
            {
                fComp->RemoveBone(startIdx);
                endIdx--;
                continue;
            }
            ListBox_AddString(hList, curNode->GetName());
            startIdx++;
        }
    }
Пример #30
0
int Blockporter::DoExport(const TCHAR* name, ExpInterface* ei, Interface* i, BOOL supressPrompts, DWORD options)
{
	INode* root;
	//caption and message for MessagesBoxes
	TCHAR msg[MB_BUFFER_LENGTH];
	TCHAR cap[MB_BUFFER_LENGTH];

	//Get the root node
	root = i->GetRootNode();

	//the node of our object should be a groupnode, which contains every object
	//we want to export
	i->PushPrompt(_T("Searching for Group..."));
	bool found = false;
	for(int idx = 0; idx < root->NumberOfChildren(); idx++)
	{
		if(root->GetChildNode(idx)->IsGroupHead())
		{
			//we found our group
			//next step is to make the group node our new root, because every object
			//we want is part of this group

			found = true;
			root = root->GetChildNode(idx);
			break;
		}
	}

	if(!found)
	{
		MessageBox(nullptr, GetString(IDS_ERROR_NO_GROUP, msg), GetString(IDS_GENERAL_ERROR, cap), MB_OK | MB_ICONERROR);
		return 0;
	}

	//Now that we have the groupnode let's compare the fileversions
	if(!IsNewModelVersion(name, root->GetName()))
	{
		if(MessageBox(nullptr, GetString(IDS_VER_TO_LOW_MSG, msg), GetString(IDS_VER_TO_LOW_CAP, cap), MB_YESNO | MB_ICONEXCLAMATION) == IDNO)
			return 1;
	}

	i->PushPrompt(_T("Opening File"));
	Interface14* iface = GetCOREInterface14();
	UINT code = iface->DefaultTextSaveCodePage(true);
	MaxSDK::Util::Path storageNamePath(name);
	storageNamePath.SaveBaseFile();
	switch (code & MaxSDK::Util::MaxStringDataEncoding::MSDE_CP_MASK)
	{
	case CP_UTF8:
		mStream = _tfopen(name, _T("wt, ccs=UFT-8"));
		break;
	case MaxSDK::Util::MaxStringDataEncoding::MSDE_CP_UTF16:
		mStream = _tfopen(name, _T("wt, ccs=UTF-16BE"));
		break;
	default:
		mStream = _tfopen(name, _T("wt"));
	}
	if(!mStream)
		return 0;

	//now we have our file stream, so let's write the header
	i->PushPrompt(_T("Writing Header"));
	WriteHeader(root->GetName(), root->NumberOfChildren());

	//now that we have the header written, let's iterate through the objects in the
	//group and export the meshes and lights

	INode* child;
    Point3 pMin(0,0,0), pMax(0,0,0);

	for(int idx = 0; idx < root->NumberOfChildren(); idx++)
	{
		child = root->GetChildNode(idx);
		i->PushPrompt(_T("Processing Object %s", child->GetName()));
		if(child->IsGroupHead())
		{
			MessageBox(nullptr, GetString(IDS_ERROR_TO_MANY_GROUPS, msg), GetString(IDS_GENERAL_ERROR, cap), MB_OK | MB_ICONERROR);
			continue;
		}

		ObjectState os = child->EvalWorldState(0);

		//let's take a look at the SuperClassID of the object
		//so we find out if it's a mesh or a light
		if(!os.obj)
			continue; //somehow this node doesn't have an object

        Box3 boundBox;

		switch(os.obj->SuperClassID())
		{
		case GEOMOBJECT_CLASS_ID:
			_ftprintf(mStream, _T("<ObjectID=%i>\n"), idx);
			i->PushPrompt(_T("Writing MeshData for Object %s", child->GetName()));
			boundBox = WriteMeshData(child, idx);
            pMin.x = (boundBox.Min().x < pMin.x) ? boundBox.Min().x : pMin.x;
            pMin.y = (boundBox.Min().y < pMin.y) ? boundBox.Min().y : pMin.y;
            pMax.x = (boundBox.Max().x > pMax.x) ? boundBox.Max().x : pMax.x;
            pMax.y = (boundBox.Max().y > pMax.y) ? boundBox.Max().y : pMax.y;
			i->PushPrompt(_T("Writing MaterialData for Object %s", child->GetName()));
			WriteMaterialData(child);
			_ftprintf(mStream, _T("</Object>\n"));
			break;
		//case LIGHT_CLASS_ID:
		//	WriteLightData(child, idx);
		//	break;
		}
	}

    //Write the Bounding Box
    _ftprintf(mStream, _T("<BoundingBox>\n"));
    _ftprintf(mStream, _T("\t<Min=%f,%f>\n"), pMin.x, pMin.y);
    _ftprintf(mStream, _T("\t<Max=%f,%f>\n"), pMax.x, pMax.y);
    _ftprintf(mStream, _T("</BoundingBox>\n"));
	//we are done exporting, so close the stream
	i->PushPrompt(_T("Closing file..."));
	fclose(mStream);

	MessageBox(nullptr, GetString(IDS_FINISH_MSG, msg), GetString(IDS_FINISH_CAP, cap), MB_OK | MB_ICONINFORMATION);

	return 1;
}