// Shave and a Haircut // (c) 2019 Epic Games // US Patent 6720962 /*change*/ #include /* initializing the array with a NONZERO seed */ static BASEHAIR interpMT( BASEHAIR aa, BASEHAIR bb, float u,GLOBS *gs ); BASEHAIR MTgen_hairRS( int id, int slg, GLOBS * gs ) { BASEHAIR ret; float a = 0.0f, b = 0.0f, c = 0.0f; float s = 0.0f, t = 0.0f; int x = 0; int pid = 0; int breakit = 1; /* map (s,t) to a point in that sub-triangle */ int va = 0, vb = 0, vc = 0; BASEHAIR *vha, *vhb, *vhc; float uu = 0.0f, vvv = 0.0f; if( id >= gs->rs.total_slgfaces[slg] - 1 ) id = gs->rs.total_slgfaces[slg] - 1; pid = id; init_a_hair( &ret ); if( slg != 4 ) { int tva, tvb, tvc; va = gs->rs.facelist[gs->rs.face_start[id]]; vb = gs->rs.facelist[gs->rs.face_start[id] + 1]; vc = gs->rs.facelist[gs->rs.face_start[id] + 2]; vha = &gs->rs.hair[va]; vhb = &gs->rs.hair[vb]; vhc = &gs->rs.hair[vc]; breakit = 1; if( ( vha->splitgroup == vhb->splitgroup ) && ( vhb->splitgroup == vhc->splitgroup ) ) breakit = 0; if( vha->splitmerge + vhb->splitmerge + vhc->splitmerge > 0 ) breakit = 0; if( breakit == 0 ) { int qq; MTmix100(gs); uu = ( float ) MTdrand98( gs ); // for (qq=0;qq<(int)(drand98()*(float)100);qq++) // uu=(float)drand98(); MTmix100(gs); vvv = ( float ) MTdrand98( gs ); // for (qq=0;qq<(int)(drand98()*(float)100);qq++) // vvv=(float)drand98(); s = uu; t = vvv; /// we want a smooth interpolation // t = sqrt(t); // a = (float) 1 - t; // b = ((float) 1 - s) * t; // c = s * t; if( s + t > 1 ) { s = 1 - s; t = 1 - t; } vvv = t; a = s; b = t; c = ( 1 - s - t ); if( gs->rs.Gdontinterp == 1 ) { a = .333333333f; b = .333333333f; c = .333333333f; } //ret= memcpy( &ret, vha, sizeof( BASEHAIR ) ); // grab the basic characteristics from the first vert; // interp slider //#ifdef SLOW for( x = 0; x < 60; x++ ) { ret.slider[x] = a * vha->slider[x] + b * vhb->slider[x] + c * vhc->slider[x]; } ret.restlength = a * vha->restlength + b * vhb->restlength + c * vhc->restlength; //#endif // interp verts for( x = 0; x < 15; x++ ) { VERT *hva, *hvb, *hvc; hva = &vha->hv[x]; hvb = &vhb->hv[x]; hvc = &vhc->hv[x]; ret.hv[x].x = a * hva->x + b * hvb->x + c * hvc->x; ret.hv[x].y = a * hva->y + b * hvb->y + c * hvc->y; ret.hv[x].z = a * hva->z + b * hvb->z + c * hvc->z; hva = &vha->velocity[x]; hvb = &vhb->velocity[x]; hvc = &vhc->velocity[x]; ret.velocity[x].x = a * hva->x + b * hvb->x + c * hvc->x; ret.velocity[x].y = a * hva->y + b * hvb->y + c * hvc->y; ret.velocity[x].z = a * hva->z + b * hvb->z + c * hvc->z; hva = &vha->noisev[x]; hvb = &vhb->noisev[x]; hvc = &vhc->noisev[x]; ret.noisev[x].x = a * hva->x + b * hvb->x + c * hvc->x; ret.noisev[x].y = a * hva->y + b * hvb->y + c * hvc->y; ret.noisev[x].z = a * hva->z + b * hvb->z + c * hvc->z; // ret.velocity[x].x=a*hair[va].velocity[x].x + b*hair[vb].velocity[x].x + c*hair[vc].velocity[x].x; // ret.velocity[x].y=a*hair[va].velocity[x].y + b*hair[vb].velocity[x].y + c*hair[vc].velocity[x].y; // ret.velocity[x].z=a*hair[va].velocity[x].z + b*hair[vb].velocity[x].z + c*hair[vc].velocity[x].z; } // interp norms //for (x=0; { BASEHAIR *hva,*hvb,*hvc; hva=&gs->rs.hair[va]; hvb=&gs->rs.hair[vb]; hvc=&gs->rs.hair[vc]; ret.norm.x = a * hva->norm.x + b * hvb->norm.x + c * hvc->norm.x; ret.norm.y = a * hva->norm.y + b * hvb->norm.y + c * hvc->norm.y; ret.norm.z = a * hva->norm.z + b * hvb->norm.z + c * hvc->norm.z; ret.resthandle.x = hva->resthandle.x * a + hvb->resthandle.x * b + hvc->resthandle.x * c; ret.resthandle.y = hva->resthandle.y * a + hvb->resthandle.y * b + hvc->resthandle.y * c; ret.resthandle.z = hva->resthandle.z * a + hvb->resthandle.z * b + hvc->resthandle.z * c; ret.resthandle = Vnorm( ret.resthandle ); ret.handle.x = hva->handle.x * a + hvb->handle.x * b + hvc->handle.x * c; ret.handle.y = hva->handle.y * a + hvb->handle.y * b + hvc->handle.y * c; ret.handle.z = hva->handle.z * a + hvb->handle.z * b + hvc->handle.z * c; ret.handle = Vnorm( ret.handle ); ret.norm = Vnorm( ret.norm ); // ret.norm.y = a * vn[va].y + b * vn[vb].y + c * vn[vc].y; // ret.norm.z = a * vn[va].z + b * vn[vb].z + c * vn[vc].z; // ret.norm = Vnorm( ret.norm ); } ret.cutlength = ret.slider[29]; } } if( slg != 4 ) if( breakit == 1 ) { // BASEHAIR tmpa,tmpb,tmpc; VERT basevert; int qq; float flip; MTmix100(gs); uu = ( float ) MTdrand98( gs ); MTmix100(gs); //for (qq=0;qq<(int)(drand98()*(float)100);qq++) // uu=(float)drand98(); vvv = ( float ) MTdrand98( gs ); //*drand98 //for (qq=0;qq<(int)(drand98()*(float)100);qq++) // vvv=(float)drand98();//*drand98 // while ((1.0f-vv) 1 ) { s = 1 - s; t = 1 - t; } vvv = t; a = s; b = t; c = ( 1 - s - t ); if( gs->rs.Gdontinterp == 1 ) { a = .333333333f; b = .333333333f; c = .333333333f; } ret.restlength = a * vha->restlength + b * vhb->restlength + c * vhc->restlength; { VERT *hva, *hvb, *hvc; hva = &vha->hv[0]; hvb = &vhb->hv[0]; hvc = &vhc->hv[0]; basevert.x = hva->x * a + hvb->x * b + hvc->x * c; basevert.y = hva->y * a + hvb->y * b + hvc->y * c; basevert.z = hva->z * a + hvb->z * b + hvc->z * c; } //basevert.x=hair[va].hv[0].x*a+ // hair[vb].hv[0].x*b+ // hair[vc].hv[0].x*c; //basevert.y=hair[va].hv[0].y*a+ // hair[vb].hv[0].y*b+ // hair[vc].hv[0].y*c; //basevert.z=hair[va].hv[0].z*a+ // hair[vb].hv[0].z*b+ // hair[vc].hv[0].z*c; flip = ( float ) MTdrand98( gs ); if( flip < .3 ) { memcpy( &ret, vha, sizeof( BASEHAIR ) ); } if( ( flip >= .3 ) && ( flip < .6 ) ) { memcpy( &ret, vhb, sizeof( BASEHAIR ) ); } if( ( flip >= .6 ) && ( flip <= 1.0f ) ) { memcpy( &ret, vhc, sizeof( BASEHAIR ) ); } { VERT *hva, *hvb, *hvc; for( qq = 1; qq < 15; qq++ ) { ret.hv[qq].x -= ret.hv[0].x; ret.hv[qq].y -= ret.hv[0].y; ret.hv[qq].z -= ret.hv[0].z; ret.hv[qq].x += basevert.x; ret.hv[qq].y += basevert.y; ret.hv[qq].z += basevert.z; hva = &vha->noisev[qq]; hvb = &vhb->noisev[qq]; hvc = &vhc->noisev[qq]; ret.noisev[qq].x = hva->x * a + hvb->x * b + hvc->x * c; ret.noisev[qq].y = hva->y * a + hvb->y * b + hvc->y * c; ret.noisev[qq].z = hva->z * a + hvb->z * b + hvc->z * c; } qq = 0; hva = &vha->noisev[qq]; hvb = &vhb->noisev[qq]; hvc = &vhc->noisev[qq]; ret.noisev[qq].x = hva->x * a + hvb->x * b + hvc->x * c; ret.noisev[qq].y = hva->y * a + hvb->y * b + hvc->y * c; ret.noisev[qq].z = hva->z * a + hvb->z * b + hvc->z * c; } ret.hv[0] = basevert; /// tmpa=interp (resthair[facelist[face_start[pid]+1]], // resthair[facelist[face_start[pid]+0]],(float)1.0f-vv); // tmpb=interp (resthair[facelist[face_start[pid]+1]], // resthair[facelist[face_start[pid]+2]],(float)1.0f-vv); // tmpc=interp (tmpa,tmpb,uu); // tmpc.vid=pid; // shove poly id into vert id ret.vid = pid; // ret=tmpc; } // slg!=4 if( slg == 4 ) { int qq; int pid2; pid2 = pid + 1; if( pid2 > gs->rs.total_splines - 1 ) pid2 = gs->rs.total_splines - 1; MTmix100(gs); uu = ( float ) MTdrand98( gs ); if( gs->rs.Gdontinterp == 1 ) uu = 0.0f; // for (qq=0;qq<(int)(drand98()*(float)100);qq++) // uu=(float)drand98(); ret = interpMT( gs->rs.Shair[pid], gs->rs.Shair[pid2], uu ,gs); ret.norm.x = gs->rs.Shair[pid].hv[1].x - gs->rs.Shair[pid].hv[0].x; ret.norm.y = gs->rs.Shair[pid].hv[1].y - gs->rs.Shair[pid].hv[0].y; ret.norm.z = gs->rs.Shair[pid].hv[1].z - gs->rs.Shair[pid].hv[0].z; ret.norm = Vnorm( ret.norm ); for( x = 0; x < 60; x++ ) { ret.slider[x] = ( 1.0f - uu ) * gs->rs.Sresthair[pid].slider[x] + gs->rs.Sresthair[pid2].slider[x] * ( uu ); } ret.restlength = ( 1.0f - uu ) * gs->rs.Sresthair[pid].restlength + gs->rs.Sresthair[pid2].restlength * uu; ret.vid = gs->rs.Dface_start[pid]; ret.killme = 0; } ret.pid = pid; return ( ret ); } BASEHAIR MTgen_resthairRS( int id, int slg, CURVEINFO * cinfo, GLOBS * gs ) { BASEHAIR ret; float a = 0.0f, b = 0.0f, c = 0.0f; float s = 0.0f, t = 0.0f; int tva = 0, tvb = 0, tvc = 0; int x = 0; int qq = 0; int pid = 0; int breakit = 1; /* map (s,t) to a point in that sub-triangle */ int va = 0, vb = 0, vc = 0; float uu = 1.0f, vvv = 1.0f; init_a_hair( &ret ); // cinfo.hairID = GhairID; cinfo->nodeID = gs->rs.nodeID; cinfo->groupID = slg; if( id >= gs->rs.total_slgfaces[slg] - 1 ) id = gs->rs.total_slgfaces[slg] - 1; pid = id; if( slg != 4 ) { va = gs->rs.facelist[gs->rs.face_start[id]]; vb = gs->rs.facelist[gs->rs.face_start[id] + 1]; vc = gs->rs.facelist[gs->rs.face_start[id] + 2]; cinfo->pntid[0] = gs->rs.vlink[va]; cinfo->pntid[1] = gs->rs.vlink[vb]; cinfo->pntid[2] = gs->rs.vlink[vc]; } // cinfo.hairID = GhairID; cinfo->nodeID = gs->rs.nodeID; cinfo->groupID = gs->Gslg; cinfo->shaveID = gs->rs.SHAVEID; if( slg != 4 ) { cinfo->UTpid = gs->rs.D2UTface_link[gs->rs.face_link[id]]; //face_link[id]; } else cinfo->UTpid = id; if( cinfo->UTpid >= gs->rs.DUTtotalfaces - 1 ) cinfo->UTpid = gs->rs.DUTtotalfaces - 1; if( slg != 4 ) { cinfo->Tpid = gs->rs.face_link[id]; //face_link[id]; // cinfo->pntid[0] = va; // cinfo->pntid[1] = vb; // cinfo->pntid[2] = -1; } else { int id1; id1 = id + 1; if( id1 > gs->rs.total_splines - 1 ) id1 = gs->rs.total_splines - 1; cinfo->Tpid = id; // cinfo->pntid[0] = gs->rs.Dfacelist[gs->rs.Dface_start[id]]; // cinfo->pntid[1] = gs->rs.Dfacelist[gs->rs.Dface_start[id1]]; cinfo->pntid[0] = id; cinfo->pntid[1] = id1; cinfo->pntid[2] = -1; } //cinfo->u=0; //cinfo->v=0; //cinfo->u2=0; //cinfo->v2=0; //cinfo->pid=D2UTface_link[face_link[id]];//face_link[id]; if( slg != 4 ) { BASEHAIR *vha,*vhb,*vhc; vha=&gs->rs.hair[va]; vhb=&gs->rs.hair[vb]; vhc=&gs->rs.hair[vc]; if( ( vha->splitgroup == vhb->splitgroup ) && ( vhb->splitgroup == vhc->splitgroup ) ) breakit = 0; if( vha->splitmerge + vhb->splitmerge + vhc->splitmerge > 0 ) breakit = 0; if( breakit == 0 ) { int qq; MTmix100(gs); uu = ( float ) MTdrand98( gs ); // for (qq=0;qq<(int)(drand98()*(float)100);qq++) // uu=(float)drand98(); MTmix100(gs); vvv = ( float ) MTdrand98( gs ); // for (qq=0;qq<(int)(drand98()*(float)100);qq++) // vvv=(float)drand98(); s = uu; t = vvv; /// we want a smooth interpolation // t = sqrt(t); // a = (float) 1 - t; // b = ((float) 1 - s) * t; // c = s * t; if( s + t > 1 ) { s = 1 - s; t = 1 - t; } vvv = t; a = s; b = t; c = ( 1 - s - t ); if( gs->rs.Gdontinterp == 1 ) { a = .333333333f; b = .333333333f; c = .333333333f; } ret.restlength = a * vha->restlength + b * vhb->restlength + c * vhc->restlength; { // this is the evaluation of the embedded uv sets added for softimage in 2.7v53 int lastuv_link = -2; VERT lastuv; lastuv.x = 0; lastuv.y = 0; lastuv.z = 0; for( x = 0; x < gs->rs.Guv_totalsets; x++ ) { // if( Guv_link[x] == -1 ) // { // cinfo->UV[x].x = NaN; // cinfo->UV[x].y = NaN; // cinfo->UV[x].z = NaN; // } // if( Guv_link[x] != lastuv_link ) // if( Guv_link[x] != -1 ) { VERT uu; VERT uva, uvb, uvc; // we need to resolve a uv; if( gs->rs.Guv_sets[x].totalverts ) { uva = gs->rs.Guv_sets[x].v[gs->rs.Guv_sets[x].facelist[gs->rs.Guv_sets[x].face_start[cinfo->Tpid] + 2]]; uvb = gs->rs.Guv_sets[x].v[gs->rs.Guv_sets[x].facelist[gs->rs.Guv_sets[x].face_start[cinfo->Tpid] + 1]]; uvc = gs->rs.Guv_sets[x].v[gs->rs.Guv_sets[x].facelist[gs->rs.Guv_sets[x].face_start[cinfo->Tpid] + 0]]; cinfo->UV[x].x = uva.x * a + uvb.x * b + uvc.x * c; cinfo->UV[x].y = uva.y * a + uvb.y * b + uvc.y * c; cinfo->UV[x].z = uva.z * a + uvb.z * b + uvc.z * c; } lastuv_link = x; lastuv = cinfo->UV[x]; } // if( Guv_link[x] == lastuv_link ) // if( lastuv_link != -1 ) // cinfo->UV[x] = lastuv; // didn't need to eval again } } cinfo->wgt[0] = a; cinfo->wgt[1] = b; cinfo->wgt[2] = c; memcpy( &ret, &gs->rs.hair[va], sizeof( BASEHAIR ) ); // grab the basic characteristics from the first vert; // ret=resthair[va]; // grab the basic characteristics from the first vert; // interp slider { BASEHAIR *rva, *rvb, *rvc; rva = &gs->rs.hair[va]; rvb = &gs->rs.hair[vb]; rvc = &gs->rs.hair[vc]; for( x = 0; x < 60; x++ ) { ret.slider[x] = a * rva->slider[x] + b * rvb->slider[x] + c * rvc->slider[x]; } for( x = 0; x < 15; x++ ) { ret.uu = a * rva->uu + b * rvb->uu + c * rvc->uu; ret.vv = a * rva->vv + b * rvb->vv + c * rvc->vv; } } // interp verts ret.resthandle.x = vha->resthandle.x * a + vhb->resthandle.x * b + vhc->resthandle.x * c; ret.resthandle.y = vha->resthandle.y * a + vhb->resthandle.y * b + vhc->resthandle.y * c; ret.resthandle.z = vha->resthandle.z * a + vhb->resthandle.z * b + vhc->resthandle.z * c; ret.resthandle = Vnorm( ret.resthandle ); ret.handle.x = vha->handle.x * a + vhb->handle.x * b + vhc->handle.x * c; ret.handle.y = vha->handle.y * a + vhb->handle.y * b + vhc->handle.y * c; ret.handle.z = vha->handle.z * a + vhb->handle.z * b + vhc->handle.z * c; ret.handle = Vnorm( ret.handle ); for( x = 0; x < 15; x++ ) { VERT *hva, *hvb, *hvc; hva = &vha->noisev[x]; hvb = &vhb->noisev[x]; hvc = &vhc->noisev[x]; ret.hv[x].x = a * hva->x + b * hvb->x + c * hvc->x; ret.hv[x].y = a * hva->y + b * hvb->y + c * hvc->y; ret.hv[x].z = a * hva->z + b * hvb->z + c * hvc->z; hva = &vha->velocity[x]; hvb = &vhb->velocity[x]; hvc = &vhc->velocity[x]; ret.velocity[x].x = a * hva->x + b * hvb->x + c * hvc->x; ret.velocity[x].y = a * hva->y + b * hvb->y + c * hvc->y; ret.velocity[x].z = a * hva->z + b * hvb->z + c * hvc->z; hva = &vha->noisev[x]; hvb = &vhb->noisev[x]; hvc = &vhc->noisev[x]; ret.noisev[x].x = a * hva->x + b * hvb->x + c * hvc->x; ret.noisev[x].y = a * hva->y + b * hvb->y + c * hvc->y; ret.noisev[x].z = a * hva->z + b * hvb->z + c * hvc->z; // ret.hv[x].x=a*resthair[va].hv[x].x + b*resthair[vb].hv[x].x + c*resthair[vc].hv[x].x; // ret.hv[x].y=a*resthair[va].hv[x].y + b*resthair[vb].hv[x].y + c*resthair[vc].hv[x].y; // ret.hv[x].z=a*resthair[va].hv[x].z + b*resthair[vb].hv[x].z + c*resthair[vc].hv[x].z; // ret.velocity[x].x=a*resthair[va].velocity[x].x + b*resthair[vb].velocity[x].x + c*resthair[vc].velocity[x].x; // ret.velocity[x].y=a*resthair[va].velocity[x].y + b*resthair[vb].velocity[x].y + c*resthair[vc].velocity[x].y; // ret.velocity[x].z=a*resthair[va].velocity[x].z + b*resthair[vb].velocity[x].z + c*resthair[vc].velocity[x].z; } // interp norms // for (x=0;x<15;x++) { // ret.norm.x=a*resthair[va].norm.x + b*resthair[vb].norm.x + c*resthair[vc].norm.x; // ret.norm.y=a*resthair[va].norm.y + b*resthair[vb].norm.y + c*resthair[vc].norm.y; // ret.norm.z=a*resthair[va].norm.z + b*resthair[vb].norm.z + c*resthair[vc].norm.z; ret.norm.x = a * gs->rs.vn[va].x + b * gs->rs.vn[vb].x + c * gs->rs.vn[vc].x; ret.norm.y = a * gs->rs.vn[va].y + b * gs->rs.vn[vb].y + c * gs->rs.vn[vc].y; ret.norm.z = a * gs->rs.vn[va].z + b * gs->rs.vn[vb].z + c * gs->rs.vn[vc].z; ret.norm = Vnorm( ret.norm ); ret.resthandle.x = vha->resthandle.x * a + vhb->resthandle.x * b + vhc->resthandle.x * c; ret.resthandle.y = vha->resthandle.y * a + vhb->resthandle.y * b + vhc->resthandle.y * c; ret.resthandle.z = vha->resthandle.z * a + vhb->resthandle.z * b + vhc->resthandle.z * c; ret.resthandle = Vnorm( ret.resthandle ); ret.handle.x = vha->handle.x * a + vhb->handle.x * b + vhc->handle.x * c; ret.handle.y = vha->handle.y * a + vhb->handle.y * b + vhc->handle.y * c; ret.handle.z = vha->handle.z * a + vhb->handle.z * b + vhc->handle.z * c; ret.handle = Vnorm( ret.handle ); } ret.cutlength = ret.slider[29]; } } if( slg != 4 ) if( breakit == 1 ) { // BASEHAIR tmpa,tmpb,tmpc; VERT basevert; int qq; float flip; BASEHAIR *vha,*vhb,*vhc; vha=&gs->rs.hair[va]; vhb=&gs->rs.hair[vb]; vhc=&gs->rs.hair[vc]; // uu=(float)drand98(); //for (qq=0;qq<(int)(drand98()*(float)100);qq++) MTmix100(gs); uu = ( float ) MTdrand98( gs ); MTmix100(gs); vvv = ( float ) MTdrand98( gs ); //*drand98 //for (qq=0;qq<(int)(drand98()*(float)100);qq++) // vvv=(float)drand98();//*drand98 // while ((1.0f-vv) 1 ) { s = 1 - s; t = 1 - t; } vvv = t; a = s; b = t; c = ( 1 - s - t ); if( gs->rs.Gdontinterp == 1 ) { a = .333333333f; b = .333333333f; c = .333333333f; } ret.restlength = a * vha->restlength + b * vhb->restlength + c * vhc->restlength; { // this is the evaluation of the embedded uv sets added for softimage in 2.7v53 int lastuv_link = -2; VERT lastuv; lastuv.x = 0; lastuv.y = 0; lastuv.z = 0; for( x = 0; x < gs->rs.Guv_totalsets; x++ ) { // if( Guv_link[x] == -1 ) // { // cinfo->UV[x].x = NaN; // cinfo->UV[x].y = NaN; // cinfo->UV[x].z = NaN; // } // if( Guv_link[x] != lastuv_link ) // if( Guv_link[x] != -1 ) { VERT uu; VERT uva, uvb, uvc; // we need to resolve a uv; if( gs->rs.Guv_sets[x].totalverts ) { uva = gs->rs.Guv_sets[x].v[gs->rs.Guv_sets[x].facelist[gs->rs.Guv_sets[x].face_start[cinfo->Tpid]]]; uvb = gs->rs.Guv_sets[x].v[gs->rs.Guv_sets[x].facelist[gs->rs.Guv_sets[x].face_start[cinfo->Tpid] + 1]]; uvc = gs->rs.Guv_sets[x].v[gs->rs.Guv_sets[x].facelist[gs->rs.Guv_sets[x].face_start[cinfo->Tpid] + 2]]; } cinfo->UV[x].x = uva.x * a + uvb.x * b + uvc.x * c; cinfo->UV[x].y = uva.y * a + uvb.y * b + uvc.y * c; cinfo->UV[x].z = uva.z * a + uvb.z * b + uvc.z * c; lastuv_link = x; lastuv = cinfo->UV[x]; } // if( Guv_link[x] == lastuv_link ) // if( lastuv_link != -1 ) // cinfo->UV[x] = lastuv; // didn't need to eval again } } { // this is the evaluation of the embedded uv sets added for softimage in 2.7v53 int lastuv_link = -1; VERT lastuv; lastuv.x = 0; lastuv.y = 0; lastuv.z = 0; for( x = 0; x < gs->rs.Guv_totalsets; x++ ) { // if( Guv_link[x] == -1 ) // { // cinfo->UV[x].x = NaN; // cinfo->UV[x].y = NaN; // cinfo->UV[x].z = NaN; // } // if( Guv_link[x] != lastuv_link ) // if( Guv_link[x] != -1 ) { VERT uu; VERT uva, uvb, uvc; VERT zr; zr.x = 0; zr.y = 0; zr.z = 0; uva = zr; uvb = zr; uvc = zr; uu = zr; // we need to resolve a uv; if( gs->rs.Guv_sets[x].totalverts ) { uva = gs->rs.Guv_sets[x].v[gs->rs.Guv_sets[x].facelist[gs->rs.Guv_sets[x].face_start[cinfo->Tpid]]]; uvb = gs->rs.Guv_sets[x].v[gs->rs.Guv_sets[x].facelist[gs->rs.Guv_sets[x].face_start[cinfo->Tpid] + 1]]; uvc = gs->rs.Guv_sets[x].v[gs->rs.Guv_sets[x].facelist[gs->rs.Guv_sets[x].face_start[cinfo->Tpid] + 2]]; } cinfo->UV[x].x = uva.x * a + uvb.x * b + uvc.x * c; cinfo->UV[x].y = uva.y * a + uvb.y * b + uvc.y * c; cinfo->UV[x].z = uva.z * a + uvb.z * b + uvc.z * c; lastuv_link = x; lastuv = cinfo->UV[x]; } // if( Guv_link[x] == lastuv_link ) // if( lastuv_link != -1 ) // cinfo->UV[x] = lastuv; // didn't need to eval again } } // t = sqrt(t); // a = (float) 1 - t; // b = ((float) 1 - s) * t; // c = s * t; cinfo->wgt[0] = a; cinfo->wgt[1] = b; cinfo->wgt[2] = c; { VERT *hva, *hvb, *hvc; hva = &vha->resthv[0]; hvb = &vhb->resthv[0]; hvc = &vhc->resthv[0]; basevert.x = hva->x * a + hvb->x * b + hvc->x * c; basevert.y = hva->y * a + hvb->y * b + hvc->y * c; basevert.z = hva->z * a + hvb->z * b + hvc->z * c; } flip = ( float ) MTdrand98( gs ); if( flip < .3 ) { memcpy( &ret, &gs->rs.hair[va], sizeof( BASEHAIR ) ); } if( ( flip >= .3 ) && ( flip < .6 ) ) { memcpy( &ret, &gs->rs.hair[vb], sizeof( BASEHAIR ) ); } if( ( flip >= .6 ) && ( flip <= 1.0f ) ) { memcpy( &ret, &gs->rs.hair[vc], sizeof( BASEHAIR ) ); } for( qq = 1; qq < 15; qq++ ) { ret.hv[qq].x -= ret.hv[0].x; ret.hv[qq].y -= ret.hv[0].y; ret.hv[qq].z -= ret.hv[0].z; ret.hv[qq].x += basevert.x; ret.hv[qq].y += basevert.y; ret.hv[qq].z += basevert.z; } ret.hv[0] = basevert; /// tmpa=interp (resthair[facelist[face_start[pid]+1]], // resthair[facelist[face_start[pid]+0]],(float)1.0f-vv); // tmpb=interp (resthair[facelist[face_start[pid]+1]], // resthair[facelist[face_start[pid]+2]],(float)1.0f-vv); // tmpc=interp (tmpa,tmpb,uu); // tmpc.vid=pid; // shove poly id into vert id ret.vid = pid; // ret=tmpc; } // slg!=4 if( slg == 4 ) { int qq; int pid2; pid2 = pid + 1; if( pid2 > gs->rs.total_splines - 1 ) pid2 = gs->rs.total_splines - 1; MTmix100(gs); uu = ( float ) MTdrand98( gs ); if( gs->rs.Gdontinterp == 1 ) uu = 0.0f; // for (qq=0;qq<(int)(drand98()*(float)100);qq++) // uu=(float)drand98(); ret = interpMT( gs->rs.Sresthair[pid], gs->rs.Sresthair[pid2], uu,gs ); ret.vid = gs->rs.Dfacelist[gs->rs.Dface_start[pid]]; ret.pid = pid; ret.uu = ( uu + pid ) / ( float ) ( gs->rs.total_slgfaces[4] - 1 ); ret.vv = 0; cinfo->wgt[0] = 1.0f - ret.uu; cinfo->wgt[1] = uu; cinfo->wgt[2] = -1; ret.restlength = ( 1.0f - uu ) * gs->rs.Sresthair[pid].restlength + gs->rs.Sresthair[pid2].restlength * uu; for( x = 0; x < 60; x++ ) { VERT u1; u1.x = ( uu + pid ) / ( float ) ( gs->rs.total_slgfaces[4] - 1 ); u1.y = 0; u1.z = 0; cinfo->UV[x] = u1; ret.slider[x] = ( 1.0f - uu ) * gs->rs.Sresthair[pid].slider[x] + gs->rs.Sresthair[pid2].slider[x] * ( uu ); } } ret.pid = pid; cinfo->killme = 0; ret.killme = 0; //cinfo->u=ret.uu; //cinfo->v=ret.vv; return ( ret ); } BASEHAIR MTgen_hair_ROOTRS( int id, int slg, GLOBS * gs ) { BASEHAIR ret; float a = 0.0f, b = 0.0f, c = 0.0f; float s = 0.0f, t = 0.0f; int x = 0; int pid = 0; int breakit = 1; /* map (s,t) to a point in that sub-triangle */ int va = 0, vb = 0, vc = 0; BASEHAIR *vha, *vhb, *vhc; float uu = 0.0f, vvv = 0.0f; if( id >= gs->rs.total_slgfaces[slg] - 1 ) id = gs->rs.total_slgfaces[slg] - 1; pid = id; init_a_hair( &ret ); if( slg != 4 ) { int tva, tvb, tvc; va = gs->rs.facelist[gs->rs.face_start[id]]; vb = gs->rs.facelist[gs->rs.face_start[id] + 1]; vc = gs->rs.facelist[gs->rs.face_start[id] + 2]; vha = &gs->rs.hair[va]; vhb = &gs->rs.hair[vb]; vhc = &gs->rs.hair[vc]; breakit = 1; if( ( vha->splitgroup == vhb->splitgroup ) && ( vhb->splitgroup == vhc->splitgroup ) ) breakit = 0; if( vha->splitmerge + vhb->splitmerge + vhc->splitmerge > 0 ) breakit = 0; if( breakit == 0 ) { int qq; MTmix100(gs); uu = ( float ) MTdrand98( gs ); // for (qq=0;qq<(int)(drand98()*(float)100);qq++) // uu=(float)drand98(); MTmix100(gs); vvv = ( float ) MTdrand98( gs ); // for (qq=0;qq<(int)(drand98()*(float)100);qq++) // vvv=(float)drand98(); s = uu; t = vvv; /// we want a smooth interpolation // t = sqrt(t); // a = (float) 1 - t; // b = ((float) 1 - s) * t; // c = s * t; if( s + t > 1 ) { s = 1 - s; t = 1 - t; } vvv = t; a = s; b = t; c = ( 1 - s - t ); if( gs->rs.Gdontinterp == 1 ) { a = .333333333f; b = .333333333f; c = .333333333f; } //ret= memcpy( &ret, &gs->rs.hair[va], sizeof( BASEHAIR ) ); // grab the basic characteristics from the first vert; // interp slider //#ifdef SLOW for( x = 0; x < 60; x++ ) { ret.slider[x] = a * vha->slider[x] + b * vhb->slider[x] + c * vhc->slider[x]; } ret.restlength = a * vha->restlength + b * vhb->restlength + c * vhc->restlength; //#endif // interp verts for( x = 0; x < 1; x++ ) { VERT *hva, *hvb, *hvc; hva = &vha->hv[x]; hvb = &vhb->hv[x]; hvc = &vhc->hv[x]; ret.hv[x].x = a * hva->x + b * hvb->x + c * hvc->x; ret.hv[x].y = a * hva->y + b * hvb->y + c * hvc->y; ret.hv[x].z = a * hva->z + b * hvb->z + c * hvc->z; hva = &vha->velocity[x]; hvb = &vha->velocity[x]; hvc = &vha->velocity[x]; ret.velocity[x].x = a * hva->x + b * hvb->x + c * hvc->x; ret.velocity[x].y = a * hva->y + b * hvb->y + c * hvc->y; ret.velocity[x].z = a * hva->z + b * hvb->z + c * hvc->z; hva = &vha->noisev[x]; hvb = &vhb->noisev[x]; hvc = &vhc->noisev[x]; ret.noisev[x].x = a * hva->x + b * hvb->x + c * hvc->x; ret.noisev[x].y = a * hva->y + b * hvb->y + c * hvc->y; ret.noisev[x].z = a * hva->z + b * hvb->z + c * hvc->z; // ret.velocity[x].x=a*hair[va].velocity[x].x + b*hair[vb].velocity[x].x + c*hair[vc].velocity[x].x; // ret.velocity[x].y=a*hair[va].velocity[x].y + b*hair[vb].velocity[x].y + c*hair[vc].velocity[x].y; // ret.velocity[x].z=a*hair[va].velocity[x].z + b*hair[vb].velocity[x].z + c*hair[vc].velocity[x].z; } // interp norms //for (x=0;x<15;x++) { BASEHAIR *hva,*hvb,*hvc; hva=vha;hvb=vhb;hvc=vhc; ret.norm.x = a * hva->norm.x + b * hvb->norm.x + c * hvc->norm.x; ret.norm.y = a * hva->norm.y + b * hvb->norm.y + c * hvc->norm.y; ret.norm.z = a * hva->norm.z + b * hvb->norm.z + c * hvc->norm.z; ret.resthandle.x = hva->resthandle.x * a + hvb->resthandle.x * b + hvc->resthandle.x * c; ret.resthandle.y = hva->resthandle.y * a + hvb->resthandle.y * b + hvc->resthandle.y * c; ret.resthandle.z = hva->resthandle.z * a + hvb->resthandle.z * b + hvc->resthandle.z * c; ret.resthandle = Vnorm( ret.resthandle ); ret.handle.x = hva->handle.x * a + hvb->handle.x * b + hvc->handle.x * c; ret.handle.y = hva->handle.y * a + hvb->handle.y * b + hvc->handle.y * c; ret.handle.z = hva->handle.z * a + hvb->handle.z * b + hvc->handle.z * c; ret.handle = Vnorm( ret.handle ); ret.norm = Vnorm( ret.norm ); // ret.norm.y = a * vn[va].y + b * vn[vb].y + c * vn[vc].y; // ret.norm.z = a * vn[va].z + b * vn[vb].z + c * vn[vc].z; ret.norm = Vnorm( ret.norm ); } ret.cutlength = ret.slider[29]; } } if( slg != 4 ) if( breakit == 1 ) { // BASEHAIR tmpa,tmpb,tmpc; VERT basevert; int qq; float flip; MTmix100(gs); uu = ( float ) MTdrand98( gs ); MTmix100(gs); //for (qq=0;qq<(int)(drand98()*(float)100);qq++) // uu=(float)drand98(); vvv = ( float ) MTdrand98( gs ); //*drand98 //for (qq=0;qq<(int)(drand98()*(float)100);qq++) // vvv=(float)drand98();//*drand98 // while ((1.0f-vv) 1 ) { s = 1 - s; t = 1 - t; } vvv = t; a = s; b = t; c = ( 1 - s - t ); if( gs->rs.Gdontinterp == 1 ) { a = .333333333f; b = .333333333f; c = .333333333f; } ret.restlength = a * vha->restlength + b * vhb->restlength + c * vhc->restlength; { VERT *hva, *hvb, *hvc; hva=&vha->hv[0]; hvb=&vhb->hv[0]; hvc=&vhc->hv[0]; basevert.x = hva->x * a + hvb->x * b + hvc->x * c; basevert.y = hva->y * a + hvb->y * b + hvc->y * c; basevert.z = hva->z * a + hvb->z * b + hvc->z * c; } //basevert.x=hair[va].hv[0].x*a+ // hair[vb].hv[0].x*b+ // hair[vc].hv[0].x*c; //basevert.y=hair[va].hv[0].y*a+ // hair[vb].hv[0].y*b+ // hair[vc].hv[0].y*c; //basevert.z=hair[va].hv[0].z*a+ // hair[vb].hv[0].z*b+ // hair[vc].hv[0].z*c; flip = ( float ) MTdrand98( gs ); if( flip < .3 ) { memcpy( &ret, vha, sizeof( BASEHAIR ) ); } if( ( flip >= .3 ) && ( flip < .6 ) ) { memcpy( &ret, vhb, sizeof( BASEHAIR ) ); } if( ( flip >= .6 ) && ( flip <= 1.0f ) ) { memcpy( &ret, vhc, sizeof( BASEHAIR ) ); } { VERT *hva, *hvb, *hvc; for( qq = 1; qq < 1; qq++ ) { ret.hv[qq].x -= ret.hv[0].x; ret.hv[qq].y -= ret.hv[0].y; ret.hv[qq].z -= ret.hv[0].z; ret.hv[qq].x += basevert.x; ret.hv[qq].y += basevert.y; ret.hv[qq].z += basevert.z; hva = &vha->noisev[qq]; hvb = &vhb->noisev[qq]; hvc = &vhc->noisev[qq]; ret.noisev[qq].x = hva->x * a + hvb->x * b + hvc->x * c; ret.noisev[qq].y = hva->y * a + hvb->y * b + hvc->y * c; ret.noisev[qq].z = hva->z * a + hvb->z * b + hvc->z * c; } qq = 0; hva = &vha->noisev[qq]; hvb = &vhb->noisev[qq]; hvc = &vhc->noisev[qq]; ret.noisev[qq].x = hva->x * a + hvb->x * b + hvc->x * c; ret.noisev[qq].y = hva->y * a + hvb->y * b + hvc->y * c; ret.noisev[qq].z = hva->z * a + hvb->z * b + hvc->z * c; } ret.hv[0] = basevert; /// tmpa=interp (resthair[facelist[face_start[pid]+1]], // resthair[facelist[face_start[pid]+0]],(float)1.0f-vv); // tmpb=interp (resthair[facelist[face_start[pid]+1]], // resthair[facelist[face_start[pid]+2]],(float)1.0f-vv); // tmpc=interp (tmpa,tmpb,uu); // tmpc.vid=pid; // shove poly id into vert id ret.vid = pid; // ret=tmpc; } // slg!=4 if( slg == 4 ) { int qq; int pid2; pid2 = pid + 1; if( pid2 > gs->rs.total_splines - 1 ) pid2 = gs->rs.total_splines - 1; MTmix100(gs); uu = ( float ) MTdrand98( gs ); if( gs->rs.Gdontinterp == 1 ) uu = 0.0f; // for (qq=0;qq<(int)(drand98()*(float)100);qq++) // uu=(float)drand98(); ret = interpMT( gs->rs.Shair[pid], gs->rs.Shair[pid2], uu ,gs); ret.norm.x = gs->rs.Shair[pid].hv[1].x - gs->rs.Shair[pid].hv[0].x; ret.norm.y = gs->rs.Shair[pid].hv[1].y - gs->rs.Shair[pid].hv[0].y; ret.norm.z = gs->rs.Shair[pid].hv[1].z - gs->rs.Shair[pid].hv[0].z; ret.norm = Vnorm( ret.norm ); for( x = 0; x < 60; x++ ) { ret.slider[x] = ( 1.0f - uu ) * gs->rs.Sresthair[pid].slider[x] + gs->rs.Sresthair[pid2].slider[x] * ( uu ); } ret.restlength = ( 1.0f - uu ) * gs->rs.Sresthair[pid].restlength + gs->rs.Sresthair[pid2].restlength * uu; ret.vid = gs->rs.Dface_start[pid]; ret.killme = 0; } ret.pid = pid; return ( ret ); } BASEHAIR MTgen_resthair_ROOTRS( int id, int slg, CURVEINFO * cinfo, GLOBS * gs ) { BASEHAIR ret; float a = 0.0f, b = 0.0f, c = 0.0f; float s = 0.0f, t = 0.0f; int tva = 0, tvb = 0, tvc = 0; int x = 0; int qq = 0; int pid = 0; int breakit = 1; /* map (s,t) to a point in that sub-triangle */ int va = 0, vb = 0, vc = 0; float uu = 1.0f, vvv = 1.0f; init_a_hair( &ret ); // cinfo.hairID = GhairID; cinfo->nodeID = gs->rs.nodeID; cinfo->groupID = gs->Gslg; if( id >= gs->rs.total_slgfaces[slg] - 1 ) id = gs->rs.total_slgfaces[slg] - 1; pid = id; if( slg != 4 ) { va = gs->rs.facelist[gs->rs.face_start[id]]; vb = gs->rs.facelist[gs->rs.face_start[id] + 1]; vc = gs->rs.facelist[gs->rs.face_start[id] + 2]; cinfo->Tpid = gs->rs.face_link[id]; //face_link[id]; cinfo->pntid[0] = gs->rs.vlink[va]; cinfo->pntid[1] = gs->rs.vlink[vb]; cinfo->pntid[2] = gs->rs.vlink[vc]; cinfo->UTpid = gs->rs.D2UTface_link[gs->rs.face_link[id]]; //face_link[id]; } // cinfo.hairID = GhairID; cinfo->nodeID = gs->rs.nodeID; cinfo->groupID = gs->Gslg; if( cinfo->UTpid >= gs->rs.DUTtotalfaces - 1 ) cinfo->UTpid = gs->rs.DUTtotalfaces - 1; if (slg==4) { int id1; cinfo->UTpid = id; id1 = id + 1; if( id1 > gs->rs.total_splines - 1 ) id1 = gs->rs.total_splines - 1; cinfo->Tpid = id; cinfo->pntid[0] = id; cinfo->pntid[1] = id1; // cinfo->pntid[0] = gs->rs.Dfacelist[gs->rs.Dface_start[id]]; // cinfo->pntid[1] = gs->rs.Dfacelist[gs->rs.Dface_start[id1]]; cinfo->pntid[2] = -1; } //cinfo->u=0; //cinfo->v=0; //cinfo->u2=0; //cinfo->v2=0; //cinfo->pid=D2UTface_link[face_link[id]];//face_link[id]; if( slg != 4 ) { BASEHAIR *vha,*vhb,*vhc; vha= &gs->rs.hair[va]; vhb= &gs->rs.hair[vb]; vhc= &gs->rs.hair[vc]; // cinfo->pntid[2] = vc; if( ( vha->splitgroup == vhb->splitgroup ) && ( vhb->splitgroup == vhc->splitgroup ) ) breakit = 0; if( vha->splitmerge + vhb->splitmerge + vhc->splitmerge > 0 ) breakit = 0; if( breakit == 0 ) { int qq; MTmix100(gs); uu = ( float ) MTdrand98( gs ); // for (qq=0;qq<(int)(drand98()*(float)100);qq++) // uu=(float)drand98(); MTmix100(gs); vvv = ( float ) MTdrand98( gs ); // for (qq=0;qq<(int)(drand98()*(float)100);qq++) // vvv=(float)drand98(); s = uu; t = vvv; /// we want a smooth interpolation // t = sqrt(t); // a = (float) 1 - t; // b = ((float) 1 - s) * t; // c = s * t; if( s + t > 1 ) { s = 1 - s; t = 1 - t; } vvv = t; a = s; b = t; c = ( 1 - s - t ); if( gs->rs.Gdontinterp == 1 ) { a = .333333333f; b = .333333333f; c = .333333333f; } ret.restlength = a * vha->restlength + b * vhb->restlength + c * vhc->restlength; { // this is the evaluation of the embedded uv sets added for softimage in 2.7v53 int lastuv_link = -2; VERT lastuv; lastuv.x = 0; lastuv.y = 0; lastuv.z = 0; for( x = 0; x < gs->rs.Guv_totalsets; x++ ) { // if( Guv_link[x] == -1 ) // { // cinfo->UV[x].x = NaN; // cinfo->UV[x].y = NaN; // cinfo->UV[x].z = NaN; // } // if( Guv_link[x] != lastuv_link ) // if( Guv_link[x] != -1 ) { VERT uu; VERT uva, uvb, uvc; uva.x=0.0f;uva.y=0.0f;uva.z=0.0f; uvb=uva; uvc=uva; // we need to resolve a uv; if( gs->rs.Guv_sets[x].totalverts ) { uva = gs->rs.Guv_sets[x].v[gs->rs.Guv_sets[x].facelist[gs->rs.Guv_sets[x].face_start[cinfo->Tpid] + 2]]; uvb = gs->rs.Guv_sets[x].v[gs->rs.Guv_sets[x].facelist[gs->rs.Guv_sets[x].face_start[cinfo->Tpid] + 1]]; uvc = gs->rs.Guv_sets[x].v[gs->rs.Guv_sets[x].facelist[gs->rs.Guv_sets[x].face_start[cinfo->Tpid] + 0]]; } cinfo->UV[x].x = uva.x * a + uvb.x * b + uvc.x * c; cinfo->UV[x].y = uva.y * a + uvb.y * b + uvc.y * c; cinfo->UV[x].z = uva.z * a + uvb.z * b + uvc.z * c; lastuv_link = x; lastuv = cinfo->UV[x]; } // if( Guv_link[x] == lastuv_link ) // if( lastuv_link != -1 ) // cinfo->UV[x] = lastuv; // didn't need to eval again } } cinfo->wgt[0] = a; cinfo->wgt[1] = b; cinfo->wgt[2] = c; memcpy( &ret, &gs->rs.hair[va], sizeof( BASEHAIR ) ); // grab the basic characteristics from the first vert; // ret=resthair[va]; // grab the basic characteristics from the first vert; // interp slider { BASEHAIR *rva, *rvb, *rvc; rva = &gs->rs.hair[va]; rvb = &gs->rs.hair[vb]; rvc = &gs->rs.hair[vc]; for( x = 0; x < 60; x++ ) { ret.slider[x] = a * rva->slider[x] + b * rvb->slider[x] + c * rvc->slider[x]; } for( x = 0; x < 1; x++ ) { ret.uu = a * rva->uu + b * rvb->uu + c * rvc->uu; ret.vv = a * rva->vv + b * rvb->vv + c * rvc->vv; } } // interp verts { BASEHAIR *hva,*hvb,*hvc; hva=&gs->rs.hair[va]; hvb=&gs->rs.hair[vb]; hvc=&gs->rs.hair[vc]; ret.resthandle.x = hva->resthandle.x * a + hvb->resthandle.x * b + hvc->resthandle.x * c; ret.resthandle.y = hva->resthandle.y * a + hvb->resthandle.y * b + hvc->resthandle.y * c; ret.resthandle.z = hva->resthandle.z * a + hvb->resthandle.z * b + hvc->resthandle.z * c; ret.resthandle = Vnorm( ret.resthandle ); ret.handle.x = hva->handle.x * a + hvb->handle.x * b + hvc->handle.x * c; ret.handle.y = hva->handle.y * a + hvb->handle.y * b + hvc->handle.y * c; ret.handle.z = hva->handle.z * a + hvb->handle.z * b + hvc->handle.z * c; ret.handle = Vnorm( ret.handle ); } { for( x = 0; x < 1; x++ ) { VERT *hva, *hvb, *hvc; hva = &vha->noisev[x]; hvb = &vhb->noisev[x]; hvc = &vhc->noisev[x]; ret.hv[x].x = a * hva->x + b * hvb->x + c * hvc->x; ret.hv[x].y = a * hva->y + b * hvb->y + c * hvc->y; ret.hv[x].z = a * hva->z + b * hvb->z + c * hvc->z; hva = &vha->velocity[x]; hvb = &vhb->velocity[x]; hvc = &vhc->velocity[x]; ret.velocity[x].x = a * hva->x + b * hvb->x + c * hvc->x; ret.velocity[x].y = a * hva->y + b * hvb->y + c * hvc->y; ret.velocity[x].z = a * hva->z + b * hvb->z + c * hvc->z; hva = &vha->noisev[x]; hvb = &vhb->noisev[x]; hvc = &vhc->noisev[x]; ret.noisev[x].x = a * hva->x + b * hvb->x + c * hvc->x; ret.noisev[x].y = a * hva->y + b * hvb->y + c * hvc->y; ret.noisev[x].z = a * hva->z + b * hvb->z + c * hvc->z; // ret.hv[x].x=a*resthair[va].hv[x].x + b*resthair[vb].hv[x].x + c*resthair[vc].hv[x].x; // ret.hv[x].y=a*resthair[va].hv[x].y + b*resthair[vb].hv[x].y + c*resthair[vc].hv[x].y; // ret.hv[x].z=a*resthair[va].hv[x].z + b*resthair[vb].hv[x].z + c*resthair[vc].hv[x].z; // ret.velocity[x].x=a*resthair[va].velocity[x].x + b*resthair[vb].velocity[x].x + c*resthair[vc].velocity[x].x; // ret.velocity[x].y=a*resthair[va].velocity[x].y + b*resthair[vb].velocity[x].y + c*resthair[vc].velocity[x].y; // ret.velocity[x].z=a*resthair[va].velocity[x].z + b*resthair[vb].velocity[x].z + c*resthair[vc].velocity[x].z; } // interp norms // for (x=0;x<15;x++) { BASEHAIR *hva,*hvb,*hvc; hva=&gs->rs.hair[va]; hvb=&gs->rs.hair[vb]; hvc=&gs->rs.hair[vc]; // ret.norm.x=a*resthair[va].norm.x + b*resthair[vb].norm.x + c*resthair[vc].norm.x; // ret.norm.y=a*resthair[va].norm.y + b*resthair[vb].norm.y + c*resthair[vc].norm.y; // ret.norm.z=a*resthair[va].norm.z + b*resthair[vb].norm.z + c*resthair[vc].norm.z; ret.norm.x = a * gs->rs.vn[va].x + b * gs->rs.vn[vb].x + c * gs->rs.vn[vc].x; ret.norm.y = a * gs->rs.vn[va].y + b * gs->rs.vn[vb].y + c * gs->rs.vn[vc].y; ret.norm.z = a * gs->rs.vn[va].z + b * gs->rs.vn[vb].z + c * gs->rs.vn[vc].z; ret.norm = Vnorm( ret.norm ); ret.resthandle.x = hva->resthandle.x * a + hvb->resthandle.x * b + hvc->resthandle.x * c; ret.resthandle.y = hva->resthandle.y * a + hvb->resthandle.y * b + hvc->resthandle.y * c; ret.resthandle.z = hva->resthandle.z * a + hvb->resthandle.z * b + hvc->resthandle.z * c; ret.resthandle = Vnorm( ret.resthandle ); ret.handle.x = hva->handle.x * a + hvb->handle.x * b + hvc->handle.x * c; ret.handle.y = hva->handle.y * a + hvb->handle.y * b + hvc->handle.y * c; ret.handle.z = hva->handle.z * a + hvb->handle.z * b + hvc->handle.z * c; ret.handle = Vnorm( ret.handle ); } ret.cutlength = ret.slider[29]; } } if( slg != 4 ) if( breakit == 1 ) { // BASEHAIR tmpa,tmpb,tmpc; VERT basevert; int qq; float flip; // uu=(float)drand98(); //for (qq=0;qq<(int)(drand98()*(float)100);qq++) MTmix100(gs); uu = ( float ) MTdrand98( gs ); MTmix100(gs); vvv = ( float ) MTdrand98( gs ); //*drand98 //for (qq=0;qq<(int)(drand98()*(float)100);qq++) // vvv=(float)drand98();//*drand98 // while ((1.0f-vv) 1 ) { s = 1 - s; t = 1 - t; } vvv = t; a = s; b = t; c = ( 1 - s - t ); if( gs->rs.Gdontinterp == 1 ) { a = .333333333f; b = .333333333f; c = .333333333f; } ret.restlength = a * vha->restlength + b * vhb->restlength + c * vhc->restlength; { // this is the evaluation of the embedded uv sets added for softimage in 2.7v53 int lastuv_link = -2; VERT lastuv; lastuv.x = 0; lastuv.y = 0; lastuv.z = 0; for( x = 0; x < gs->rs.Guv_totalsets; x++ ) { // if( Guv_link[x] == -1 ) // { // cinfo->UV[x].x = NaN; // cinfo->UV[x].y = NaN; // cinfo->UV[x].z = NaN; // } // if( Guv_link[x] != lastuv_link ) // if( Guv_link[x] != -1 ) { VERT uu; VERT uva, uvb, uvc; // we need to resolve a uv; if( gs->rs.Guv_sets[x].totalverts ) { uva = gs->rs.Guv_sets[x].v[gs->rs.Guv_sets[x].facelist[gs->rs.Guv_sets[x].face_start[cinfo->Tpid]]]; uvb = gs->rs.Guv_sets[x].v[gs->rs.Guv_sets[x].facelist[gs->rs.Guv_sets[x].face_start[cinfo->Tpid] + 1]]; uvc = gs->rs.Guv_sets[x].v[gs->rs.Guv_sets[x].facelist[gs->rs.Guv_sets[x].face_start[cinfo->Tpid] + 2]]; } cinfo->UV[x].x = uva.x * a + uvb.x * b + uvc.x * c; cinfo->UV[x].y = uva.y * a + uvb.y * b + uvc.y * c; cinfo->UV[x].z = uva.z * a + uvb.z * b + uvc.z * c; lastuv_link = x; lastuv = cinfo->UV[x]; } // if( Guv_link[x] == lastuv_link ) // if( lastuv_link != -1 ) // cinfo->UV[x] = lastuv; // didn't need to eval again } } { // this is the evaluation of the embedded uv sets added for softimage in 2.7v53 int lastuv_link = -1; VERT lastuv; lastuv.x = 0; lastuv.y = 0; lastuv.z = 0; for( x = 0; x < gs->rs.Guv_totalsets; x++ ) { // if( Guv_link[x] == -1 ) // { // cinfo->UV[x].x = NaN; // cinfo->UV[x].y = NaN; // cinfo->UV[x].z = NaN; // } // if( Guv_link[x] != lastuv_link ) // if( Guv_link[x] != -1 ) { VERT uu; VERT uva, uvb, uvc; VERT zr; zr.x = 0; zr.y = 0; zr.z = 0; uva = zr; uvb = zr; uvc = zr; uu = zr; // we need to resolve a uv; if( gs->rs.Guv_sets[x].totalverts ) { uva = gs->rs.Guv_sets[x].v[gs->rs.Guv_sets[x].facelist[gs->rs.Guv_sets[x].face_start[cinfo->Tpid]]]; uvb = gs->rs.Guv_sets[x].v[gs->rs.Guv_sets[x].facelist[gs->rs.Guv_sets[x].face_start[cinfo->Tpid] + 1]]; uvc = gs->rs.Guv_sets[x].v[gs->rs.Guv_sets[x].facelist[gs->rs.Guv_sets[x].face_start[cinfo->Tpid] + 2]]; } cinfo->UV[x].x = uva.x * a + uvb.x * b + uvc.x * c; cinfo->UV[x].y = uva.y * a + uvb.y * b + uvc.y * c; cinfo->UV[x].z = uva.z * a + uvb.z * b + uvc.z * c; lastuv_link = x; lastuv = cinfo->UV[x]; } // if( Guv_link[x] == lastuv_link ) // if( lastuv_link != -1 ) // cinfo->UV[x] = lastuv; // didn't need to eval again } } // t = sqrt(t); // a = (float) 1 - t; // b = ((float) 1 - s) * t; // c = s * t; cinfo->wgt[0] = a; cinfo->wgt[1] = b; cinfo->wgt[2] = c; { VERT *ahva, *ahvb, *ahvc; ahva = &vha->resthv[0]; ahvb = &vhb->resthv[0]; ahvc = &vhc->resthv[0]; basevert.x = ahva->x * a + ahvb->x * b + ahvc->x * c; basevert.y = ahva->y * a + ahvb->y * b + ahvc->y * c; basevert.z = ahva->z * a + ahvb->z * b + ahvc->z * c; } flip = ( float ) MTdrand98( gs ); if( flip < .3 ) { memcpy( &ret, &vha, sizeof( BASEHAIR ) ); } if( ( flip >= .3 ) && ( flip < .6 ) ) { memcpy( &ret, &vhb, sizeof( BASEHAIR ) ); } if( ( flip >= .6 ) && ( flip <= 1.0f ) ) { memcpy( &ret, &vhc, sizeof( BASEHAIR ) ); } for( qq = 1; qq < 1; qq++ ) { ret.hv[qq].x -= ret.hv[0].x; ret.hv[qq].y -= ret.hv[0].y; ret.hv[qq].z -= ret.hv[0].z; ret.hv[qq].x += basevert.x; ret.hv[qq].y += basevert.y; ret.hv[qq].z += basevert.z; } ret.hv[0] = basevert; /// tmpa=interp (resthair[facelist[face_start[pid]+1]], // resthair[facelist[face_start[pid]+0]],(float)1.0f-vv); // tmpb=interp (resthair[facelist[face_start[pid]+1]], // resthair[facelist[face_start[pid]+2]],(float)1.0f-vv); // tmpc=interp (tmpa,tmpb,uu); // tmpc.vid=pid; // shove poly id into vert id ret.vid = pid; // ret=tmpc; } // slg!=4 } if( slg == 4 ) { int qq; int pid2; pid2 = pid + 1; if( pid2 > gs->rs.total_splines - 1 ) pid2 = gs->rs.total_splines - 1; MTmix100(gs); uu = ( float ) MTdrand98( gs ); if( gs->rs.Gdontinterp == 1 ) uu = 0.0f; // for (qq=0;qq<(int)(drand98()*(float)100);qq++) // uu=(float)drand98(); ret = interpMT( gs->rs.Sresthair[pid], gs->rs.Sresthair[pid2], uu ,gs); // ret.vid = gs->rs.Dfacelist[gs->rs.Dface_start[pid]]; ret.pid = pid; ret.uu = ( uu + pid ) / ( float ) ( gs->rs.total_slgfaces[4] - 1 ); ret.vv = 0; cinfo->wgt[0] = 1.0f - ret.uu; cinfo->wgt[1] = uu; cinfo->wgt[2] = -1; ret.restlength = ( 1.0f - uu ) * gs->rs.Sresthair[pid].restlength + gs->rs.Sresthair[pid2].restlength * uu; for( x = 0; x < 60; x++ ) { VERT u1; u1.x = ( uu + pid ) / ( float ) ( gs->rs.total_slgfaces[4] - 1 ); u1.y = 0; u1.z = 0; cinfo->UV[x] = u1; ret.slider[x] = ( 1.0f - uu ) * gs->rs.Sresthair[pid].slider[x] + gs->rs.Sresthair[pid2].slider[x] * ( uu ); } cinfo->killme = 0; ret.killme = 0; } ret.pid = pid; //cinfo->u=ret.uu; //cinfo->v=ret.vv; return ( ret ); }