void HodginDidItApp::update() { int cTime = getElapsedFrames(); if(cTime < S_HELLO_START) mStage = 0; else if(cTime>=S_HELLO_START&&cTime<S_ASK_START) mStage = 1; else if(cTime>=S_ASK_START&&cTime<S_BL_2_SEG) mStage = 2; else if(cTime>=S_BL_2_SEG&&cTime<S_SEG_2_BW) mStage = 3; else if(cTime>=S_SEG_2_BW&&cTime<S_BW_2_RGB) mStage = 4; else if(cTime>=S_BW_2_RGB&&cTime<S_VEIL_START) mStage = 5; else if(cTime>=S_VEIL_START) mStage = 6; if(mStage>=3) { if(mPXC.AcquireFrame(true)) { updateCamera(); mPXC.ReleaseFrame(); } } switch(mStage) { case 1: case 2: { updateStrings(); break; } case 3: case 4: case 5: { updateBlend(); break; } case 6: { updateVeil(); break; } } }
Vector3 FlexBody::flexit() { if(faulty) return Vector3::ZERO; if(!enabled) return Vector3::ZERO; if (haveblend) updateBlend(); //compute the local center Vector3 normal; Vector3 center; if(cref >= 0) { normal=(nodes[cy].smoothpos-nodes[cref].smoothpos).crossProduct(nodes[cx].smoothpos-nodes[cref].smoothpos); normal.normalise(); center=nodes[cref].smoothpos+coffset.x*(nodes[cx].smoothpos-nodes[cref].smoothpos)+coffset.y*(nodes[cy].smoothpos-nodes[cref].smoothpos); center=(center+normal*coffset.z); } else { normal = Vector3::UNIT_Y; center = nodes[0].smoothpos; } //okay for (int i=0; i<(int)vertex_count; i++) { Locator_t *loc=&locs[i]; Matrix3 mat; mat.SetColumn(0, nodes[loc->nx].smoothpos-nodes[loc->ref].smoothpos); mat.SetColumn(1, nodes[loc->ny].smoothpos-nodes[loc->ref].smoothpos); // mat.SetColumn(2, nodes[loc->nz].smoothpos-nodes[loc->ref].smoothpos); Vector3 vz=(nodes[loc->nx].smoothpos-nodes[loc->ref].smoothpos).crossProduct(nodes[loc->ny].smoothpos-nodes[loc->ref].smoothpos); vz.normalise(); mat.SetColumn(2, vz); dstpos[i]=mat*loc->coords+nodes[loc->ref].smoothpos-center; dstnormals[i]=mat*srcnormals[i]; dstnormals[i].normalise(); //painfull but necessary! } Vector3 *ppt=dstpos; Vector3 *npt=dstnormals; if (hasshared) { sharedpbuf->writeData(0, sharedcount*sizeof(Vector3), ppt, true); ppt+=sharedcount; sharednbuf->writeData(0, sharedcount*sizeof(Vector3), npt, true); npt+=sharedcount; } for (int i=0; i<numsubmeshbuf; i++) { subpbufs[i]->writeData(0, subnodecounts[i]*sizeof(Vector3), ppt, true); ppt+=subnodecounts[i]; subnbufs[i]->writeData(0, subnodecounts[i]*sizeof(Vector3), npt, true); npt+=subnodecounts[i]; } if (haveshadows) { EdgeData * ed=msh->getEdgeList(); //ed->updateFaceNormals(0, pbuf); //wtf? } snode->setPosition(center); return center; }