use boneName instead of boneIndex for setBoneTransform
This commit is contained in:
@@ -62,10 +62,10 @@ namespace polyvox
|
||||
/// @param entityId
|
||||
/// @param entityName
|
||||
/// @param skinIndex
|
||||
/// @param boneIndex
|
||||
/// @param boneName
|
||||
/// @param transform
|
||||
/// @return
|
||||
bool setBoneTransform(EntityId entityId, const char *entityName, int skinIndex, int boneIndex, math::mat4f transform);
|
||||
bool setBoneTransform(EntityId entityId, const char *entityName, int skinIndex, const char* boneName, math::mat4f transform);
|
||||
|
||||
/// @brief Set frame data to animate the given bones/entities.
|
||||
/// @param entity
|
||||
|
||||
@@ -127,7 +127,7 @@ extern "C"
|
||||
EntityId asset,
|
||||
const char *entityName,
|
||||
const float *const transform,
|
||||
int boneIndex);
|
||||
const char *boneName);
|
||||
FLUTTER_PLUGIN_EXPORT void play_animation(void *assetManager, EntityId asset, int index, bool loop, bool reverse, bool replaceActive, float crossfade);
|
||||
FLUTTER_PLUGIN_EXPORT void set_animation_frame(void *assetManager, EntityId asset, int animationIndex, int animationFrame);
|
||||
FLUTTER_PLUGIN_EXPORT void stop_animation(void *assetManager, EntityId asset, int index);
|
||||
|
||||
@@ -389,10 +389,10 @@ namespace polyvox
|
||||
}
|
||||
}
|
||||
|
||||
bool AssetManager::setBoneTransform(EntityId entityId, const char *entityName, int32_t skinIndex, int32_t boneIndex, math::mat4f localTransform)
|
||||
bool AssetManager::setBoneTransform(EntityId entityId, const char *entityName, int32_t skinIndex, const char* boneName, math::mat4f localTransform)
|
||||
{
|
||||
|
||||
Log("Setting transform for bone %d/skin %d for mesh target %s", boneIndex, skinIndex, entityName);
|
||||
Log("Setting transform for bone %s/skin %d for mesh target %s", boneName, skinIndex, entityName);
|
||||
|
||||
const auto &pos = _entityIdLookup.find(entityId);
|
||||
if (pos == _entityIdLookup.end())
|
||||
@@ -411,6 +411,25 @@ namespace polyvox
|
||||
TransformManager &transformManager = _engine->getTransformManager();
|
||||
|
||||
const auto &filamentInstance = sceneAsset.asset->getInstance();
|
||||
|
||||
int numJoints = filamentInstance->getJointCountAt(skinIndex);
|
||||
auto joints = filamentInstance->getJointsAt(skinIndex);
|
||||
int boneIndex = -1;
|
||||
for (int i = 0; i < numJoints; i++)
|
||||
{
|
||||
const char *jointName = _ncm->getName(_ncm->getInstance(joints[i]));
|
||||
if (strcmp(jointName, boneName) == 0)
|
||||
{
|
||||
boneIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(boneIndex == -1) {
|
||||
Log("Failed to find bone %s", boneName);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
utils::Entity joint = filamentInstance->getJointsAt(skinIndex)[boneIndex];
|
||||
|
||||
if (joint.isNull())
|
||||
|
||||
@@ -344,7 +344,7 @@ extern "C"
|
||||
EntityId entityId,
|
||||
const char *entityName,
|
||||
const float *const transform,
|
||||
int boneIndex)
|
||||
const char* boneName)
|
||||
{
|
||||
|
||||
auto matrix = math::mat4f(
|
||||
@@ -362,7 +362,7 @@ extern "C"
|
||||
transform[13],
|
||||
transform[14],
|
||||
transform[15]);
|
||||
return ((AssetManager *)assetManager)->setBoneTransform(entityId, entityName, 0, boneIndex, matrix);
|
||||
return ((AssetManager *)assetManager)->setBoneTransform(entityId, entityName, 0, boneName, matrix);
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void play_animation(
|
||||
|
||||
Reference in New Issue
Block a user