gpt4 book ai didi

c++ - 3dsmax SDK c++ bonesdef.h

转载 作者:太空宇宙 更新时间:2023-11-04 12:47:20 25 4
gpt4 key购买 nike

这是我的代码,如果我把它放在 BonesDef 项目中就可以完美地工作:

#include "mods.h"
#include "bonesdef.h"
#include <maxscript/macros/define_instantiation_functions.h>
#include "modstack.h"

Modifier* FindSkinModifier(INode* nodePtr)
{
Object* ObjectPtr = nodePtr->GetObjectRef();
if (!ObjectPtr) return NULL;
while (ObjectPtr && ObjectPtr->SuperClassID() == GEN_DERIVOB_CLASS_ID)
{
IDerivedObject *DerivedObjectPtr = (IDerivedObject *)(ObjectPtr);
int ModStackIndex = 0;
while (ModStackIndex < DerivedObjectPtr->NumModifiers())
{
Modifier* ModifierPtr = DerivedObjectPtr->GetModifier(ModStackIndex);
if (ModifierPtr->ClassID() == Class_ID(SKIN_CLASSID))
{
return ModifierPtr;
}
ModStackIndex++;
}
ObjectPtr = DerivedObjectPtr->GetObjRef();
}
return NULL;
}

void RecursiveRemoveUnusedBones(INode* node)
{
Modifier* skin = FindSkinModifier(node);
if (skin)
{
ISkin* iskin = (ISkin*)skin->GetInterface(I_SKIN);
BonesDefMod* bmod = (BonesDefMod*)iskin;
ISkinContextData* skinData = iskin->GetContextInterface(node);
BitArray usedbones = BitArray(iskin->GetNumBones());
for (int i = 0; i < skinData->GetNumPoints(); i++)
{
for (int j = 0; j < skinData->GetNumAssignedBones(i); j++)
{
int boneIndex = skinData->GetAssignedBone(i, j);
float boneWeight = skinData->GetBoneWeight(i, j);
if (boneWeight > 0) usedbones.Set(boneIndex);
}
}
for (int i = usedbones.GetSize(); i >= 0; i--)
{
if (usedbones[i] != 1) bmod->RemoveBone(i);
}
}

for (int i = 0; i < node->NumberOfChildren(); ++i)
{
RecursiveRemoveUnusedBones(node->GetChildNode(i));
}
}

def_visible_primitive(RemoveUnusedBones, "RemoveUnusedBones");
Value* RemoveUnusedBones_cf(Value **arg_list, int count)
{
RecursiveRemoveUnusedBones(GetCOREInterface()->GetRootNode());
return &ok;
}

但问题是,如果我将这段代码放在 BonesDef 项目之外的项目中,我会遇到几个错误:

Severity    Code    Description    Project    File    Line    Suppression State
Error LNK2001 unresolved external symbol "public: void __cdecl BonesDefMod::RemoveBone(int)" (?RemoveBone@BonesDefMod@@QEAAXH@Z) SamplePlugin C:\Users\Mehdi\Documents\Visual Studio 2015\Projects\SamplePlugin\Source.obj 1

Severity Code Description Project File Line Suppression State
Error LNK2001 unresolved external symbol "public: static class IObjParam * BonesDefMod::ip" (?ip@BonesDefMod@@2PEAVIObjParam@@EA) SamplePlugin C:\Users\Mehdi\Documents\Visual Studio 2015\Projects\SamplePlugin\Source.obj 1

这是我的附加内容:

F:\Software\3dsMax\SDK\3ds Max 2018 SDK\maxsdk\obj\x64\Release\bonesdef\
F:\Software\3dsMax\SDK\3ds Max 2018 SDK\maxsdk\include\XRef
F:\Software\3dsMax\SDK\3ds Max 2018 SDK\maxsdk\samples\modifiers\bonesdef
F:\Software\3dsMax\SDK\3ds Max 2018 SDK\maxsdk\include
%(AdditionalIncludeDirectories)

和图书馆:

F:\Software\3dsMax\SDK\3ds Max 2018 SDK\maxsdk\lib\x64\Release
%(AdditionalLibraryDirectories)

但始终无法构建。我的问题是如何配置项目以便使用(调用)BonesDef(Skin) 函数?

最佳答案

我终于弄明白了如何创建一个独立项目并包含 BonesDef 函数!我们应该遵循以下步骤:

  1. 包含 BonesDef.h。
  2. 创建 BonesDef (.lib) 的静态库。
  3. 将该库添加到项目设置/附加库。
  4. 从 BonesDef 项目/Additional Dependency 复制依赖列表并将其附加到我们的项目。
  5. 将 BonesDef.lib 附加到 Additional Dependency 选项。

关于c++ - 3dsmax SDK c++ bonesdef.h,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50781627/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com