Show / Hide Table of Contents

    Working with skinning data

    The Simplygon API now provides the user to add skinning information per-vertex. The skinning data is kept intact when performing reduction. The API also provides the ability to reduce bones and generate new skinning data based on the reduction. For more on how to use bone reduction see the section about bone reduction settings or the bone reduction example.

    Skinning

    Smooth skinning

    Simplygon API provides support for smooth skinning. Two new fields have been added to the IGeometryData class for skinning purposes. These two fields are the BoneIds and BoneWeights. The figure above shows how smooth skinning works.

    Bones

    To add skinning information in IGeometryData use the AddBoneWeights. The method takes the tuple size which should be equal to the number of bones influencing a vertex. The API allows a vertex to be influenced by a maximum of four bones. Calling AddBoneWeightsalso creates the BoneIds field with the same tuple size. The bone ids field contains integer ids. The bone weights field can accept floating point values. Set the bone id and bone weight to -1 and 0 respectively if the tuple is not used. Bone setup is provided through the Simplygon scenegraph see ISceneBone documentation.

    Example - Skinning data

    void AddBoneToGeometryData(spGeometryData geom)
    {
        // Add bone weights to geometry data (per vertex).
        // Up to two bones can influence each vertex.
        geom->AddBoneWeights(2);
        spRealArray BoneWeights = geom->GetBoneWeights();
        spRidArray BoneIds = geom->GetBoneIds();
    
        // Add bone info to the bone weight and id fields.
        for( int v_index=0; v_index<vertex_count; ++v_index )
        {   
            // Set the bone weight to perform skinning.
            BoneWeights->SetItem((v_index*2)+0, 0.5);
            BoneWeights->SetItem((v_index*2)+1, 0.5);
    
            // Set the bone ids influencing the vertex.
            // Second argument is bone id.
            BoneIds->SetItem((v_index*2)+0, 0);
            BoneIds->SetItem((v_index*2)+1, 0);
    
        }
    }
    
    Back to top Terms of Use | Privacy and cookies | Trademarks | Copyright © 2019 Microsoft