Exemplo n.º 1
0
void Xrefutil::ConvertSelectedToXrefScene(HWND hWnd)
{
    // *** ConvertSelectedToXrefScene ***
    //
    // Relatively simple -- take the selected nodes, save them out
    // to a new .MAX file, delete the selected nodes from the 
    // current scene, and then do a RootNode->AddNewXRefFile
    // with the just-saved MAX file.
	
    INode * pNode = NULL;
    TSTR filename = _T("");
    int i;
	
    INode * pRootNode = m_pInterface->GetRootNode();
    if (!pRootNode) {
        // well, this is actually _really_ bad, but we just exit
        return;
    }
    if (m_pInterface->GetSelNodeCount() == 0) {
        ::MessageBox(hWnd, GetString(IDS_ERR3), ERROR_TITLE, MB_ICONSTOP | MB_OK);
        return;
    }
	
    Tab<INode *> nodetab;
    nodetab.ZeroCount();
	nodetab.Shrink();
    for (i = 0; i < m_pInterface->GetSelNodeCount(); i++) {
        pNode = m_pInterface->GetSelNode(i);
        nodetab.Append(1, &pNode, 5);
    }
	
    if (!DoOpenSaveDialog(filename)) {
        // either cancel or fail, just return
        return;
    }
	
    m_pInterface->FileSaveSelected(filename);
	
    // delete selected nodes, don't refresh yet
    for (i = 0; i < nodetab.Count(); i++) {
        nodetab[i]->Delete(0,TRUE);
    }

	AssetUser asset = IAssetManager::GetInstance()->GetAsset(filename,kXRefAsset);
    // add in the nodes we saved out as an xref'd scene
    pRootNode->AddNewXRefFile(asset, TRUE);
    
    m_pInterface->RedrawViews(m_pInterface->GetTime());
	
}
Exemplo n.º 2
0
void RenderMesh::ConvertFaces(Mesh *Mesh, int MatIndex, Tab<Vert3> &Verts, Tab<Face3> &Faces, bool NegScale)
{
    Face3			TmpFace;
    Vert3			TmpVert;
	BitArray		Written;
	int				i,j,k,NumFace;
	int				NumUV,UVCount,Index;
	int				NumVert,Count,VIndex;
	Face			*aFace;
	Tab<BasisVert>	FNormals;
	Tab<VNormal>	Normals;
	UVVert			*UVVert;
	TVFace			*UVFace;
	Point3			S,T,SxT;
	unsigned long	Sg;

	bool useMeshNorms = false;


	if(NegScale)
	{
		gVIndex[0] = 2;
		gVIndex[1] = 1;
		gVIndex[2] = 0;
	}
	else
	{
		gVIndex[0] = 0;
		gVIndex[1] = 1;
		gVIndex[2] = 2;
	}

	// Do we have an EditNormal modifier present - if so we use those normals instead.
	// We only use this if they have been applied on a face with smoothing groups, otherwise
	// it messes up the tangent space calculation.  Probably not the most obtmized route, but it
	// works...

	MeshNormalSpec * meshNorm = Mesh->GetSpecifiedNormals();
	if(meshNorm && meshNorm->GetNumNormals())
		useMeshNorms = true;

	NumFace = 0;

	for(i=0; i < Mesh->getNumFaces(); i++) 
	{
		if(!Mesh->faces[i].Hidden())
		{
			Index = Mesh->getFaceMtlIndex(i) + 1;

			if(Index == MatIndex || MatIndex == 0)
			{
				NumFace++;
			}
		}

	}

	NumVert = Mesh->getNumVerts();
    Verts.SetCount(NumVert);

    Faces.SetCount(NumFace);

	if(NumVert == 0 || NumFace == 0)
	{
		return;
	}

	ComputeVertexNormals(Mesh,FNormals,Normals,NegScale);

    Written.SetSize(Mesh->getNumVerts());
    Written.ClearAll();

	NumUV = Mesh->getNumMaps();	

	if(NumUV)
	{	
		Count = 0;

		if(NumUV > MAX_TMUS + 1)
		{
			NumUV = MAX_TMUS + 1;
		}

		for(i=0; i < Mesh->getNumFaces(); i++) 
		{
			aFace = &Mesh->faces[i];

			TmpFace.m_Num[0] = aFace->v[gVIndex[0]];
			TmpFace.m_Num[1] = aFace->v[gVIndex[1]];
			TmpFace.m_Num[2] = aFace->v[gVIndex[2]];


			Sg = aFace->smGroup;

			for(j=0; j < 3; j++) 
			{
				VIndex			 = aFace->v[gVIndex[j]];
				TmpVert.m_Pos	 = Mesh->verts[VIndex];

				if(Sg)
				{
					if(useMeshNorms)
					{
						int normID = meshNorm->Face(i).GetNormalID(gVIndex[j]);
						TmpVert.m_Normal = meshNorm->Normal(normID).Normalize();
						Normals[VIndex].GetNormal(Sg,S,T,SxT);
					}
					else
					        TmpVert.m_Normal = Normals[VIndex].GetNormal(Sg,S,T,SxT);
					
					TmpVert.m_S		 = S;
					TmpVert.m_T		 = T;
					TmpVert.m_SxT	 = SxT;

				}
				else
				{
					TmpVert.m_Normal = FNormals[i].m_Normal;
					TmpVert.m_S		 = FNormals[i].m_S;
					TmpVert.m_T		 = FNormals[i].m_T;
					TmpVert.m_SxT	 = FNormals[i].m_SxT;
				}

				UVCount		 = 0;
				TmpVert.m_Sg = Sg;

				for(k=0;k<m_MapChannels.Count();k++)
				{	
					int index = m_MapChannels[k];

					if(Mesh->getNumMapVerts(index))
					{
						UVVert = Mesh->mapVerts(index);
						UVFace = Mesh->mapFaces(index);

						TmpVert.m_UV[k].x = UVVert[UVFace[i].t[gVIndex[j]]].x;
						TmpVert.m_UV[k].y = UVVert[UVFace[i].t[gVIndex[j]]].y;

	
					}
					else
					{
						TmpVert.m_UV[k].x = 0.0f;
						TmpVert.m_UV[k].y = 0.0f;
					}
				}
				
		
				if(Written[VIndex]) 
				{
					if((Sg == 0) || 
					   (Verts[VIndex].m_Sg != TmpVert.m_Sg) ||	
					   (!UVVertEqual(Verts[VIndex].m_UV[0],TmpVert.m_UV[0]))) 
					{
						TmpFace.m_Num[j] = Verts.Count();
						Verts.Append(1,&TmpVert,10);
					}
				} 
				else 
				{
					Verts[VIndex] = TmpVert;
					Written.Set(VIndex);
				}

			}

			if(!Mesh->faces[i].Hidden())
			{
				Index = Mesh->getFaceMtlIndex(i) + 1;

				if(Index == MatIndex || MatIndex == 0)
				{
					Faces[Count++] = TmpFace;
				}

			}

		}

	}
	else
	{
		for(i=0; i < Mesh->getNumFaces(); i++) 
		{
			aFace = &Mesh->faces[i];

			Faces[i].m_Num[0] = aFace->v[gVIndex[0]];
			Faces[i].m_Num[1] = aFace->v[gVIndex[1]];
			Faces[i].m_Num[2] = aFace->v[gVIndex[2]];

			for(j=0; j < 3; j++) 
			{
				VIndex					= aFace->v[gVIndex[j]];
				Verts[VIndex].m_Pos		= Mesh->verts[VIndex];
				Verts[VIndex].m_Normal	= Normals[VIndex].GetNormal(aFace->smGroup,S,T,SxT);
				Verts[VIndex].m_S		= Point3(0.0f,0.0f,0.0f);
				Verts[VIndex].m_T		= Point3(0.0f,0.0f,0.0f);
				Verts[VIndex].m_SxT		= Point3(0.0f,0.0f,0.0f);

				for(k=0; k < MAX_TMUS; k++)
				{
					Verts[VIndex].m_UV[k].x = 0.0f;
					Verts[VIndex].m_UV[k].y = 0.0f;
				}

			}

		}

	}
	Verts.Shrink();
	

}
Exemplo n.º 3
0
void xref_low_error(std::wstring project_path, std::wstring pname) {

	//Tab<const MCHAR*> sourceFile_Files;
	Tab<const MCHAR*>* pointer_sourceFile_Files = new Tab<const MCHAR*>();

	std::wstring filename = (project_path + L"\\" + pname + L"_low0.max");
	const wchar_t* file = filename.c_str();
	sourceFile_Files.Append(1, &file);
	sourceFile_Files.Shrink();
	pointer_sourceFile_Files->Init();
	pointer_sourceFile_Files->Append(1, &file);

	Tab<MSTR*> tstr_tab;
	MSTR str(filename.c_str());
	MSTR* a = &str;
	tstr_tab.Append(1, &a);
	tstr_tab.Shrink();

	Tab<MSTR*> tstr_tab_dynamic_allocate_items;
	MSTR* str_dynamic_allocate_items = new MSTR(filename.c_str());
	tstr_tab_dynamic_allocate_items.Append(1, &str_dynamic_allocate_items);
	tstr_tab_dynamic_allocate_items.Shrink();


	//FPValue param1;
	//int i = 10;
	////param1.LoadPtr(FILENAME_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM1_TYPE, filename.data());	
	//param1.type = FILENAME_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM1_TYPE;
	//param1.s = filename.data();
	//param1.LoadPtr(ParamType2::TYPE_INT_BP, &i);	
	//LOG("param1.s here= "); LOG(param1.s); LOG("\n");

	//  	FPValue param1_FPValue;
	//  	TCHAR* param1_TCHAR = _T("Test Track View");
	// 	param1_FPValue.type = TYPE_STRING,
	// 	param1_FPValue.s = param1_TCHAR;
	//  	param1.type = (ParamType2)TYPE_FPVALUE;
	//  	param1.fpv = &param1_FPValue;
	try
	{
		{
			//std::lock_guard<std::mutex> lock(mymutex);
			//FPValue param3;
			param3.type = ParamType2::TYPE_STRING_TAB;
			//param3.s_tab = pointer_sourceFile_Files;
			param3.s_tab = &sourceFile_Files;
			
			//OBJNAMES_ADDXREFITEMSFROMFILE_IOBJXREFMGR_PARAM3_TYPE;
			//param3.InitTab(ParamType2::TYPE_STRING_TAB, sourceFile_Files.Count());
			//param3.LoadPtr(ParamType2::TYPE_STRING_TAB_BV, &sourceFile_Files);
			//param3.Load(ParamType2::TYPE_STRING_TAB_BV,&sourceFile_Files);
			//param3.LoadPtr(ParamType2::TYPE_STRING_TAB, &sourceFile_Files);
			//param3.LoadPtr(ParamType2::TYPE_STRING_TAB_BV, tstr_tab);
			//param3.LoadPtr(ParamType2::TYPE_STRING_TAB_BV, &tstr_tab_dynamic_allocate_items);
			//SYSTEM_CALL(param3.LoadPtr(ParamType2::TYPE_STRING_TAB_BV, &sourceFile_Files);)
			//param3.Load(ParamType2::TYPE_STRING_TAB, &sourceFile_Files);
			mprintf((*param3.s_tab)[0]);
			//LOG();
		}
	}
	catch (const std::exception&)
	{
		//LOG("Why this is error, tell me pls");
	};


	
	//  	FPValue param4;
	//  	param4.type = ParamType2::TYPE_FPVALUE_TAB_BV;
	// 	Tab<FPValue*> param4_fpvalues;
	// 	FPValue param4_fpvalue;
	// 	FPValue* pointer_param4_fpvalue;
	// 	param4_fpvalue.type = (ParamType2)1;
	// 	param4_fpvalue.i = 10;
	// 	param4_fpvalues.Append(1, &pointer_param4_fpvalue);
	// 	param4.fpv_tab = &param4_fpvalues;

	FPValue param4;
	//param4.type = ParamType2::TYPE_INT_TAB;
	//param4.type = ParamType2::TYPE_INT_TAB_BV;
	//param4.type = ParamType2::TYPE_INT_TAB_BR;
	Tab<int> xrefoptions;
	xrefoptions.Resize(1);
	int h = 1;
	xrefoptions.Append(1, &h);

	//param4.i_tab = &xrefoptions;

	//LOG("type is {0}", param4.type);




	//FPParams fnParams;
	//FPValue result, param1;
	//FPValue param1_FPValue;
	//TCHAR* param1_TCHAR = _T("Test Track View");
	//param1_FPValue.type = TYPE_STRING,
	//	param1_FPValue.s = param1_TCHAR;

	//param1.type = (ParamType2)TYPE_FPVALUE,
	//	param1.fpv = &param1_FPValue;
	//fnParams.params.append(&param1,1);

	//LOG("type is {0}", param1.type);

	// 	auto s_tab = param3.s_tab;
	// 	auto count = s_tab->Count();
	// 	LOG("count here is {}\n", count);
	// 	for (int i = 0; i < count; i++)
	// 	{
	// 		auto sp = (*s_tab)[i];
	// 		LOG("Name {} from param3.s_tab ", i); LOG(sp); LOG("\n");
	// 	}
	// 	if (s_tab == nullptr)
	// 		LOG("this not good\n");
	// 	else
	// 		LOG("uha\n");
}