Esempio n. 1
0
void WorkspaceGrid::setEntries( std::vector<WorkspaceRepresentation::WorkspaceCut2DTransformationPtr> &wsData, Eigen::Matrix4f &graspGlobal, GraspPtr grasp )
{
	if (!data)
		return;

	float x,y;

	for (int i=0;i<(int)wsData.size();i++)
	{
		Eigen::Matrix4f tmpPos2 = graspGlobal * wsData[i]->transformation.inverse();
		x = tmpPos2(0,3);
		y = tmpPos2(1,3);

		setEntryCheckNeighbors(x,y,wsData[i]->value,grasp);
		//setEntry(x,y,vData[i].value);
	}
}
void akGeometryDeformer::DLBSkinningNoNormals(
    const btAlignedObjectArray<akMatrix4>* mpalette,
    const btAlignedObjectArray<akDualQuat>* dqpalette,
    const UTsize vtxCount,
    const float*     weights, const UTsize weightsStride,
    const UTuint8*   indices, const UTsize indicesStride,
    const akVector3* vtxSrc,  const UTsize vtxSrcStride,
    akVector3*       vtxDst,  const UTsize vtxDstStride)
{
    const btAlignedObjectArray<akMatrix4>& matrices = *mpalette;
    const btAlignedObjectArray<akDualQuat>& dquats = *dqpalette;

    for(unsigned int i=0; i<vtxCount; i++)
    {
        // position 1st pass for non rigid part of the transformation using matrices
        akVector4 pos(vtxSrc[0].getX(), vtxSrc[0].getY(), vtxSrc[0].getZ(), 1);
        akVector4 posout(0,0,0,1);
        if (weights[0]) posout += matrices[indices[0]] * weights[0] * pos;
        if (weights[1]) posout += matrices[indices[1]] * weights[1] * pos;
        if (weights[2]) posout += matrices[indices[2]] * weights[2] * pos;
        if (weights[3]) posout += matrices[indices[3]] * weights[3] * pos;

        // position 2nd pass for rigid transformation (rotaion & location) using dual quats
        akDualQuat dq = dquats[indices[0]] * weights[0];
        if (weights[1]) dq += dquats[indices[1]] * weights[1];
        if (weights[2]) dq += dquats[indices[2]] * weights[2];
        if (weights[3]) dq += dquats[indices[3]] * weights[3];

        dq /= length(dq.n);

        akVector3 tmpPos2(posout.getXYZ());
        akVector3 ndxyz(dq.n.getXYZ());
        akVector3 dxyz(dq.d.getXYZ());
        *vtxDst = tmpPos2 + 2.0 * cross( ndxyz, cross(ndxyz, tmpPos2) + dq.n.getW() * tmpPos2 ) +
                  2.0 * ( dq.n.getW() * dxyz - dq.d.getW() * ndxyz + cross(ndxyz, dxyz) );

        akAdvancePointer(weights, weightsStride);
        akAdvancePointer(indices, indicesStride);
        akAdvancePointer(vtxSrc, vtxSrcStride);
        akAdvancePointer(vtxDst, vtxDstStride);
    }
}