Joint* SkeletonBlendedGeometry::getJoint(UInt32 index) const
{
    if(index < getMFInternalJoints()->size())
    {
        return (*getMFInternalJoints())[index];
    }
    else
    {
        return NULL;
    }
}
void SkeletonBlendedGeometry::addJointBlending(UInt32 VertexIndex, Joint* const TheJoint, Real32 BlendAmount)
{
    if(getWeightIndexes() == NULL)
    {
        GeoUInt32PropertyUnrecPtr Indexes = GeoUInt32Property::create();
        setWeightIndexes(Indexes);
    }
    if(getWeights() == NULL)
    {
        GeoVec1fPropertyUnrecPtr Weights = GeoVec1fProperty::create();
        setWeights(Weights);
    }
    
    Int32 JointIndex(getMFInternalJoints()->findIndex(TheJoint));
    if(JointIndex < 0)
    {
        SFATAL << "Cannot add weight for joint, because that joint is not connected." << std::endl;
        return;
    }

    //Vertex Index
    getWeightIndexes()->push_back(VertexIndex);

    //Joint Index
    getWeightIndexes()->push_back(JointIndex);

    //Weight Index
    getWeightIndexes()->push_back(getWeights()->getSize());

    getWeights()->push_back(Pnt1f(BlendAmount));
}
void SkeletonBlendedGeometry::updateJointTransformations(void)
{
	//Loop through bone hierarchy and update their transformations
	for(UInt32 i(0); i < getMFInternalJoints()->size(); ++i)
	{
		//getJoints(i)->updateTransformations(false);
	}
}
Int32 SkeletonBlendedGeometry::getJointParentIndex(UInt32 index) const
{
    Node* ChildJoint(getJoint(index));

    if(ChildJoint->getParent())
    {
        return getMFInternalJoints()->findIndex(ChildJoint->getParent());
    }
    return -1;
}
Int32 SkeletonBlendedGeometry::getJointParentIndex(UInt32 index) const
{
    Joint* ChildJoint(getJoint(index));
    Node* ChildNode(dynamic_cast<Node*>(ChildJoint->getParents()[0]));

    if(ChildNode->getParent())
    {
        NodeCore* ParentCore(ChildNode->getParent()->getCore());
        if(ParentCore->getType().isDerivedFrom(Joint::getClassType()))
        {
            return getMFInternalJoints()->findIndex(ParentCore);
        }
    }
    return -1;
}
UInt32 SkeletonBlendedGeometry::getNumJoints(void) const
{
    return getMFInternalJoints()->size();
}
Int32 SkeletonBlendedGeometry::getJointIndex(Joint* theJoint) const
{
    return getMFInternalJoints()->findIndex(theJoint);
}
void SkeletonBlendedGeometry::removeObjFromJoints(Joint* const jointValue)
{
    editMFInternalJointInvBindTransformations()->erase(getMFInternalJoints()->findIndex(jointValue));
    editMFInternalJointBindTransformations()->erase(getMFInternalJoints()->findIndex(jointValue));
    removeObjFromInternalJoints(jointValue);
}