void akGeometryDeformer::LBSkinningNoNormals( const btAlignedObjectArray<akMatrix4>* mpalette, 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; for(unsigned int i=0; i<vtxCount; i++) { 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; *vtxDst = posout.getXYZ(); akAdvancePointer(weights, weightsStride); akAdvancePointer(indices, indicesStride); akAdvancePointer(vtxSrc, vtxSrcStride); akAdvancePointer(vtxDst, vtxDstStride); } }
void akGeometryDeformer::DLBAntipodalitySkinningNoNormals( 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; akDualQuat dq0 = dquats[indices[0]]; akDualQuat dq1 = dquats[indices[1]]; akDualQuat dq2 = dquats[indices[2]]; akDualQuat dq3 = dquats[indices[3]]; if( dot(dq0.n, dq1.n) < 0.0) dq1 *= -1.0; if( dot(dq0.n, dq2.n) < 0.0) dq2 *= -1.0; if( dot(dq0.n, dq3.n) < 0.0) dq3 *= -1.0; akDualQuat dq = dq0 * weights[0]; if (weights[1]) dq += dq1 * weights[1]; if (weights[2]) dq += dq2 * weights[2]; if (weights[3]) dq += dq3 * weights[3]; dq /= length(dq.n); akVector3 ndxyz(dq.n.getXYZ()); akVector3 dxyz(dq.d.getXYZ()); //position akVector3 in(posout.getXYZ()); *vtxDst = in + 2.0 * cross( ndxyz, cross(ndxyz, in) + dq.n.getW() * in ) + 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); } }
void Groove::setup(Disc* disc, Player* player, vector<Player *> otherPlayers){ turn = true; //groove should not operate without getting disc this->disc = disc; this->me = player; this->otherPlayers = otherPlayers; for(int i = 0; i < disc->getDiscIndex(); i++){ // meshmeshmesh ofMesh _mesh; _mesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP); _mesh.enableIndices(); mesh.push_back(_mesh); //generate mesh int resolution = 70; for(int a = 0; a <= 360; a += 360/resolution){ ofVec3f posin(disc->getRadius(i-1)*cos(a*PI/180), disc->getRadius(i-1)*sin(a*PI/180), disc->getPosition(i)); ofVec3f posout(disc->getRadius(i)*cos(a*PI/180), disc->getRadius(i)*sin(a*PI/180), disc->getPosition(i)); mesh[i].addVertex(posin); mesh[i].addColor(ofFloatColor(1.0, 1.0, 1.0)); mesh[i].addVertex(posout); mesh[i].addColor(ofFloatColor(1.0, 1.0, 1.0)); } for(int a = 0; a < mesh[i].getNumVertices(); a++){ ofVec3f vert = mesh[i].getVertex(a); mesh[i].addIndex(a); } } // life bar & life for(int i = 0; i < otherPlayers.size()+1; i++){ ofRectangle thisBar; lifeBar.push_back(thisBar); } }
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); } }