本文整理汇总了C++中FbxSurfaceMaterial::GetUserDataPtr方法的典型用法代码示例。如果您正苦于以下问题:C++ FbxSurfaceMaterial::GetUserDataPtr方法的具体用法?C++ FbxSurfaceMaterial::GetUserDataPtr怎么用?C++ FbxSurfaceMaterial::GetUserDataPtr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FbxSurfaceMaterial
的用法示例。
在下文中一共展示了FbxSurfaceMaterial::GetUserDataPtr方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void FBXMesh::Builder::unloadCacheRecursive(FbxNode * pNode)
{
// Unload the material cache
const int lMaterialCount = pNode->GetMaterialCount();
for (int lMaterialIndex = 0; lMaterialIndex < lMaterialCount; ++lMaterialIndex)
{
FbxSurfaceMaterial * lMaterial = pNode->GetMaterial(lMaterialIndex);
if (lMaterial && lMaterial->GetUserDataPtr())
{
FBXMaterialCache* lMaterialCache = static_cast<FBXMaterialCache*>(lMaterial->GetUserDataPtr());
lMaterial->SetUserDataPtr(NULL);
delete lMaterialCache;
}
}
FbxNodeAttribute* lNodeAttribute = pNode->GetNodeAttribute();
if (lNodeAttribute)
{
// Unload the mesh cache
if (lNodeAttribute->GetAttributeType() == FbxNodeAttribute::eMesh)
{
FbxMesh * lMesh = pNode->GetMesh();
if (lMesh && lMesh->GetUserDataPtr())
{
#ifndef USE_META_DATA
VBOMesh * lMeshCache = static_cast<VBOMesh *>(lMesh->GetUserDataPtr());
lMesh->SetUserDataPtr(NULL);
delete lMeshCache;
#else
FbxMetaData * fbxMetaData = static_cast<FbxMetaData*>(lMesh->GetUserDataPtr());
lMesh->SetUserDataPtr(NULL);
delete fbxMetaData;
#endif
}
}
// Unload the light cache
else if (lNodeAttribute->GetAttributeType() == FbxNodeAttribute::eLight)
{
FbxLight * lLight = pNode->GetLight();
if (lLight && lLight->GetUserDataPtr())
{
FBXLightCache* lLightCache = static_cast<FBXLightCache*>(lLight->GetUserDataPtr());
lLight->SetUserDataPtr(NULL);
delete lLightCache;
}
}
}
const int lChildCount = pNode->GetChildCount();
for (int lChildIndex = 0; lChildIndex < lChildCount; ++lChildIndex)
{
unloadCacheRecursive(pNode->GetChild(lChildIndex));
}
}
示例2: UnloadCacheRecursive
// Unload the cache and release the memory under this node recursively.
void UnloadCacheRecursive(FbxNode * pNode)
{
// Unload the material cache
const int lMaterialCount = pNode->GetMaterialCount();
for (int lMaterialIndex = 0; lMaterialIndex < lMaterialCount; ++lMaterialIndex)
{
FbxSurfaceMaterial * lMaterial = pNode->GetMaterial(lMaterialIndex);
if (lMaterial && lMaterial->GetUserDataPtr())
{
MaterialCache * lMaterialCache = static_cast<MaterialCache *>(lMaterial->GetUserDataPtr());
lMaterial->SetUserDataPtr(NULL);
delete lMaterialCache;
}
}
FbxNodeAttribute* lNodeAttribute = pNode->GetNodeAttribute();
if (lNodeAttribute)
{
// Unload the mesh cache
if (lNodeAttribute->GetAttributeType() == FbxNodeAttribute::eMesh)
{
FbxMesh * lMesh = pNode->GetMesh();
if (lMesh && lMesh->GetUserDataPtr())
{
VBOMesh * lMeshCache = static_cast<VBOMesh *>(lMesh->GetUserDataPtr());
lMesh->SetUserDataPtr(NULL);
delete lMeshCache;
}
}
// Unload the light cache
else if (lNodeAttribute->GetAttributeType() == FbxNodeAttribute::eLight)
{
FbxLight * lLight = pNode->GetLight();
if (lLight && lLight->GetUserDataPtr())
{
LightCache * lLightCache = static_cast<LightCache *>(lLight->GetUserDataPtr());
lLight->SetUserDataPtr(NULL);
delete lLightCache;
}
}
}
const int lChildCount = pNode->GetChildCount();
for (int lChildIndex = 0; lChildIndex < lChildCount; ++lChildIndex)
{
UnloadCacheRecursive(pNode->GetChild(lChildIndex));
}
}
示例3: LoadCacheRecursive
// Bake node attributes and materials under this node recursively.
// Currently only mesh, light and material.
void LoadCacheRecursive(SceneContext* pSceneCtx, FbxNode * pNode, FbxAnimLayer * pAnimLayer, bool pSupportVBO)
{
// Bake material and hook as user data.
const int lMaterialCount = pNode->GetMaterialCount();
for (int lMaterialIndex = 0; lMaterialIndex < lMaterialCount; ++lMaterialIndex)
{
FbxSurfaceMaterial * lMaterial = pNode->GetMaterial(lMaterialIndex);
if (lMaterial && !lMaterial->GetUserDataPtr())
{
FbxAutoPtr<MaterialCache> lMaterialCache(new MaterialCache);
if (lMaterialCache->Initialize(lMaterial))
{
lMaterial->SetUserDataPtr(lMaterialCache.Release());
}
}
}
FbxNodeAttribute* lNodeAttribute = pNode->GetNodeAttribute();
if (lNodeAttribute)
{
// Bake mesh as VBO(vertex buffer object) into GPU.
if (lNodeAttribute->GetAttributeType() == FbxNodeAttribute::eMesh)
{
FbxMesh * lMesh = pNode->GetMesh();
if (pSupportVBO && lMesh && !lMesh->GetUserDataPtr())
{
FbxAutoPtr<VBOMesh> lMeshCache(new VBOMesh);
if (lMeshCache->Initialize(pSceneCtx, lMesh))
{
lMesh->SetUserDataPtr(lMeshCache.Release());
}
}
}
// Bake light properties.
else if (lNodeAttribute->GetAttributeType() == FbxNodeAttribute::eLight)
{
FbxLight * lLight = pNode->GetLight();
if (lLight && !lLight->GetUserDataPtr())
{
FbxAutoPtr<LightCache> lLightCache(new LightCache);
if (lLightCache->Initialize(lLight, pAnimLayer))
{
lLight->SetUserDataPtr(lLightCache.Release());
}
}
}
}
const int lChildCount = pNode->GetChildCount();
for (int lChildIndex = 0; lChildIndex < lChildCount; ++lChildIndex)
{
LoadCacheRecursive(pSceneCtx, pNode->GetChild(lChildIndex), pAnimLayer, pSupportVBO);
}
}
示例4: LoadMeshes
void LoadMeshes(FbxNode* pFbxNode, packed_freelist<Mesh>& sceneMeshes)
{
// Material
const uint32_t materialCount = pFbxNode->GetMaterialCount();
for (uint32_t i = 0; i < materialCount; ++i) {
FbxSurfaceMaterial* pFbxMaterial = pFbxNode->GetMaterial(i);
if (pFbxMaterial && !pFbxMaterial->GetUserDataPtr()) {
FbxAutoPtr<Material> pMaterial(new Material);
if (pMaterial->init(pFbxMaterial)) {
pFbxMaterial->SetUserDataPtr(pMaterial.Release());
}
}
}
FbxNodeAttribute* nodeAttribute = pFbxNode->GetNodeAttribute();
if (nodeAttribute) {
// Mesh
if (nodeAttribute->GetAttributeType() == FbxNodeAttribute::eMesh) {
FbxMesh* pFbxMesh = pFbxNode->GetMesh();
if (pFbxMesh && !pFbxMesh->GetUserDataPtr()) {
Mesh mesh;
if (mesh.init(pFbxMesh)) {
sceneMeshes.insert(mesh);
}
// TODO:
FbxAutoPtr<Mesh> pMesh(new Mesh);
if (pMesh->init(pFbxMesh)) {
pFbxMesh->SetUserDataPtr(pMesh.Release());
}
}
}
// Light
else if (nodeAttribute->GetAttributeType() == FbxNodeAttribute::eLight) {
FbxLight* pFbxLight = pFbxNode->GetLight();
if (pFbxLight && !pFbxLight->GetUserDataPtr()) {
FbxAutoPtr<Light> pLight(new Light);
if (pLight->init(pFbxLight)) {
pFbxLight->SetUserDataPtr(pLight.Release());
}
}
}
}
const int childCount = pFbxNode->GetChildCount();
for (int i = 0; i < childCount; ++i) {
LoadMeshes(pFbxNode->GetChild(i), sceneMeshes);
}
}
示例5: FillData
bool FillData(ModelData* someData,FbxNode* aNode, AnimationData* aAnimation)
{
FbxMesh* mesh = aNode->GetMesh();
if (mesh == nullptr || !aNode)
return false;
const int lPolygonCount = mesh->GetPolygonCount();
// Count the polygon count of each material
FbxLayerElementArrayTemplate<int>* lMaterialIndice = NULL;
FbxGeometryElement::EMappingMode lMaterialMappingMode = FbxGeometryElement::eNone;
if (mesh->GetElementMaterial())
{
lMaterialIndice = &mesh->GetElementMaterial()->GetIndexArray();
lMaterialMappingMode = mesh->GetElementMaterial()->GetMappingMode();
if (lMaterialIndice && lMaterialMappingMode == FbxGeometryElement::eByPolygon)
{
FBX_ASSERT(lMaterialIndice->GetCount() == lPolygonCount);
if (lMaterialIndice->GetCount() == lPolygonCount)
{
// Count the faces of each material
for (int lPolygonIndex = 0; lPolygonIndex < lPolygonCount; ++lPolygonIndex)
{
const int lMaterialIndex = lMaterialIndice->GetAt(lPolygonIndex);
lMaterialIndex;
/*if (someData->mSubMeshes[lMaterialIndex] == NULL)
{
someData->mSubMeshes[lMaterialIndex] = new ModelData::SubMesh;
}
someData->mSubMeshes[lMaterialIndex]->TriangleCount += 1;*/
}
// Make sure we have no "holes" (NULL) in the mSubMeshes table. This can happen
// if, in the loop above, we resized the mSubMeshes by more than one slot.
/*for (int i = 0; i < someData->mSubMeshes.Count(); i++)
{
if (someData->mSubMeshes[i] == NULL)
someData->mSubMeshes[i] = new ModelData::SubMesh;
}*/
// Record the offset (how many vertex)
const int lMaterialCount = someData->mSubMeshes.Size();
lMaterialCount;
int lOffset = 0;
/*for (int lIndex = 0; lIndex < lMaterialCount; ++lIndex)
{
someData->mSubMeshes[lIndex]->IndexOffset = lOffset;
lOffset += someData->mSubMeshes[lIndex]->TriangleCount * 3;
// This will be used as counter in the following procedures, reset to zero
someData->mSubMeshes[lIndex]->TriangleCount = 0;
}*/
FBX_ASSERT(lOffset == lPolygonCount * 3);
}
}
}
// All faces will use the same material.
if (someData->mSubMeshes.Size() == 0)
{
if (someData->mSubMeshes.GetCapacity() == 0)
{
someData->mSubMeshes.Init(1);
}
someData->mSubMeshes.RemoveAll();
someData->mSubMeshes.AddEmptyObject();
someData->mSubMeshes[0] = new ModelData::SubMesh();
}
bool hasNormalMap = false;
const int lMaterialCount = aNode->GetMaterialCount();
for (int lMaterialIndex = 0; lMaterialIndex < lMaterialCount; ++lMaterialIndex)
{
FbxSurfaceMaterial * lMaterial = aNode->GetMaterial(lMaterialIndex);
if (lMaterial && !lMaterial->GetUserDataPtr())
{
TextureInfo diffuseInfo;
GetMaterialProperty(lMaterial,FbxSurfaceMaterial::sDiffuse,FbxSurfaceMaterial::sDiffuseFactor,diffuseInfo.myFileName);
diffuseInfo.myType = DIFFUSE;
if(diffuseInfo.myFileName.empty() == false)
{
someData->myTextures.push_back(diffuseInfo);
}
TextureInfo normalInfo;
GetMaterialProperty(lMaterial,FbxSurfaceMaterial::sNormalMap,FbxSurfaceMaterial::sBumpFactor,normalInfo.myFileName);
hasNormalMap = normalInfo.myFileName.empty() == false;
normalInfo.myType = NORMALMAP;
if(normalInfo.myFileName.empty() == false)
{
someData->myTextures.push_back(normalInfo);
hasNormalMap = true;
}
TextureInfo roughnessInfo;
GetMaterialProperty(lMaterial,FbxSurfaceMaterial::sSpecular,FbxSurfaceMaterial::sSpecularFactor,roughnessInfo.myFileName);
roughnessInfo.myType = ROUGHNESS;
//.........这里部分代码省略.........