expose methods for getting bone names
This commit is contained in:
@@ -510,6 +510,19 @@ extern "C"
|
||||
strcpy(outPtr, name.c_str());
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE int get_bone_count(void *sceneManager, EntityId assetEntity, int skinIndex) {
|
||||
auto names = ((SceneManager *)sceneManager)->getBoneNames(assetEntity, skinIndex);
|
||||
return names->size();
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE void get_bone_names(void *sceneManager, EntityId assetEntity, const char** out, int skinIndex) {
|
||||
auto names = ((SceneManager *)sceneManager)->getBoneNames(assetEntity, skinIndex);
|
||||
|
||||
for(int i = 0; i < names->size(); i++) {
|
||||
memcpy((void*)out[i], names->at(i).c_str(), names->at(i).length());
|
||||
}
|
||||
}
|
||||
|
||||
EMSCRIPTEN_KEEPALIVE int get_morph_target_name_count(void *sceneManager, EntityId assetEntity, EntityId childEntity)
|
||||
{
|
||||
auto names = ((SceneManager *)sceneManager)->getMorphTargetNames(assetEntity, childEntity);
|
||||
|
||||
@@ -1239,6 +1239,44 @@ namespace flutter_filament
|
||||
return names;
|
||||
}
|
||||
|
||||
unique_ptr<vector<string>> SceneManager::getBoneNames(EntityId assetEntityId, int skinIndex) {
|
||||
|
||||
unique_ptr<std::vector<std::string>> names = std::make_unique<std::vector<std::string>>();
|
||||
|
||||
auto *instance = getInstanceByEntityId(assetEntityId);
|
||||
|
||||
if (!instance)
|
||||
{
|
||||
auto *asset = getAssetByEntityId(assetEntityId);
|
||||
if (asset)
|
||||
{
|
||||
instance = asset->getInstance();
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("ERROR: failed to find instance for entity %d", assetEntityId);
|
||||
return names;
|
||||
}
|
||||
}
|
||||
|
||||
size_t skinCount = instance->getSkinCount();
|
||||
|
||||
if (skinCount > 1)
|
||||
{
|
||||
Log("WARNING - skin count > 1 not currently implemented. This will probably not work");
|
||||
}
|
||||
|
||||
size_t numJoints = instance->getJointCountAt(skinIndex);
|
||||
auto joints = instance->getJointsAt(skinIndex);
|
||||
for (int i = 0; i < numJoints; i++)
|
||||
{
|
||||
const char *jointName = _ncm->getName(_ncm->getInstance(joints[i]));
|
||||
names->push_back(jointName);
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
|
||||
void SceneManager::transformToUnitCube(EntityId entityId)
|
||||
{
|
||||
const auto *instance = getInstanceByEntityId(entityId);
|
||||
|
||||
Reference in New Issue
Block a user