<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:re="http://purl.org/atompub/rank/1.0">
    <title type="text">Newest questions tagged assimp - Stack Overflow</title>
    <link rel="self" href="https://stackoverflow.com/feeds/tag?tagnames=assimp&amp;sort=newest" type="application/atom+xml" />
    <link rel="alternate" href="https://stackoverflow.com/questions/tagged/?tagnames=assimp&amp;sort=newest" type="text/html" />
    <subtitle>most recent 30 from stackoverflow.com</subtitle>
    <updated>2025-08-05T13:24:23Z</updated>
    <id>https://stackoverflow.com/feeds/tag?tagnames=assimp&amp;sort=newest</id>
    <creativeCommons:license>https://creativecommons.org/licenses/by-sa/4.0/rdf</creativeCommons:license> 
    <entry>
        <id>https://stackoverflow.com/q/79716429</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">Animation not animating correctly in assimp [closed]</title>
            <category scheme="https://stackoverflow.com/tags" term="c" />
            <category scheme="https://stackoverflow.com/tags" term="animation" />
            <category scheme="https://stackoverflow.com/tags" term="vulkan" />
            <category scheme="https://stackoverflow.com/tags" term="assimp" />
        <author>
            <name>Slugarius Maximur</name>
            <uri>https://stackoverflow.com/users/28527649</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/79716429/animation-not-animating-correctly-in-assimp" />
        <published>2025-07-27T13:19:32Z</published>
        <updated>2025-07-27T13:19:32Z</updated>
        <summary type="html">
            &lt;p&gt;I&#x27;m using assimp in my C game engine (which uses Vulkan) to try and animate a model but it&#x27;s animating extremely weirdly. The animation implementation is based off the learnopengl.com skeletal animation tutorial. Bone class:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;typedef struct skBone&#xA;{&#xA;    skVector* positions; // skPosition&#xA;    skVector* rotations; // skRotation&#xA;    skVector* scales; // skScale&#xA;    int numPositions;&#xA;    int numRotations;&#xA;    int numScales;&#xA;&#xA;    mat4 localTransform;&#xA;    char name[128];&#xA;    int ID;&#xA;} skBone;&#xA;&#xA;skBone skBone_Create(const char* name, int ID,&#xA;                     const struct aiNodeAnim* channel)&#xA;{&#xA;    skBone bone = {0};&#xA;&#xA;    strcpy(bone.name, name);&#xA;    bone.ID = ID;&#xA;    glm_mat4_identity(bone.localTransform);&#xA;&#xA;    // Initialize all keyframes by acessing them through assimp&#xA;&#xA;    bone.positions = skVector_Create(sizeof(skKeyPosition), 5);&#xA;    bone.rotations = skVector_Create(sizeof(skKeyRotation), 5);&#xA;    bone.scales = skVector_Create(sizeof(skKeyScale), 5);&#xA;&#xA;    bone.numPositions = channel-&amp;gt;mNumPositionKeys;&#xA;    for (int positionIndex = 0; positionIndex &amp;lt; bone.numPositions;&#xA;         &#x2B;&#x2B;positionIndex)&#xA;    {&#xA;        const struct aiVector3D aiPosition =&#xA;            channel-&amp;gt;mPositionKeys[positionIndex].mValue;&#xA;        float timeStamp = channel-&amp;gt;mPositionKeys[positionIndex].mTime;&#xA;        skKeyPosition data;&#xA;        skAssimpVec3ToGLM(&amp;amp;aiPosition, data.position);&#xA;        data.timeStamp = timeStamp;&#xA;&#xA;        skVector_PushBack(bone.positions, &amp;amp;data);&#xA;    }&#xA;&#xA;    bone.numRotations = channel-&amp;gt;mNumRotationKeys;&#xA;    for (int rotationIndex = 0; rotationIndex &amp;lt; bone.numRotations;&#xA;         &#x2B;&#x2B;rotationIndex)&#xA;    {&#xA;        const struct aiQuaternion aiOrientation =&#xA;            channel-&amp;gt;mRotationKeys[rotationIndex].mValue;&#xA;        float timeStamp = channel-&amp;gt;mRotationKeys[rotationIndex].mTime;&#xA;        skKeyRotation data;&#xA;        data.rotation[0] = aiOrientation.w;&#xA;        data.rotation[1] = aiOrientation.x;&#xA;        data.rotation[2] = aiOrientation.y;&#xA;        data.rotation[3] = aiOrientation.z;&#xA;        data.timeStamp = timeStamp;&#xA;&#xA;        skVector_PushBack(bone.rotations, &amp;amp;data);&#xA;    }&#xA;&#xA;    bone.numScales = channel-&amp;gt;mNumScalingKeys;&#xA;    for (int keyIndex = 0; keyIndex &amp;lt; bone.numScales; &#x2B;&#x2B;keyIndex)&#xA;    {&#xA;        const struct aiVector3D scale =&#xA;            channel-&amp;gt;mScalingKeys[keyIndex].mValue;&#xA;        float      timeStamp = channel-&amp;gt;mScalingKeys[keyIndex].mTime;&#xA;        skKeyScale data;&#xA;        skAssimpVec3ToGLM(&amp;amp;scale, data.scale);&#xA;        data.timeStamp = timeStamp;&#xA;&#xA;        skVector_PushBack(bone.scales, &amp;amp;data);&#xA;    }&#xA;&#xA;    return bone;&#xA;}&#xA;&#xA;int skBone_GetPositionIndex(skBone* bone, float animationTime)&#xA;{&#xA;    for (int index = 0; index &amp;lt; bone-&amp;gt;numPositions - 1; &#x2B;&#x2B;index)&#xA;    {&#xA;        skKeyPosition* pos =&#xA;            (skKeyPosition*)skVector_Get(bone-&amp;gt;positions, index &#x2B; 1);&#xA;&#xA;        if (animationTime &amp;lt; pos-&amp;gt;timeStamp)&#xA;            return index;&#xA;    }&#xA;    assert(0);&#xA;}&#xA;&#xA;int skBone_GetRotationIndex(skBone* bone, float animationTime)&#xA;{&#xA;    for (int index = 0; index &amp;lt; bone-&amp;gt;numRotations - 1; &#x2B;&#x2B;index)&#xA;    {&#xA;        skKeyRotation* rot =&#xA;            (skKeyRotation*)skVector_Get(bone-&amp;gt;rotations, index &#x2B; 1);&#xA;&#xA;        if (animationTime &amp;lt; rot-&amp;gt;timeStamp)&#xA;            return index;&#xA;    }&#xA;    assert(0);&#xA;}&#xA;&#xA;int skBone_GetScaleIndex(skBone* bone, float animationTime)&#xA;{&#xA;    for (int index = 0; index &amp;lt; bone-&amp;gt;numScales - 1; &#x2B;&#x2B;index)&#xA;    {&#xA;        skKeyScale* scale =&#xA;            (skKeyScale*)skVector_Get(bone-&amp;gt;scales, index &#x2B; 1);&#xA;&#xA;        if (animationTime &amp;lt; scale-&amp;gt;timeStamp)&#xA;            return index;&#xA;    }&#xA;    assert(0);&#xA;}&#xA;&#xA;float skGetScaleFactor(float lastTimeStamp, float nextTimeStamp,&#xA;                       float animationTime)&#xA;{&#xA;    float scaleFactor = 0.0f;&#xA;    float midWayLength = animationTime - lastTimeStamp;&#xA;    float framesDiff = nextTimeStamp - lastTimeStamp;&#xA;    scaleFactor = midWayLength / framesDiff;&#xA;    return scaleFactor;&#xA;}&#xA;&#xA;void skBone_InterpolatePosition(skBone* bone, float animationTime,&#xA;                                mat4 dest)&#xA;{&#xA;    if (bone-&amp;gt;numPositions == 1)&#xA;    {&#xA;        skKeyPosition* pos =&#xA;            (skKeyPosition*)skVector_Get(bone-&amp;gt;positions, 0);&#xA;        glm_translate(dest, pos-&amp;gt;position);&#xA;        return;&#xA;    }&#xA;&#xA;    int p0Index = skBone_GetPositionIndex(bone, animationTime);&#xA;    int p1Index = p0Index &#x2B; 1;&#xA;&#xA;    skKeyPosition* key1 =&#xA;        (skKeyPosition*)skVector_Get(bone-&amp;gt;positions, p0Index);&#xA;    skKeyPosition* key2 =&#xA;        (skKeyPosition*)skVector_Get(bone-&amp;gt;positions, p1Index);&#xA;&#xA;    float scaleFactor = skGetScaleFactor(&#xA;        key1-&amp;gt;timeStamp, key2-&amp;gt;timeStamp, animationTime);&#xA;&#xA;    vec3 finalPosition;&#xA;    glm_vec3_mix(key1-&amp;gt;position, key2-&amp;gt;position, scaleFactor,&#xA;                 finalPosition);&#xA;&#xA;    glm_translate(dest, finalPosition);&#xA;}&#xA;&#xA;void skBone_InterpolateRotation(skBone* bone, float animationTime,&#xA;                                mat4 dest)&#xA;{&#xA;    if (bone-&amp;gt;numRotations == 1)&#xA;    {&#xA;        skKeyRotation* rot =&#xA;            (skKeyRotation*)skVector_Get(bone-&amp;gt;rotations, 0);&#xA;        glm_quat_mat4(rot-&amp;gt;rotation, dest);&#xA;        return;&#xA;    }&#xA;&#xA;    int p0Index = skBone_GetRotationIndex(bone, animationTime);&#xA;    int p1Index = p0Index &#x2B; 1;&#xA;&#xA;    skKeyRotation* key1 =&#xA;        (skKeyRotation*)skVector_Get(bone-&amp;gt;rotations, p0Index);&#xA;    skKeyRotation* key2 =&#xA;        (skKeyRotation*)skVector_Get(bone-&amp;gt;rotations, p1Index);&#xA;&#xA;    float scaleFactor = skGetScaleFactor(&#xA;        key1-&amp;gt;timeStamp, key2-&amp;gt;timeStamp, animationTime);&#xA;&#xA;    vec4 finalRotation;&#xA;    glm_quat_slerp(key1-&amp;gt;rotation, key2-&amp;gt;rotation, scaleFactor,&#xA;                   finalRotation);&#xA;&#xA;    glm_quat_mat4(finalRotation, dest);&#xA;}&#xA;&#xA;void skBone_InterpolateScale(skBone* bone, float animationTime,&#xA;                             mat4 dest)&#xA;{&#xA;    if (bone-&amp;gt;numScales == 1)&#xA;    {&#xA;        skKeyScale* scale =&#xA;            (skKeyScale*)skVector_Get(bone-&amp;gt;scales, 0);&#xA;        glm_scale(dest, scale-&amp;gt;scale);&#xA;        return;&#xA;    }&#xA;&#xA;    int   p0Index = skBone_GetScaleIndex(bone, animationTime);&#xA;    int   p1Index = p0Index &#x2B; 1;&#xA;    float scaleFactor = skGetScaleFactor(&#xA;        ((skKeyScale*)skVector_Get(bone-&amp;gt;scales, p0Index))-&amp;gt;timeStamp,&#xA;        ((skKeyScale*)skVector_Get(bone-&amp;gt;scales, p1Index))-&amp;gt;timeStamp,&#xA;        animationTime);&#xA;&#xA;    vec3 finalScale;&#xA;    glm_vec3_mix(&#xA;        ((skKeyScale*)skVector_Get(bone-&amp;gt;scales, p0Index))-&amp;gt;scale,&#xA;        ((skKeyScale*)skVector_Get(bone-&amp;gt;scales, p1Index))-&amp;gt;scale,&#xA;        scaleFactor, finalScale);&#xA;&#xA;    glm_scale(dest, finalScale);&#xA;}&#xA;&#xA;void skBone_Update(skBone* bone, float animationTime)&#xA;{&#xA;    mat4 trans = GLM_MAT4_IDENTITY_INIT,&#xA;         rotation = GLM_MAT4_IDENTITY_INIT,&#xA;         scale = GLM_MAT4_IDENTITY_INIT;&#xA;    skBone_InterpolatePosition(bone, animationTime, trans);&#xA;    skBone_InterpolateRotation(bone, animationTime, rotation);&#xA;    skBone_InterpolateScale(bone, animationTime, scale);&#xA;    glm_mat4_mul(trans, rotation, bone-&amp;gt;localTransform);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Animator and animation class:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;typedef struct skAnimation&#xA;{&#xA;    skVector* bones; // skBone&#xA;    skMap* boneInfoMap; // char*, skBoneInfo&#xA;    float duration;&#xA;    int ticksPerSecond;&#xA;    skAssimpNodeData rootNode;&#xA;    mat4 inverseGlobalTransformation;&#xA;} skAnimation;&#xA;&#xA;typedef struct skAnimator&#xA;{&#xA;    skVector* finalBoneMatrices; // mat4&#xA;    skAnimation* currentAnimation;&#xA;    float currentTime;&#xA;    float deltaTime;&#xA;} skAnimator;&#xA;&#xA;skAnimation skAnimation_Create(const char* animationPath,&#xA;                               skModel*    model)&#xA;{&#xA;    skAnimation animation = {0};&#xA;&#xA;    animation.bones = skVector_Create(sizeof(skBone), 16);&#xA;    animation.boneInfoMap = model-&amp;gt;boneInfoMap;&#xA;&#xA;    const struct aiScene* scene = aiImportFile(&#xA;        animationPath, aiProcess_Triangulate);&#xA;&#xA;    struct aiMatrix4x4 globalTransformation =&#xA;        scene-&amp;gt;mRootNode-&amp;gt;mTransformation;&#xA;    aiMatrix4Inverse(&amp;amp;globalTransformation);&#xA;    skAssimpMat4ToGLM(&amp;amp;globalTransformation,&#xA;                      animation.inverseGlobalTransformation);&#xA;&#xA;    if (!scene || !scene-&amp;gt;mRootNode || !scene-&amp;gt;mNumAnimations)&#xA;    {&#xA;        printf(&amp;quot;Error: Failed to load animation file: %s\n&amp;quot;,&#xA;               animationPath);&#xA;        return animation;&#xA;    }&#xA;&#xA;    const struct aiAnimation* aiAnim = scene-&amp;gt;mAnimations[0];&#xA;    animation.duration = (float)aiAnim-&amp;gt;mDuration;&#xA;    animation.ticksPerSecond = (int)aiAnim-&amp;gt;mTicksPerSecond;&#xA;&#xA;    skAnimation_ReadHierarchyData(&amp;amp;animation.rootNode,&#xA;                                  scene-&amp;gt;mRootNode);&#xA;&#xA;    skAnimation_ReadMissingBones(&amp;amp;animation, aiAnim, model);&#xA;&#xA;    aiReleaseImport(scene);&#xA;&#xA;    return animation;&#xA;}&#xA;&#xA;void skAnimation_Free(skAnimation* animation)&#xA;{&#xA;    if (!animation)&#xA;        return;&#xA;&#xA;    if (animation-&amp;gt;bones)&#xA;    {&#xA;        for (size_t i = 0; i &amp;lt; animation-&amp;gt;bones-&amp;gt;size; i&#x2B;&#x2B;)&#xA;        {&#xA;            skBone* bone = (skBone*)skVector_Get(animation-&amp;gt;bones, i);&#xA;            if (bone)&#xA;            {&#xA;                if (bone-&amp;gt;positions)&#xA;                    skVector_Free(bone-&amp;gt;positions);&#xA;                if (bone-&amp;gt;rotations)&#xA;                    skVector_Free(bone-&amp;gt;rotations);&#xA;                if (bone-&amp;gt;scales)&#xA;                    skVector_Free(bone-&amp;gt;scales);&#xA;            }&#xA;        }&#xA;        skVector_Free(animation-&amp;gt;bones);&#xA;    }&#xA;&#xA;    skAssimpNodeData_Free(&amp;amp;animation-&amp;gt;rootNode);&#xA;&#xA;    // boneInfoMap isn&#x27;t freed here as it belongs to the model&#xA;&#xA;    *animation = (skAnimation) {0};&#xA;}&#xA;&#xA;skBone* skAnimation_FindBone(skAnimation* animation, const char* name)&#xA;{&#xA;    if (!animation || !animation-&amp;gt;bones || !name)&#xA;        return NULL;&#xA;&#xA;    for (size_t i = 0; i &amp;lt; animation-&amp;gt;bones-&amp;gt;size; i&#x2B;&#x2B;)&#xA;    {&#xA;        skBone* bone = (skBone*)skVector_Get(animation-&amp;gt;bones, i);&#xA;        if (bone &amp;amp;&amp;amp; strcmp(bone-&amp;gt;name, name) == 0)&#xA;        {&#xA;            return bone;&#xA;        }&#xA;    }&#xA;&#xA;    return NULL;&#xA;}&#xA;&#xA;void skAnimation_ReadMissingBones(skAnimation*              animation,&#xA;                                  const struct aiAnimation* aiAnim,&#xA;                                  skModel*                  model)&#xA;{&#xA;    if (!animation || !aiAnim || !model)&#xA;        return;&#xA;&#xA;    int size = (int)aiAnim-&amp;gt;mNumChannels;&#xA;&#xA;    // Process each channel (bone) in the animation&#xA;    for (int i = 0; i &amp;lt; size; i&#x2B;&#x2B;)&#xA;    {&#xA;        const struct aiNodeAnim* channel = aiAnim-&amp;gt;mChannels[i];&#xA;        const char* boneNamePtr = channel-&amp;gt;mNodeName.data;&#xA;&#xA;        // Check if bone exists in model&#x27;s bone info map&#xA;        if (!skMap_Contains(model-&amp;gt;boneInfoMap, &amp;amp;boneNamePtr))&#xA;        {&#xA;            // Add new bone info to model&#x27;s map&#xA;            skBoneInfo newBoneInfo;&#xA;            newBoneInfo.id = model-&amp;gt;boneCount;&#xA;            glm_mat4_identity(newBoneInfo.offset);&#xA;&#xA;            skMap_Insert(model-&amp;gt;boneInfoMap, &amp;amp;boneNamePtr,&#xA;                         &amp;amp;newBoneInfo);&#xA;            model-&amp;gt;boneCount&#x2B;&#x2B;;&#xA;        }&#xA;&#xA;        // Get bone info from map&#xA;        skBoneInfo* boneInfo =&#xA;            (skBoneInfo*)skMap_Get(model-&amp;gt;boneInfoMap, &amp;amp;boneNamePtr);&#xA;&#xA;        // Create bone object and add to animation&#xA;        skBone bone =&#xA;            skBone_Create(boneNamePtr, boneInfo-&amp;gt;id, channel);&#xA;        skVector_PushBack(animation-&amp;gt;bones, &amp;amp;bone);&#xA;    }&#xA;}&#xA;&#xA;void skAnimation_ReadHierarchyData(skAssimpNodeData*    dest,&#xA;                                   const struct aiNode* src)&#xA;{&#xA;    if (!dest || !src)&#xA;        return;&#xA;&#xA;    // Copy node name&#xA;    strncpy(dest-&amp;gt;name, src-&amp;gt;mName.data, sizeof(dest-&amp;gt;name) - 1);&#xA;    dest-&amp;gt;name[sizeof(dest-&amp;gt;name) - 1] = &#x27;\0&#x27;;&#xA;&#xA;    // Convert Assimp matrix to CGLM matrix&#xA;    skAssimpMat4ToGLM(&amp;amp;src-&amp;gt;mTransformation, dest-&amp;gt;transformation);&#xA;&#xA;    dest-&amp;gt;childrenCount = (int)src-&amp;gt;mNumChildren;&#xA;&#xA;    // Initialize children vector&#xA;    dest-&amp;gt;children = skVector_Create(sizeof(skAssimpNodeData),&#xA;                                     dest-&amp;gt;childrenCount);&#xA;&#xA;    for (int i = 0; i &amp;lt; dest-&amp;gt;childrenCount; i&#x2B;&#x2B;)&#xA;    {&#xA;        skAssimpNodeData childData = {0};&#xA;        skAnimation_ReadHierarchyData(&amp;amp;childData, src-&amp;gt;mChildren[i]);&#xA;        skVector_PushBack(dest-&amp;gt;children, &amp;amp;childData);&#xA;    }&#xA;}&#xA;&#xA;void skAssimpNodeData_Free(skAssimpNodeData* nodeData)&#xA;{&#xA;    if (!nodeData)&#xA;        return;&#xA;&#xA;    if (nodeData-&amp;gt;children)&#xA;    {&#xA;        // Recursively free children&#xA;        for (size_t i = 0; i &amp;lt; nodeData-&amp;gt;children-&amp;gt;size; i&#x2B;&#x2B;)&#xA;        {&#xA;            skAssimpNodeData* child = (skAssimpNodeData*)skVector_Get(&#xA;                nodeData-&amp;gt;children, i);&#xA;            if (child)&#xA;            {&#xA;                skAssimpNodeData_Free(child);&#xA;            }&#xA;        }&#xA;        skVector_Free(nodeData-&amp;gt;children);&#xA;        nodeData-&amp;gt;children = NULL;&#xA;    }&#xA;}&#xA;&#xA;// Get bone by index&#xA;skBone* skAnimation_GetBone(skAnimation* animation, size_t index)&#xA;{&#xA;    if (!animation || !animation-&amp;gt;bones ||&#xA;        index &amp;gt;= animation-&amp;gt;bones-&amp;gt;size)&#xA;    {&#xA;        return NULL;&#xA;    }&#xA;    return (skBone*)skVector_Get(animation-&amp;gt;bones, index);&#xA;}&#xA;&#xA;// Check if animation is valid&#xA;int skAnimation_IsValid(skAnimation* animation)&#xA;{&#xA;    return animation &amp;amp;&amp;amp; animation-&amp;gt;bones &amp;amp;&amp;amp;&#xA;           animation-&amp;gt;bones-&amp;gt;size &amp;gt; 0 &amp;amp;&amp;amp; animation-&amp;gt;duration &amp;gt; 0.0f;&#xA;}&#xA;&#xA;skAnimator skAnimator_Create(skAnimation* animation)&#xA;{&#xA;    skAnimator anim = {0};&#xA;&#xA;    anim.currentTime = 0.0f;&#xA;    anim.currentAnimation = animation;&#xA;&#xA;    anim.finalBoneMatrices = skVector_Create(sizeof(mat4), 100);&#xA;&#xA;    for (int i = 0; i &amp;lt; 100; i&#x2B;&#x2B;)&#xA;    {&#xA;        mat4 ident = GLM_MAT4_IDENTITY_INIT;&#xA;        skVector_PushBack(anim.finalBoneMatrices, &amp;amp;ident);&#xA;    }&#xA;&#xA;    return anim;&#xA;}&#xA;&#xA;void skAnimator_UpdateAnimation(skAnimator* animator, float dt)&#xA;{&#xA;    animator-&amp;gt;deltaTime = dt;&#xA;    if (animator-&amp;gt;currentAnimation)&#xA;    {&#xA;        animator-&amp;gt;currentTime &#x2B;=&#xA;            animator-&amp;gt;currentAnimation-&amp;gt;ticksPerSecond * dt;&#xA;&#xA;        animator-&amp;gt;currentTime =&#xA;            fmod(animator-&amp;gt;currentTime,&#xA;                 animator-&amp;gt;currentAnimation-&amp;gt;duration);&#xA;&#xA;        skAnimator_CalculateBoneTransform(&#xA;            animator, &amp;amp;animator-&amp;gt;currentAnimation-&amp;gt;rootNode,&#xA;            GLM_MAT4_IDENTITY);&#xA;    }&#xA;}&#xA;&#xA;void skAnimator_PlayAnimation(skAnimator* animator, skAnimation* anim)&#xA;{&#xA;    animator-&amp;gt;currentAnimation = anim;&#xA;    animator-&amp;gt;currentTime = 0.0f;&#xA;}&#xA;&#xA;void skAnimator_CalculateBoneTransform(skAnimator*       animator,&#xA;                                       skAssimpNodeData* node,&#xA;                                       mat4 parentTransform)&#xA;{&#xA;    skBone* bone =&#xA;        skAnimation_FindBone(animator-&amp;gt;currentAnimation, node-&amp;gt;name);&#xA;&#xA;    mat4 nodeTransform;&#xA;    glm_mat4_copy(node-&amp;gt;transformation, nodeTransform);&#xA;&#xA;    if (bone)&#xA;    {&#xA;        skBone_Update(bone, animator-&amp;gt;currentTime);&#xA;        glm_mat4_copy(bone-&amp;gt;localTransform, nodeTransform);&#xA;    }&#xA;&#xA;    mat4 globalTransformation;&#xA;    glm_mat4_mul(parentTransform, nodeTransform,&#xA;                 globalTransformation);&#xA;&#xA;    const char* nodeName = &amp;amp;node-&amp;gt;name;&#xA;&#xA;    if (skMap_Contains(animator-&amp;gt;currentAnimation-&amp;gt;boneInfoMap,&#xA;                       &amp;amp;nodeName))&#xA;    {&#xA;        skBoneInfo* info = (skBoneInfo*)skMap_Get(&#xA;            animator-&amp;gt;currentAnimation-&amp;gt;boneInfoMap, &amp;amp;nodeName);&#xA;&#xA;        int index = info-&amp;gt;id;&#xA;&#xA;        mat4 bruhMat;&#xA;        glm_mat4_mul(globalTransformation, info-&amp;gt;offset, bruhMat);&#xA;&#xA;        mat4* boneMat =&#xA;            (mat4*)skVector_Get(animator-&amp;gt;finalBoneMatrices, index);&#xA;        glm_mat4_copy(bruhMat, *boneMat);&#xA;    }&#xA;&#xA;    for (int i = 0; i &amp;lt; node-&amp;gt;childrenCount; i&#x2B;&#x2B;)&#xA;    {&#xA;        skAssimpNodeData* nodeData =&#xA;            (skAssimpNodeData*)skVector_Get(node-&amp;gt;children, i);&#xA;&#xA;        skAnimator_CalculateBoneTransform(&#xA;            animator, nodeData,&#xA;            globalTransformation);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The animator class has a vector of bone matrices which I then feed to the vertex shader which transforms the vertices by the bone matrices but something is clearly going wrong here. The bone weights and IDs are transferring correctly I&#x27;m pretty sure as when I input them into the fragment shader to visualize them, they do have seemingly correct values even though Vulkan does scream at me and says &lt;code&gt;Vertex attribute at location 6 and 7 not consumed by vertex shader&lt;/code&gt; even though they clearly are.&#xA;I don&#x27;t know what I&#x27;m doing wrong here.&lt;/p&gt;&#xA;&lt;p&gt;Result: &lt;a href=&quot;https://i.sstatic.net/zCCRVx5n.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.sstatic.net/zCCRVx5n.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Expected result:&#xA;&lt;a href=&quot;https://i.sstatic.net/O9iaz9T1.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.sstatic.net/O9iaz9T1.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The model is moving slightly and the movements look natural, though it&#x27;s obviously incorrect.&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/79699476</id>
        <re:rank scheme="https://stackoverflow.com">2</re:rank>
        <title type="text">What is the purpose of the pkey parameter?</title>
            <category scheme="https://stackoverflow.com/tags" term="c" />
            <category scheme="https://stackoverflow.com/tags" term="assimp" />
        <author>
            <name>user1785730</name>
            <uri>https://stackoverflow.com/users/1785730</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/79699476/what-is-the-purpose-of-the-pkey-parameter" />
        <published>2025-07-12T18:02:41Z</published>
        <updated>2025-07-13T19:50:58Z</updated>
        <summary type="html">
            &lt;p&gt;I want to read a diffuse texture like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;aiGetMaterialString(material,&#xA;                    AI_MATKEY_COLOR_DIFFUSE, // this is the pkey parameter&#xA;                    aiTextureType_DIFFUSE,&#xA;                    0,&#xA;                    path);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Why is there a pkey parameter? Is it not enough to specify the type?&lt;/p&gt;&#xA;&lt;p&gt;Anyway, the &lt;code&gt;path&lt;/code&gt; string is empty after calling above function. I was expecting to get the filename of the texture.&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/79689152</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">Reading a 3D model with lwjgl-assimp failes in Clojure</title>
            <category scheme="https://stackoverflow.com/tags" term="clojure" />
            <category scheme="https://stackoverflow.com/tags" term="lwjgl" />
            <category scheme="https://stackoverflow.com/tags" term="assimp" />
        <author>
            <name>user1785730</name>
            <uri>https://stackoverflow.com/users/1785730</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/79689152/reading-a-3d-model-with-lwjgl-assimp-failes-in-clojure" />
        <published>2025-07-03T16:06:35Z</published>
        <updated>2025-07-05T20:38:24Z</updated>
        <summary type="html">
            &lt;p&gt;This is my Clojure code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;(ns learnopengl.mesh-model&#xA;  (:import [org.lwjgl.assimp Assimp AINode AIMesh]))&#xA;&#xA;(defn read-model&#xA;  &amp;quot;read a 3D model from a file&amp;quot;&#xA;  [path]&#xA;  (let [scene (Assimp/aiImportFile path (bit-or Assimp/aiProcess_Triangulate&#xA;                                                Assimp/aiProcess_FlipUVs))]&#xA;    (if (= scene nil)&#xA;      (println (Assimp/aiGetErrorString))&#xA;      (for [index (range (.mNumMeshes scene))]&#xA;        (do&#xA;          (println index)&#xA;          (AIMesh/create (.get (.mMeshes scene) index)))))))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;which fails with:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;0&#xA;Execution error (IllegalArgumentException) at java.nio.Buffer/createCapacityException (Buffer.java:290).&#xA;capacity &amp;lt; 0: (-576307456 &amp;lt; 0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This happens inside AIMesh/create.&lt;/p&gt;&#xA;&lt;p&gt;Believing I may have encountered a bug, I rewrote the snippet in Java:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import org.lwjgl.assimp.Assimp;&#xA;import org.lwjgl.assimp.AIScene;&#xA;import org.lwjgl.assimp.AIMesh;&#xA;&#xA;class Test {&#xA;    public static void main(String[] args) {&#xA;        AIScene scene = Assimp.aiImportFile(&amp;quot;backpack/backpack.obj&amp;quot;, Assimp.aiProcess_Triangulate);&#xA;        if (scene == null) {&#xA;            System.out.println(Assimp.aiGetErrorString());&#xA;        } else {&#xA;            for (int i = 0; i &amp;lt; scene.mNumMeshes(); i&#x2B;&#x2B;) {&#xA;                System.out.println(i);&#xA;                AIMesh mesh = AIMesh.create(scene.mMeshes().get(i));&#xA;            }&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The Java code however runs smoothly. I don&#x27;t understand why, since I believe the two snippets to be essentially the same. Can someone spot where I may have gone wrong in the Clojure code?&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://learnopengl.com/data/models/backpack.zip&quot; rel=&quot;nofollow noreferrer&quot;&gt;This is the 3D model I&#x27;ve been testing with.&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit:&lt;/strong&gt; This is my project.clj:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;(defproject learnopengl &amp;quot;0.1.0-SNAPSHOT&amp;quot;&#xA;  :description &amp;quot;learnopengl book code&amp;quot;&#xA;  :url &amp;quot;learnopengl.com&amp;quot;&#xA;  :license {:name &amp;quot;EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0&amp;quot;&#xA;            :url &amp;quot;https://www.eclipse.org/legal/epl-2.0/&amp;quot;}&#xA;  :dependencies [[org.clojure/clojure &amp;quot;1.11.1&amp;quot;]&#xA;                 [org.lwjgl/lwjgl &amp;quot;3.3.6&amp;quot;]&#xA;                 [org.lwjgl/lwjgl &amp;quot;3.3.6&amp;quot; :classifier &amp;quot;natives-linux&amp;quot;]&#xA;                 [org.lwjgl/lwjgl-opengl &amp;quot;3.3.6&amp;quot;]&#xA;                 [org.lwjgl/lwjgl-opengl &amp;quot;3.3.6&amp;quot; :classifier &amp;quot;natives-linux&amp;quot;]&#xA;                 [org.lwjgl/lwjgl-stb &amp;quot;3.3.6&amp;quot;]&#xA;                 [org.lwjgl/lwjgl-stb &amp;quot;3.3.6&amp;quot; :classifier &amp;quot;natives-linux&amp;quot;]&#xA;                 [org.lwjgl/lwjgl-glfw &amp;quot;3.3.6&amp;quot;]&#xA;                 [org.lwjgl/lwjgl-glfw &amp;quot;3.3.6&amp;quot; :classifier &amp;quot;natives-linux&amp;quot;]&#xA;                 [org.lwjgl/lwjgl-assimp &amp;quot;3.3.6&amp;quot;]&#xA;                 [org.lwjgl/lwjgl-assimp &amp;quot;3.3.6&amp;quot; :classifier &amp;quot;natives-linux&amp;quot;]&#xA;                 [org.joml/joml &amp;quot;1.10.8&amp;quot;]]&#xA;  :main ^:skip-aot learnopengl.core&#xA;  :target-path &amp;quot;target/%s&amp;quot;&#xA;  :profiles {:uberjar {:aot :all&#xA;                       :jvm-opts [&amp;quot;-Dclojure.compiler.direct-linking=true&amp;quot;]}})&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit2:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is my &lt;a href=&quot;https://github.com/cyberdynesoftware/learnopengl/commit/6e0943c11d51a46591dbdd716f4216247aef9ba3&quot; rel=&quot;nofollow noreferrer&quot;&gt;repository&lt;/a&gt; with the full code that breaks for me. &lt;code&gt;read-model&lt;/code&gt; is defined in mesh-model.clj, and it is called an line 11 in core.clj.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Edit3:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is the content from the /tmp/clojure-xxx.edn file produced for the crash, which contains the stack trace:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;{:clojure.main/message&#xA; &amp;quot;Execution error (IllegalArgumentException) at java.nio.Buffer/createCapacityException (Buffer.java:290).\ncapacity &amp;lt; 0: (-689151616 &amp;lt; 0)\n&amp;quot;,&#xA; :clojure.main/triage&#xA; {:clojure.error/class java.lang.IllegalArgumentException,&#xA;  :clojure.error/line 290,&#xA;  :clojure.error/cause &amp;quot;capacity &amp;lt; 0: (-689151616 &amp;lt; 0)&amp;quot;,&#xA;  :clojure.error/symbol java.nio.Buffer/createCapacityException,&#xA;  :clojure.error/source &amp;quot;Buffer.java&amp;quot;,&#xA;  :clojure.error/phase :execution},&#xA; :clojure.main/trace&#xA; {:via&#xA;  [{:type clojure.lang.Compiler$CompilerException,&#xA;    :message&#xA;    &amp;quot;Syntax error macroexpanding at (learnopengl/core.clj:12:1).&amp;quot;,&#xA;    :data&#xA;    {:clojure.error/phase :execution,&#xA;     :clojure.error/line 12,&#xA;     :clojure.error/column 1,&#xA;     :clojure.error/source &amp;quot;learnopengl/core.clj&amp;quot;},&#xA;    :at [clojure.lang.Compiler load &amp;quot;Compiler.java&amp;quot; 7665]}&#xA;   {:type java.lang.IllegalArgumentException,&#xA;    :message &amp;quot;capacity &amp;lt; 0: (-689151616 &amp;lt; 0)&amp;quot;,&#xA;    :at [java.nio.Buffer createCapacityException &amp;quot;Buffer.java&amp;quot; 290]}],&#xA;  :trace&#xA;  [[java.nio.Buffer createCapacityException &amp;quot;Buffer.java&amp;quot; 290]&#xA;   [java.nio.Buffer &amp;lt;init&amp;gt; &amp;quot;Buffer.java&amp;quot; 253]&#xA;   [java.nio.ByteBuffer &amp;lt;init&amp;gt; &amp;quot;ByteBuffer.java&amp;quot; 316]&#xA;   [java.nio.ByteBuffer &amp;lt;init&amp;gt; &amp;quot;ByteBuffer.java&amp;quot; 324]&#xA;   [java.nio.MappedByteBuffer &amp;lt;init&amp;gt; &amp;quot;MappedByteBuffer.java&amp;quot; 113]&#xA;   [java.nio.DirectByteBuffer &amp;lt;init&amp;gt; &amp;quot;DirectByteBuffer.java&amp;quot; 107]&#xA;   [java.nio.ByteBuffer allocateDirect &amp;quot;ByteBuffer.java&amp;quot; 360]&#xA;   [org.lwjgl.system.Struct __create &amp;quot;Struct.java&amp;quot; 118]&#xA;   [org.lwjgl.assimp.AIMesh create &amp;quot;AIMesh.java&amp;quot; 487]&#xA;   [jdk.internal.reflect.DirectMethodHandleAccessor&#xA;    invoke&#xA;    &amp;quot;DirectMethodHandleAccessor.java&amp;quot;&#xA;    103]&#xA;   [java.lang.reflect.Method invoke &amp;quot;Method.java&amp;quot; 580]&#xA;   [clojure.lang.Reflector invokeMatchingMethod &amp;quot;Reflector.java&amp;quot; 167]&#xA;   [clojure.lang.Reflector invokeStaticMethod &amp;quot;Reflector.java&amp;quot; 332]&#xA;   [learnopengl.mesh_model$read_model$iter__332__336$fn__337$fn__338&#xA;    invoke&#xA;    &amp;quot;mesh_model.clj&amp;quot;&#xA;    66]&#xA;   [learnopengl.mesh_model$read_model$iter__332__336$fn__337&#xA;    invoke&#xA;    &amp;quot;mesh_model.clj&amp;quot;&#xA;    63]&#xA;   [clojure.lang.LazySeq sval &amp;quot;LazySeq.java&amp;quot; 42]&#xA;   [clojure.lang.LazySeq seq &amp;quot;LazySeq.java&amp;quot; 51]&#xA;   [clojure.lang.RT seq &amp;quot;RT.java&amp;quot; 535]&#xA;   [clojure.lang.RT countFrom &amp;quot;RT.java&amp;quot; 650]&#xA;   [clojure.lang.RT count &amp;quot;RT.java&amp;quot; 643]&#xA;   [learnopengl.core$eval351 invokeStatic &amp;quot;core.clj&amp;quot; 12]&#xA;   [learnopengl.core$eval351 invoke &amp;quot;core.clj&amp;quot; 12]&#xA;   [clojure.lang.Compiler eval &amp;quot;Compiler.java&amp;quot; 7194]&#xA;   [clojure.lang.Compiler load &amp;quot;Compiler.java&amp;quot; 7653]&#xA;   [clojure.lang.RT loadResourceScript &amp;quot;RT.java&amp;quot; 381]&#xA;   [clojure.lang.RT loadResourceScript &amp;quot;RT.java&amp;quot; 372]&#xA;   [clojure.lang.RT load &amp;quot;RT.java&amp;quot; 459]&#xA;   [clojure.lang.RT load &amp;quot;RT.java&amp;quot; 424]&#xA;   [clojure.core$load$fn__6908 invoke &amp;quot;core.clj&amp;quot; 6161]&#xA;   [clojure.core$load invokeStatic &amp;quot;core.clj&amp;quot; 6160]&#xA;   [clojure.core$load doInvoke &amp;quot;core.clj&amp;quot; 6144]&#xA;   [clojure.lang.RestFn invoke &amp;quot;RestFn.java&amp;quot; 408]&#xA;   [clojure.core$load_one invokeStatic &amp;quot;core.clj&amp;quot; 5933]&#xA;   [clojure.core$load_one invoke &amp;quot;core.clj&amp;quot; 5928]&#xA;   [clojure.core$load_lib$fn__6850 invoke &amp;quot;core.clj&amp;quot; 5975]&#xA;   [clojure.core$load_lib invokeStatic &amp;quot;core.clj&amp;quot; 5974]&#xA;   [clojure.core$load_lib doInvoke &amp;quot;core.clj&amp;quot; 5953]&#xA;   [clojure.lang.RestFn applyTo &amp;quot;RestFn.java&amp;quot; 142]&#xA;   [clojure.core$apply invokeStatic &amp;quot;core.clj&amp;quot; 669]&#xA;   [clojure.core$load_libs invokeStatic &amp;quot;core.clj&amp;quot; 6016]&#xA;   [clojure.core$load_libs doInvoke &amp;quot;core.clj&amp;quot; 6000]&#xA;   [clojure.lang.RestFn applyTo &amp;quot;RestFn.java&amp;quot; 137]&#xA;   [clojure.core$apply invokeStatic &amp;quot;core.clj&amp;quot; 669]&#xA;   [clojure.core$require invokeStatic &amp;quot;core.clj&amp;quot; 6038]&#xA;   [clojure.core$require doInvoke &amp;quot;core.clj&amp;quot; 6038]&#xA;   [clojure.lang.RestFn invoke &amp;quot;RestFn.java&amp;quot; 408]&#xA;   [user$eval140$fn__144 invoke &amp;quot;form-init15974239925031016013.clj&amp;quot; 1]&#xA;   [user$eval140 invokeStatic &amp;quot;form-init15974239925031016013.clj&amp;quot; 1]&#xA;   [user$eval140 invoke &amp;quot;form-init15974239925031016013.clj&amp;quot; 1]&#xA;   [clojure.lang.Compiler eval &amp;quot;Compiler.java&amp;quot; 7194]&#xA;   [clojure.lang.Compiler eval &amp;quot;Compiler.java&amp;quot; 7184]&#xA;   [clojure.lang.Compiler load &amp;quot;Compiler.java&amp;quot; 7653]&#xA;   [clojure.lang.Compiler loadFile &amp;quot;Compiler.java&amp;quot; 7591]&#xA;   [clojure.main$load_script invokeStatic &amp;quot;main.clj&amp;quot; 475]&#xA;   [clojure.main$init_opt invokeStatic &amp;quot;main.clj&amp;quot; 477]&#xA;   [clojure.main$init_opt invoke &amp;quot;main.clj&amp;quot; 477]&#xA;   [clojure.main$initialize invokeStatic &amp;quot;main.clj&amp;quot; 508]&#xA;   [clojure.main$null_opt invokeStatic &amp;quot;main.clj&amp;quot; 542]&#xA;   [clojure.main$null_opt invoke &amp;quot;main.clj&amp;quot; 539]&#xA;   [clojure.main$main invokeStatic &amp;quot;main.clj&amp;quot; 664]&#xA;   [clojure.main$main doInvoke &amp;quot;main.clj&amp;quot; 616]&#xA;   [clojure.lang.RestFn applyTo &amp;quot;RestFn.java&amp;quot; 137]&#xA;   [clojure.lang.Var applyTo &amp;quot;Var.java&amp;quot; 705]&#xA;   [clojure.main main &amp;quot;main.java&amp;quot; 40]],&#xA;  :cause &amp;quot;capacity &amp;lt; 0: (-689151616 &amp;lt; 0)&amp;quot;,&#xA;  :phase :execution}}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/79626949</id>
        <re:rank scheme="https://stackoverflow.com">1</re:rank>
        <title type="text">Failing to load FBX meshes with correct transform. Assimp 5.2.5</title>
            <category scheme="https://stackoverflow.com/tags" term="c&#x2B;&#x2B;" />
            <category scheme="https://stackoverflow.com/tags" term="transform" />
            <category scheme="https://stackoverflow.com/tags" term="directx" />
            <category scheme="https://stackoverflow.com/tags" term="assimp" />
        <author>
            <name>TheChamp</name>
            <uri>https://stackoverflow.com/users/7978004</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/79626949/failing-to-load-fbx-meshes-with-correct-transform-assimp-5-2-5" />
        <published>2025-05-17T20:14:44Z</published>
        <updated>2025-05-24T03:12:20Z</updated>
        <summary type="html">
            &lt;p&gt;I exported a model to fbx format inside 3ds max. Inside Max the scene look like this:&lt;br /&gt;&#xA;&lt;a href=&quot;https://i.sstatic.net/bNH0FOUr.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.sstatic.net/bNH0FOUr.png&quot; alt=&quot;Max viewport&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;When i import it in my software i get this:&lt;br /&gt;&#xA;&lt;a href=&quot;https://youtu.be/WPQnkxzL24g&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://youtu.be/WPQnkxzL24g&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The meshes transform is wrong. &lt;strong&gt;But if I import the max FBX file inside Blender then i export from there I get it right&lt;/strong&gt;:&lt;br /&gt;&#xA;&lt;a href=&quot;https://youtu.be/LBk9CTjSwlo&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://youtu.be/LBk9CTjSwlo&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Here how a model is loaded:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;void BaseModel::loadAssimpModel(const std::wstring&amp;amp; path)&#xA;{&#xA;    // Read file via ASSIMP&#xA;    aiPropertyStore* props = aiCreatePropertyStore();&#xA;    aiSetImportPropertyInteger(props, AI_CONFIG_PP_SLM_TRIANGLE_LIMIT, MAX_TRIANGLES_PER_MESH);&#xA;&#xA;    const uint32_t flags = aiProcess_Triangulate | aiProcess_CalcTangentSpace;&#xA;    const std::string pathStr = Utilities::nativeStringToStdString(path);&#xA;    const aiScene* scene = aiImportFileExWithProperties(pathStr.c_str(), flags, NULL, props);&#xA;&#xA;    aiReleasePropertyStore(props);&#xA;&#xA;    // Check for errors&#xA;    const nbBool success = scene &amp;amp;&amp;amp; scene-&amp;gt;mFlags != AI_SCENE_FLAGS_INCOMPLETE &amp;amp;&amp;amp; scene-&amp;gt;mRootNode;&#xA;    assert(success);&#xA;&#xA;    // Process ASSIMP&#x27;s root node recursively here !!! :)&#xA;    processNode(scene, scene-&amp;gt;mRootNode, aiMatrix4x4());&#xA;&#xA;    aiReleaseImport(scene);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;The processNode method is straightforward:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;void BaseModel::processNode(const aiScene* scene, aiNode* node, const aiMatrix4x4&amp;amp; transform)&#xA;{&#xA;    const aiMatrix4x4 accTransform = node-&amp;gt;mTransformation * transform;&#xA;&#xA;    // Process each mesh located at the current node.&#xA;    if (node-&amp;gt;mNumMeshes)&#xA;    {&#xA;        // Create group.&#xA;        DatabaseMeshPtr meshGroup;&#xA;        {&#xA;            aiMesh* firstMesh = scene-&amp;gt;mMeshes[node-&amp;gt;mMeshes[0]];&#xA;&#xA;            std::wstring groupName(Utilities::stdStringToNativeString(firstMesh-&amp;gt;mName.C_Str()));&#xA;&#xA;            meshGroup = EntityDatabaseSingleton::instance()-&amp;gt;createEntity&amp;lt;MeshGroup&amp;gt;();&#xA;            meshGroup-&amp;gt;setName(groupName);&#xA;&#xA;            meshGroup-&amp;gt;m_materialId = m_aiLoadingMaterialIds[firstMesh-&amp;gt;mMaterialIndex];&#xA;&#xA;            m_meshGroupIdentifiers.push_back(meshGroup-&amp;gt;getIdentifier());&#xA;        }&#xA;&#xA;        // Add meshes.&#xA;        for (uint32_t i = 0; i &amp;lt; node-&amp;gt;mNumMeshes; i&#x2B;&#x2B;)&#xA;        {&#xA;            // The node object only contains indices to index the actual objects in the scene. &#xA;            // The scene contains all the data, node is just to keep stuff organized (like relations between nodes).&#xA;            aiMesh* mesh = scene-&amp;gt;mMeshes[node-&amp;gt;mMeshes[i]];&#xA;            this-&amp;gt;addMesh(mesh, accTransform, meshGroup);&#xA;        }&#xA;    }&#xA;&#xA;    // After we&#x27;ve processed all of the meshes (if any) we then recursively process each of the children nodes&#xA;    for (uint32_t i = 0; i &amp;lt; node-&amp;gt;mNumChildren; i&#x2B;&#x2B;)&#xA;    {&#xA;        this-&amp;gt;processNode(scene, node-&amp;gt;mChildren[i], accTransform);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;The addMesh method:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;void BaseModel::addMesh(aiMesh* mesh, const aiMatrix4x4&amp;amp; transform, DatabaseMeshPtr meshGroup)&#xA;{&#xA;    // Data to fill&#xA;    VertexArray vertices;&#xA;    std::vector&amp;lt;uint32_t&amp;gt; indices;&#xA;&#xA;    // The 3x3 transform.&#xA;    const aiMatrix3x3 transform3x3 = aiMatrix3x3(transform);&#xA;&#xA;    // Walk through each of the mesh&#x27;s vertices&#xA;    for (uint32_t i = 0; i &amp;lt; mesh-&amp;gt;mNumVertices; i&#x2B;&#x2B;)&#xA;    {&#xA;        FullVertex vertex;&#xA;&#xA;        mesh-&amp;gt;mVertices[i] = transform * mesh-&amp;gt;mVertices[i];&#xA;&#xA;        // Position&#xA;        vertex.position.x = mesh-&amp;gt;mVertices[i].x;&#xA;        vertex.position.y = mesh-&amp;gt;mVertices[i].y;&#xA;        vertex.position.z = mesh-&amp;gt;mVertices[i].z;&#xA;&#xA;        // Normal.&#xA;        if (mesh-&amp;gt;mNormals)&#xA;        {&#xA;            mesh-&amp;gt;mNormals[i] = transform3x3 * mesh-&amp;gt;mNormals[i];&#xA;&#xA;            vertex.normal.x = mesh-&amp;gt;mNormals[i].x;&#xA;            vertex.normal.y = mesh-&amp;gt;mNormals[i].y;&#xA;            vertex.normal.z = mesh-&amp;gt;mNormals[i].z;&#xA;        }&#xA;&#xA;        // Tangent&#xA;        if (mesh-&amp;gt;mTangents)&#xA;        {&#xA;            vertex.tangent.x = mesh-&amp;gt;mTangents[i].x;&#xA;            vertex.tangent.y = mesh-&amp;gt;mTangents[i].y;&#xA;            vertex.tangent.z = mesh-&amp;gt;mTangents[i].z;&#xA;        }&#xA;&#xA;        // Bitangent&#xA;        if (mesh-&amp;gt;mBitangents)&#xA;        {&#xA;            vertex.bitangent.x = mesh-&amp;gt;mBitangents[i].x;&#xA;            vertex.bitangent.y = mesh-&amp;gt;mBitangents[i].y;&#xA;            vertex.bitangent.z = mesh-&amp;gt;mBitangents[i].z;&#xA;        }&#xA;&#xA;        // Texture Coordinates&#xA;        if (mesh-&amp;gt;mTextureCoords[0]) // Does the mesh contain texture coordinates?&#xA;        {&#xA;            // A vertex can contain up to 8 different texture coordinates. We thus make the assumption that we won&#x27;t &#xA;            // use models where a vertex can have multiple texture coordinates so we always take the first set (0).&#xA;            vertex.texCoord.x = mesh-&amp;gt;mTextureCoords[0][i].x;&#xA;            vertex.texCoord.y = mesh-&amp;gt;mTextureCoords[0][i].y;&#xA;        }&#xA;&#xA;        vertices.push_back(vertex);&#xA;    }&#xA;&#xA;    // Now wak through each of the mesh&#x27;s faces (a face is a mesh its triangle) and retrieve the corresponding vertex indices.&#xA;    for (uint32_t i = 0; i &amp;lt; mesh-&amp;gt;mNumFaces; i&#x2B;&#x2B;)&#xA;    {&#xA;        aiFace face = mesh-&amp;gt;mFaces[i];&#xA;        // Retrieve all indices of the face and store them in the indices vector&#xA;        for (uint32_t j = 0; j &amp;lt; face.mNumIndices; j&#x2B;&#x2B;)&#xA;            indices.push_back(face.mIndices[j]);&#xA;    }&#xA;&#xA;    const MeshFlatId meshFlatId = (MeshFlatId)m_flatMeshContainer.size();&#xA;&#xA;    Mesh* nativeMesh = new Mesh(vertices, indices, meshFlatId, meshGroup.get());&#xA;&#xA;    meshGroup-&amp;gt;m_meshes.push_back(nativeMesh);&#xA;    m_flatMeshContainer.push_back(nativeMesh);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Once loading is done vertices are converted to local space. I dont think this is linked to the issue:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;for (const EntityIdentifier&amp;amp; entityId : m_meshGroupIdentifiers)&#xA;{&#xA;    Math::Vec3 center;&#xA;    size_t nbVertices = 0u;&#xA;&#xA;    const auto group = getMeshGroupPtr_FromEntity(entityId);&#xA;&#xA;    for (const auto*mesh : group-&amp;gt;m_meshes)&#xA;    {&#xA;        const auto&amp;amp; vertices = mesh-&amp;gt;getRealVertices();&#xA;        for (auto&amp;amp; vertex : vertices)&#xA;            center &#x2B;= vertex.position;&#xA;&#xA;        nbVertices &#x2B;= vertices.size();&#xA;    }&#xA;&#xA;    center /= nbVertices;&#xA;    for (auto* mesh : group-&amp;gt;m_meshes)&#xA;    {&#xA;        auto&amp;amp; vertices = mesh-&amp;gt;getMutableVertices();&#xA;        for (auto&amp;amp; vertex : vertices)&#xA;            vertex.position -= center;&#xA;    }&#xA;&#xA;    group-&amp;gt;setPosition(center);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The last &lt;strong&gt;setPosition&lt;/strong&gt; call set the worlspace transform of the mesh group. It is used when performing DirectX 12 realtime rendering. This is clearly not the issue:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cbuffer VertexShaderSharedCB : register(b0)&#xA;{&#xA;    float4x4 vpMat;&#xA;};&#xA;&#xA;VS_OUTPUT main(VS_INPUT input, uint instanceID : SV_InstanceID)&#xA;{&#xA;    VS_OUTPUT output;&#xA;&#xA;    const float4x4 modelMat = meshGroupDatas[instanceID].transform;// transform here!&#xA;    const float4 worldPosition = mul(float4(input.position, 1.0f), modelMat);&#xA;    output.worldPosition = worldPosition.xyz;&#xA;    output.position = mul(worldPosition, vpMat);&#xA;    output.texCoord = input.texCoord;&#xA;    output.normal = normalize(mul(float4(input.normal, 0.0f), modelMat));&#xA;    output.tangent = normalize(mul(float4(input.tangent, 0.0f), modelMat));&#xA;    output.bitangent = normalize(mul(float4(input.bitangent, 0.0f), modelMat));&#xA;&#xA;    return output;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;strong&gt;What am I doing wrong? And especially why the Blender FBX is loaded properly and not the 3ds max one?  I am probably missing a transform somewhere. Note that OBJs are always properly loaded ;)&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Thanks!&lt;br /&gt;&#xA;//---------------------------------------------------------------------------------&lt;br /&gt;&#xA;The 3ds Max FBX file:&lt;br /&gt;&#xA;&lt;a href=&quot;https://www.dropbox.com/scl/fi/5rus8jyhz0xbxghrpus67/max_fbx_nope.fbx?rlkey=c2muf2mhcjbizmllqdx0h0wlx&amp;amp;st=6941tiin&amp;amp;dl=0&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.dropbox.com/scl/fi/5rus8jyhz0xbxghrpus67/max_fbx_nope.fbx?rlkey=c2muf2mhcjbizmllqdx0h0wlx&amp;amp;st=6941tiin&amp;amp;dl=0&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The Blender FBX  file:&lt;br /&gt;&#xA;&lt;a href=&quot;https://www.dropbox.com/scl/fi/zv9slsjz41xlx7nanoyy2/blender_fbx_ok.fbx?rlkey=7olvgnbhceik0qm351rj0lbww&amp;amp;st=dwkzsjn6&amp;amp;dl=0&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.dropbox.com/scl/fi/zv9slsjz41xlx7nanoyy2/blender_fbx_ok.fbx?rlkey=7olvgnbhceik0qm351rj0lbww&amp;amp;st=dwkzsjn6&amp;amp;dl=0&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;The 3ds Max 2025 native file:&lt;br /&gt;&#xA;&lt;a href=&quot;https://www.dropbox.com/scl/fi/pjcv6896uzv6su8992156/native.max?rlkey=yggek65khewpxntm87zchznjc&amp;amp;st=ze7hq6k7&amp;amp;dl=0&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.dropbox.com/scl/fi/pjcv6896uzv6su8992156/native.max?rlkey=yggek65khewpxntm87zchznjc&amp;amp;st=ze7hq6k7&amp;amp;dl=0&lt;/a&gt;&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/79451804</id>
        <re:rank scheme="https://stackoverflow.com">1</re:rank>
        <title type="text">Visual Studio 2022 OpenGL Project: &#x27;assimp/Importer.hpp&#x27; Not Found Despite Correct Include Path</title>
            <category scheme="https://stackoverflow.com/tags" term="c&#x2B;&#x2B;" />
            <category scheme="https://stackoverflow.com/tags" term="visual-studio-2022" />
            <category scheme="https://stackoverflow.com/tags" term="include-path" />
            <category scheme="https://stackoverflow.com/tags" term="assimp" />
        <author>
            <name>Zoro</name>
            <uri>https://stackoverflow.com/users/12917380</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/79451804/visual-studio-2022-opengl-project-assimp-importer-hpp-not-found-despite-corre" />
        <published>2025-02-19T14:53:54Z</published>
        <updated>2025-02-19T14:53:54Z</updated>
        <summary type="html">
            &lt;p&gt;I keep getting below error during build at &lt;code&gt;#include &amp;lt;assimp/Importer.hpp&amp;gt;&lt;/code&gt; &lt;br&gt;&#xA;Error: &lt;code&gt;C1083: Cannot open include file: &#x27;assimp/Importer.hpp&#x27;: No such file or directory&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have tried to clean the solution, rebuild, updated it with the fullpath, nothing is working.&lt;/p&gt;&#xA;&lt;p&gt;I have been working and building my OpenGL project in Debug-Win32, I wanted to load models, so came across Assimp. Since they do not release the builds anymore, I downloaded the latest &lt;a href=&quot;https://github.com/assimp/assimp/releases/tag/v5.4.3&quot; rel=&quot;nofollow noreferrer&quot;&gt;release&lt;/a&gt; v5.4.3 from GitHub and followed below to build it locally.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Open command promt, and run &lt;code&gt;cmake .\CMakeLists.txt&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Once completed, you should be able to see a &lt;code&gt;Assimp.sln&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Open the &lt;code&gt;Assimp.sln&lt;/code&gt; and selected &lt;code&gt;Debug&lt;/code&gt; and it was available for &lt;code&gt;x64&lt;/code&gt; only&lt;/li&gt;&#xA;&lt;li&gt;Once done, copied the generated &lt;code&gt;lib&lt;/code&gt; and &lt;code&gt;bin&lt;/code&gt; to my project&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;code&gt;Project Setup:&lt;/code&gt;&#xA;Visual Studio 2022&lt;br&gt;&#xA;Initially I was using &lt;code&gt;Win32&lt;/code&gt;, but since I didnt get latest versions of assimp in win32, I reconfigured project to run on x64 as well, added relevant GLEW, GLFW paths and I was able to run application without any issues.&lt;/p&gt;&#xA;&lt;p&gt;I added the assimp files to my &lt;code&gt;Dependencies&lt;/code&gt;. And then added below configurations:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Include Directory Settings&lt;/strong&gt;&#xA;&lt;em&gt;(C/C&#x2B;&#x2B; -&amp;gt; General -&amp;gt; Additional Include Directories)&lt;/em&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;src&#xA;src\vendor&#xA;Core&#xA;$(SolutionDir)Dependencies\GLFW\include&#xA;$(SolutionDir)Dependencies\GLEW\include&#xA;$(SolutionDir)Dependencies\assimp\include&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Verified that &lt;code&gt;$(SolutionDir)Dependencies\assimp\include&lt;/code&gt; is actually pointing to correct path.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Library Directories &amp;amp; Linking&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;Linker -&amp;gt; General -&amp;gt; Additional Library Directories:&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre&gt;&lt;code&gt;$(SolutionDir)Dependencies\GLFW\lib-vc2022&#xA;$(SolutionDir)Dependencies\GLEW\lib\Release\x64&#xA;$(SolutionDir)Dependencies\assimp\lib\Debug&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;em&gt;Linker -&amp;gt; Input -&amp;gt; Additional Dependencies:&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre&gt;&lt;code&gt;assimp-vc143-mtd.lib&#xA;glew32s.lib&#xA;glfw3.lib&#xA;opengl32.lib&#xA;User32.lib&#xA;Gdi32.lib&#xA;Shell32.lib&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Why is Visual Studio not finding assimp/Importer.hpp despite it being in the include directory? Is there something wrong with my configuration?&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Directory Structure of Assimp&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;Dependencies/assimp/&#xA;&#x251C;&#x2500;&#x2500;&#x2500;Debug&#xA;&#x251C;&#x2500;&#x2500;&#x2500;Dependencies&#xA;&#x2502;   &#x251C;&#x2500;&#x2500;&#x2500;assimp&#xA;&#x2502;   &#x2502;   &#x251C;&#x2500;&#x2500;&#x2500;bin&#xA;&#x2502;   &#x2502;   &#x2502;   &#x2514;&#x2500;&#x2500;&#x2500;Debug&#xA;&#x2502;   &#x2502;   &#x251C;&#x2500;&#x2500;&#x2500;include&#xA;&#x2502;   &#x2502;   &#x2502;   &#x2514;&#x2500;&#x2500;&#x2500;assimp&#xA;&#x2502;   &#x2502;   &#x2502;       &#x251C;&#x2500;&#x2500;&#x2500;Compiler&#xA;&#x2502;   &#x2502;   &#x2502;       &#x2514;&#x2500;&#x2500;&#x2500;port&#xA;&#x2502;   &#x2502;   &#x2502;           &#x2514;&#x2500;&#x2500;&#x2500;AndroidJNI&#xA;&#x2502;   &#x2502;   &#x2514;&#x2500;&#x2500;&#x2500;lib&#xA;&#x2502;   &#x2502;       &#x2514;&#x2500;&#x2500;&#x2500;Debug&#xA;&#x2502;   &#x251C;&#x2500;&#x2500;&#x2500;GLEW&#xA;&#x2502;   &#x2502;   &#x251C;&#x2500;&#x2500;&#x2500;doc&#xA;&#x2502;   &#x2502;   &#x251C;&#x2500;&#x2500;&#x2500;include&#xA;&#x2502;   &#x2502;   &#x2502;   &#x2514;&#x2500;&#x2500;&#x2500;GL&#xA;&#x2502;   &#x2502;   &#x2514;&#x2500;&#x2500;&#x2500;lib&#xA;&#x2502;   &#x2502;       &#x2514;&#x2500;&#x2500;&#x2500;Release&#xA;&#x2502;   &#x2502;           &#x251C;&#x2500;&#x2500;&#x2500;Win32&#xA;&#x2502;   &#x2502;           &#x2514;&#x2500;&#x2500;&#x2500;x64&#xA;&#x2502;   &#x2514;&#x2500;&#x2500;&#x2500;GLFW&#xA;&#x2502;       &#x251C;&#x2500;&#x2500;&#x2500;include&#xA;&#x2502;       &#x2502;   &#x2514;&#x2500;&#x2500;&#x2500;GLFW&#xA;&#x2502;       &#x2514;&#x2500;&#x2500;&#x2500;lib-vc2022&#xA;&#x2514;&#x2500;&#x2500;&#x2500;OpenGL&#xA;    &#x251C;&#x2500;&#x2500;&#x2500;Core&#xA;    &#x251C;&#x2500;&#x2500;&#x2500;res&#xA;    &#x2514;&#x2500;&#x2500;&#x2500;src (Application.cpp/main)&#xA;        &#x251C;&#x2500;&#x2500;&#x2500;tests&#xA;        &#x2514;&#x2500;&#x2500;&#x2500;vendor&#xA;            &#x251C;&#x2500;&#x2500;&#x2500;glm&#xA;            &#x251C;&#x2500;&#x2500;&#x2500;imgui&#xA;            &#x2514;&#x2500;&#x2500;&#x2500;stb_image&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/79408696</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">Texture mapping issues with Assimp and OpenGL: Some meshes have incorrect UV mapping [closed]</title>
            <category scheme="https://stackoverflow.com/tags" term="c&#x2B;&#x2B;" />
            <category scheme="https://stackoverflow.com/tags" term="opengl" />
            <category scheme="https://stackoverflow.com/tags" term="texture-mapping" />
            <category scheme="https://stackoverflow.com/tags" term="assimp" />
        <author>
            <name>Leonard</name>
            <uri>https://stackoverflow.com/users/27655441</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/79408696/texture-mapping-issues-with-assimp-and-opengl-some-meshes-have-incorrect-uv-map" />
        <published>2025-02-03T11:45:12Z</published>
        <updated>2025-02-04T13:36:41Z</updated>
        <summary type="html">
            &lt;p&gt;I am trying to load and render 3D models using C&#x2B;&#x2B;, modern OpenGL (glfw 3.4.0, glad, glm), and the newest Assimp. My model loader is mostly working, but I am encountering an issue where some meshes are not textured correctly.&lt;/p&gt;&#xA;&lt;p&gt;For example, in this glTF &lt;a href=&quot;https://i.sstatic.net/28DakDM6.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;aircraft model&lt;/a&gt;, most of the parts are mapped correctly, but the canopy texture is mapped incorrect. Instead of using the correct UV mapping, it appears as if the entire texture for the model is being applied incorrectly. I have disabled blending right now, but the issue persists with or without blending. Also, I only load the diffuse textures right now.&lt;/p&gt;&#xA;&lt;p&gt;Here is the code of model.cpp:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;quot;model.h&amp;quot;&#xA;&#xA;Model::Model(const std::string&amp;amp; file_path) &#xA;{&#xA;    load_model(file_path);&#xA;}&#xA;&#xA;void Model::load_model(const std::string&amp;amp; file_path) &#xA;{&#xA;    Assimp::Importer importer;&#xA;    const aiScene* scene = importer.ReadFile(file_path, aiProcess_Triangulate | aiProcess_GenSmoothNormals | aiProcess_FlipUVs);&#xA;&#xA;    if (!scene || (scene-&amp;gt;mFlags &amp;amp; AI_SCENE_FLAGS_INCOMPLETE) || !scene-&amp;gt;mRootNode) {&#xA;        std::cerr &amp;lt;&amp;lt; &amp;quot;Assimp error: &amp;quot; &amp;lt;&amp;lt; importer.GetErrorString() &amp;lt;&amp;lt; std::endl;&#xA;        return;&#xA;    }&#xA;&#xA;    directory = file_path.substr(0, file_path.find_last_of(&amp;quot;/&amp;quot;));&#xA;    process_node(scene-&amp;gt;mRootNode, scene);&#xA;}&#xA;&#xA;void Model::process_node(aiNode* node, const aiScene* scene) &#xA;{&#xA;    for (unsigned int i = 0; i &amp;lt; node-&amp;gt;mNumMeshes; i&#x2B;&#x2B;) {&#xA;        aiMesh* mesh = scene-&amp;gt;mMeshes[node-&amp;gt;mMeshes[i]];&#xA;&#xA;        meshes.push_back(process_mesh(mesh, scene));&#xA;    }&#xA;    for (unsigned int i = 0; i &amp;lt; node-&amp;gt;mNumChildren; i&#x2B;&#x2B;) {&#xA;        process_node(node-&amp;gt;mChildren[i], scene);&#xA;    }&#xA;}&#xA;&#xA;Mesh Model::process_mesh(aiMesh* mesh, const aiScene* scene) &#xA;{&#xA;    std::vector&amp;lt;Vertex&amp;gt; vertices;&#xA;    std::vector&amp;lt;GLuint&amp;gt; indices;&#xA;    std::vector&amp;lt;Texture&amp;gt; textures;&#xA;&#xA;    for (unsigned int i = 0; i &amp;lt; mesh-&amp;gt;mNumVertices; i&#x2B;&#x2B;) {&#xA;        Vertex vertex;&#xA;        vertex.position = glm::vec3(mesh-&amp;gt;mVertices[i].x, mesh-&amp;gt;mVertices[i].y, mesh-&amp;gt;mVertices[i].z);&#xA;&#xA;        if (mesh-&amp;gt;HasNormals()) {&#xA;            vertex.normal = glm::vec3(mesh-&amp;gt;mNormals[i].x, mesh-&amp;gt;mNormals[i].y, mesh-&amp;gt;mNormals[i].z);&#xA;        }&#xA;&#xA;        if (mesh-&amp;gt;mTextureCoords[0]) {&#xA;            vertex.tex_coords = glm::vec2(mesh-&amp;gt;mTextureCoords[0][i].x, mesh-&amp;gt;mTextureCoords[0][i].y);&#xA;        } else {&#xA;            vertex.tex_coords = glm::vec2(0.0f, 0.0f);&#xA;        }&#xA;&#xA;        vertices.push_back(vertex);&#xA;    }&#xA;&#xA;    for (unsigned int i = 0; i &amp;lt; mesh-&amp;gt;mNumFaces; i&#x2B;&#x2B;) {&#xA;        aiFace face = mesh-&amp;gt;mFaces[i];&#xA;        for (unsigned int j = 0; j &amp;lt; face.mNumIndices; j&#x2B;&#x2B;) {&#xA;            indices.push_back(face.mIndices[j]);&#xA;        }&#xA;    }&#xA;&#xA;    aiMaterial* material = scene-&amp;gt;mMaterials[mesh-&amp;gt;mMaterialIndex];&#xA;    std::vector&amp;lt;Texture&amp;gt; diffuse_maps = load_material_textures(material, aiTextureType_DIFFUSE, &amp;quot;diffuse&amp;quot;);&#xA;    textures.insert(textures.end(), diffuse_maps.begin(), diffuse_maps.end());&#xA;    &#xA;    return Mesh(vertices, indices, textures);&#xA;}&#xA;&#xA;std::vector&amp;lt;Texture&amp;gt; Model::load_material_textures(aiMaterial* material, aiTextureType type, const std::string&amp;amp; type_name) &#xA;{&#xA;    std::vector&amp;lt;Texture&amp;gt; textures;&#xA;    &#xA;    for (unsigned int i = 0; i &amp;lt; material-&amp;gt;GetTextureCount(type); i&#x2B;&#x2B;) {&#xA;&#xA;        aiString str;&#xA;        material-&amp;gt;GetTexture(type, i, &amp;amp;str);&#xA;&#xA;        bool skip = false;&#xA;        for (const auto&amp;amp; loaded_texture : textures_loaded) {&#xA;            if (std::strcmp(loaded_texture.path.data(), str.C_Str()) == 0) {&#xA;                textures.push_back(loaded_texture);&#xA;                skip = true;&#xA;                break;&#xA;            }&#xA;        }&#xA;        if (!skip) {&#xA;            Texture texture;&#xA;            texture.id = load_texture_from_file(str.C_Str(), directory);&#xA;            texture.type = type_name;&#xA;            texture.path = str.C_Str();&#xA;            textures.push_back(texture);&#xA;            textures_loaded.push_back(texture);&#xA;        }&#xA;    }&#xA;    return textures;&#xA;}&#xA;&#xA;void Model::render(Shader&amp;amp; shader, Camera&amp;amp; camera) {&#xA;    for (auto&amp;amp; mesh : meshes) {&#xA;        mesh.render(shader, camera);&#xA;    }&#xA;}&#xA;&#xA;GLuint load_texture_from_file(const char* file_path, const std::string&amp;amp; directory) &#xA;{&#xA;    std::string file_name = directory &#x2B; &amp;quot;/&amp;quot; &#x2B; file_path;&#xA;    GLuint texture_id;&#xA;    glGenTextures(1, &amp;amp;texture_id);&#xA;&#xA;    int width, height, number_of_color_channels;&#xA;    unsigned char* data = stbi_load(file_name.c_str(), &amp;amp;width, &amp;amp;height, &amp;amp;number_of_color_channels, 0);&#xA;    if (data) {&#xA;        GLenum format = (number_of_color_channels == 1) ? GL_RED : (number_of_color_channels == 3) ? GL_RGB : GL_RGBA;&#xA;        glBindTexture(GL_TEXTURE_2D, texture_id);&#xA;        glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format, GL_UNSIGNED_BYTE, data);&#xA;        glGenerateMipmap(GL_TEXTURE_2D);&#xA;        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);&#xA;        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);&#xA;        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);&#xA;        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);&#xA;        stbi_image_free(data);&#xA;    } else {&#xA;        std::cerr &amp;lt;&amp;lt; &amp;quot;Texture failed to load: &amp;quot; &amp;lt;&amp;lt; file_path &amp;lt;&amp;lt; std::endl;&#xA;        stbi_image_free(data);&#xA;    }&#xA;&#xA;    std::cout &amp;lt;&amp;lt; file_name &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;;&#xA;&#xA;    return texture_id;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And here is the code of mesh.cpp:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#include &amp;quot;mesh.h&amp;quot;&#xA;#include &amp;lt;iostream&amp;gt;&#xA;&#xA;Mesh::Mesh(std::vector &amp;lt;Vertex&amp;gt;&amp;amp; vertices, std::vector &amp;lt;GLuint&amp;gt;&amp;amp; indices, std::vector &amp;lt;Texture&amp;gt;&amp;amp; textures) &#xA;{&#xA;    Mesh::vertices = vertices;&#xA;    Mesh::indices = indices;&#xA;    Mesh::textures = textures;&#xA;&#xA;    GLuint vbo_id, ebo_id;&#xA;&#xA;    glGenVertexArrays(1, &amp;amp;vao_id);&#xA;    glGenBuffers(1, &amp;amp;vbo_id);&#xA;    glGenBuffers(1, &amp;amp;ebo_id);&#xA;&#xA;    glBindVertexArray(vao_id);&#xA;&#xA;    glBindBuffer(GL_ARRAY_BUFFER, vbo_id);&#xA;&#xA;    glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(Vertex), &amp;amp;vertices[0], GL_STATIC_DRAW);  &#xA;&#xA;    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo_id);&#xA;    glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices.size() * sizeof(GLuint), &amp;amp;indices[0], GL_STATIC_DRAW);&#xA;&#xA;    glEnableVertexAttribArray(0);   &#xA;    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)0);&#xA;&#xA;    glEnableVertexAttribArray(1);   &#xA;    glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, normal));&#xA;&#xA;    glEnableVertexAttribArray(2);   &#xA;    glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, tex_coords));&#xA;}&#xA;&#xA;void Mesh::render(Shader&amp;amp; shader_program, Camera&amp;amp; camera) &#xA;{&#xA;    shader_program.use();&#xA;&#xA;    unsigned int diffuse_number = 0;&#xA;    unsigned int specular_number = 0;&#xA;    unsigned int normal_number = 0;&#xA;&#xA;    for (unsigned int i = 0;  i &amp;lt; textures.size(); i&#x2B;&#x2B;)&#xA;    {&#xA;        glActiveTexture(GL_TEXTURE0 &#x2B; i);&#xA;        &#xA;        std::string number;&#xA;        std::string type = textures[i].type;&#xA;&#xA;        if (type == &amp;quot;diffuse&amp;quot;)&#xA;        {&#xA;            number = std::to_string(diffuse_number&#x2B;&#x2B;);  &#xA;        }&#xA;&#xA;        else if (type == &amp;quot;specular&amp;quot;)&#xA;        {&#xA;           number = std::to_string(specular_number&#x2B;&#x2B;);&#xA;        }&#xA;&#xA;        else if (type == &amp;quot;normal&amp;quot;)&#xA;        {&#xA;           number = std::to_string(normal_number&#x2B;&#x2B;);&#xA;        }&#xA;&#xA;        glUniform1i(glGetUniformLocation(shader_program.id, (type &#x2B; number).c_str()), i);&#xA;        glBindTexture(GL_TEXTURE_2D, textures[i].id);&#xA;    }&#xA;&#xA;    glBindVertexArray(vao_id);&#xA;    glDrawElements(GL_TRIANGLES, static_cast&amp;lt;unsigned int&amp;gt;(indices.size()), GL_UNSIGNED_INT, 0);&#xA;&#xA;    glBindVertexArray(0);&#xA;    glActiveTexture(GL_TEXTURE0);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Vertex shader:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#version 330 core&#xA;&#xA;layout (location = 0) in vec3 aPos;&#xA;layout (location = 1) in vec3 aNormal;&#xA;layout (location = 2) in vec2 aTexCoord;&#xA;&#xA;out vec3 crntPos;&#xA;out vec3 Normal;&#xA;out vec2 texCoord;&#xA;&#xA;uniform mat4 view;&#xA;uniform mat4 proj;&#xA;uniform mat4 model;&#xA;&#xA;void main()&#xA;{&#xA;    crntPos = vec3(model * vec4(aPos, 1.0f));&#xA;&#xA;    Normal = mat3(transpose(inverse(model))) * aNormal;&#xA;&#xA;    texCoord = aTexCoord;&#xA;&#xA;    gl_Position = proj * view * model * vec4(aPos, 1.0);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Fragment shader:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;#version 330 core&#xA;&#xA;out vec4 FragColor;&#xA;&#xA;in vec3 crntPos;&#xA;in vec3 Normal;&#xA;in vec2 texCoord;&#xA;&#xA;uniform sampler2D diffuse0;&#xA;&#xA;uniform vec4 lightColor;&#xA;uniform vec3 camPos;&#xA;&#xA;void main()&#xA;{&#xA;    float ambient = 0.20f;&#xA;    vec3 lightDirection = vec3(0.0f, 1.0f, 0.0f);&#xA;&#xA;    vec3 normal = normalize(Normal);&#xA;&#xA;    float diffuse = max(dot(normal, lightDirection), 0.0f);&#xA;&#xA;    FragColor = texture(diffuse0, texCoord) * lightColor * (diffuse &#x2B; ambient);&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I have tried to change the flags from assimp like aiProcess_FlipUVs or aiProcess_GenUVCoords, but nothing worked. I also tried GL_CLAMP_TO_EDGE instead of GL_REPEAT. I think that the correct texture files are loaded.&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/79289708</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">C&#x2B;&#x2B;/Raylib - Unable to load mesh with Assimp</title>
            <category scheme="https://stackoverflow.com/tags" term="c&#x2B;&#x2B;" />
            <category scheme="https://stackoverflow.com/tags" term="assimp" />
            <category scheme="https://stackoverflow.com/tags" term="raylib" />
        <author>
            <name>Venelin</name>
            <uri>https://stackoverflow.com/users/2661419</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/79289708/c-raylib-unable-to-load-mesh-with-assimp" />
        <published>2024-12-18T00:55:22Z</published>
        <updated>2024-12-18T00:55:22Z</updated>
        <summary type="html">
            &lt;p&gt;I want to preload 3d obj files before I run InitWindow from Raylib by preloading with assimp. So I have the following code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;std::vector&amp;lt;Mesh&amp;gt; preloadedMeshes;    // Store preloaded meshes&#xA;std::vector&amp;lt;Model&amp;gt; terrainTiles;      // Models created from the preloaded meshes&#xA;&#xA;// Function to load meshes with Assimp&#xA;Mesh LoadMeshWithAssimp(const std::string&amp;amp; filePath) {&#xA;    Assimp::Importer importer;&#xA;    const aiScene* scene = importer.ReadFile(filePath, aiProcess_Triangulate | aiProcess_FlipUVs);&#xA;&#xA;    if (!scene || !scene-&amp;gt;HasMeshes()) {&#xA;        throw std::runtime_error(&amp;quot;Failed to load mesh: &amp;quot; &#x2B; filePath);&#xA;    }&#xA;&#xA;    aiMesh* ai_mesh = scene-&amp;gt;mMeshes[0]; // Assume a single mesh for simplicity&#xA;&#xA;    Mesh mesh = { 0 };&#xA;    mesh.vertexCount = ai_mesh-&amp;gt;mNumVertices;&#xA;    mesh.triangleCount = ai_mesh-&amp;gt;mNumFaces;&#xA;&#xA;    // Allocate and copy vertex positions (CPU memory)&#xA;    mesh.vertices = (float*)MemAlloc(mesh.vertexCount * 3 * sizeof(float));&#xA;    for (unsigned int i = 0; i &amp;lt; mesh.vertexCount; i&#x2B;&#x2B;) {&#xA;        mesh.vertices[i * 3 &#x2B; 0] = ai_mesh-&amp;gt;mVertices[i].x;&#xA;        mesh.vertices[i * 3 &#x2B; 1] = ai_mesh-&amp;gt;mVertices[i].y;&#xA;        mesh.vertices[i * 3 &#x2B; 2] = ai_mesh-&amp;gt;mVertices[i].z;&#xA;    }&#xA;&#xA;    // Allocate and copy normals (CPU memory)&#xA;    if (ai_mesh-&amp;gt;HasNormals()) {&#xA;        mesh.normals = (float*)MemAlloc(mesh.vertexCount * 3 * sizeof(float));&#xA;        for (unsigned int i = 0; i &amp;lt; mesh.vertexCount; i&#x2B;&#x2B;) {&#xA;            mesh.normals[i * 3 &#x2B; 0] = ai_mesh-&amp;gt;mNormals[i].x;&#xA;            mesh.normals[i * 3 &#x2B; 1] = ai_mesh-&amp;gt;mNormals[i].y;&#xA;            mesh.normals[i * 3 &#x2B; 2] = ai_mesh-&amp;gt;mNormals[i].z;&#xA;        }&#xA;    }&#xA;&#xA;    // Allocate and copy texture coordinates (CPU memory)&#xA;    if (ai_mesh-&amp;gt;HasTextureCoords(0)) {&#xA;        mesh.texcoords = (float*)MemAlloc(mesh.vertexCount * 2 * sizeof(float));&#xA;        for (unsigned int i = 0; i &amp;lt; mesh.vertexCount; i&#x2B;&#x2B;) {&#xA;            mesh.texcoords[i * 2 &#x2B; 0] = ai_mesh-&amp;gt;mTextureCoords[0][i].x;&#xA;            mesh.texcoords[i * 2 &#x2B; 1] = ai_mesh-&amp;gt;mTextureCoords[0][i].y;&#xA;        }&#xA;    }&#xA;&#xA;    // Allocate and copy indices (CPU memory)&#xA;    mesh.indices = (unsigned short*)MemAlloc(mesh.triangleCount * 3 * sizeof(unsigned short));&#xA;    for (unsigned int i = 0; i &amp;lt; mesh.triangleCount; i&#x2B;&#x2B;) {&#xA;        mesh.indices[i * 3 &#x2B; 0] = (unsigned short)ai_mesh-&amp;gt;mFaces[i].mIndices[0];&#xA;        mesh.indices[i * 3 &#x2B; 1] = (unsigned short)ai_mesh-&amp;gt;mFaces[i].mIndices[1];&#xA;        mesh.indices[i * 3 &#x2B; 2] = (unsigned short)ai_mesh-&amp;gt;mFaces[i].mIndices[2];&#xA;    }&#xA;&#xA;    return mesh; // CPU-side Mesh, not yet uploaded&#xA;}&#xA;&#xA;&#xA;&#xA;// Preload meshes before initializing OpenGL&#xA;void PreloadMeshes() {&#xA;    try {&#xA;        preloadedMeshes.push_back(LoadMeshWithAssimp(&amp;quot;resources/models/Farabale_0.obj&amp;quot;));&#xA;        preloadedMeshes.push_back(LoadMeshWithAssimp(&amp;quot;resources/models/Farabale_1.obj&amp;quot;));&#xA;        preloadedMeshes.push_back(LoadMeshWithAssimp(&amp;quot;resources/models/Farabale_2.obj&amp;quot;));&#xA;        preloadedMeshes.push_back(LoadMeshWithAssimp(&amp;quot;resources/models/Farabale_3.obj&amp;quot;));&#xA;    } catch (const std::exception&amp;amp; e) {&#xA;        TraceLog(LOG_ERROR, e.what());&#xA;    }&#xA;}&#xA;&#xA;// Upload meshes to GPU and create models&#xA;void CreateModelsFromMeshes() {&#xA;    for (auto&amp;amp; mesh : preloadedMeshes) {&#xA;        UploadMesh(&amp;amp;mesh, true);  // Upload the mesh to GPU&#xA;        Model model = LoadModelFromMesh(mesh);&#xA;        terrainTiles.push_back(model);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;And if I do the following:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;const int screenWidth = 1280;&#xA;const int screenHeight = 720;&#xA;Vector3 unityPosition = (Vector3){-189.29, 105.66, 68.22};&#xA;PreloadMeshes();&#xA;InitWindow(screenWidth, screenHeight, &amp;quot;Dear ImGui Raylib(OpenGL) example&amp;quot;);&#xA;CreateModelsFromMeshes();&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I can see very weird obj files loaded. Take a look:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.sstatic.net/0kGRlPIC.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.sstatic.net/0kGRlPIC.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;But if I comment out and call loading of obj by the LoadModel function provided from raylib I see the scene perfectly fine:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;PreloadMeshes();&#xA;InitWindow(screenWidth, screenHeight, &amp;quot;Dear ImGui Raylib(OpenGL) example&amp;quot;);&#xA;//CreateModelsFromMeshes();&#xA;&#xA;terrainTiles.push_back(LoadModel(&amp;quot;resources/models/Farabale_0.obj&amp;quot;));&#xA;terrainTiles.push_back(LoadModel(&amp;quot;resources/models/Farabale_1.obj&amp;quot;));&#xA;terrainTiles.push_back(LoadModel(&amp;quot;resources/models/Farabale_2.obj&amp;quot;));&#xA;terrainTiles.push_back(LoadModel(&amp;quot;resources/models/Farabale_3.obj&amp;quot;));&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Produces this:&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.sstatic.net/vgFAVfo7.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.sstatic.net/vgFAVfo7.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;So as you can see no weird artifacts. Why is that? What am I doing wrong with Assimp ?&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/79281361</id>
        <re:rank scheme="https://stackoverflow.com">1</re:rank>
        <title type="text">Assimp .NET Model Animation went wrong (DEFAULT VALUES?)</title>
            <category scheme="https://stackoverflow.com/tags" term=".net" />
            <category scheme="https://stackoverflow.com/tags" term="animation" />
            <category scheme="https://stackoverflow.com/tags" term="model" />
            <category scheme="https://stackoverflow.com/tags" term="assimp" />
            <category scheme="https://stackoverflow.com/tags" term="skeletal-animation" />
        <author>
            <name>MrScautHD</name>
            <uri>https://stackoverflow.com/users/21882479</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/79281361/assimp-net-model-animation-went-wrong-default-values" />
        <published>2024-12-14T20:28:30Z</published>
        <updated>2024-12-14T20:28:30Z</updated>
        <summary type="html">
            &lt;p&gt;I made today a skinned mesh, and i tried out my Blockbench model with a animation and saw that the keyframes of this model that set to 0 not set into the model, so my question is now how can i reproduce the empty positions, roations, scale for my model.&lt;/p&gt;&#xA;&lt;p&gt;For Blender everything works fine because they even set the default values in the model, but with Blockbench i need to reproduce this values.&lt;/p&gt;&#xA;&lt;p&gt;This is my Code:&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cs prettyprint-override&quot;&gt;&lt;code&gt;using Assimp;&#xA;using Bliss.CSharp.Geometry.Animations.Bones;&#xA;using Bliss.CSharp.Geometry.Conversions;&#xA;using Bliss.CSharp.Logging;&#xA;using AMatrix4x4 = Assimp.Matrix4x4;&#xA;using Matrix4x4 = System.Numerics.Matrix4x4;&#xA;using AQuaternion = Assimp.Quaternion;&#xA;&#xA;namespace Bliss.CSharp.Geometry.Animations;&#xA;&#xA;public class MeshAmateurBuilder {&#xA;&#xA;    private Node _rootNode;&#xA;    private ModelAnimation[] _animations;&#xA;    &#xA;    private Dictionary&amp;lt;uint, Bone&amp;gt; _bonesByName;&#xA;    private Matrix4x4[] _boneTransformations;&#xA;    &#xA;    /// &amp;lt;summary&amp;gt;&#xA;    /// Initializes a new instance of the &amp;lt;see cref=&amp;quot;MeshAmateurBuilder&amp;quot;/&amp;gt; class with a root node and animations.&#xA;    /// &amp;lt;/summary&amp;gt;&#xA;    /// &amp;lt;param name=&amp;quot;rootNode&amp;quot;&amp;gt;The root &amp;lt;see cref=&amp;quot;Node&amp;quot;/&amp;gt; representing the hierarchical structure of the mesh.&amp;lt;/param&amp;gt;&#xA;    /// &amp;lt;param name=&amp;quot;animations&amp;quot;&amp;gt;An array of &amp;lt;see cref=&amp;quot;ModelAnimation&amp;quot;/&amp;gt; objects defining animations for the mesh.&amp;lt;/param&amp;gt;&#xA;    public MeshAmateurBuilder(Node rootNode, ModelAnimation[] animations) {&#xA;        this._rootNode = rootNode;&#xA;        this._animations = animations;&#xA;    }&#xA;&#xA;    /// &amp;lt;summary&amp;gt;&#xA;    /// Constructs a dictionary containing bone information mapped by animation name and frame index.&#xA;    /// &amp;lt;/summary&amp;gt;&#xA;    /// &amp;lt;param name=&amp;quot;bonesByName&amp;quot;&amp;gt;A dictionary mapping bone identifiers to bone objects.&amp;lt;/param&amp;gt;&#xA;    /// &amp;lt;returns&amp;gt;A dictionary where keys are animation names, and values are dictionaries that map frame indices to arrays of bone information.&amp;lt;/returns&amp;gt;&#xA;    public Dictionary&amp;lt;string, Dictionary&amp;lt;int, BoneInfo[]&amp;gt;&amp;gt; Build(Dictionary&amp;lt;uint, Bone&amp;gt; bonesByName) {&#xA;        this._bonesByName = bonesByName;&#xA;        this._boneTransformations = new Matrix4x4[bonesByName.Count];&#xA;        &#xA;        Dictionary&amp;lt;string, Dictionary&amp;lt;int, BoneInfo[]&amp;gt;&amp;gt; boneInfos = new Dictionary&amp;lt;string, Dictionary&amp;lt;int, BoneInfo[]&amp;gt;&amp;gt;();&#xA;        &#xA;        foreach (ModelAnimation animation in this._animations) {&#xA;            boneInfos.Add(animation.Name, this.SetupBoneInfos(animation));&#xA;        }&#xA;&#xA;        return boneInfos;&#xA;    }&#xA;&#xA;    /// &amp;lt;summary&amp;gt;&#xA;    /// Generates a dictionary that maps frame indices to arrays of &amp;lt;see cref=&amp;quot;BoneInfo&amp;quot;/&amp;gt; for a given animation.&#xA;    /// &amp;lt;/summary&amp;gt;&#xA;    /// &amp;lt;param name=&amp;quot;animation&amp;quot;&amp;gt;The animation for which bone information is being set up.&amp;lt;/param&amp;gt;&#xA;    /// &amp;lt;returns&amp;gt;A dictionary with frame indices as keys and arrays of &amp;lt;see cref=&amp;quot;BoneInfo&amp;quot;/&amp;gt; as values.&amp;lt;/returns&amp;gt;&#xA;    private Dictionary&amp;lt;int, BoneInfo[]&amp;gt; SetupBoneInfos(ModelAnimation animation) {&#xA;        Dictionary&amp;lt;int, BoneInfo[]&amp;gt; bones = new Dictionary&amp;lt;int, BoneInfo[]&amp;gt;();&#xA;        &#xA;        for (int i = 0; i &amp;lt; animation.FrameCount; i&#x2B;&#x2B;) {&#xA;            List&amp;lt;BoneInfo&amp;gt; boneInfos = new List&amp;lt;BoneInfo&amp;gt;();&#xA;            &#xA;            this.UpdateChannel(this._rootNode, animation, i, AMatrix4x4.Identity);&#xA;&#xA;            for (uint boneId = 0; boneId &amp;lt; this._boneTransformations.Length; boneId&#x2B;&#x2B;) {&#xA;                BoneInfo boneInfo = new BoneInfo(this._bonesByName[boneId].Name, boneId, this._boneTransformations[boneId]);&#xA;                boneInfos.Add(boneInfo);&#xA;            }&#xA;            &#xA;            bones.Add(i, boneInfos.ToArray());&#xA;        }&#xA;&#xA;        return bones;&#xA;    }&#xA;&#xA;    /// &amp;lt;summary&amp;gt;&#xA;    /// Updates the transformation channel of a specified node based on the animation data and current frame index.&#xA;    /// &amp;lt;/summary&amp;gt;&#xA;    /// &amp;lt;param name=&amp;quot;node&amp;quot;&amp;gt;The node whose transformation channel is to be updated.&amp;lt;/param&amp;gt;&#xA;    /// &amp;lt;param name=&amp;quot;animation&amp;quot;&amp;gt;The animation containing the transformation data.&amp;lt;/param&amp;gt;&#xA;    /// &amp;lt;param name=&amp;quot;frame&amp;quot;&amp;gt;The current frame index being processed.&amp;lt;/param&amp;gt;&#xA;    /// &amp;lt;param name=&amp;quot;parentTransform&amp;quot;&amp;gt;The transformation matrix of the parent node.&amp;lt;/param&amp;gt;&#xA;    private void UpdateChannel(Node node, ModelAnimation animation, int frame, AMatrix4x4 parentTransform) {&#xA;        AMatrix4x4 nodeTransformation = AMatrix4x4.Identity;&#xA;&#xA;        if (this.GetChannel(node, animation, out NodeAnimationChannel? channel)) {&#xA;            AMatrix4x4 scale = this.InterpolateScale(channel!, animation, frame);&#xA;            AMatrix4x4 rotation = this.InterpolateRotation(channel!, animation, frame);&#xA;            AMatrix4x4 translation = this.InterpolateTranslation(channel!, animation, frame);&#xA;            &#xA;            nodeTransformation = scale * rotation * translation;&#xA;        }&#xA;&#xA;        foreach (uint boneId in this._bonesByName.Keys) {&#xA;            Bone bone = this._bonesByName[boneId];&#xA;            &#xA;            if (node.Name == bone.Name) {&#xA;                AMatrix4x4 rootInverseTransform = this._rootNode.Transform;&#xA;                rootInverseTransform.Inverse();&#xA;                &#xA;                AMatrix4x4 transformation = bone.OffsetMatrix * nodeTransformation * parentTransform * rootInverseTransform;&#xA;                this._boneTransformations[boneId] = Matrix4x4.Transpose(ModelConversion.FromAMatrix4X4(transformation));&#xA;            }&#xA;        }&#xA;&#xA;        foreach (Node childNode in node.Children) {&#xA;            this.UpdateChannel(childNode, animation, frame, nodeTransformation * parentTransform);&#xA;        }&#xA;    }&#xA;&#xA;    /// &amp;lt;summary&amp;gt;&#xA;    /// Interpolates the translation transformation at a specific frame using the provided animation channel and animation data.&#xA;    /// &amp;lt;/summary&amp;gt;&#xA;    /// &amp;lt;param name=&amp;quot;channel&amp;quot;&amp;gt;The &amp;lt;see cref=&amp;quot;NodeAnimationChannel&amp;quot;/&amp;gt; containing position keys for the node.&amp;lt;/param&amp;gt;&#xA;    /// &amp;lt;param name=&amp;quot;animation&amp;quot;&amp;gt;The &amp;lt;see cref=&amp;quot;ModelAnimation&amp;quot;/&amp;gt; containing the animation data, including timing information.&amp;lt;/param&amp;gt;&#xA;    /// &amp;lt;param name=&amp;quot;frame&amp;quot;&amp;gt;The current frame for which the translation is being interpolated.&amp;lt;/param&amp;gt;&#xA;    /// &amp;lt;returns&amp;gt;An &amp;lt;see cref=&amp;quot;Assimp.Matrix4x4&amp;quot;/&amp;gt; representing the interpolated translation transformation for the given frame.&amp;lt;/returns&amp;gt;&#xA;    private AMatrix4x4 InterpolateTranslation(NodeAnimationChannel channel, ModelAnimation animation, int frame) {&#xA;        double frameTime = frame / 60.0F * animation.TicksPerSecond;&#xA;        Vector3D position;&#xA;        &#xA;        if (channel.PositionKeyCount == 1) {&#xA;            position = channel.PositionKeys[0].Value;&#xA;        }&#xA;        else {&#xA;            uint frameIndex = 0;&#xA;            for (uint i = 0; i &amp;lt; channel.PositionKeyCount - 1; i&#x2B;&#x2B;) {&#xA;                if (frameTime &amp;lt; channel.PositionKeys[(int) (i &#x2B; 1)].Time) {&#xA;                    frameIndex = i;&#xA;                    break;&#xA;                }&#xA;            }&#xA;&#xA;            VectorKey currentFrame = channel.PositionKeys[(int) frameIndex];&#xA;            VectorKey nextFrame = channel.PositionKeys[(int) ((frameIndex &#x2B; 1) % channel.PositionKeyCount)];&#xA;&#xA;            double delta = (frameTime - currentFrame.Time) / (nextFrame.Time - currentFrame.Time);&#xA;&#xA;            Vector3D start = currentFrame.Value;&#xA;            Vector3D end = nextFrame.Value;&#xA;            position = start &#x2B; (float) delta * (end - start);&#xA;        }&#xA;        &#xA;        return AMatrix4x4.FromTranslation(position);&#xA;    }&#xA;&#xA;    /// &amp;lt;summary&amp;gt;&#xA;    /// Interpolates the rotation transformation for a given node animation channel at a specified frame.&#xA;    /// &amp;lt;/summary&amp;gt;&#xA;    /// &amp;lt;param name=&amp;quot;channel&amp;quot;&amp;gt;The &amp;lt;see cref=&amp;quot;NodeAnimationChannel&amp;quot;/&amp;gt; containing the rotation keyframes for the node.&amp;lt;/param&amp;gt;&#xA;    /// &amp;lt;param name=&amp;quot;animation&amp;quot;&amp;gt;The &amp;lt;see cref=&amp;quot;ModelAnimation&amp;quot;/&amp;gt; object defining the overall animation data.&amp;lt;/param&amp;gt;&#xA;    /// &amp;lt;param name=&amp;quot;frame&amp;quot;&amp;gt;The current frame for which the rotation needs to be interpolated.&amp;lt;/param&amp;gt;&#xA;    /// &amp;lt;returns&amp;gt;An &amp;lt;see cref=&amp;quot;AMatrix4x4&amp;quot;/&amp;gt; representing the interpolated rotation transformation matrix for the specified frame.&amp;lt;/returns&amp;gt;&#xA;    private AMatrix4x4 InterpolateRotation(NodeAnimationChannel channel, ModelAnimation animation, int frame) {&#xA;        double frameTime = frame / 60.0F * animation.TicksPerSecond;&#xA;        AQuaternion rotation;&#xA;&#xA;        if (channel.RotationKeyCount == 1) {&#xA;            rotation = channel.RotationKeys[0].Value;&#xA;        }&#xA;        else {&#xA;            uint frameIndex = 0;&#xA;            for (uint i = 0; i &amp;lt; channel.RotationKeyCount - 1; i&#x2B;&#x2B;) {&#xA;                if (frameTime &amp;lt; channel.RotationKeys[(int) (i &#x2B; 1)].Time) {&#xA;                    frameIndex = i;&#xA;                    break;&#xA;                }&#xA;            }&#xA;&#xA;            QuaternionKey currentFrame = channel.RotationKeys[(int) frameIndex];&#xA;            QuaternionKey nextFrame = channel.RotationKeys[(int) ((frameIndex &#x2B; 1) % channel.RotationKeyCount)];&#xA;&#xA;            double delta = (frameTime - currentFrame.Time) / (nextFrame.Time - currentFrame.Time);&#xA;&#xA;            AQuaternion start = currentFrame.Value;&#xA;            AQuaternion end = nextFrame.Value;&#xA;            rotation = AQuaternion.Slerp(start, end, (float) delta);&#xA;            rotation.Normalize();&#xA;        }&#xA;        &#xA;        return rotation.GetMatrix();&#xA;    }&#xA;&#xA;    /// &amp;lt;summary&amp;gt;&#xA;    /// Computes the interpolated scale transformation for a given animation channel at a specific frame.&#xA;    /// &amp;lt;/summary&amp;gt;&#xA;    /// &amp;lt;param name=&amp;quot;channel&amp;quot;&amp;gt;The &amp;lt;see cref=&amp;quot;NodeAnimationChannel&amp;quot;/&amp;gt; containing scaling keyframes.&amp;lt;/param&amp;gt;&#xA;    /// &amp;lt;param name=&amp;quot;animation&amp;quot;&amp;gt;The &amp;lt;see cref=&amp;quot;ModelAnimation&amp;quot;/&amp;gt; associated with the animation data.&amp;lt;/param&amp;gt;&#xA;    /// &amp;lt;param name=&amp;quot;frame&amp;quot;&amp;gt;The current frame of the animation for which the scale transformation is calculated.&amp;lt;/param&amp;gt;&#xA;    /// &amp;lt;returns&amp;gt;An &amp;lt;see cref=&amp;quot;AMatrix4x4&amp;quot;/&amp;gt; representing the interpolated scale transformation at the specified frame.&amp;lt;/returns&amp;gt;&#xA;    private AMatrix4x4 InterpolateScale(NodeAnimationChannel channel, ModelAnimation animation, int frame) {&#xA;        double frameTime = frame / 60.0F * animation.TicksPerSecond;&#xA;        Vector3D scale;&#xA;&#xA;        if (channel.ScalingKeyCount == 1) {&#xA;            scale = channel.ScalingKeys[0].Value;&#xA;        }&#xA;        else {&#xA;            uint frameIndex = 0;&#xA;            for (uint i = 0; i &amp;lt; channel.ScalingKeyCount - 1; i&#x2B;&#x2B;) {&#xA;                if (frameTime &amp;lt; channel.ScalingKeys[(int) (i &#x2B; 1)].Time) {&#xA;                    frameIndex = i;&#xA;                    break;&#xA;                }&#xA;            }&#xA;&#xA;            VectorKey currentFrame = channel.ScalingKeys[(int)frameIndex];&#xA;            VectorKey nextFrame = channel.ScalingKeys[(int)((frameIndex &#x2B; 1) % channel.ScalingKeyCount)];&#xA;&#xA;            double delta = (frameTime - currentFrame.Time) / (nextFrame.Time - currentFrame.Time);&#xA;&#xA;            Vector3D start = currentFrame.Value;&#xA;            Vector3D end = nextFrame.Value;&#xA;&#xA;            scale = start &#x2B; (float) delta * (end - start);&#xA;        }&#xA;        &#xA;        return AMatrix4x4.FromScaling(scale);&#xA;    }&#xA;&#xA;    /// &amp;lt;summary&amp;gt;&#xA;    /// Retrieves the animation channel for a given node from the specified animation.&#xA;    /// &amp;lt;/summary&amp;gt;&#xA;    /// &amp;lt;param name=&amp;quot;node&amp;quot;&amp;gt;The node for which the animation channel should be retrieved.&amp;lt;/param&amp;gt;&#xA;    /// &amp;lt;param name=&amp;quot;animation&amp;quot;&amp;gt;The animation containing the channels to check.&amp;lt;/param&amp;gt;&#xA;    /// &amp;lt;param name=&amp;quot;channel&amp;quot;&amp;gt;The output parameter that will hold the retrieved node animation channel if found; otherwise, null.&amp;lt;/param&amp;gt;&#xA;    /// &amp;lt;returns&amp;gt;True if the channel for the specified node is found in the animation; otherwise, false.&amp;lt;/returns&amp;gt;&#xA;    private bool GetChannel(Node node, ModelAnimation animation, out NodeAnimationChannel? channel) {&#xA;        foreach (NodeAnimationChannel nodeChannel in animation.AnimationChannels) {&#xA;            if (nodeChannel.NodeName == node.Name) {&#xA;                channel = nodeChannel;&#xA;                return true;&#xA;            }&#xA;        }&#xA;&#xA;        channel = null;&#xA;        return false;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/79162575</id>
        <re:rank scheme="https://stackoverflow.com">1</re:rank>
        <title type="text">What am I doing wrong when loading a skeleton and animation?</title>
            <category scheme="https://stackoverflow.com/tags" term="c&#x2B;&#x2B;" />
            <category scheme="https://stackoverflow.com/tags" term="matrix" />
            <category scheme="https://stackoverflow.com/tags" term="directx-11" />
            <category scheme="https://stackoverflow.com/tags" term="assimp" />
            <category scheme="https://stackoverflow.com/tags" term="skeleton" />
        <author>
            <name>ZultooX</name>
            <uri>https://stackoverflow.com/users/16650078</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/79162575/what-am-i-doing-wrong-when-loading-a-skeleton-and-animation" />
        <published>2024-11-06T12:26:10Z</published>
        <updated>2024-11-12T12:45:48Z</updated>
        <summary type="html">
            &lt;p&gt;I am trying to load an animation and skeleton using assimp. Im not sure if im doing the matrix multiplication correct or if I&#x27;m missing a Inverse or transpose somewhere.&#xA;My engine is using a lefthanded coordinate system, using row-major matrices.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.sstatic.net/TMKiIuYJ.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;Gif of how its currently looking.&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h1&gt;Im storing the animation and skeleton in the structure below.&lt;/h1&gt;&#xA;&lt;pre&gt;&lt;code&gt;struct Skeleton&#xA;{&#xA;    struct Joint&#xA;    {&#xA;        Matrix4x4f BindPoseInverse;&#xA;        int ParentIdx;&#xA;        std::vector&amp;lt;int&amp;gt; Children;&#xA;        std::string Name;&#xA;    };&#xA;&#xA;    std::vector&amp;lt;Joint&amp;gt; Joints;&#xA;    std::unordered_map&amp;lt;std::string, size_t&amp;gt; JointNameToIndex;&#xA;};&#xA;&#xA;&#xA;struct Animation&#xA;{&#xA;    struct Frame&#xA;    {&#xA;        std::unordered_map&amp;lt;&#xA;            std::string,&#xA;            Matrix4x4f&#xA;        &amp;gt; Transforms;&#xA;    };&#xA;    std::vector&amp;lt;Frame&amp;gt; Frames;&#xA;    float Duration;&#xA;    float FramesPerSecond;&#xA;};&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h1&gt;Code from the importer.&lt;/h1&gt;&#xA;&lt;pre&gt;&lt;code&gt;Mesh* MeshFactory::LoadMesh(const char* aMeshPath)&#xA;{&#xA;    static int flags = aiProcess_Triangulate |&#xA;        aiProcess_FlipUVs |&#xA;        aiProcess_GenSmoothNormals |&#xA;        aiProcess_CalcTangentSpace |&#xA;        aiProcess_MakeLeftHanded |&#xA;        aiProcess_FlipWindingOrder;&#xA;&#xA;    Assimp::Importer importer;&#xA;    importer.SetPropertyBool(AI_CONFIG_IMPORT_FBX_PRESERVE_PIVOTS, false);&#xA;    importer.SetPropertyInteger(AI_CONFIG_PP_LBW_MAX_WEIGHTS, 4);&#xA;&#xA;    const aiScene* scene = importer.ReadFile(aMeshPath, flags);&#xA;&#xA;&#xA;    Mesh* _mesh = new Mesh;&#xA;    unsigned int vertexOffset = 0;&#xA;&#xA;    auto myMAtrixToassimp = [](aiMatrix4x4 aiMat) {&#xA;        Matrix4x4f mat;&#xA;        for (int i = 0; i &amp;lt; 4; i&#x2B;&#x2B;) {&#xA;            for (int j = 0; j &amp;lt; 4; j&#x2B;&#x2B;) {&#xA;                mat(i &#x2B; 1, j &#x2B; 1) = aiMat[i][j];&#xA;            }&#xA;        }&#xA;        return mat;&#xA;        };&#xA;&#xA;    if (scene-&amp;gt;mNumMeshes == 0 &amp;amp;&amp;amp; scene-&amp;gt;mNumAnimations &amp;gt; 0)&#xA;    {&#xA;        Animation* anim = LoadAnimation(scene);&#xA;        AnimationFactory::GetInstance()-&amp;gt;AddAnimation(anim);&#xA;    }&#xA;    else&#xA;    {&#xA;        for (unsigned int i = 0; i &amp;lt; scene-&amp;gt;mNumMeshes; &#x2B;&#x2B;i)&#xA;        {&#xA;            aiMesh* mesh = scene-&amp;gt;mMeshes[i];&#xA;&#xA;            for (unsigned int v = 0; v &amp;lt; mesh-&amp;gt;mNumVertices; &#x2B;&#x2B;v)&#xA;            {&#xA;                aiVector3D vertex = mesh-&amp;gt;mVertices[v];&#xA;&#xA;                aiVector3D normal = mesh-&amp;gt;HasNormals() ? mesh-&amp;gt;mNormals[v] : aiVector3D(0, 0, 0);&#xA;                aiVector3D uv = mesh-&amp;gt;HasTextureCoords(0) ? mesh-&amp;gt;mTextureCoords[0][v] : aiVector3D(0, 0, 0);&#xA;                aiVector3D tangent = mesh-&amp;gt;HasTangentsAndBitangents() ? mesh-&amp;gt;mTangents[v] : aiVector3D(0, 0, 0);&#xA;                aiVector3D bitangent = mesh-&amp;gt;HasTangentsAndBitangents() ? mesh-&amp;gt;mBitangents[v] : aiVector3D(0, 0, 0);&#xA;&#xA;                Vertex vert =&#xA;                {&#xA;                    {vertex.x, vertex.y, vertex.z, 1.f},&#xA;                    {1.f, 1.f, 1.f, 1.f},&#xA;                    {normal.x, normal.y, normal.z, 1.f},&#xA;                    {tangent.x, tangent.y, tangent.z, 1.f},&#xA;                    {bitangent.x, bitangent.y, bitangent.z, 1.f},&#xA;                    {0,0,0,0},&#xA;                    {0.f,0.f,0.f,0.f},&#xA;                    {uv.x, uv.y},&#xA;                };&#xA;&#xA;                _mesh-&amp;gt;AddVertex(vert);&#xA;            }&#xA;&#xA;            for (unsigned int f = 0; f &amp;lt; mesh-&amp;gt;mNumFaces; &#x2B;&#x2B;f)&#xA;            {&#xA;                aiFace face = mesh-&amp;gt;mFaces[f];&#xA;                if (face.mNumIndices == 3)&#xA;                {&#xA;                    _mesh-&amp;gt;AddFace(face.mIndices[0] &#x2B; vertexOffset, face.mIndices[1] &#x2B; vertexOffset, face.mIndices[2] &#x2B; vertexOffset);&#xA;                }&#xA;            }&#xA;&#xA;            vertexOffset &#x2B;= mesh-&amp;gt;mNumVertices;&#xA;        }&#xA;&#xA;        if (scene-&amp;gt;HasAnimations())&#xA;        {&#xA;            _mesh-&amp;gt;mySkeleton = LoadSkeleton(scene, *_mesh);&#xA;            ExtractBoneWeights(scene, *_mesh);&#xA;        }&#xA;    }&#xA;&#xA;    if (_mesh != nullptr)&#xA;    {&#xA;        _mesh-&amp;gt;SetName(aMeshPath);&#xA;        myMeshes[aMeshPath] = _mesh;&#xA;    }&#xA;&#xA;    return _mesh;&#xA;}&#xA;&#xA;&#xA;&#xA;Skeleton* MeshFactory::LoadSkeleton(const aiScene* aScene, Mesh&amp;amp; aMesh)&#xA;{&#xA;    auto myMAtrixToassimp = [](aiMatrix4x4 aiMat) {&#xA;        Matrix4x4f mat;&#xA;        for (int i = 0; i &amp;lt; 4; i&#x2B;&#x2B;) {&#xA;            for (int j = 0; j &amp;lt; 4; j&#x2B;&#x2B;) {&#xA;                mat(i &#x2B; 1, j &#x2B; 1) = aiMat[i][j];&#xA;            }&#xA;        }&#xA;&#xA;        for (int i = 0; i &amp;lt; 3; i&#x2B;&#x2B;)&#xA;        {&#xA;            mat(i &#x2B; 1, 4) = 0;&#xA;        }&#xA;        mat(4, 4) = 1;&#xA;&#xA;&#xA;        return mat;&#xA;        };&#xA;&#xA;    Skeleton* skeleton = new Skeleton();&#xA;&#xA;    for (unsigned int i = 0; i &amp;lt; aScene-&amp;gt;mNumMeshes; &#x2B;&#x2B;i) &#xA;    {&#xA;        aiMesh* mesh = aScene-&amp;gt;mMeshes[i];&#xA;&#xA;        for (unsigned int j = 0; j &amp;lt; mesh-&amp;gt;mNumBones; &#x2B;&#x2B;j) &#xA;        {&#xA;            aiBone* aiBone = mesh-&amp;gt;mBones[j];&#xA;            std::string boneName = aiBone-&amp;gt;mName.C_Str();&#xA;&#xA;            if (skeleton-&amp;gt;JointNameToIndex.find(boneName) == skeleton-&amp;gt;JointNameToIndex.end()) &#xA;            {&#xA;                Skeleton::Joint joint;&#xA;                joint.Name = boneName;&#xA;                joint.BindPoseInverse = myMAtrixToassimp(aiBone-&amp;gt;mOffsetMatrix).GetInverse();&#xA;&#xA;                size_t jointIndex = skeleton-&amp;gt;Joints.size();&#xA;                skeleton-&amp;gt;JointNameToIndex[boneName] = jointIndex;&#xA;                skeleton-&amp;gt;Joints.push_back(joint);&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;    std::function&amp;lt;void(aiNode*, int)&amp;gt; processNode = [&amp;amp;](aiNode* node, int parentIndex)&#xA;        {&#xA;            std::string nodeName = node-&amp;gt;mName.C_Str();&#xA;&#xA;            if (skeleton-&amp;gt;JointNameToIndex.find(nodeName) != skeleton-&amp;gt;JointNameToIndex.end())&#xA;            {&#xA;                size_t jointIndex = skeleton-&amp;gt;JointNameToIndex[nodeName];&#xA;                Skeleton::Joint&amp;amp; joint = skeleton-&amp;gt;Joints[jointIndex];&#xA;&#xA;                joint.ParentIdx = parentIndex;&#xA;&#xA;                // Set up parent-child relationship&#xA;                if (parentIndex != -1)&#xA;                {&#xA;                    skeleton-&amp;gt;Joints[parentIndex].Children.push_back(jointIndex);&#xA;                }&#xA;&#xA;                parentIndex = static_cast&amp;lt;int&amp;gt;(jointIndex);&#xA;            }&#xA;&#xA;            for (unsigned int i = 0; i &amp;lt; node-&amp;gt;mNumChildren; &#x2B;&#x2B;i)&#xA;            {&#xA;                processNode(node-&amp;gt;mChildren[i], parentIndex);&#xA;            }&#xA;        };&#xA;&#xA;    processNode(aScene-&amp;gt;mRootNode, -1);&#xA;&#xA;    return skeleton;&#xA;}&#xA;&#xA;&#xA;Animation* MeshFactory::LoadAnimation(const aiScene* aScene)&#xA;{&#xA;    aiAnimation* aiAnim = aScene-&amp;gt;mAnimations[0];&#xA;&#xA;    Animation* animation = new Animation();&#xA;    float ticksPerSecond = aiAnim-&amp;gt;mTicksPerSecond &amp;gt; 0.0 ? static_cast&amp;lt;float&amp;gt;(aiAnim-&amp;gt;mTicksPerSecond) : 24.0f;&#xA;    animation-&amp;gt;Duration = static_cast&amp;lt;float&amp;gt;(aiAnim-&amp;gt;mDuration) / ticksPerSecond;&#xA;&#xA;    animation-&amp;gt;FramesPerSecond = ticksPerSecond;&#xA;&#xA;    int totalFrames = static_cast&amp;lt;int&amp;gt;(animation-&amp;gt;Duration * animation-&amp;gt;FramesPerSecond);&#xA;    animation-&amp;gt;Frames.resize(totalFrames);&#xA;&#xA;    for (unsigned int channelIndex = 0; channelIndex &amp;lt; aiAnim-&amp;gt;mNumChannels; &#x2B;&#x2B;channelIndex)&#xA;    {&#xA;        aiNodeAnim* channel = aiAnim-&amp;gt;mChannels[channelIndex];&#xA;        std::string jointName = channel-&amp;gt;mNodeName.C_Str();&#xA;&#xA;        for (int frameIndex = 0; frameIndex &amp;lt; totalFrames; &#x2B;&#x2B;frameIndex) &#xA;        {&#xA;            float timeInTicks = (frameIndex / animation-&amp;gt;FramesPerSecond) * aiAnim-&amp;gt;mTicksPerSecond;&#xA;&#xA;&#xA;            aiVector3D position;&#xA;            if (channel-&amp;gt;mNumPositionKeys == 1) &#xA;            {&#xA;                position = channel-&amp;gt;mPositionKeys[0].mValue;&#xA;            }&#xA;            else &#xA;            {&#xA;                for (unsigned int i = 0; i &amp;lt; channel-&amp;gt;mNumPositionKeys - 1; i&#x2B;&#x2B;) &#xA;                {&#xA;                    if (timeInTicks &amp;lt; channel-&amp;gt;mPositionKeys[i &#x2B; 1].mTime) &#xA;                    {&#xA;                        aiVectorKey key1 = channel-&amp;gt;mPositionKeys[i];&#xA;                        aiVectorKey key2 = channel-&amp;gt;mPositionKeys[i &#x2B; 1];&#xA;                        float factor = (timeInTicks - key1.mTime) / (key2.mTime - key1.mTime);&#xA;                        position = key1.mValue &#x2B; (key2.mValue - key1.mValue) * factor;&#xA;                        break;&#xA;                    }&#xA;                }&#xA;            }&#xA;&#xA;&#xA;            aiQuaternion rotation;&#xA;            if (channel-&amp;gt;mNumRotationKeys == 1) &#xA;            {&#xA;                rotation = channel-&amp;gt;mRotationKeys[0].mValue;&#xA;            }&#xA;            else &#xA;            {&#xA;                for (unsigned int i = 0; i &amp;lt; channel-&amp;gt;mNumRotationKeys - 1; i&#x2B;&#x2B;) &#xA;                {&#xA;                    if (timeInTicks &amp;lt; channel-&amp;gt;mRotationKeys[i &#x2B; 1].mTime) &#xA;                    {&#xA;                        aiQuatKey key1 = channel-&amp;gt;mRotationKeys[i];&#xA;                        aiQuatKey key2 = channel-&amp;gt;mRotationKeys[i &#x2B; 1];&#xA;                        float factor = (timeInTicks - key1.mTime) / (key2.mTime - key1.mTime);&#xA;                        aiQuaternion::Interpolate(rotation, key1.mValue, key2.mValue, factor);&#xA;                        rotation.Normalize();&#xA;                        break;&#xA;                    }&#xA;                }&#xA;            }&#xA;&#xA;&#xA;            aiVector3D scale;&#xA;            if (channel-&amp;gt;mNumScalingKeys == 1)&#xA;            {&#xA;                scale = channel-&amp;gt;mScalingKeys[0].mValue;&#xA;            }&#xA;            else&#xA;            {&#xA;                for (unsigned int i = 0; i &amp;lt; channel-&amp;gt;mNumScalingKeys - 1; i&#x2B;&#x2B;)&#xA;                {&#xA;                    if (timeInTicks &amp;lt; channel-&amp;gt;mScalingKeys[i &#x2B; 1].mTime)&#xA;                    {&#xA;                        aiVectorKey key1 = channel-&amp;gt;mScalingKeys[i];&#xA;                        aiVectorKey key2 = channel-&amp;gt;mScalingKeys[i &#x2B; 1];&#xA;                        float factor = (timeInTicks - key1.mTime) / (key2.mTime - key1.mTime);&#xA;                        scale = key1.mValue &#x2B; (key2.mValue - key1.mValue) * factor;&#xA;                        break;&#xA;                    }&#xA;                }&#xA;            }&#xA;&#xA;&#xA;            Matrix4x4f translationMat;&#xA;            translationMat.SetPosition({ position.x, position.y, position.z, 1.f });&#xA;&#xA;            Matrix4x4f rotationMat;&#xA;            {&#xA;                float x = rotation.x;&#xA;                float y = rotation.y;&#xA;                float z = rotation.z;&#xA;                float w = rotation.w;&#xA;&#xA;                float xx = x * x;&#xA;                float yy = y * y;&#xA;                float zz = z * z;&#xA;                float xy = x * y;&#xA;                float xz = x * z;&#xA;                float yz = y * z;&#xA;                float wx = w * x;&#xA;                float wy = w * y;&#xA;                float wz = w * z;&#xA;&#xA;                float r11 = 1.0f - 2.0f * (yy &#x2B; zz);&#xA;                float r12 = 2.0f * (xy - wz);&#xA;                float r13 = 2.0f * (xz &#x2B; wy);&#xA;&#xA;                float r21 = 2.0f * (xy &#x2B; wz);&#xA;                float r22 = 1.0f - 2.0f * (xx &#x2B; zz);&#xA;                float r23 = 2.0f * (yz - wx);&#xA;&#xA;                float r31 = 2.0f * (xz - wy);&#xA;                float r32 = 2.0f * (yz &#x2B; wx);&#xA;                float r33 = 1.0f - 2.0f * (xx &#x2B; yy);&#xA;&#xA;                rotationMat(1, 1) = r11;&#xA;                rotationMat(1, 2) = r12;&#xA;                rotationMat(1, 3) = r13;&#xA;                rotationMat(1, 4) = 0;&#xA;&#xA;                rotationMat(2, 1) = r21;&#xA;                rotationMat(2, 2) = r22;&#xA;                rotationMat(2, 3) = r23;&#xA;                rotationMat(2, 4) = 0;&#xA;&#xA;                rotationMat(3, 1) = r31;&#xA;                rotationMat(3, 2) = r32;&#xA;                rotationMat(3, 3) = r33;&#xA;                rotationMat(3, 4) = 0;&#xA;&#xA;                rotationMat = rotationMat.GetTranspose();&#xA;            }&#xA;&#xA;            Matrix4x4f scaleMat;&#xA;            scaleMat = Matrix4x4f::CreateScaleMatrix({ scale.x, scale.y, scale.z, 0.f });&#xA;&#xA;            Matrix4x4f finalTransform = translationMat * rotationMat ;&#xA;&#xA;&#xA;            animation-&amp;gt;Frames[frameIndex].Transforms[jointName] = finalTransform;&#xA;        }&#xA;    }&#xA;&#xA;    return animation;&#xA;}&#xA;&#xA;void MeshFactory::ExtractBoneWeights(const aiScene* aScene, Mesh&amp;amp; aMesh)&#xA;{&#xA;    if (!aScene) return;&#xA;&#xA;    for (unsigned int m = 0; m &amp;lt; aScene-&amp;gt;mNumMeshes; &#x2B;&#x2B;m)&#xA;    {&#xA;        const aiMesh* mesh = aScene-&amp;gt;mMeshes[m];&#xA;&#xA;        if (mesh-&amp;gt;mNumBones &amp;gt; 0)&#xA;        {&#xA;            for (unsigned int b = 0; b &amp;lt; mesh-&amp;gt;mNumBones; &#x2B;&#x2B;b)&#xA;            {&#xA;                aiBone* bone = mesh-&amp;gt;mBones[b];&#xA;&#xA;                for (unsigned int w = 0; w &amp;lt; bone-&amp;gt;mNumWeights; &#x2B;&#x2B;w)&#xA;                {&#xA;                    unsigned int vertexId = bone-&amp;gt;mWeights[w].mVertexId; &#xA;                    float weight = bone-&amp;gt;mWeights[w].mWeight; &#xA;&#xA;                    if (vertexId &amp;lt; aMesh.m_Verticies.size())&#xA;                    {&#xA;                        Vertex&amp;amp; vertex = aMesh.m_Verticies[vertexId];&#xA;&#xA;                        for (size_t i = 0; i &amp;lt; 4; i&#x2B;&#x2B;)&#xA;                        {&#xA;                            if (vertex.BoneWeights[i] == 0)&#xA;                            {&#xA;                                vertex.BoneIDs[i] = b; &#xA;                                vertex.BoneWeights[i] = weight; &#xA;                            }&#xA;                        }&#xA;                    }&#xA;                }&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;    for (Vertex&amp;amp; vertex : aMesh.m_Verticies)&#xA;    {&#xA;        float totalWeight = 0.0f;&#xA;&#xA;        for (int i = 0; i &amp;lt; 4; i&#x2B;&#x2B;)&#xA;        {&#xA;            totalWeight &#x2B;= vertex.BoneWeights[i];&#xA;        }&#xA;&#xA;        if (totalWeight &amp;gt; 0.0f)&#xA;        {&#xA;            for (int i = 0; i &amp;lt; 4; i&#x2B;&#x2B;)&#xA;            {&#xA;                vertex.BoneWeights[i] /= totalWeight;&#xA;            }&#xA;        }&#xA;        else&#xA;        {&#xA;            for (int i = 0; i &amp;lt; 4; i&#x2B;&#x2B;)&#xA;            {&#xA;                vertex.BoneWeights[i] = 0.0f;&#xA;            }&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h1&gt;Code from the animator.&lt;/h1&gt;&#xA;&lt;pre&gt;&lt;code&gt;void Animator::UpdateAnimator(unsigned aJointID, const Matrix4x4f&amp;amp; aParentJointTransform, AnimationBuffer&amp;amp; aOutAnimationBuffer)&#xA;{&#xA;    const std::string&amp;amp; jointName = mySkeleton-&amp;gt;Joints[aJointID].Name;&#xA;    const Matrix4x4f&amp;amp; bindPoseInverse = mySkeleton-&amp;gt;Joints[aJointID].BindPoseInverse;&#xA;    const Matrix4x4f&amp;amp; jointLocalTransform = myCurrentAnimation-&amp;gt;Frames[myCurrentFrame].Transforms[jointName];&#xA;&#xA;    Matrix4x4f transform = jointLocalTransform * aParentJointTransform;&#xA;    Matrix4x4f globalJointTransform = bindPoseInverse * transform;&#xA;&#xA;    aOutAnimationBuffer.JointTransforms[aJointID] = globalJointTransform;&#xA;&#xA;    for (unsigned childJointID : mySkeleton-&amp;gt;Joints[aJointID].Children)&#xA;    {&#xA;        UpdateAnimator(childJointID, globalJointTransform, aOutAnimationBuffer);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Im not sure what im expecting. Expecting it to work? hehe.&lt;/p&gt;&#xA;&lt;p&gt;But I&#x27;ve tried changing the order of how im multiplying the matricies and tried getting inverse and transpose of them.&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/79141246</id>
        <re:rank scheme="https://stackoverflow.com">2</re:rank>
        <title type="text">Strange relative paths containing &quot;*0\0&quot; or &quot;*1\0&quot; cutting off the first 3 characters of path while working with Blender, Assimp.NET and FBX files</title>
            <category scheme="https://stackoverflow.com/tags" term="c#" />
            <category scheme="https://stackoverflow.com/tags" term=".net" />
            <category scheme="https://stackoverflow.com/tags" term="relative-path" />
            <category scheme="https://stackoverflow.com/tags" term="fbx" />
            <category scheme="https://stackoverflow.com/tags" term="assimp" />
        <author>
            <name>Nova</name>
            <uri>https://stackoverflow.com/users/28050579</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/79141246/strange-relative-paths-containing-0-0-or-1-0-cutting-off-the-first-3-chara" />
        <published>2024-10-30T13:10:11Z</published>
        <updated>2024-11-27T13:46:00Z</updated>
        <summary type="html">
            &lt;p&gt;I am trying to make a program to merge fbx models. Each model have multiple nodes. Some of the nodes have a specific name meaning that those are functioning as connection points for other models.&lt;/p&gt;&#xA;&lt;p&gt;I already solved pretty much everything regarding the merge, except for the problem of textures. Mesh and material indexes has been updated, but when it come to textures, which are referenced by materials as file paths, I encountered a strange problem.&#xA;To solve the problem of merging models with different full paths, textures cause a problem, since they are referenced with relative paths to the model file.&lt;/p&gt;&#xA;&lt;p&gt;When loaded with the basic code below:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;// Initialize the Assimp context&#xA;AssimpContext importer = new AssimpContext();&#xA;&#xA;// Load the model with desired post-processing flags&#xA;Scene model = importer.ImportFile(filePath, PostProcessPreset.TargetRealTimeMaximumQuality | &#xA;                                            PostProcessSteps.Triangulate |&#xA;                                            PostProcessSteps.FlipUVs |&#xA;                                            PostProcessSteps.EmbedTextures |&#xA;                                            PostProcessSteps.GlobalScale |&#xA;                                            PostProcessSteps.ValidateDataStructure);&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The paths stored by the material looks very strange.&#xA;For example a relative path of the file &amp;quot;Normal.jpg&amp;quot; in the same folder as the fbx file itself gets stored as &amp;quot;*1\0mal.jpg&amp;quot;, another one in a .fbm subfolder named &amp;quot;GPV-2.fbm\BaseColor.jpg&amp;quot; as &amp;quot;*0\0-2 BG.fbm\BaseColor.jpg&amp;quot;.&#xA;To me it looks like the first 3 character gets overwritten at some point during import.&lt;/p&gt;&#xA;&lt;p&gt;I use the Assimp.NET 5.0.0-beta1 package.&lt;/p&gt;&#xA;&lt;p&gt;Has someone seen anything like this before? What is the reason the paths look like this and how can I solve it?&lt;/p&gt;&#xA;&lt;p&gt;Since Assimp.NET has no problem loading the textures I guess the paths are good during the import. Perhaps I could somehow get the fullpath out of assimp?&lt;/p&gt;&#xA;&lt;hr /&gt;&#xA;&lt;p&gt;Path.Combine Does not work. I tried to manually cut the pieces, but the missing characters still cause a problem, and I would try file search if nothing else would work.&lt;/p&gt;&#xA;&lt;p&gt;I tried to look into Assimp code, but couldn&#x27;t find exactly how it imports.&lt;/p&gt;&#xA;&lt;p&gt;I also tried to discuss it with ChatGPT, but couldn&#x27;t solve it either, neither could it give me pointers where to look.&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/78932946</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">How can I use assimp&#x27;s aiMeshMorphKey to animate a character&#x27;s facial expressions?</title>
            <category scheme="https://stackoverflow.com/tags" term="c&#x2B;&#x2B;" />
            <category scheme="https://stackoverflow.com/tags" term="assimp" />
        <author>
            <name>siwameron</name>
            <uri>https://stackoverflow.com/users/23290437</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/78932946/how-can-i-use-assimps-aimeshmorphkey-to-animate-a-characters-facial-expression" />
        <published>2024-08-30T16:19:02Z</published>
        <updated>2024-09-24T20:37:17Z</updated>
        <summary type="html">
            &lt;p&gt;I&#x27;m trying to implement facial expressions using morph animation in my 3D application. I&#x27;ve been looking into the assimp library and found the aiMeshMorphKey structure within the aiAnimation. Could you provide a code example demonstrating how to use aiMeshMorphKey to create morph animations, such as changing a character&#x27;s facial expression over time?&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    for (int i = 0; i &amp;lt; pAnimation-&amp;gt;mNumMorphMeshChannels; &#x2B;&#x2B;i)&#xA;    {&#xA;        if (nodeName &#x2B; &amp;quot;*0&amp;quot; == pAnimation-&amp;gt;mMorphMeshChannels[i]-&amp;gt;mName.C_Str())&#xA;        {&#xA;            std::map&amp;lt;float, glm::mat4&amp;gt; morphMeshKeys;&#xA;            for (int j = 0; j &amp;lt; pAnimation-&amp;gt;mMorphMeshChannels[i]-&amp;gt;mNumKeys; &#x2B;&#x2B;j)&#xA;            {&#xA;                std::cout &amp;lt;&amp;lt; pAnimation-&amp;gt;mMorphMeshChannels[i]-&amp;gt;mName.data &amp;lt;&amp;lt; std::endl;&#xA;                std::cout &amp;lt;&amp;lt; pAnimation-&amp;gt;mMorphMeshChannels[i]-&amp;gt;mKeys[j].mTime &amp;lt;&amp;lt; std::endl;&#xA;                std::cout &amp;lt;&amp;lt; pAnimation-&amp;gt;mMorphMeshChannels[i]-&amp;gt;mKeys-&amp;gt;mValues &amp;lt;&amp;lt; std::endl;&#xA;                std::cout &amp;lt;&amp;lt; pAnimation-&amp;gt;mMorphMeshChannels[i]-&amp;gt;mKeys-&amp;gt;mWeights &amp;lt;&amp;lt; std::endl;&#xA;            }&#xA;        }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Unfortunately, the official documentation was limited to this statement.&#xA;C_STRUCT aiMeshMorphAnim ** mMorphMeshChannels&#xA;The morph mesh animation channels.&lt;/p&gt;&#xA;&lt;p&gt;Each channel affects a single mesh. The array is mNumMorphMeshChannels in size.&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/78905024</id>
        <re:rank scheme="https://stackoverflow.com">-1</re:rank>
        <title type="text">What is aiAnimation in assimp library?</title>
            <category scheme="https://stackoverflow.com/tags" term="animation" />
            <category scheme="https://stackoverflow.com/tags" term="assimp" />
        <author>
            <name>siwameron</name>
            <uri>https://stackoverflow.com/users/23290437</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/78905024/what-is-aianimation-in-assimp-library" />
        <published>2024-08-23T08:39:43Z</published>
        <updated>2024-08-29T21:44:20Z</updated>
        <summary type="html">
            &lt;p&gt;What is aiAnimation in assimp library?&lt;/p&gt;&#xA;&lt;p&gt;I learned about implementing skeletal animation using assimp at the link below.&lt;a href=&quot;https://ogldev.org/www/tutorial38/tutorial38.html&quot; rel=&quot;nofollow noreferrer&quot;&gt;text&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Therefore, I loaded a 3D model file intended to be used in Unity and an FBX file containing only the armature to be applied to that model.&lt;/p&gt;&#xA;&lt;p&gt;However, the 3D model is not drawn well.&#xA;When I looked into it, I found that there were multiple aiAnimations. I know that aiAnimation is an array of aiNodeAnim. When there was only one aiAnimation, it was possible to draw properly.&lt;/p&gt;&#xA;&lt;p&gt;What is the situation when there are multiple aiAnimations, and how should I play the animations?&lt;/p&gt;&#xA;&lt;p&gt;3D model with multiple aiAnimations&#xA;&lt;a href=&quot;https://i.sstatic.net/DtFhgV4E.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;enter image description here&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;3D model with one aiAnimation(plays properly)&#xA;&lt;a href=&quot;https://i.sstatic.net/oTW6VLWA.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;enter image description here&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I tried to play the animation using aiNodeAnim included in all aiAnimation, but it turned out like the top image.&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/78849543</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">Miscalculating skeleton matrices from assimp</title>
            <category scheme="https://stackoverflow.com/tags" term="assimp" />
            <category scheme="https://stackoverflow.com/tags" term="skinning" />
            <category scheme="https://stackoverflow.com/tags" term="skeleton" />
        <author>
            <name>Joao Pincho</name>
            <uri>https://stackoverflow.com/users/1426626</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/78849543/miscalculating-skeleton-matrices-from-assimp" />
        <published>2024-08-08T16:38:58Z</published>
        <updated>2024-08-08T16:38:58Z</updated>
        <summary type="html">
            &lt;p&gt;After loading a model with assimp, all the bone data, nodes, etc, I went on a two step task to implement skinning.&lt;/p&gt;&#xA;&lt;p&gt;If I use just the vertex data with the node hierarchy, I am able to render the model correctly. No skinning, no bone data is sent to the shader, nothing. There are only two meshes but around 60 nodes, specifying parts of the skeleton. The two nodes to which the meshes are attached both have identity matrices, loaded from the file.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.sstatic.net/ypZCAw0w.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.sstatic.net/ypZCAw0w.png&quot; alt=&quot;no bones, simple node hierarchy&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;After implementing skinning in the vertex shader, without loading any animation, letting it be the default pose, the model appears all deformed.&#xA;&lt;a href=&quot;https://i.sstatic.net/mdJlTmeD.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.sstatic.net/mdJlTmeD.png&quot; alt=&quot;same model, but deformed&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I checked the matrices that are loaded, and some of them are not identity matrices. Shouldn&#x27;t they be, for the bind pose?&lt;/p&gt;&#xA;&lt;p&gt;if I pass an identity matrix for every bone, the model appears correctly once again.&#xA;What am I doing wrong here?&lt;/p&gt;&#xA;&lt;p&gt;This is the code I&#x27;m using to calculate the node hierarchy&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;struct MeshTreeNode&#xA;    {&#xA;    std::string Name;&#xA;    glm::mat4 DefaultTransformationMatrix;&#xA;    std::vector &amp;lt;uint32_t&amp;gt; MeshIndices;&#xA;    std::vector &amp;lt;int&amp;gt; ChildNodes;&#xA;    int ParentNode;&#xA;    };&#xA;void ModelCalcMatrices ( const std::vector &amp;lt;MeshTreeNode&amp;gt; &amp;amp;NodeTree, std::vector &amp;lt;glm::mat4&amp;gt; &amp;amp;OutputMatrices, std::vector &amp;lt;NodeMeshIndexPair&amp;gt; &amp;amp;OutputMeshIndices, const unsigned CurrentNodeIndex = 0, const glm::mat4 &amp;amp;CurrentMatrix = glm::identity&amp;lt;glm::mat4&amp;gt; () );&#xA;&#xA;void ModelCalcMatrices ( const std::vector &amp;lt;MeshTreeNode&amp;gt; &amp;amp;NodeTree, std::vector &amp;lt;glm::mat4&amp;gt; &amp;amp;OutputMatrices, std::vector &amp;lt;NodeMeshIndexPair&amp;gt; &amp;amp;OutputMeshIndices, const unsigned CurrentNodeIndex, const glm::mat4 &amp;amp;CurrentMatrix )&#xA;    {&#xA;    glm::mat4 NewMatrix = NodeTree[CurrentNodeIndex].DefaultTransformationMatrix * CurrentMatrix;&#xA;    OutputMatrices.push_back ( NewMatrix );&#xA;    // If there are any meshes to be drawn at this node, add them and their corresponding nodes to the vectors.&#xA;    for ( unsigned MeshIterator = 0; MeshIterator &amp;lt; NodeTree[CurrentNodeIndex].MeshIndices.size (); &#x2B;&#x2B;MeshIterator )&#xA;        {&#xA;        OutputMeshIndices.push_back ( NodeMeshIndexPair ( CurrentNodeIndex, MeshIterator ) );&#xA;        }&#xA;    // Process children&#xA;    for ( unsigned ChildIterator = 0; ChildIterator &amp;lt; NodeTree[CurrentNodeIndex].ChildNodes.size (); &#x2B;&#x2B;ChildIterator )&#xA;        {&#xA;        ModelCalcMatrices ( NodeTree, OutputMatrices, OutputMeshIndices, NodeTree[CurrentNodeIndex].ChildNodes[ChildIterator], NewMatrix );&#xA;        }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I pass it the vector with all nodes as loaded by assimp, and expect an equal-sized vector of matrices to come out. Also outputs another vector with the nodes that actually have some mesh to render.&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/78769674</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">CMake: including assimp header files and linking to shared library [duplicate]</title>
            <category scheme="https://stackoverflow.com/tags" term="c&#x2B;&#x2B;" />
            <category scheme="https://stackoverflow.com/tags" term="cmake" />
            <category scheme="https://stackoverflow.com/tags" term="makefile" />
            <category scheme="https://stackoverflow.com/tags" term="assimp" />
        <author>
            <name>aag</name>
            <uri>https://stackoverflow.com/users/21526642</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/78769674/cmake-including-assimp-header-files-and-linking-to-shared-library" />
        <published>2024-07-19T13:34:46Z</published>
        <updated>2024-07-19T16:24:03Z</updated>
        <summary type="html">
            &lt;p&gt;I am trying to include the assimp library to import models. When I went to compile the code using CMake I got a series of errors. I followed the build instructions to build a dynamic library on &lt;a href=&quot;https://github.com/assimp/assimp/blob/master/Build.md&quot; rel=&quot;nofollow noreferrer&quot;&gt;Assimp&#x27;s Repo&lt;/a&gt; and put the compiled library in a lib folder, as well as the assimp header files in my include directory.&lt;/p&gt;&#xA;&lt;p&gt;My CMakeLists.txt is:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cmake_minimum_required(VERSION 3.20.0)&#xA;project(app)&#xA;&#xA;# set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/bin)&#xA;&#xA;find_package(glfw3 3.4 REQUIRED)&#xA;set(SOURCES main.cpp glad.c shader.h camera.h stb_image.h mesh.h model.h)&#xA;&#xA;include_directories(${CMAKE_SOURCE_DIR}/include)&#xA;# link_directories(${CMAKE_SOURCE_DIR}/lib)&#xA;&#xA;# target_include_directories(${PROJECT_NAME} PUBLIC&#xA;# ${CMAKE_SOURCE_DIR}/include/&#xA;# ${CMAKE_SOURCE_DIR}/include/glad/include&#xA;# ${CMAKE_SOURCE_DIR}/include/GLFW/include&#xA;# ${CMAKE_SOURCE_DIR}/include/glm/include&#xA;# ${CMAKE_SOURCE_DIR}/include/assimp/include&#xA;# )&#xA;&#xA;&#xA;&#xA;add_executable(${PROJECT_NAME} ${SOURCES})&#xA;&#xA;&#xA;target_link_libraries(${PROJECT_NAME})&#xA;target_link_libraries(${PROJECT_NAME} glfw)&#xA;target_link_libraries(${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/lib/libassimp.a)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;and my project structure is&lt;/p&gt;&#xA;&lt;p&gt;Project Directory:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;CMakeLists.txt&lt;/li&gt;&#xA;&lt;li&gt;source files&lt;/li&gt;&#xA;&lt;li&gt;include:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;assimp&lt;/li&gt;&#xA;&lt;li&gt;&lt;em&gt;other includes&lt;/em&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;lib:&#xA;&lt;ul&gt;&#xA;&lt;li&gt;libassimp.5.4.1.dylib&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The errors occur when I run &lt;code&gt;make&lt;/code&gt; and I don&#x27;t get any errors when running cmake&lt;/p&gt;&#xA;&lt;p&gt;How can I fix my CMakeLists.txt to properly include the compiled assimp library and link to to my project?&lt;/p&gt;&#xA;&lt;p&gt;I have tried changing my CMakelists.txt to use target include directories, before and after the add_executable line (after research I know it has to go after now), as well as attempting to use a static library &lt;code&gt;target_link_libraries(${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/lib/libassimp.a)&lt;/code&gt; with no luck.&lt;/p&gt;&#xA;&lt;p&gt;I have run into the same problem trying to include ImGui and tried to use GLOB with no success.&lt;/p&gt;&#xA;&lt;p&gt;I have deleted my CMakeCache and build-files after each change.&lt;/p&gt;&#xA;&lt;p&gt;ERRORS:&#xA;This is the first two errors I get when I run make:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;[ 33%] Building CXX object CMakeFiles/app.dir/main.cpp.o&#xA;In file included from /Users/aag/Documents/code-projects/testcpp/main.cpp:11:&#xA;In file included from /Users/aag/Documents/code-projects/testcpp/model.h:9:&#xA;In file included from /Users/aag/Documents/code-projects/testcpp/include/assimp/Importer.hpp:58:&#xA;In file included from /Users/aag/Documents/code-projects/testcpp/include/assimp/types.h:61:&#xA;/Users/aag/Documents/code-projects/testcpp/include/assimp/defs.h:292:1: error: unknown type name &#x27;constexpr&#x27;&#xA;constexpr ai_real ai_epsilon = (ai_real) 1e-6;&#xA;^&#xA;/Users/aag/Documents/code-projects/testcpp/include/assimp/defs.h:292:18: error: expected &#x27;;&#x27; after top level declarator&#xA;constexpr ai_real ai_epsilon = (ai_real) 1e-6;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Linker Failing Error when running make:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;/opt/homebrew/Cellar/cmake/3.28.1/bin/cmake -S/Users/aag/Documents/code-projects/testcpp -B/Users/aag/Documents/code-projects/testcpp/build --check-build-system CMakeFiles/Makefile.cmake 0&#xA;/opt/homebrew/Cellar/cmake/3.28.1/bin/cmake -E cmake_progress_start /Users/aag/Documents/code-projects/testcpp/build/CMakeFiles /Users/aag/Documents/code-projects/testcpp/build//CMakeFiles/progress.marks&#xA;/Applications/Xcode.app/Contents/Developer/usr/bin/make  -f CMakeFiles/Makefile2 all&#xA;/Applications/Xcode.app/Contents/Developer/usr/bin/make  -f CMakeFiles/assimp.dir/build.make CMakeFiles/assimp.dir/depend&#xA;cd /Users/aag/Documents/code-projects/testcpp/build &amp;amp;&amp;amp; /opt/homebrew/Cellar/cmake/3.28.1/bin/cmake -E cmake_depends &amp;quot;Unix Makefiles&amp;quot; /Users/aag/Documents/code-projects/testcpp /Users/aag/Documents/code-projects/testcpp /Users/aag/Documents/code-projects/testcpp/build /Users/aag/Documents/code-projects/testcpp/build /Users/aag/Documents/code-projects/testcpp/build/CMakeFiles/assimp.dir/DependInfo.cmake &amp;quot;--color=&amp;quot;&#xA;/Applications/Xcode.app/Contents/Developer/usr/bin/make  -f CMakeFiles/assimp.dir/build.make CMakeFiles/assimp.dir/build&#xA;[ 25%] Linking CXX shared library libassimp.dylib&#xA;/opt/homebrew/Cellar/cmake/3.28.1/bin/cmake -E cmake_link_script CMakeFiles/assimp.dir/link.txt --verbose=1&#xA;/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c&#x2B;&#x2B;  -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -dynamiclib -Wl,-headerpad_max_install_names -o libassimp.dylib -install_name @rpath/libassimp.dylib  -Wl,-rpath,/Users/aag/Documents/code-projects/testcpp/lib/libassimp.5.4.1.dylib &#xA;[ 25%] Built target assimp&#xA;/Applications/Xcode.app/Contents/Developer/usr/bin/make  -f CMakeFiles/app.dir/build.make CMakeFiles/app.dir/depend&#xA;cd /Users/aag/Documents/code-projects/testcpp/build &amp;amp;&amp;amp; /opt/homebrew/Cellar/cmake/3.28.1/bin/cmake -E cmake_depends &amp;quot;Unix Makefiles&amp;quot; /Users/aag/Documents/code-projects/testcpp /Users/aag/Documents/code-projects/testcpp /Users/aag/Documents/code-projects/testcpp/build /Users/aag/Documents/code-projects/testcpp/build /Users/aag/Documents/code-projects/testcpp/build/CMakeFiles/app.dir/DependInfo.cmake &amp;quot;--color=&amp;quot;&#xA;/Applications/Xcode.app/Contents/Developer/usr/bin/make  -f CMakeFiles/app.dir/build.make CMakeFiles/app.dir/build&#xA;[ 50%] Linking CXX executable app&#xA;/opt/homebrew/Cellar/cmake/3.28.1/bin/cmake -E cmake_link_script CMakeFiles/app.dir/link.txt --verbose=1&#xA;/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c&#x2B;&#x2B;  -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/app.dir/main.cpp.o CMakeFiles/app.dir/glad.c.o -o app   -L/Users/aag/Documents/code-projects/testcpp/lib  -Wl,-rpath,/Users/aag/Documents/code-projects/testcpp/lib/libassimp.5.4.1.dylib -Wl,-rpath,/opt/homebrew/lib -Wl,-rpath,/Users/aag/Documents/code-projects/testcpp/lib -Wl,-rpath,/Users/aag/Documents/code-projects/testcpp/build /opt/homebrew/lib/libglfw.3.4.dylib libassimp.dylib &#xA;ld: Undefined symbols:&#xA;  Assimp::Importer::ReadFile(char const*, unsigned int), referenced from:&#xA;      Assimp::Importer::ReadFile(std::__1::basic_string&amp;lt;char, std::__1::char_traits&amp;lt;char&amp;gt;, std::__1::allocator&amp;lt;char&amp;gt;&amp;gt; const&amp;amp;, unsigned int) in main.cpp.o&#xA;  Assimp::Importer::Importer(), referenced from:&#xA;      Model::loadModel(std::__1::basic_string&amp;lt;char, std::__1::char_traits&amp;lt;char&amp;gt;, std::__1::allocator&amp;lt;char&amp;gt;&amp;gt; const&amp;amp;) in main.cpp.o&#xA;  Assimp::Importer::~Importer(), referenced from:&#xA;      Model::loadModel(std::__1::basic_string&amp;lt;char, std::__1::char_traits&amp;lt;char&amp;gt;, std::__1::allocator&amp;lt;char&amp;gt;&amp;gt; const&amp;amp;) in main.cpp.o&#xA;      Model::loadModel(std::__1::basic_string&amp;lt;char, std::__1::char_traits&amp;lt;char&amp;gt;, std::__1::allocator&amp;lt;char&amp;gt;&amp;gt; const&amp;amp;) in main.cpp.o&#xA;  Assimp::Importer::GetErrorString() const, referenced from:&#xA;      Model::loadModel(std::__1::basic_string&amp;lt;char, std::__1::char_traits&amp;lt;char&amp;gt;, std::__1::allocator&amp;lt;char&amp;gt;&amp;gt; const&amp;amp;) in main.cpp.o&#xA;  _aiGetMaterialTexture, referenced from:&#xA;      aiMaterial::GetTexture(aiTextureType, unsigned int, aiString*, aiTextureMapping*, unsigned int*, float*, aiTextureOp*, aiTextureMapMode*) const in main.cpp.o&#xA;  _aiGetMaterialTextureCount, referenced from:&#xA;      aiMaterial::GetTextureCount(aiTextureType) const in main.cpp.o&#xA;  _stbi_image_free, referenced from:&#xA;      TextureFromFile(char const*, std::__1::basic_string&amp;lt;char, std::__1::char_traits&amp;lt;char&amp;gt;, std::__1::allocator&amp;lt;char&amp;gt;&amp;gt; const&amp;amp;, bool) in main.cpp.o&#xA;      TextureFromFile(char const*, std::__1::basic_string&amp;lt;char, std::__1::char_traits&amp;lt;char&amp;gt;, std::__1::allocator&amp;lt;char&amp;gt;&amp;gt; const&amp;amp;, bool) in main.cpp.o&#xA;  _stbi_load, referenced from:&#xA;      TextureFromFile(char const*, std::__1::basic_string&amp;lt;char, std::__1::char_traits&amp;lt;char&amp;gt;, std::__1::allocator&amp;lt;char&amp;gt;&amp;gt; const&amp;amp;, bool) in main.cpp.o&#xA;  _stbi_set_flip_vertically_on_load, referenced from:&#xA;      _main in main.cpp.o&#xA;clang: error: linker command failed with exit code 1 (use -v to see invocation)&#xA;make[2]: *** [app] Error 1&#xA;make[1]: *** [CMakeFiles/app.dir/all] Error 2&#xA;make: *** [all] Error 2&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;updated CMakeLists.txt&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cmake_minimum_required(VERSION 3.20.0)&#xA;set(CMAKE_CXX_STANDARD 11)&#xA;set(CMAKE_VERBOSE_MAKEFILE ON)&#xA;project(app)&#xA;&#xA;set(CMAKE_BUILD_RPATH ${CMAKE_SOURCE_DIR}/lib/libassimp.5.4.1.dylib)&#xA;&#xA;find_package(glfw3 3.4 REQUIRED)&#xA;&#xA;&#xA;add_library(assimp SHARED ${CMAKE_SOURCE_DIR}/lib/libassimp.5.4.1.dylib)&#xA;set_target_properties(assimp PROPERTIES LINKER_LANGUAGE CXX)&#xA;set(SOURCES main.cpp glad.c shader.h camera.h stb_image.h mesh.h model.h)&#xA;&#xA;include_directories(${CMAKE_SOURCE_DIR}/include)&#xA;link_directories(${CMAKE_SOURCE_DIR}/lib)&#xA;&#xA;add_executable(${PROJECT_NAME} ${SOURCES})&#xA;&#xA;&#xA;target_link_libraries(${PROJECT_NAME})&#xA;target_link_libraries(${PROJECT_NAME} glfw)&#xA;target_link_libraries(${PROJECT_NAME} assimp)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/78561387</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">Helix Viewport &#x2B; SharpDX - Loaded models not visible in viewport</title>
            <category scheme="https://stackoverflow.com/tags" term="c#" />
            <category scheme="https://stackoverflow.com/tags" term="direct3d" />
            <category scheme="https://stackoverflow.com/tags" term="sharpdx" />
            <category scheme="https://stackoverflow.com/tags" term="assimp" />
            <category scheme="https://stackoverflow.com/tags" term="helix-3d-toolkit" />
        <author>
            <name>aten intelligencecasino</name>
            <uri>https://stackoverflow.com/users/25333412</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/78561387/helix-viewport-sharpdx-loaded-models-not-visible-in-viewport" />
        <published>2024-05-31T17:17:09Z</published>
        <updated>2024-05-31T17:17:09Z</updated>
        <summary type="html">
            &lt;p&gt;For some reason I can&#x27;t see any of the models I&#x27;m importing into this Helix viewport I&#x27;ve set up. I&#x27;ve tried a thousand code combinations, drawing from the examples in the HelixToolkit git as well. Nothing. No errors, no exceptions, no crashes, nothing at all. The models simply aren&#x27;t visible, even though I know for a fact the program is parsing them because it used to throw exceptions at me. Maybe it&#x27;s just, you know, something really dumb I&#x27;m overlooking, but right now I&#x27;m drawing a blank.&lt;/p&gt;&#xA;&lt;p&gt;(Slightly modified) code from model importer demo with some really simple console outputs for debugging purposes:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;// MainViewModel.cs&#xA;using System;&#xA;using System.Collections.Generic;&#xA;using System.Collections.ObjectModel;&#xA;using System.Diagnostics;&#xA;using System.Threading;&#xA;using System.Threading.Tasks;&#xA;using System.Windows;&#xA;using System.Windows.Input;&#xA;using HelixToolkit.Wpf.SharpDX;&#xA;using HelixToolkit.Wpf.SharpDX.Animations;&#xA;using HelixToolkit.Wpf.SharpDX.Assimp;&#xA;using HelixToolkit.Wpf.SharpDX.Controls;&#xA;using HelixToolkit.Wpf.SharpDX.Model;&#xA;using HelixToolkit.Wpf.SharpDX.Model.Scene;&#xA;using Microsoft.Win32;&#xA;using MvvmHelpers;&#xA;using Point3D = System.Windows.Media.Media3D.Point3D;&#xA;using Vector3D = System.Windows.Media.Media3D.Vector3D;&#xA;using Color = System.Windows.Media.Color;&#xA;using Colors = System.Windows.Media.Colors;&#xA;using SharpDX;&#xA;using JulMar.Windows.Mvvm;&#xA;using System.Linq;&#xA;&#xA;namespace FileLoadDemo&#xA;{&#xA;    public class MainViewModel : BaseViewModel&#xA;    {&#xA;        private string OpenFileFilter = $&amp;quot;{HelixToolkit.Wpf.SharpDX.Assimp.Importer.SupportedFormatsString}&amp;quot;;&#xA;        private string ExportFileFilter = $&amp;quot;{HelixToolkit.Wpf.SharpDX.Assimp.Exporter.SupportedFormatsString}&amp;quot;;&#xA;        private bool showWireframe = false;&#xA;        public bool ShowWireframe&#xA;        {&#xA;            set&#xA;            {&#xA;                if (SetProperty(ref showWireframe, value))&#xA;                {&#xA;                    ShowWireframeFunct(value);&#xA;                }&#xA;            }&#xA;            get&#xA;            {&#xA;                return showWireframe;&#xA;            }&#xA;        }&#xA;&#xA;        private bool renderFlat = false;&#xA;        public bool RenderFlat&#xA;        {&#xA;            set&#xA;            {&#xA;                if (SetProperty(ref renderFlat, value))&#xA;                {&#xA;                    RenderFlatFunct(value);&#xA;                }&#xA;            }&#xA;            get&#xA;            {&#xA;                return renderFlat;&#xA;            }&#xA;        }&#xA;&#xA;        private bool renderEnvironmentMap = true;&#xA;        public bool RenderEnvironmentMap&#xA;        {&#xA;            set&#xA;            {&#xA;                if (SetProperty(ref renderEnvironmentMap, value) &amp;amp;&amp;amp; scene != null &amp;amp;&amp;amp; scene.Root != null)&#xA;                {&#xA;                    foreach (var node in scene.Root.Traverse())&#xA;                    {&#xA;                        if (node is MaterialGeometryNode m &amp;amp;&amp;amp; m.Material is PBRMaterialCore material)&#xA;                        {&#xA;                            material.RenderEnvironmentMap = value;&#xA;                        }&#xA;                    }&#xA;                }&#xA;            }&#xA;            get =&amp;gt; renderEnvironmentMap;&#xA;        }&#xA;&#xA;        public ICommand OpenFileCommand { get; set; }&#xA;        public DefaultEffectsManager EffectsManager { get; }&#xA;        public OrthographicCamera Camera { get; }&#xA;        public ICommand ResetCameraCommand { get; set; }&#xA;        public ICommand ExportCommand { private set; get; }&#xA;        public ICommand CopyAsBitmapCommand { private set; get; }&#xA;        public ICommand CopyAsHiresBitmapCommand { private set; get; }&#xA;&#xA;        private bool isLoading = false;&#xA;        public bool IsLoading&#xA;        {&#xA;            private set =&amp;gt; SetProperty(ref isLoading, value);&#xA;            get =&amp;gt; isLoading;&#xA;        }&#xA;&#xA;        private bool isPlaying = false;&#xA;        public bool IsPlaying&#xA;        {&#xA;            private set =&amp;gt; SetProperty(ref isPlaying, value);&#xA;            get =&amp;gt; isPlaying;&#xA;        }&#xA;&#xA;        private float startTime;&#xA;        public float StartTime&#xA;        {&#xA;            private set =&amp;gt; SetProperty(ref startTime, value);&#xA;            get =&amp;gt; startTime;&#xA;        }&#xA;&#xA;        private float endTime;&#xA;        public float EndTime&#xA;        {&#xA;            private set =&amp;gt; SetProperty(ref endTime, value);&#xA;            get =&amp;gt; endTime;&#xA;        }&#xA;&#xA;        private float currAnimationTime = 0;&#xA;        public float CurrAnimationTime&#xA;        {&#xA;            set&#xA;            {&#xA;                if (EndTime == 0)&#xA;                { return; }&#xA;                if (SetProperty(ref currAnimationTime, value % EndTime &#x2B; StartTime))&#xA;                {&#xA;                    animationUpdater?.Update(value, 1);&#xA;                }&#xA;            }&#xA;            get =&amp;gt; currAnimationTime;&#xA;        }&#xA;&#xA;        public ObservableCollection&amp;lt;IAnimationUpdater&amp;gt; Animations { get; } = new ObservableCollection&amp;lt;IAnimationUpdater&amp;gt;();&#xA;&#xA;        public SceneNodeGroupModel3D GroupModel { get; } = new SceneNodeGroupModel3D();&#xA;&#xA;        private IAnimationUpdater selectedAnimation = null;&#xA;        public IAnimationUpdater SelectedAnimation&#xA;        {&#xA;            set&#xA;            {&#xA;                if (SetProperty(ref selectedAnimation, value))&#xA;                {&#xA;                    StopAnimation();&#xA;                    CurrAnimationTime = 0;&#xA;                    if (value != null)&#xA;                    {&#xA;                        animationUpdater = value;&#xA;                        animationUpdater.Reset();&#xA;                        animationUpdater.RepeatMode = AnimationRepeatMode.Loop;&#xA;                        StartTime = value.StartTime;&#xA;                        EndTime = value.EndTime;&#xA;                    }&#xA;                    else&#xA;                    {&#xA;                        animationUpdater = null;&#xA;                        StartTime = EndTime = 0;&#xA;                    }&#xA;                }&#xA;            }&#xA;            get&#xA;            {&#xA;                return selectedAnimation;&#xA;            }&#xA;        }&#xA;&#xA;        private float speed = 1.0f;&#xA;        public float Speed&#xA;        {&#xA;            set&#xA;            {&#xA;                SetProperty(ref speed, value);&#xA;            }&#xA;            get =&amp;gt; speed;&#xA;        }&#xA;&#xA;        private Point3D modelCentroid = default;&#xA;        public Point3D ModelCentroid&#xA;        {&#xA;            private set =&amp;gt; SetProperty(ref modelCentroid, value);&#xA;            get =&amp;gt; modelCentroid;&#xA;        }&#xA;        private BoundingBox modelBound = new BoundingBox();&#xA;        public BoundingBox ModelBound&#xA;        {&#xA;            private set =&amp;gt; SetProperty(ref modelBound, value);&#xA;            get =&amp;gt; modelBound;&#xA;        }&#xA;        public TextureModel EnvironmentMap { get; }&#xA;&#xA;        public ICommand PlayCommand { get; }&#xA;&#xA;        private SynchronizationContext context = SynchronizationContext.Current;&#xA;        private HelixToolkitScene scene;&#xA;        private IAnimationUpdater animationUpdater;&#xA;        private List&amp;lt;BoneSkinMeshNode&amp;gt; boneSkinNodes = new List&amp;lt;BoneSkinMeshNode&amp;gt;();&#xA;        private List&amp;lt;BoneSkinMeshNode&amp;gt; skeletonNodes = new List&amp;lt;BoneSkinMeshNode&amp;gt;();&#xA;        private CompositionTargetEx compositeHelper = new CompositionTargetEx();&#xA;        private long initTimeStamp = 0;&#xA;&#xA;        public MainViewModel(DefaultEffectsManager effectsManager)&#xA;        {&#xA;            EffectsManager = effectsManager;&#xA;            this.OpenFileCommand = new DelegateCommand(this.OpenFile);&#xA;            Camera = new OrthographicCamera()&#xA;            {&#xA;                LookDirection = new System.Windows.Media.Media3D.Vector3D(0, -10, -10),&#xA;                Position = new System.Windows.Media.Media3D.Point3D(0, 10, 10),&#xA;                UpDirection = new System.Windows.Media.Media3D.Vector3D(0, 1, 0),&#xA;                FarPlaneDistance = 5000,&#xA;                NearPlaneDistance = 0.1f&#xA;            };&#xA;            ResetCameraCommand = new DelegateCommand(() =&amp;gt;&#xA;            {&#xA;                (Camera as OrthographicCamera).Reset();&#xA;                (Camera as OrthographicCamera).FarPlaneDistance = 5000;&#xA;                (Camera as OrthographicCamera).NearPlaneDistance = 0.1f;&#xA;            });&#xA;            ExportCommand = new DelegateCommand(() =&amp;gt; { ExportFile(); });&#xA;&#xA;            CopyAsBitmapCommand = new DelegateCommand(() =&amp;gt; { CopyAsBitmapToClipBoard(); });&#xA;            CopyAsHiresBitmapCommand = new DelegateCommand(() =&amp;gt; { CopyAsHiResBitmapToClipBoard(); });&#xA;&#xA;            EnvironmentMap = TextureModel.Create(&amp;quot;Cubemap_Grandcanyon.dds&amp;quot;);&#xA;&#xA;            PlayCommand = new DelegateCommand(() =&amp;gt;&#xA;            {&#xA;                if (!IsPlaying &amp;amp;&amp;amp; SelectedAnimation != null)&#xA;                {&#xA;                    StartAnimation();&#xA;                }&#xA;                else&#xA;                {&#xA;                    StopAnimation();&#xA;                }&#xA;            });&#xA;        }&#xA;&#xA;        private void CopyAsBitmapToClipBoard()&#xA;        {&#xA;            var bitmap = ViewportExtensions.RenderBitmap((Viewport3DX)Application.Current.MainWindow.FindName(&amp;quot;view&amp;quot;));&#xA;            try&#xA;            {&#xA;                Clipboard.Clear();&#xA;                Clipboard.SetImage(bitmap);&#xA;            }&#xA;            catch (Exception e)&#xA;            {&#xA;                Debug.WriteLine(e);&#xA;            }&#xA;        }&#xA;&#xA;        private void CopyAsHiResBitmapToClipBoard()&#xA;        {&#xA;            var stopwatch = new Stopwatch();&#xA;            stopwatch.Start();&#xA;&#xA;            var bitmap = ViewportExtensions.RenderBitmap((Viewport3DX)Application.Current.MainWindow.FindName(&amp;quot;view&amp;quot;), 1920, 1080);&#xA;            try&#xA;            {&#xA;                Clipboard.Clear();&#xA;                Clipboard.SetImage(bitmap);&#xA;                stopwatch.Stop();&#xA;                Debug.WriteLine($&amp;quot;creating bitmap needs {stopwatch.ElapsedMilliseconds} ms&amp;quot;);&#xA;            }&#xA;            catch (Exception e)&#xA;            {&#xA;                Debug.WriteLine(e);&#xA;            }&#xA;        }&#xA;&#xA;        private void OpenFile()&#xA;        {&#xA;            if (isLoading)&#xA;            {&#xA;                Console.WriteLine(&amp;quot;Loading&amp;quot;);&#xA;                return;&#xA;            }&#xA;            string path = OpenFileDialog(OpenFileFilter);&#xA;            if (path == null)&#xA;            {&#xA;                Console.WriteLine(&amp;quot;Null path&amp;quot;);&#xA;                return;&#xA;            }&#xA;            StopAnimation();&#xA;            var syncContext = SynchronizationContext.Current;&#xA;            IsLoading = true;&#xA;            Task.Run(() =&amp;gt;&#xA;            {&#xA;                var loader = new Importer();&#xA;                var scene = loader.Load(path);&#xA;                scene.Root.Attach(EffectsManager); // Pre attach scene graph&#xA;                Console.WriteLine(&amp;quot;Attached scene graph&amp;quot;);&#xA;                scene.Root.UpdateAllTransformMatrix();&#xA;                Console.WriteLine(&amp;quot;Transform matrix updated&amp;quot;);&#xA;                if (scene.Root.TryGetBound(out var bound))&#xA;                {&#xA;                    /// Must use UI thread to set value back.&#xA;                    syncContext.Post((o) =&amp;gt; { ModelBound = bound; }, null);&#xA;                }&#xA;                if (scene.Root.TryGetCentroid(out var centroid))&#xA;                {&#xA;                    /// Must use UI thread to set value back.&#xA;                    syncContext.Post((o) =&amp;gt; { ModelCentroid = centroid.ToPoint3D(); }, null);&#xA;                }&#xA;                return scene;&#xA;            }).ContinueWith((result) =&amp;gt;&#xA;            {&#xA;                IsLoading = false;&#xA;                Console.WriteLine(&amp;quot;Completed&amp;quot;);&#xA;                if (result.IsCompleted)&#xA;                {&#xA;                    scene = result.Result;&#xA;                    Animations.Clear();&#xA;                    var oldNode = GroupModel.SceneNode.Items.ToArray();&#xA;                    GroupModel.Clear(false);&#xA;                    Task.Run(() =&amp;gt;&#xA;                    {&#xA;                        foreach (var node in oldNode)&#xA;                        { node.Dispose(); }&#xA;                    });&#xA;                    if (scene != null)&#xA;                    {&#xA;                        if (scene.Root != null)&#xA;                        {&#xA;                            foreach (var node in scene.Root.Traverse())&#xA;                            {&#xA;                                if (node is MaterialGeometryNode m)&#xA;                                {&#xA;                                    //m.Geometry.SetAsTransient();&#xA;                                    if (m.Material is PBRMaterialCore pbr)&#xA;                                    {&#xA;                                        pbr.RenderEnvironmentMap = RenderEnvironmentMap;&#xA;                                        Console.WriteLine(&amp;quot;pbr&amp;quot;);&#xA;                                    }&#xA;                                    else if (m.Material is PhongMaterialCore phong)&#xA;                                    {&#xA;                                        phong.RenderEnvironmentMap = RenderEnvironmentMap;&#xA;                                        Console.WriteLine(&amp;quot;phong&amp;quot;);&#xA;                                    }&#xA;                                }&#xA;                            }&#xA;                        }&#xA;                        GroupModel.AddNode(scene.Root);&#xA;                        if (scene.HasAnimation)&#xA;                        {&#xA;                            var dict = scene.Animations.CreateAnimationUpdaters();&#xA;                            foreach (var ani in dict.Values)&#xA;                            {&#xA;                                Animations.Add(ani);&#xA;                            }&#xA;                        }&#xA;                        FocusCameraToScene();&#xA;                    }&#xA;                }&#xA;                else if (result.IsFaulted &amp;amp;&amp;amp; result.Exception != null)&#xA;                {&#xA;                    MessageBox.Show(result.Exception.Message);&#xA;                }&#xA;            }, TaskScheduler.FromCurrentSynchronizationContext());&#xA;        }&#xA;&#xA;        public void StartAnimation()&#xA;        {&#xA;            initTimeStamp = Stopwatch.GetTimestamp();&#xA;            compositeHelper.Rendering &#x2B;= CompositeHelper_Rendering;&#xA;            IsPlaying = true;&#xA;        }&#xA;&#xA;        public void StopAnimation()&#xA;        {&#xA;            IsPlaying = false;&#xA;            compositeHelper.Rendering -= CompositeHelper_Rendering;&#xA;        }&#xA;&#xA;        private void CompositeHelper_Rendering(object sender, System.Windows.Media.RenderingEventArgs e)&#xA;        {&#xA;            if (animationUpdater != null)&#xA;            {&#xA;                var elapsed = (Stopwatch.GetTimestamp() - initTimeStamp) * speed;&#xA;                CurrAnimationTime = elapsed / Stopwatch.Frequency;&#xA;            }&#xA;        }&#xA;&#xA;        private void FocusCameraToScene()&#xA;        {&#xA;            var maxWidth = Math.Max(Math.Max(modelBound.Width, modelBound.Height), modelBound.Depth);&#xA;            var pos = modelBound.Center &#x2B; new Vector3(0, 0, maxWidth);&#xA;            Camera.Position = pos.ToPoint3D();&#xA;            Camera.LookDirection = (modelBound.Center - pos).ToVector3D();&#xA;            Camera.UpDirection = Vector3.UnitY.ToVector3D();&#xA;            if (Camera is OrthographicCamera orthCam)&#xA;            {&#xA;                orthCam.Width = maxWidth;&#xA;            }&#xA;        }&#xA;&#xA;        private void ExportFile()&#xA;        {&#xA;            var index = SaveFileDialog(ExportFileFilter, out var path);&#xA;            if (!string.IsNullOrEmpty(path) &amp;amp;&amp;amp; index &amp;gt;= 0)&#xA;            {&#xA;                var id = HelixToolkit.Wpf.SharpDX.Assimp.Exporter.SupportedFormats[index].FormatId;&#xA;                var exporter = new HelixToolkit.Wpf.SharpDX.Assimp.Exporter();&#xA;                exporter.ExportToFile(path, scene, id);&#xA;                return;&#xA;            }&#xA;        }&#xA;&#xA;        private string OpenFileDialog(string filter)&#xA;        {&#xA;            var d = new OpenFileDialog();&#xA;            d.CustomPlaces.Clear();&#xA;            d.Filter = filter;&#xA;&#xA;            if (!d.ShowDialog().Value)&#xA;            {&#xA;                return null;&#xA;            }&#xA;            return d.FileName;&#xA;        }&#xA;&#xA;        private int SaveFileDialog(string filter, out string path)&#xA;        {&#xA;            var d = new SaveFileDialog();&#xA;            d.Filter = filter;&#xA;            if (d.ShowDialog() == true)&#xA;            {&#xA;                path = d.FileName;&#xA;                return d.FilterIndex - 1; // This is starting from 1. So must minus 1&#xA;            }&#xA;            else&#xA;            {&#xA;                path = &amp;quot;&amp;quot;;&#xA;                return -1;&#xA;            }&#xA;        }&#xA;&#xA;        private void ShowWireframeFunct(bool show)&#xA;        {&#xA;            foreach (var node in GroupModel.GroupNode.Items.PreorderDFT((node) =&amp;gt; node.IsRenderable))&#xA;            {&#xA;                if (node is MeshNode m)&#xA;                {&#xA;                    m.RenderWireframe = show;&#xA;                }&#xA;            }&#xA;        }&#xA;&#xA;        private void RenderFlatFunct(bool show)&#xA;        {&#xA;            foreach (var node in GroupModel.GroupNode.Items.PreorderDFT((node) =&amp;gt; node.IsRenderable))&#xA;            {&#xA;                if (node is MeshNode m)&#xA;                {&#xA;                    if (m.Material is PhongMaterialCore phong)&#xA;                    {&#xA;                        phong.EnableFlatShading = show;&#xA;                    }&#xA;                    else if (m.Material is PBRMaterialCore pbr)&#xA;                    {&#xA;                        pbr.EnableFlatShading = show;&#xA;                    }&#xA;                }&#xA;            }&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The code I&#x27;m attempting to call previous code from:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;using System;&#xA;using System.Windows.Forms;&#xA;using System.Windows.Forms.Integration;&#xA;using HelixToolkit.Wpf.SharpDX.Controls;&#xA;using FileLoadDemo;&#xA;using HelixToolkit.Wpf.SharpDX;&#xA;&#xA;namespace Intelligencecasinos_Animation_Maker&#xA;{&#xA;    public partial class Form3 : Form&#xA;    {&#xA;        private Viewport3DX viewport;&#xA;        private MainViewModel viewModel;&#xA;        private DefaultEffectsManager effectsManager;&#xA;&#xA;        public Form3()&#xA;        {&#xA;            InitializeComponent();&#xA;            this.Load &#x2B;= Form3_Load;&#xA;        }&#xA;&#xA;        private void Form3_Load(object sender, EventArgs e)&#xA;        {&#xA;            InitializeEffectsManager();&#xA;            InitializeHelixViewport();&#xA;            InitializeViewModel();&#xA;        }&#xA;        private void CreateGrid()&#xA;        {&#xA;            var grid = new AxisPlaneGridModel3D();&#xA;            viewport.Items.Add(grid);&#xA;        }&#xA;        private void InitializeEffectsManager()&#xA;        {&#xA;            effectsManager = new DefaultEffectsManager();&#xA;        }&#xA;&#xA;        private void InitializeHelixViewport()&#xA;        {&#xA;            viewport = new Viewport3DX&#xA;            {&#xA;                Name = &amp;quot;view&amp;quot;,&#xA;                EffectsManager = effectsManager,&#xA;                Camera = new PerspectiveCamera&#xA;                {&#xA;                    LookDirection = new System.Windows.Media.Media3D.Vector3D(0, -10, -10),&#xA;                    Position = new System.Windows.Media.Media3D.Point3D(0, 10, 10),&#xA;                    UpDirection = new System.Windows.Media.Media3D.Vector3D(0, 1, 0),&#xA;                    FarPlaneDistance = 5000,&#xA;                    NearPlaneDistance = 0.1f&#xA;                },&#xA;                BackgroundColor = System.Windows.Media.Color.FromRgb(30, 30, 30) // Dark background&#xA;            };&#xA;&#xA;            // Create a WindowsFormsHost to host the WPF control&#xA;            var host = new ElementHost&#xA;            {&#xA;                Dock = DockStyle.Fill,&#xA;                Child = viewport&#xA;            };&#xA;&#xA;            // Add the WindowsFormsHost to the existing viewportPanel&#xA;            CreateGrid();&#xA;            viewportPanel.Controls.Add(host);&#xA;        }&#xA;&#xA;        private void InitializeViewModel()&#xA;        {&#xA;            viewModel = new MainViewModel(effectsManager);&#xA;            viewport.DataContext = viewModel;&#xA;            viewport.Items.Add(viewModel.GroupModel);&#xA;            Console.WriteLine(&amp;quot;Viewmodel initialized&amp;quot;);&#xA;        }&#xA;&#xA;        private void openToolStripMenuItem_Click(object sender, EventArgs e)&#xA;        {&#xA;            viewModel.OpenFileCommand.Execute(null);&#xA;        }&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/78556554</id>
        <re:rank scheme="https://stackoverflow.com">1</re:rank>
        <title type="text">How to convert UTextureRenderTarget2D to Assimp embaded texture?</title>
            <category scheme="https://stackoverflow.com/tags" term="png" />
            <category scheme="https://stackoverflow.com/tags" term="unreal-engine5" />
            <category scheme="https://stackoverflow.com/tags" term="assimp" />
            <category scheme="https://stackoverflow.com/tags" term="rendertarget" />
        <author>
            <name>DigitalBug</name>
            <uri>https://stackoverflow.com/users/10472085</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/78556554/how-to-convert-utexturerendertarget2d-to-assimp-embaded-texture" />
        <published>2024-05-30T17:46:59Z</published>
        <updated>2024-05-30T17:46:59Z</updated>
        <summary type="html">
            &lt;p&gt;I&#x27;m using Assimp to export FBX with embedded textures.&#xA;Reading an image from a png file (into the built-in aiTexture*) works fine.&#xA;But when I try to convert UTextureRenderTarget2D to aiTexel* pcData I always get wrong data.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&#xA;static FName ImageWrapperName(&amp;quot;ImageWrapper&amp;quot;);&#xA;IImageWrapperModule&amp;amp; ImageWrapperModule = FModuleManager::LoadModuleChecked&amp;lt;IImageWrapperModule&amp;gt;(ImageWrapperName);&#xA;&#xA;FTextureRenderTargetResource* RTResource = RenderTarget-&amp;gt;GameThread_GetRenderTargetResource();&#xA;FIntPoint                     DestSize(RenderTarget-&amp;gt;GetSurfaceWidth(), RenderTarget-&amp;gt;GetSurfaceHeight());&#xA;&#xA;TUniquePtr&amp;lt;TImagePixelData&amp;lt;FColor&amp;gt;&amp;gt; PixelData;&#xA;PixelData = MakeUnique&amp;lt;TImagePixelData&amp;lt;FColor&amp;gt;&amp;gt;(FIntPoint((int32)DestSize.X, (int32)DestSize.Y));&#xA;PixelData-&amp;gt;Pixels.SetNumUninitialized(DestSize.X * DestSize.Y);&#xA;RTResource-&amp;gt;ReadPixelsPtr(PixelData-&amp;gt;Pixels.GetData());&#xA;&#xA;FImagePixelData* Data = PixelData.Get();&#xA;FImageView Image = Data-&amp;gt;GetImageView();&#xA;&#xA;TArray64&amp;lt;uint8&amp;gt; CompressedFile;&#xA;ImageWrapperModule.CompressImage(CompressedFile, EImageFormat::PNG, Image, (int32)EImageCompressionQuality::Max);&#xA;&#xA;aiTexture* texture = new aiTexture;&#xA;texture-&amp;gt;mHeight = 0;&#xA;texture-&amp;gt;mWidth = CompressedFile.Num();&#xA;texture-&amp;gt;pcData = new aiTexel[1ul &#x2B; static_cast&amp;lt;unsigned long&amp;gt;(CompressedFile.Num()) / sizeof(aiTexel)];&#xA;&#xA;for (int i = 0; i &amp;lt; CompressedFile.Num(); i &#x2B;= 4)&#xA;{&#xA;    int32 index = i / 4;&#xA;    texture-&amp;gt;pcData[index].b = CompressedFile[i &#x2B; 0];&#xA;    texture-&amp;gt;pcData[index].g = CompressedFile[i &#x2B; 1];&#xA;    texture-&amp;gt;pcData[index].r = CompressedFile[i &#x2B; 2];&#xA;    texture-&amp;gt;pcData[index].a = CompressedFile[i &#x2B; 3];&#xA;}&#xA;&#xA;texture-&amp;gt;achFormatHint[0] = &#x27;p&#x27;;&#xA;texture-&amp;gt;achFormatHint[1] = &#x27;n&#x27;;&#xA;texture-&amp;gt;achFormatHint[2] = &#x27;g&#x27;;&#xA;texture-&amp;gt;achFormatHint[3] = &#x27;\0&#x27;;&#xA;&#xA;scene.mTextures[0] = texture;&#xA;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/78509182</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">Getting a lot of &quot;Duplicate class ... found in modules assimp.jar&quot;</title>
            <category scheme="https://stackoverflow.com/tags" term="android" />
            <category scheme="https://stackoverflow.com/tags" term="kotlin" />
            <category scheme="https://stackoverflow.com/tags" term="opengl-es" />
            <category scheme="https://stackoverflow.com/tags" term="assimp" />
        <author>
            <name>juliano.net</name>
            <uri>https://stackoverflow.com/users/1184708</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/78509182/getting-a-lot-of-duplicate-class-found-in-modules-assimp-jar" />
        <published>2024-05-21T00:07:35Z</published>
        <updated>2024-05-29T08:30:47Z</updated>
        <summary type="html">
            &lt;p&gt;I&#x27;m creating an Android app using Kotlin to read PLY files and render them using OpenGL. I found about the &lt;code&gt;Assimp&lt;/code&gt; library and tried some approaches like building from its source (had issues creating the JNI bindings), using different packages on MavenCentral (different options available, some of them are not complete or caused some random issue), and ended up getting the JAR file from this &lt;a href=&quot;https://github.com/kotlin-graphics/assimp&quot; rel=&quot;nofollow noreferrer&quot;&gt;GitHub repo&lt;/a&gt; to give it a try.&lt;/p&gt;&#xA;&lt;p&gt;I&#x27;ve added it to &lt;code&gt;build.gradle.kts&lt;/code&gt; using:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;implementation(files(&amp;quot;libs/assimp.jar&amp;quot;))&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This is one of the JAR files I&#x27;ve tried: &lt;a href=&quot;https://github.com/kotlin-graphics/assimp/releases/download/v4.0/assimp-all.jar&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://github.com/kotlin-graphics/assimp/releases/download/v4.0/assimp-all.jar&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;But I&#x27;m getting a lot of errors like this:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Duplicate class kotlin.ArrayIntrinsicsKt found in modules assimp.jar -&amp;gt; assimp (assimp.jar) and kotlin-stdlib-1.9.0.jar -&amp;gt; kotlin-stdlib-1.9.0 (org.jetbrains.kotlin:kotlin-stdlib:1.9.0)&#xA;Duplicate class kotlin.Deprecated found in modules assimp.jar -&amp;gt; assimp (assimp.jar) and kotlin-stdlib-1.9.0.jar -&amp;gt; kotlin-stdlib-1.9.0 (org.jetbrains.kotlin:kotlin-stdlib:1.9.0)&#xA;Duplicate class kotlin.DeprecationLevel found in modules assimp.jar -&amp;gt; assimp (assimp.jar) and kotlin-stdlib-1.9.0.jar -&amp;gt; kotlin-stdlib-1.9.0 (org.jetbrains.kotlin:kotlin-stdlib:1.9.0)&#xA;Duplicate class kotlin.DslMarker found in modules assimp.jar -&amp;gt; assimp (assimp.jar) and kotlin-stdlib-1.9.0.jar -&amp;gt; kotlin-stdlib-1.9.0 (org.jetbrains.kotlin:kotlin-stdlib:1.9.0)&#xA;Duplicate class kotlin.ExceptionsKt found in modules assimp.jar -&amp;gt; assimp (assimp.jar) and kotlin-stdlib-1.9.0.jar -&amp;gt; kotlin-stdlib-1.9.0 (org.jetbrains.kotlin:kotlin-stdlib:1.9.0)&#xA;Duplicate class kotlin.ExceptionsKt__ExceptionsKt found in modules assimp.jar -&amp;gt; assimp (assimp.jar) and kotlin-stdlib-1.9.0.jar -&amp;gt; kotlin-stdlib-1.9.0 (org.jetbrains.kotlin:kotlin-stdlib:1.9.0)&#xA;Duplicate class kotlin.ExtensionFunctionType found in modules assimp.jar -&amp;gt; assimp (assimp.jar) and kotlin-stdlib-1.9.0.jar -&amp;gt; kotlin-stdlib-1.9.0 (org.jetbrains.kotlin:kotlin-stdlib:1.9.0)&#xA;Duplicate class kotlin.Function found in modules assimp.jar -&amp;gt; assimp (assimp.jar) and kotlin-stdlib-1.9.0.jar -&amp;gt; kotlin-stdlib-1.9.0 (org.jetbrains.kotlin:kotlin-stdlib:1.9.0)&#xA;Duplicate class kotlin.InitializedLazyImpl found in modules assimp.jar -&amp;gt; assimp (assimp.jar) and kotlin-stdlib-1.9.0.jar -&amp;gt; kotlin-stdlib-1.9.0 (org.jetbrains.kotlin:kotlin-stdlib:1.9.0)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I thought about excluding the duplicates using &lt;code&gt;proguard-rules.pro&lt;/code&gt;, but did not find how to do it.&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/78073131</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">Using rapidjson and assimp together causes rapidjson to behave unpredictably</title>
            <category scheme="https://stackoverflow.com/tags" term="c&#x2B;&#x2B;" />
            <category scheme="https://stackoverflow.com/tags" term="assimp" />
            <category scheme="https://stackoverflow.com/tags" term="rapidjson" />
        <author>
            <name>Adversus</name>
            <uri>https://stackoverflow.com/users/678022</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/78073131/using-rapidjson-and-assimp-together-causes-rapidjson-to-behave-unpredictably" />
        <published>2024-02-28T08:59:05Z</published>
        <updated>2024-02-28T08:59:05Z</updated>
        <summary type="html">
            &lt;p&gt;I have the following test program (test.gltf is a file containing just &amp;quot;{}&amp;quot;):&lt;/p&gt;&#xA;&lt;pre class=&quot;lang-cpp prettyprint-override&quot;&gt;&lt;code&gt;#include &amp;quot;assimp/Importer.hpp&amp;quot;&#xA;#include &amp;quot;assimp/postprocess.h&amp;quot;&#xA;#include &amp;quot;assimp/scene.h&amp;quot;&#xA;&#xA;#include &amp;quot;rapidjson/document.h&amp;quot;&#xA;&#xA;#include &amp;lt;iostream&amp;gt;&#xA;&#xA;int main()&#xA;{&#xA;    std::cout &amp;lt;&amp;lt; &amp;quot;reading test&amp;quot; &amp;lt;&amp;lt; std::endl;&#xA;    Assimp::Importer importer;&#xA;    const aiScene *scene = importer.ReadFile(&amp;quot;test.gltf&amp;quot;, {});&#xA;    std::cout &amp;lt;&amp;lt; &amp;quot;SUCCESS&amp;quot; &amp;lt;&amp;lt; std::endl;&#xA;&#xA;    std::cout &amp;lt;&amp;lt; &amp;quot;testing document&amp;quot; &amp;lt;&amp;lt; std::endl;&#xA;    rapidjson::Document document;&#xA;    std::cout &amp;lt;&amp;lt; document.HasMember(&amp;quot;product&amp;quot;) &amp;lt;&amp;lt; std::endl;&#xA;&#xA;    return 0;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;When I run this I get an error on the &lt;code&gt;ReadFile&lt;/code&gt; call:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;main: /home/sanderv/dev/twikbot-core/external/assimp/code/../contrib/rapidjson/include/rapidjson/document.h:1336: rapidjson::GenericValue::MemberIterator rapidjson::GenericValue&amp;lt;rapidjson::UTF8&amp;lt;&amp;gt;&amp;gt;::FindMember(const GenericValue&amp;lt;Encoding, SourceAllocator&amp;gt; &amp;amp;) [Encoding = rapidjson::UTF8&amp;lt;&amp;gt;, Allocator = rapidjson::MemoryPoolAllocator&amp;lt;&amp;gt;, SourceAllocator = rapidjson::MemoryPoolAllocator&amp;lt;&amp;gt;]: Assertion `IsObject()&#x27; failed.&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;This is odd because &lt;code&gt;ReadFile&lt;/code&gt; should work, and just return &lt;code&gt;nullptr&lt;/code&gt;. When I remove the call to &lt;code&gt;document.HasMember&lt;/code&gt; in the above program this does work. Stepping through the code shows that something very odd is going on, on stepping into the actual &lt;code&gt;FindMember&lt;/code&gt; function the &lt;code&gt;*this&lt;/code&gt; object looks corrupt.&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/77963963</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">PyAssimp error for any loaded file - Scene has not attribute meshes, materials or textures</title>
            <category scheme="https://stackoverflow.com/tags" term="python" />
            <category scheme="https://stackoverflow.com/tags" term="assimp" />
        <author>
            <name>rbaleksandar</name>
            <uri>https://stackoverflow.com/users/1559401</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/77963963/pyassimp-error-for-any-loaded-file-scene-has-not-attribute-meshes-materials-o" />
        <published>2024-02-08T18:19:30Z</published>
        <updated>2024-03-11T07:48:47Z</updated>
        <summary type="html">
            &lt;p&gt;I am trying to get any sample (including the ones found in the Assimp repo) to work. Using &lt;code&gt;pyassimp 5.2.5&lt;/code&gt; with Python 3.11.6. Below there is an example for a very basic call. I am loading an OBJ of a cube, which one can even write manually. :D&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;import pyassimp&#xA;import pyassimp.postprocess&#xA;&#xA;def main(filename=None):&#xA;&#xA;    scene = pyassimp.load(filename, processing=pyassimp.postprocess.aiProcess_Triangulate)&#xA;    &#xA;    &#xA;    print(&amp;quot;Meshes:&amp;quot; &#x2B; str(len(scene.meshes)))&#xA;    pyassimp.release(scene)&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The cube&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Blender v2.61 (sub 0) OBJ File: &#x27;&#x27;&#xA;# www.blender.org&#xA;mtllib bigger-cube.mtl&#xA;o Cube&#xA;v 0.700000 -0.700000 -0.700000&#xA;v 0.700000 -0.700000 0.700000&#xA;v -0.700000 -0.700000 0.700000&#xA;v -0.700000 -0.700000 -0.700000&#xA;v 0.700000 0.700000 -0.700000&#xA;v 0.700000 0.700000 0.700000&#xA;v -0.700000 0.700000 0.700000&#xA;v -0.700000 0.700000 -0.700000&#xA;vt 0.000000 0.000000&#xA;vt 1.000000 0.000000&#xA;vt 1.000000 1.000000&#xA;vt 0.000000 1.000000&#xA;vn 0.000000 -1.000000 0.000000&#xA;vn 0.000000 1.000000 0.000000&#xA;vn 1.000000 0.000000 0.000000&#xA;vn -0.000000 -0.000000 1.000000&#xA;vn -1.000000 -0.000000 -0.000000&#xA;vn 0.000000 0.000000 -1.000000&#xA;usemtl Material.001&#xA;s off&#xA;f 1/1/1 2/2/1 3/3/1 4/4/1&#xA;f 5/1/2 8/2/2 7/3/2 6/4/2&#xA;f 1/1/3 5/2/3 6/3/3 2/4/3&#xA;f 2/1/4 6/2/4 7/3/4 3/4/4&#xA;f 3/1/5 7/2/5 8/3/5 4/4/5&#xA;f 5/1/6 1/2/6 4/3/6 8/4/6&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The trace is&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;INFO:pyassimp:Adding Anaconda lib path:/home/user/miniconda3/envs/computergraphics/lib/&#xA;MODEL:bigger-cube.obj&#xA;SCENE:&#xA;Traceback (most recent call last):&#xA;  File &amp;quot;/home/ale56337/Projects/cgi/playground.py&amp;quot;, line 83, in &amp;lt;module&amp;gt;&#xA;    main(sys.argv[1])&#xA;  File &amp;quot;/home/user/Projects/cgi/playground.py&amp;quot;, line 24, in main&#xA;    print(&amp;quot;  meshes:&amp;quot; &#x2B; str(len(scene.meshes)))&#xA;                                ^^^^^^^^^^^^&#xA;AttributeError: &#x27;_GeneratorContextManager&#x27; object has no attribute &#x27;meshes&#x27;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I also tried calling &lt;code&gt;materials&lt;/code&gt; and &lt;code&gt;textures&lt;/code&gt; but the result is the same. There is an &lt;a href=&quot;https://github.com/assimp/assimp/pull/3979&quot; rel=&quot;nofollow noreferrer&quot;&gt;issue in the official repo&lt;/a&gt;, which was fixed two years or so ago. Yet with the current version the issue is still there (perhaps regression or another source of the problem leading to the same outcome?).&lt;/p&gt;&#xA;&lt;p&gt;Any ideas how to make PyAssimp work?&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/77812911</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">Converting local space normals into world space</title>
            <category scheme="https://stackoverflow.com/tags" term="mesh" />
            <category scheme="https://stackoverflow.com/tags" term="unreal-engine5" />
            <category scheme="https://stackoverflow.com/tags" term="assimp" />
        <author>
            <name>Fynn Haupt</name>
            <uri>https://stackoverflow.com/users/23240298</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/77812911/converting-local-space-normals-into-world-space" />
        <published>2024-01-13T20:01:19Z</published>
        <updated>2024-01-13T23:55:52Z</updated>
        <summary type="html">
            &lt;p&gt;I need to convert a local space mesh into global space.&#xA;The resulting normal vectors don&#x27;t seem to be correct.&lt;/p&gt;&#xA;&lt;p&gt;I got the world transform matrix for the vertex (Which works, because the position of the vertex is correct). Then I get the transform matrix for the normals by getting the transposed matrix of the inverse matrix of the world transform matrix. Which I use for transforming the local space normal vector.&lt;/p&gt;&#xA;&lt;p&gt;Which results in:&#xA;&lt;a href=&quot;https://i.sstatic.net/qiUei.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;Calculation Result&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;But the result should be more like this:&#xA;&lt;a href=&quot;https://i.sstatic.net/M8Tqc.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;Expected Result&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;Used code for the current result (Look where the &amp;quot;// TODO: Fix normals (Buggy)&amp;quot; is)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;        FMeshData &amp;amp;MeshData = ModelData.Meshes[MeshIndex];&#xA;        aiMesh *Mesh = Scene-&amp;gt;mMeshes[MeshIndex];&#xA;        aiNode *Node = GetParentNode(Scene-&amp;gt;mRootNode, MeshIndex);&#xA;&#xA;        // Get world transform&#xA;        FMatrix PositionMatrix = GetWorldTransformOfNode(Node);&#xA;        FMatrix NormalMatrix =   UKismetMathLibrary::Matrix_GetTransposed(PositionMatrix.Inverse());&#xA;&#xA;        // Material id&#xA;        MeshData.MaterialId = Mesh-&amp;gt;mMaterialIndex;&#xA;&#xA;        // Lod Data&#xA;        GetLodData(LodFilePath, FString(Mesh-&amp;gt;mName.C_Str()), MeshData.LodData);&#xA;&#xA;        // Vertices&#xA;        for (uint32 VertexIndex = 0; VertexIndex &amp;lt; Mesh-&amp;gt;mNumVertices; VertexIndex&#x2B;&#x2B;)&#xA;        {&#xA;            // Position&#xA;            aiVector3D &amp;amp;aiVertex = Mesh-&amp;gt;mVertices[VertexIndex];&#xA;            FVector PositionVertex = PositionMatrix.TransformFVector4(FVector(&#xA;                aiVertex.x,&#xA;                aiVertex.y,&#xA;                aiVertex.z));&#xA;&#xA;            FVector3f Position(&#xA;                PositionVertex.X,&#xA;                PositionVertex.Y,&#xA;                PositionVertex.Z);&#xA;&#xA;            // Normal&#xA;            FVector3f Normal = FVector3f::ZeroVector;&#xA;            if (Mesh-&amp;gt;HasNormals())&#xA;            {&#xA;                //TODO: Fix normals (Buggy)&#xA;                aiVector3D &amp;amp;aiNormal = Mesh-&amp;gt;mNormals[VertexIndex];&#xA;                FVector NormalVector = NormalMatrix.TransformFVector4(FVector(&#xA;                    aiNormal.x,&#xA;                    aiNormal.y,&#xA;                    aiNormal.z));&#xA;&#xA;                Normal = FVector3f(&#xA;                    NormalVector.X,&#xA;                    NormalVector.Y,&#xA;                    NormalVector.Z);&#xA;            }&#xA;&#xA;            // Tangent&#xA;            FVector3f Tangent = FVector3f::ZeroVector;&#xA;            if (Mesh-&amp;gt;HasTangentsAndBitangents())&#xA;            {&#xA;                aiVector3D &amp;amp;aiTangent = Mesh-&amp;gt;mTangents[VertexIndex];&#xA;                Tangent = FVector3f(&#xA;                    aiTangent.x,&#xA;                    aiTangent.y,&#xA;                    aiTangent.z);&#xA;            }&#xA;&#xA;            // Linear Color&#xA;            FLinearColor LinearColor = FLinearColor::White;&#xA;            if (Mesh-&amp;gt;HasVertexColors(0))&#xA;            {&#xA;                aiColor4D &amp;amp;aiColor = Mesh-&amp;gt;mColors[0][VertexIndex];&#xA;                LinearColor = FLinearColor(&#xA;                    aiColor.r,&#xA;                    aiColor.g,&#xA;                    aiColor.b,&#xA;                    aiColor.a);&#xA;            }&#xA;&#xA;            // UVs&#xA;            FVector2f UV0 = FVector2f::ZeroVector;&#xA;            FVector2f UV1 = FVector2f::ZeroVector;&#xA;            FVector2f UV2 = FVector2f::ZeroVector;&#xA;            FVector2f UV3 = FVector2f::ZeroVector;&#xA;            for (uint32 ChannelIndex = 0; ChannelIndex &amp;lt;= 3; ChannelIndex&#x2B;&#x2B;)&#xA;            {&#xA;                if (Mesh-&amp;gt;HasTextureCoords(ChannelIndex))&#xA;                {&#xA;                    aiVector3D &amp;amp;aiCoordinate = Mesh-&amp;gt;mTextureCoords[ChannelIndex][VertexIndex];&#xA;                    FVector2f Coordinate(aiCoordinate.x, -aiCoordinate.y);&#xA;&#xA;                    switch (ChannelIndex)&#xA;                    {&#xA;                    case 0:&#xA;                        UV0 = Coordinate;&#xA;                        break;&#xA;                    case 1:&#xA;                        UV1 = Coordinate;&#xA;                        break;&#xA;                    case 2:&#xA;                        UV2 = Coordinate;&#xA;                        break;&#xA;                    case 3:&#xA;                        UV3 = Coordinate;&#xA;                        break;&#xA;                    }&#xA;                }&#xA;            }&#xA;&#xA;            // Create vertex&#xA;            FVertexData Vertex;&#xA;            Vertex.Position = Position;&#xA;            Vertex.Normal = Normal;&#xA;            Vertex.Tangent = Tangent;&#xA;            Vertex.Color = LinearColor;&#xA;            Vertex.UV0 = UV0;&#xA;            Vertex.UV1 = UV1;&#xA;            Vertex.UV2 = UV2;&#xA;            Vertex.UV3 = UV3;&#xA;&#xA;            // Save vertex&#xA;            MeshData.Verticies.Push(Vertex);&#xA;        }&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/77749986</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">UV texture mapping issue in .X file using assimp</title>
            <category scheme="https://stackoverflow.com/tags" term="visual-c&#x2B;&#x2B;" />
            <category scheme="https://stackoverflow.com/tags" term="directx-11" />
            <category scheme="https://stackoverflow.com/tags" term="assimp" />
        <author>
            <name>Pratik kumar</name>
            <uri>https://stackoverflow.com/users/23188445</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/77749986/uv-texture-mapping-issue-in-x-file-using-assimp" />
        <published>2024-01-03T06:03:16Z</published>
        <updated>2024-02-08T07:36:08Z</updated>
        <summary type="html">
            &lt;p&gt;Describe the bug&#xA;UV texture mapping issue in .X file, sometimes it loads perfectly but in some rare cases it happens.&lt;/p&gt;&#xA;&lt;p&gt;To Reproduce&#xA;Steps to reproduce the behavior:&lt;/p&gt;&#xA;&lt;p&gt;Try loading Land_Objects_WareHouse.zip .x FIle.&lt;/p&gt;&#xA;&lt;p&gt;Expected behavior&#xA;It should load perfectly in all cases.&lt;/p&gt;&#xA;&lt;p&gt;Screenshots&#xA;If applicable, add screenshots to help explain your problem.&#xA;warehouse texture issue&lt;/p&gt;&#xA;&lt;p&gt;Platform (please complete the following information):&lt;/p&gt;&#xA;&lt;p&gt;OS: WIndows&#xA;Version 5.0.1&#xA;&lt;a href=&quot;https://i.sstatic.net/MYaEF.jpg&quot; rel=&quot;nofollow noreferrer&quot;&gt;enter image description here&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;It should load perfectly in all cases , what is the possible solution to apply&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;Assimp::Importer imp;&#xA;fiuint loadHierarchy = 0;&#xA;if (false == _bLoadHierarchy)&#xA;{&#xA;loadHierarchy |= (aiProcess_PreTransformVertices | aiProcess_OptimizeGraph);&#xA;}&#xA;//else&#xA;// loadHierarchy |= aiProcess_GenSmoothNormals; //for quality /not performance&#xA;imp.SetPropertyInteger(&amp;quot;AI_CONFIG_PP_RVC_FLAGS&amp;quot;, aiComponent_CAMERAS | aiComponent_COLORS | aiComponent_LIGHTS);&#xA;//imp.SetPropertyBool(AI_CONFIG_IMPORT_FBX_PRESERVE_PIVOTS, false);&#xA;&#xA;    const aiScene* pScene = imp.ReadFile(newfile.c_str(),&#xA;        aiProcess_ConvertToLeftHanded&#xA;        | aiProcess_RemoveComponent&#xA;        | aiProcess_LimitBoneWeights&#xA;        | aiProcess_Triangulate&#xA;        | aiProcess_JoinIdenticalVertices&#xA;        | aiProcess_ValidateDataStructure&#xA;        | aiProcess_ImproveCacheLocality&#xA;        | aiProcess_RemoveRedundantMaterials&#xA;        | aiProcess_FindInvalidData&#xA;        | aiProcess_GenUVCoords&#xA;        //| aiProcess_GenNormals&#xA;        &#xA;        //| aiProcess_TransformUVCoords&#xA;        | aiProcess_FindInstances&#xA;        | aiProcess_OptimizeMeshes&#xA;        | aiProcess_SortByPType&#xA;        | aiProcess_CalcTangentSpace&#xA;        | aiProcess_SplitLargeMeshes&#xA;        | loadHierarchy&#xA;        /*  aiProcessPreset_TargetRealtime_Quality*/&#xA;        );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/77719982</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">Issue Linking Assimp Windows 11</title>
            <category scheme="https://stackoverflow.com/tags" term="c&#x2B;&#x2B;" />
            <category scheme="https://stackoverflow.com/tags" term="c&#x2B;&#x2B;17" />
            <category scheme="https://stackoverflow.com/tags" term="g&#x2B;&#x2B;" />
            <category scheme="https://stackoverflow.com/tags" term="assimp" />
        <author>
            <name>Maxwell Stevens</name>
            <uri>https://stackoverflow.com/users/23124762</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/77719982/issue-linking-assimp-windows-11" />
        <published>2023-12-27T03:59:50Z</published>
        <updated>2023-12-27T07:28:50Z</updated>
        <summary type="html">
            &lt;p&gt;I am having issues with linking assimp in c&#x2B;&#x2B; for windows 11. I am working the the LearnOpenGL tutorial however I cannot get assimp to link correctly. I am able to make, and generate the assimp .dll and .lib, and grab the include files without error. I am also able to compile without issue, with just including some assimp headers. However whenever I attempt to use anything from an assimp file, I receive an &#x27;undefined reference to ...&#x27; error. My g&#x2B;&#x2B; version is 13.2.0 and I am using this command to compile my project, with {project_dir} replaced as the path to the project directory.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;g&#x2B;&#x2B; -g -std=c&#x2B;&#x2B;17 -I./include -L./lib {project_dir}\*.cpp {project_dir}\*.c -lglfw3dll -lassimp-vc143-mtd -o myprogram&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.sstatic.net/wxgfg.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;Here&lt;/a&gt; is an picture of the project directory layout.&lt;/p&gt;&#xA;&lt;p&gt;The exact error results from &lt;a href=&quot;https://i.sstatic.net/tEdIc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;these lines&lt;/a&gt; and the error message given by g&#x2B;&#x2B; is: &lt;code&gt;{terminal_exe_location} {file_path} undefined reference to `Assimp::Importer::~Importer()&#x27; &lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;I have tried multiple versions of g&#x2B;&#x2B;, through differing versions of mSys2 and mingw. With no noticeable change in the error message asides from the terminal filepath.&lt;/p&gt;&#xA;&lt;p&gt;It would be amazing if someone could help me understand what it is I have done wrong in attempting to build / link assimp it would be greatly appreciated. I am fairly inexperience with c&#x2B;&#x2B; and building my own binaries so I may not have provided all necessary information, and I can provide any logs / information that is not included upon request.&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/77663739</id>
        <re:rank scheme="https://stackoverflow.com">1</re:rank>
        <title type="text">DirectX12 Problems with skeletal animation and Assimp library</title>
            <category scheme="https://stackoverflow.com/tags" term="c&#x2B;&#x2B;" />
            <category scheme="https://stackoverflow.com/tags" term="game-engine" />
            <category scheme="https://stackoverflow.com/tags" term="assimp" />
            <category scheme="https://stackoverflow.com/tags" term="directx-12" />
            <category scheme="https://stackoverflow.com/tags" term="skeletal-animation" />
        <author>
            <name>GCourtney7</name>
            <uri>https://stackoverflow.com/users/11849699</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/77663739/directx12-problems-with-skeletal-animation-and-assimp-library" />
        <published>2023-12-15T00:37:25Z</published>
        <updated>2023-12-27T07:46:12Z</updated>
        <summary type="html">
            &lt;p&gt;I&#x27;m trying to implement skeletal animation in my game engine but I&#x27;m running into problems when animating the bones in C&#x2B;&#x2B;. The character animates but the torso and arms appear twisted. I&#x27;m following &lt;a href=&quot;https://www.youtube.com/watch?v=GZQkwx10p-8&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; OpenGL tutorial and expect the model to look like &lt;a href=&quot;https://www.youtube.com/watch?v=aHUTof9S8mM&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; but instead it looks like the video below. The vertices and bones are being parsed and uploaded properly but when I apply animations to the bones this happens.&#xA;&lt;a href=&quot;https://i.sstatic.net/nqZ69.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.sstatic.net/nqZ69.gif&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I&#x27;ve assembled all the bones into an array and saved their parents to work through the bone hierarchy as was demonstrated in &lt;a href=&quot;https://www.youtube.com/watch?v=ZzMnu3v_MOw&amp;amp;t=911s&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; tutorial. I believe the problem is somewhere in here because the model renders find in T-pose when I multiply the m_LocalMatrix instead of the AnimatedTransform in the first for loop. However, when I do this I must also multiply the Offset matrix for that bone when calculating the FinalTransformation matrix in the last for loop. Here is my code to animate the model:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;std::vector&amp;lt;FMatrix&amp;gt; LocalTransforms( m_SkeletalMesh-&amp;gt;Joints.size() );&#xA;std::vector&amp;lt;FMatrix&amp;gt; ModelTransforms( m_SkeletalMesh-&amp;gt;Joints.size() );&#xA;&#xA;for (uint32 i = 0; i &amp;lt; m_SkeletalMesh-&amp;gt;Joints.size(); i&#x2B;&#x2B;)&#xA;{&#xA;    FJoint&amp;amp; joint = m_SkeletalMesh-&amp;gt;Joints[i];&#xA;&#xA;    if (m_anim-&amp;gt;m_KeyFrames.find( joint.m_Name ) != m_anim-&amp;gt;m_KeyFrames.end())&#xA;    {&#xA;        uint32 KeyIndex = 0;&#xA;        uint32 NextKeyIndex = 0;&#xA;        for (uint32 i = 0; i &amp;lt; m_anim-&amp;gt;m_KeyFrames[joint.m_Name].size() - 1; i&#x2B;&#x2B;)&#xA;        {&#xA;            if (AnimationTimeTicks &amp;lt; m_anim-&amp;gt;m_KeyFrames[joint.m_Name][i &#x2B; 1].m_Timestamp)&#xA;            {&#xA;                KeyIndex = i;&#xA;                break;&#xA;            }&#xA;        }&#xA;        NextKeyIndex = KeyIndex &#x2B; 1;&#xA;        float t1 = m_anim-&amp;gt;m_KeyFrames[joint.m_Name][KeyIndex].m_Timestamp;&#xA;        float t2 = m_anim-&amp;gt;m_KeyFrames[joint.m_Name][NextKeyIndex].m_Timestamp;&#xA;        float DeltaTime = t2 - t1;&#xA;        float Factor = (AnimationTimeTicks - (float)t1) / DeltaTime;&#xA;        HE_ASSERT( Factor &amp;gt;= 0.f &amp;amp;&amp;amp; Factor &amp;lt;= 1.f );&#xA;        FTransform&amp;amp; Start = m_anim-&amp;gt;m_KeyFrames[joint.m_Name][KeyIndex].m_AnimatedTransform;&#xA;        FTransform&amp;amp; End = m_anim-&amp;gt;m_KeyFrames[joint.m_Name][NextKeyIndex].m_AnimatedTransform;&#xA;        FTransform AnimatedTransform = FTransform::Interpolate( Start, End, Factor );&#xA;&#xA;        LocalTransforms[i] = AnimatedTransform.GetLocalMatrix();&#xA;    }&#xA;    else&#xA;    {&#xA;        LocalTransforms[i] = joint.m_LocalMatrix;&#xA;    }&#xA;}&#xA;&#xA;ModelTransforms[0] = LocalTransforms[0];&#xA;for (uint32 i = 1; i &amp;lt; m_SkeletalMesh-&amp;gt;Joints.size(); i&#x2B;&#x2B;)&#xA;{&#xA;    FJoint&amp;amp; joint = m_SkeletalMesh-&amp;gt;Joints[i];&#xA;&#xA;    ModelTransforms[i] = ModelTransforms[joint.m_ParentIndex] * LocalTransforms[i];&#xA;}&#xA;&#xA;JointCBData* pJointCB = m_SkeletalMesh-&amp;gt;m_JointCB.GetBufferPointer();&#xA;for (uint32 i = 0; i &amp;lt; m_SkeletalMesh-&amp;gt;Joints.size(); i&#x2B;&#x2B;)&#xA;{&#xA;    FJoint&amp;amp; joint = m_SkeletalMesh-&amp;gt;Joints[i];&#xA;    FMatrix&amp;amp; FinalTransform = pJointCB-&amp;gt;kJoints[i];&#xA;&#xA;    FinalTransform = m_SkeletalMesh-&amp;gt;m_GlobalInverseTransform * ModelTransforms[i];&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I&#x27;m confident the hierarchy is being parsed correctly but here is my code to do so:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;void ProcessJoints( std::vector&amp;lt;FJoint&amp;gt;&amp;amp; Joints, const aiNode* pNode, const uint32&amp;amp; ParentIndex, const aiMesh* pMesh )&#xA;{&#xA;    FJoint&amp;amp; joint = Joints.emplace_back();&#xA;    strcpy_s( joint.m_Name, sizeof( joint.m_Name ), pNode-&amp;gt;mName.C_Str());&#xA;    joint.m_NameHash = StringHash( joint.m_Name );&#xA;    joint.m_ParentIndex = ParentIndex;&#xA;    memcpy( &amp;amp;joint.m_LocalMatrix, &amp;amp;pNode-&amp;gt;mTransformation, sizeof( FMatrix ) );&#xA;    for (uint32 i = 0; i &amp;lt; pMesh-&amp;gt;mNumBones; i&#x2B;&#x2B;)&#xA;    {&#xA;        if (pNode-&amp;gt;mName == pMesh-&amp;gt;mBones[i]-&amp;gt;mName)&#xA;        {&#xA;            memcpy( &amp;amp;joint.m_OffsetMatrix, &amp;amp;pMesh-&amp;gt;mBones[i]-&amp;gt;mOffsetMatrix, sizeof( FMatrix ) );&#xA;            break;&#xA;        }&#xA;    }&#xA;&#xA;    uint32 NewParentIndex = (uint32)Joints.size() - 1u;&#xA;    for (uint32 i = 0; i &amp;lt; pNode-&amp;gt;mNumChildren; i&#x2B;&#x2B;)&#xA;    {&#xA;        ProcessJoints( Joints, pNode-&amp;gt;mChildren[i], NewParentIndex, pMesh );&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Here is my shader code as well which is taken from Frank Luna&#x27;s DirectX12 book:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    float weights[4] = { 0.0f, 0.0f, 0.0f, 0.0f };&#xA;    weights[0] = Input.Weights[0];&#xA;    weights[1] = Input.Weights[1];&#xA;    weights[2] = Input.Weights[2];&#xA;    weights[3] = 1.0f - weights[0] - weights[1] - weights[2];&#xA;    float3 totalLocalPos = float3(0, 0, 0);&#xA;    for (int i = 0; i &amp;lt; HE_MAX_JOINTS_PER_VERTEX; i&#x2B;&#x2B;)&#xA;    {&#xA;        totalLocalPos &#x2B;= weights[i] * mul( float4(Input.Position, 0), Joints[Input.JointIDs[i]] ).xyz;&#xA;    }&#xA;    Result.Position = mul( float4(totalLocalPos, 1), WorldViewProjection );&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I&#x27;ve been banging my head against this problem for weeks now and just cannot find the problem. Any help would be appreciated!&lt;/p&gt;&#xA;&lt;p&gt;Other things I tried with no success were:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Update Assimp to the latest version thinking that might be the problem with the Assimp library&lt;/li&gt;&#xA;&lt;li&gt;Made sure the vertices has the proper data types which was the solution to &lt;a href=&quot;https://stackoverflow.com/questions/69143039/skeletal-animation-bug-with-assimp-in-directx-12&quot;&gt;this&lt;/a&gt; problem&lt;/li&gt;&#xA;&lt;li&gt;Made sure the matrices were in row-major in C&#x2B;&#x2B; then column-major for hlsl&lt;/li&gt;&#xA;&lt;li&gt;Different models with different animations. Each model I tried had the same stretched/deformed look to them&lt;/li&gt;&#xA;&lt;li&gt;Re-exporting the same models from blender as I saw some might cause issues without it like &lt;a href=&quot;https://youtu.be/7JMehLi2vWk?t=473&quot; rel=&quot;nofollow noreferrer&quot;&gt;this&lt;/a&gt; tutorial&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/77303994</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">Bind different 3d models to a main model with opengl and assimp</title>
            <category scheme="https://stackoverflow.com/tags" term="android" />
            <category scheme="https://stackoverflow.com/tags" term="opengl-es" />
            <category scheme="https://stackoverflow.com/tags" term="assimp" />
        <author>
            <name>MARCOS MEDINA</name>
            <uri>https://stackoverflow.com/users/16882266</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/77303994/bind-different-3d-models-to-a-main-model-with-opengl-and-assimp" />
        <published>2023-10-16T17:48:35Z</published>
        <updated>2023-11-03T14:20:34Z</updated>
        <summary type="html">
            &lt;p&gt;I hope you&#x27;re doing well. I am starting with OpenGL, and currently, I have been implementing Assimp to load 3D models and animations, and so far, everything is going well. However, now what I want to know is whether it is possible to have several FBX files and link them to a bone of a main model. For example, I have an FBX file&lt;/p&gt;&#xA;&lt;p&gt;male_character.fbx&#xA;, and I have another file&lt;/p&gt;&#xA;&lt;p&gt;helmet.fbx&#xA;, and I want to associate it with the character&#x27;s head. Is this possible, or can it only be done with one file and different meshes? Additionally, I have attached a gif to show what I have accomplished so far using Android Kotlin, NDK (C&#x2B;&#x2B;), OpenGL ES, and Assimp. Thank you for your assistance!&#xA;&lt;a href=&quot;https://i.sstatic.net/cFYLj.gif&quot; rel=&quot;nofollow noreferrer&quot;&gt;enter image description here&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I added several 3D objects to the character from the same file (meaning different meshes), but I started thinking, if a new item needs to be added later on, then the entire FBX file would have to be completely updated to include this new item. That&#x27;s why I want to know if it is possible to do this with separate files.&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/77155868</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">cookTriangleMesh access exception</title>
            <category scheme="https://stackoverflow.com/tags" term="c&#x2B;&#x2B;" />
            <category scheme="https://stackoverflow.com/tags" term="c&#x2B;&#x2B;17" />
            <category scheme="https://stackoverflow.com/tags" term="directx-11" />
            <category scheme="https://stackoverflow.com/tags" term="assimp" />
            <category scheme="https://stackoverflow.com/tags" term="physx" />
        <author>
            <name>shroow</name>
            <uri>https://stackoverflow.com/users/11531561</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/77155868/cooktrianglemesh-access-exception" />
        <published>2023-09-22T08:10:29Z</published>
        <updated>2023-10-13T09:27:19Z</updated>
        <summary type="html">
            &lt;pre&gt;&lt;code&gt;PxTriangleMesh* PhysX::CreateTriangleMesh(const PxVec3* verts, const PxU32 numVerts&#xA;    , const PxU32* indexs, const PxU32 numIndexes, PxPhysics* physics, PxCooking* cooking)&#xA;{&#xA;    // Create descriptor for triangle mesh&#xA;    PxTriangleMeshDesc meshDesc;&#xA;    meshDesc.points.count = numVerts;&#xA;    meshDesc.points.stride = sizeof(PxVec3);    &#xA;    meshDesc.points.data = verts;&#xA;&#xA;    meshDesc.triangles.count = numIndexes / 3;&#xA;    meshDesc.triangles.stride = 3 * sizeof(PxU32);&#xA;    meshDesc.triangles.data = indexs;&#xA;&#xA;    // for prevent stackoverflow&#xA;    PxU32 estimatedVertSize = numVerts * sizeof(PxVec3) * 1.5;&#xA;    PxU32 estimatedIndexSize = numIndexes * sizeof(PxU32) * 1.5;&#xA;    PxU32 initialSize = estimatedVertSize &#x2B; estimatedIndexSize;&#xA;    CustomPhysXMemory writeBuffer(initialSize);&#xA;&#xA;    //PxDefaultMemoryOutputStream writeBuffer;&#xA;    bool status = cooking-&amp;gt;cookTriangleMesh(meshDesc, writeBuffer);&#xA;    if (!status)&#xA;        return nullptr; &#xA;&#xA;    PxDefaultMemoryInputData readBuffer(writeBuffer.getData(), writeBuffer.getSize());&#xA;    PxTriangleMesh* triangleMesh = physics-&amp;gt;createTriangleMesh(readBuffer);&#xA;&#xA;    return triangleMesh;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;I want to give a collider to mesh that load by assimp so I made a physX triangleMesh.&#xA;In many situations, it works&#xA;But sometimes in cookTriangleMesh&#xA;Exception thrown at 0x00007FFD322F259E (PhysXCooking_64.dll) in Client.exe: 0xC0000005: Access violation reading location 0x0000019F69AA8000.&#xA;occurs.&lt;/p&gt;&#xA;&lt;p&gt;I was worried about the capacity of buffer and gave him a 1.5 times space, and I checked&#xA;&lt;em&gt;((physx::PxSimpleTriangleMesh&lt;/em&gt;)&amp;amp;meshDesc),nd {points={count=82772 } triangles={count=43798 } flags={mBits=0 } }&#xA;writeBuffer.mBuffer.capacity() 2278260&#xA;These two always came out the same either success or failure..&lt;/p&gt;&#xA;&lt;p&gt;So I don&#x27;t have a clue what the problem is. Can someone who knows the problem and how to solve it help me?&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/76984640</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">Improve mesh geometry serialization performance</title>
            <category scheme="https://stackoverflow.com/tags" term="graphics" />
            <category scheme="https://stackoverflow.com/tags" term="3d" />
            <category scheme="https://stackoverflow.com/tags" term="mesh" />
            <category scheme="https://stackoverflow.com/tags" term="assimp" />
        <author>
            <name>TheChamp</name>
            <uri>https://stackoverflow.com/users/7978004</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/76984640/improve-mesh-geometry-serialization-performance" />
        <published>2023-08-26T19:59:44Z</published>
        <updated>2023-09-02T18:27:32Z</updated>
        <summary type="html">
            &lt;p&gt;I want to improve the serialization time of my 3D application.&#xA;I use the following scene for testing:&#xA;&lt;a href=&quot;https://www.dropbox.com/scl/fi/j8ays9phm2xs45icla4bo/TestScene.zip?rlkey=qy8jpwgz3s8b95mz62l8axcug&amp;amp;dl=0&quot; rel=&quot;nofollow noreferrer&quot;&gt;https://www.dropbox.com/scl/fi/j8ays9phm2xs45icla4bo/TestScene.zip?rlkey=qy8jpwgz3s8b95mz62l8axcug&amp;amp;dl=0&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;I did a performance comparison with Blender and 3DS Max.&lt;br /&gt;&#xA;Blender: 1 second&lt;br /&gt;&#xA;3DS max: 2 seconds&lt;br /&gt;&#xA;My application: 15 seconds !!&lt;/p&gt;&#xA;&lt;p&gt;To serialize meshes I use the OBJ file format and Assimp.&lt;br /&gt;&#xA;The Assimp serialization time is too high.&#xA;Should I write my own format? Is there any tricks I should know about?&lt;/p&gt;&#xA;&lt;p&gt;Thank you. For convenience here my serialization code:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;    aiScene* scene = new aiScene();&#xA;&#xA;    // Allocate materials memory&#xA;    scene-&amp;gt;mNumMaterials = 1;&#xA;    scene-&amp;gt;mMaterials = new aiMaterial*[scene-&amp;gt;mNumMaterials];&#xA;    &#xA;    // Allocate mesh memory&#xA;    scene-&amp;gt;mNumMeshes = (unsigned)m_flatMeshContainer.size();&#xA;    scene-&amp;gt;mMeshes = new aiMesh*[m_flatMeshContainer.size()];&#xA;&#xA;    scene-&amp;gt;mRootNode = new aiNode();&#xA;    scene-&amp;gt;mRootNode-&amp;gt;mNumMeshes = 0;&#xA;&#xA;    // Create materials&#xA;    for (Uint32 i = 0u; i &amp;lt; scene-&amp;gt;mNumMaterials; &#x2B;&#x2B;i)&#xA;    {&#xA;        scene-&amp;gt;mMaterials[i] = new aiMaterial();&#xA;    }&#xA;&#xA;    // Create meshes&#xA;    std::mutex mtx;&#xA;    tbb::parallel_for(size_t(0), m_meshGroupIdentifiers.size(), [&amp;amp;](size_t idx) {&#xA;&#xA;        const auto&amp;amp; groupId = m_meshGroupIdentifiers[idx];&#xA;        const auto group = getMeshGroupPtr_FromEntity(groupId);&#xA;&#xA;        // Create meshes&#xA;        const auto nbMeshes = (unsigned)group-&amp;gt;m_meshes.size();&#xA;        aiNode* node = new aiNode();&#xA;        node-&amp;gt;mMeshes = new unsigned int[nbMeshes];&#xA;        node-&amp;gt;mNumMeshes = nbMeshes;&#xA;&#xA;        for (Uint32 i = 0u; i &amp;lt; nbMeshes; &#x2B;&#x2B;i)&#xA;        {&#xA;            // Init mesh&#xA;            const Mesh* nativeMesh = group-&amp;gt;m_meshes[i];&#xA;            const auto flatMeshIdx = nativeMesh-&amp;gt;getFlatId();&#xA;            scene-&amp;gt;mMeshes[flatMeshIdx] = new aiMesh();&#xA;            node-&amp;gt;mMeshes[i] = flatMeshIdx;&#xA;&#xA;            aiMesh* mesh = scene-&amp;gt;mMeshes[flatMeshIdx];&#xA;            mesh-&amp;gt;mName = group-&amp;gt;getName();&#xA;            mesh-&amp;gt;mMaterialIndex = 0;&#xA;&#xA;            // Build vertices&#xA;            const auto&amp;amp; vertices = nativeMesh-&amp;gt;getRealVertices();&#xA;            const auto nbVertex = (unsigned)vertices.size();&#xA;&#xA;            mesh-&amp;gt;mVertices = new aiVector3D[nbVertex];&#xA;            mesh-&amp;gt;mNormals = new aiVector3D[nbVertex];&#xA;            mesh-&amp;gt;mNumVertices = nbVertex;&#xA;&#xA;            mesh-&amp;gt;mTextureCoords[0] = new aiVector3D[nbVertex];&#xA;            mesh-&amp;gt;mNumUVComponents[0] = nbVertex;&#xA;&#xA;            for (Uint32 j = 0u; j &amp;lt; nbVertex; &#x2B;&#x2B;j)&#xA;            {&#xA;                const auto&amp;amp; vtx = vertices[j];&#xA;&#xA;                mesh-&amp;gt;mVertices[j] = aiVector3D(vtx.position.x, vtx.position.y, vtx.position.z);&#xA;                mesh-&amp;gt;mNormals[j] = aiVector3D(vtx.normal.x, vtx.normal.y, vtx.normal.z);&#xA;                mesh-&amp;gt;mTextureCoords[0][j] = aiVector3D(vtx.texCoord.x, vtx.texCoord.y, 0);&#xA;            }&#xA;&#xA;            // Build faces&#xA;            const auto&amp;amp; indices = nativeMesh-&amp;gt;getRealIndices();&#xA;            mesh-&amp;gt;mNumFaces = (unsigned)indices.size() / PRIMITIVE_NB_VTX;&#xA;            mesh-&amp;gt;mFaces = new aiFace[mesh-&amp;gt;mNumFaces];&#xA;&#xA;            for (Uint32 j = 0u; j &amp;lt; indices.size(); j &#x2B;= PRIMITIVE_NB_VTX)&#xA;            {&#xA;                aiFace &amp;amp;face = mesh-&amp;gt;mFaces[j / PRIMITIVE_NB_VTX];&#xA;                face.mIndices = new unsigned int[PRIMITIVE_NB_VTX];&#xA;                face.mNumIndices = PRIMITIVE_NB_VTX;&#xA;&#xA;                for (Uint32 k = 0; k &amp;lt; PRIMITIVE_NB_VTX; &#x2B;&#x2B;k)&#xA;                {&#xA;                    face.mIndices[k] = indices[k &#x2B; j];&#xA;                }&#xA;            }&#xA;        }&#xA;&#xA;        std::lock_guard&amp;lt;std::mutex&amp;gt; lock(mtx);&#xA;        scene-&amp;gt;mRootNode-&amp;gt;addChildren(1, &amp;amp;node);&#xA;    });&#xA;&#xA;&#xA;    const auto objPath = m_serializationFullPath.string();&#xA;    Assimp::Exporter exporter;&#xA;    // HERE : SLOW  --------------------------------------------------------------------------------------------&#xA;    exporter.Export(scene, &amp;quot;obj&amp;quot;, objPath);&#xA;    // ---------------------------------------------------------------------------------------------------------&#xA;&#xA;    delete scene;&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/76905039</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">How can I get texture file by using assimp?</title>
            <category scheme="https://stackoverflow.com/tags" term="3d" />
            <category scheme="https://stackoverflow.com/tags" term="fbx" />
            <category scheme="https://stackoverflow.com/tags" term="assimp" />
        <author>
            <name>yldbear77</name>
            <uri>https://stackoverflow.com/users/13320800</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/76905039/how-can-i-get-texture-file-by-using-assimp" />
        <published>2023-08-15T10:07:25Z</published>
        <updated>2023-08-22T08:58:06Z</updated>
        <summary type="html">
            &lt;p&gt;I am developing FBX model viewer using directx and assimp library. For loading texture, I called function like below. (I got FBX from mixamo)&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;aiString path;&#xA;mat-&amp;gt;Get(AI_MATKEY_TEXTURE_DIFFUSE(0), path); // mat is aiMaterial*&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;The &amp;quot;path&amp;quot; variable now has &amp;quot;&lt;strong&gt;../../../../home/app/mixamo-mini/tmp/skins_XXX.fbm/Mutant_Diffuse.png&lt;/strong&gt;&amp;quot;&lt;/p&gt;&#xA;&lt;p&gt;I cannot find that path on my computer from the location where FBX file exists. I use Windows 11 Pro. How can I read the texture files Assimp extracted ? Even &amp;quot;../../../../home&amp;quot; does not exist.&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/76897318</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">How to check that extracted FBX indices are correct?</title>
            <category scheme="https://stackoverflow.com/tags" term="import" />
            <category scheme="https://stackoverflow.com/tags" term="fbx" />
            <category scheme="https://stackoverflow.com/tags" term="assimp" />
        <author>
            <name>YoonSeok OH</name>
            <uri>https://stackoverflow.com/users/11701719</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/76897318/how-to-check-that-extracted-fbx-indices-are-correct" />
        <published>2023-08-14T08:14:44Z</published>
        <updated>2023-08-22T12:57:18Z</updated>
        <summary type="html">
            &lt;p&gt;I am trying to import FBX file using FBX SDK. Reference was &amp;quot;ImportScene&amp;quot; sample of FBX. I&#x27;ve extracted vertices (control point in FBX) and indices. I wanted to check whether the extracted values are correct by comparing the values using other library on same FBX file. The other library is ASSIMP. However, the extracted values of each library are different and I have no idea the values of which library is correct. I&#x27;ve tried to check which values are correct using other tools such as Blender and Unity. However, I couldn&#x27;t find way to see the table of vertex indices. So my question is&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Q. How to check that extracted FBX indices are correct?&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;Below are extracted values from FBX SDK and ASSIMP.&lt;/p&gt;&#xA;&lt;div class=&quot;s-table-container&quot;&gt;&#xA;&lt;table class=&quot;s-table&quot;&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th&gt;&lt;/th&gt;&#xA;&lt;th&gt;FBX SDK&lt;/th&gt;&#xA;&lt;th&gt;ASSIMP&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Vertices&lt;/td&gt;&#xA;&lt;td&gt;&lt;a href=&quot;https://i.sstatic.net/LMURT.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.sstatic.net/LMURT.png&quot; alt=&quot;FBX_Vertex&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;a href=&quot;https://i.sstatic.net/31d8k.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.sstatic.net/31d8k.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Indices&lt;/td&gt;&#xA;&lt;td&gt;&lt;a href=&quot;https://i.sstatic.net/fnKAc.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.sstatic.net/fnKAc.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;a href=&quot;https://i.sstatic.net/8SPtl.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.sstatic.net/8SPtl.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;Triangulate&lt;/td&gt;&#xA;&lt;td&gt;&lt;a href=&quot;https://i.sstatic.net/Tt2TJ.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.sstatic.net/Tt2TJ.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&#xA;&lt;td&gt;&lt;a href=&quot;https://i.sstatic.net/rOv9u.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.sstatic.net/rOv9u.png&quot; alt=&quot;enter image description here&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;&lt;strong&gt;[Assumption]&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;My assumption is&#xA;FBX vertices are correct while ASSIMP vertices z values are inverted (to negative).&#xA;FBX indices are correct while ASSIMP indices are wrong.&lt;/p&gt;&#xA;&lt;p&gt;The reason for assumption is&#xA;Vertex count is 2409, face count is 4602 in Blender.&#xA;FBX SDK gives 4602 faces and all GetPolygonSize gives 3, which means 13806 (= 4602 * 3) vertices (overlapping).&#xA;However, ASSIMP gives 10482 vertices and some vertices have exact same x, y, z values. It seems ASSIMP is trying to give overlapping vertices. 10482 vertices seem weird anyway.&lt;/p&gt;&#xA;&lt;p&gt;But assumption is assumption. I&#x27;d want to check the extracted values by model viewer that can show tables of imported mesh&#x27;s vertices and indices. However, I could not find so far.&lt;/p&gt;&#xA;&lt;p&gt;If anyone helps, it will be really appreciated.&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/76863055</id>
        <re:rank scheme="https://stackoverflow.com">0</re:rank>
        <title type="text">How do I compile cmake generated binaries in 64bits using MinGW (Windows, GCC)?</title>
            <category scheme="https://stackoverflow.com/tags" term="c&#x2B;&#x2B;" />
            <category scheme="https://stackoverflow.com/tags" term="cmake" />
            <category scheme="https://stackoverflow.com/tags" term="mingw" />
            <category scheme="https://stackoverflow.com/tags" term="mingw-w64" />
            <category scheme="https://stackoverflow.com/tags" term="assimp" />
        <author>
            <name>Ian vos</name>
            <uri>https://stackoverflow.com/users/14555986</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/76863055/how-do-i-compile-cmake-generated-binaries-in-64bits-using-mingw-windows-gcc" />
        <published>2023-08-08T20:36:16Z</published>
        <updated>2023-08-10T19:39:51Z</updated>
        <summary type="html">
            &lt;p&gt;I&#x27;ve been trying to compile the model loading library Assimp for my project using cmake and then MinGW. However, I don&#x27;t know how to do that for 64bits which is what I&#x27;m using on my project. I used the command &amp;quot;mingw32-make&amp;quot; but if I understand correctly that is for 32bits and when I try to run my project with the obtained DLL it exits without explanation. I&#x27;ve heard this can happen when you try to link 32bit files with a 64bit projects. I heard about &amp;quot;make.exe&amp;quot; but I don&#x27;t know if it&#x27;s what I need and either way I can&#x27;t find it in my MinGW folder. I&#x27;d rather not resort to Visual Studio, I use VSCode.&lt;/p&gt;&#xA;
        </summary>
    </entry>
    <entry>
        <id>https://stackoverflow.com/q/76841913</id>
        <re:rank scheme="https://stackoverflow.com">1</re:rank>
        <title type="text">Can you check if there are any errors in the collada (.dae) models that I extracted?</title>
            <category scheme="https://stackoverflow.com/tags" term="game-engine" />
            <category scheme="https://stackoverflow.com/tags" term="game-development" />
            <category scheme="https://stackoverflow.com/tags" term="directx-11" />
            <category scheme="https://stackoverflow.com/tags" term="collada" />
            <category scheme="https://stackoverflow.com/tags" term="assimp" />
        <author>
            <name>user19632259</name>
            <uri>https://stackoverflow.com/users/19632259</uri>
        </author>
        <link rel="alternate" href="https://stackoverflow.com/questions/76841913/can-you-check-if-there-are-any-errors-in-the-collada-dae-models-that-i-extrac" />
        <published>2023-08-05T13:38:51Z</published>
        <updated>2023-08-05T13:38:51Z</updated>
        <summary type="html">
            &lt;p&gt;I used the Assimp loader in my DirectX 11 engine to open my .dae model files, but it&#x27;s not functioning correctly.&lt;/p&gt;&#xA;&lt;p&gt;My team and I don&#x27;t believe there are any errors in my code, so I asked others for help. They suggested that there might be an issue with the model itself. I will upload the model files, and I would appreciate it if you could let me know if there are any problems with them.&lt;/p&gt;&#xA;&lt;p&gt;The issues I anticipate are as follows:&lt;/p&gt;&#xA;&lt;p&gt;Debugging results show that the values of the base vectors are incorrect.&#xA;The bone information I was manipulating is in local space, so the expected world position, rotation, and base are not being applied correctly.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://drive.google.com/drive/folders/1gl6LV-4rlHUwJoTULTZQrLF5_KjkdYVp?usp=drive_link&quot; rel=&quot;nofollow noreferrer&quot;&gt;Model - Google drive&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&quot;https://i.sstatic.net/bxojq.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.sstatic.net/bxojq.png&quot; alt=&quot;my engine moddel&quot; /&gt;&lt;/a&gt;&#xA;&lt;a href=&quot;https://i.sstatic.net/Foi4R.png&quot; rel=&quot;nofollow noreferrer&quot;&gt;&lt;img src=&quot;https://i.sstatic.net/Foi4R.png&quot; alt=&quot;tool model&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;This is the code I used to load the model.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;void Model::recursiveProcessBoneMatrix(aiMatrix4x4 matrix, const std::wstring&amp;amp; nodeName)&#xA;{&#xA;    const ModelNode* modelNode = FindNode(nodeName);&#xA;    aiMatrix4x4 transform = modelNode-&amp;gt;mTransformation;&#xA;&#xA;    if (mParentModel)&#xA;    {&#xA;        // Code written to search for nodes with the same name in the model.&#xA;        ModelNode* parentModelNode = mParentModel-&amp;gt;FindNode(nodeName);&#xA;        if (parentModelNode)&#xA;        {&#xA;            /*&#xA;            Set my hierarchy information based on the parent&#x27;s corresponding node hierarchy.&#xA;            Although the model is forced to move to the position of that node, &#xA;            it causes rotation issues.&#xA;            */&#xA;            Bone* bone = mParentModel-&amp;gt;FindBone(nodeName);&#xA;&#xA;            if (bone != nullptr)&#xA;            {&#xA;                bone = mParentModel-&amp;gt;GetBone(bone-&amp;gt;mIndex);&#xA;&#xA;                matrix = bone-&amp;gt;mLocalMatrix;&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;    matrix = matrix * transform;&#xA;&#xA;&#xA;    if (mBoneMap.find(nodeName) != mBoneMap.end())&#xA;    {&#xA;        Bone* bone = &amp;amp;mBoneMap.find(nodeName)-&amp;gt;second;&#xA;        aiMatrix4x4 glovalInvers = FindNode(L&amp;quot;Scene&amp;quot;)-&amp;gt;GetTransformation();&#xA;&#xA;        // bone-&amp;gt;mOffsetMatrix - vectex to bonespace (like world, view, projection transform)&#xA;        //matrix - transformed martrix from root&#xA;        bone-&amp;gt;mFinalMatrix = glovalInvers.Inverse() * matrix * bone-&amp;gt;mOffsetMatrix;&#xA;        bone-&amp;gt;mLocalMatrix = matrix;&#xA;&#xA;        mBones[bone-&amp;gt;mIndex].mFinalMatrix = bone-&amp;gt;mFinalMatrix;&#xA;        mBones[bone-&amp;gt;mIndex].mLocalMatrix = matrix;&#xA;    }&#xA;&#xA;    for (size_t i = 0; i &amp;lt; modelNode-&amp;gt;mChilds.size(); &#x2B;&#x2B;i)&#xA;    {&#xA;        recursiveProcessBoneMatrix(matrix, modelNode-&amp;gt;mChilds[i]-&amp;gt;mName);&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;
        </summary>
    </entry>
</feed>