// Shave and a Haircut // (c) 2019 Epic Games // US Patent 6720962 /*change*/ #include #include "TriPointsRS.c" /* initializing the array with a NONZERO seed */ static BASEHAIR interpMT( BASEHAIR aa, BASEHAIR bb, float u,GLOBS *gs ); static void MTsgenrand( unsigned long seed, GLOBS * gs ) { gs->sgenrand_been_seeded = 1; GLseed = seed; /* setting initial seeds to mt[N] using */ /* the generator Line 25 of Table 1 in */ /* [KNUTH 1981, The Art of Computer Programming */ /* Vol. 2 (2nd Ed.), pp102] */ gs->mt[0] = seed & 0xffffffff; for( gs->mti = 1; gs->mti < N11; gs->mti++ ) gs->mt[gs->mti] = ( 69069 * gs->mt[gs->mti - 1] ) & 0xffffffff; } static unsigned long MTgenrand( GLOBS * gs ) { unsigned long y; static unsigned long mag01[2] = { 0x0, MATRIX_A }; if( gs->sgenrand_been_seeded == 0 ) MTsgenrand( 0, gs ); /* mag01[x] = x * MATRIX_A for x=0,1 */ if( gs->mti >= N11 ) { /* generate N words at one time */ int kk; if( gs->mti == N11 + 1 ) /* if sgenrand() has not been called, */ MTsgenrand( 4357, gs ); /* a default initial seed is used */ for( kk = 0; kk < N11 - M11; kk++ ) { y = ( gs->mt[kk] & UPPER_MASK ) | ( gs->mt[kk + 1] & LOWER_MASK ); gs->mt[kk] = gs->mt[kk + M11] ^ ( y >> 1 ) ^ mag01[y & 0x1]; } for( ; kk < N11 - 1; kk++ ) { y = ( gs->mt[kk] & UPPER_MASK ) | ( gs->mt[kk + 1] & LOWER_MASK ); gs->mt[kk] = gs->mt[kk + ( M11 - N11 )] ^ ( y >> 1 ) ^ mag01[y & 0x1]; } y = ( gs->mt[N11 - 1] & UPPER_MASK ) | ( gs->mt[0] & LOWER_MASK ); gs->mt[N11 - 1] = gs->mt[M11 - 1] ^ ( y >> 1 ) ^ mag01[y & 0x1]; gs->mti = 0; } y = gs->mt[gs->mti++]; y ^= TEMPERING_SHIFT_U( y ); y ^= TEMPERING_SHIFT_S( y ) & TEMPERING_MASK_B; y ^= TEMPERING_SHIFT_T( y ) & TEMPERING_MASK_C; y ^= TEMPERING_SHIFT_L( y ); return y; } //static void //MTmix100(gs)(gs)( void ) //{ // int qq; // float uu; // for (qq=0;qq<(int)(drand98()*(float)100);qq++) // uu=(float)drand98(); //++ Jsrand((unsigned int) GLseed); //+1000); //++ GLseed+=1000; //} static void MTmix100( GLOBS *gs ) { int qq; float uu; for (qq=0;qq<(int)(MTdrand98(gs)*(float)15);qq++) uu=(float)MTdrand98(gs); } static BASEHAIR gen_hair( int id, int slg ) { 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 >= total_slgfaces[slg] - 1 ) id = total_slgfaces[slg] - 1; pid = id; init_a_hair( &ret ); if( slg != 4 ) { int tva, tvb, tvc; va = facelist[face_start[id]]; vb = facelist[face_start[id] + 1]; vc = facelist[face_start[id] + 2]; vha = &hair[va]; vhb = &hair[vb]; vhc = &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 ) drand98( ); // for (qq=0;qq<(int)(drand98()*(float)100);qq++) // uu=(float)drand98(); // MTmix100(gs); vvv = ( float ) drand98( ); // 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( Gdontinterp == 1 ) { a = .333333333f; b = .333333333f; c = .333333333f; } //ret= memcpy( &ret, &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 < 15; x++ ) { VERT *hva, *hvb, *hvc; hva = &hair[va].hv[x]; hvb = &hair[vb].hv[x]; hvc = &hair[vc].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 = &hair[va].velocity[x]; hvb = &hair[vb].velocity[x]; hvc = &hair[vc].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 = &hair[va].noisev[x]; hvb = &hair[vb].noisev[x]; hvc = &hair[vc].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=&hair[va]; hvb=&hair[vb]; hvc=&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; printf( "broken \n" ); // MTmix100(gs); uu = ( float ) drand98( ); // MTmix100(gs); //for (qq=0;qq<(int)(drand98()*(float)100);qq++) // uu=(float)drand98(); vvv = ( float ) drand98( ); //*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( Gdontinterp == 1 ) { a = .333333333f; b = .333333333f; c = .333333333f; } ret.restlength = a * vha->restlength + b * vhb->restlength + c * vhc->restlength; { VERT *hva, *hvb, *hvc; hva = &hair[va].hv[0]; hvb = &hair[vb].hv[0]; hvc = &hair[vc].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 ) drand98( ); 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 = &hair[va].noisev[qq]; hvb = &hair[vb].noisev[qq]; hvc = &hair[vc].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 = &hair[va].noisev[qq]; hvb = &hair[vb].noisev[qq]; hvc = &hair[vc].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>total_splines-1) pid2=total_splines-1; // MTmix100(gs); uu = ( float ) drand98( ); if( Gdontinterp == 1 ) uu = 0.0f; // for (qq=0;qq<(int)(drand98()*(float)100);qq++) // uu=(float)drand98(); ret = interp( Shair[pid], Shair[pid2], uu ); ret.norm.x = Shair[pid].hv[1].x - Shair[pid].hv[0].x; ret.norm.y = Shair[pid].hv[1].y - Shair[pid].hv[0].y; ret.norm.z = Shair[pid].hv[1].z - Shair[pid].hv[0].z; ret.norm = Vnorm( ret.norm ); for( x = 0; x < 60; x++ ) { ret.slider[x] = ( 1.0f - uu ) * Sresthair[pid].slider[x] + Sresthair[pid2].slider[x] * ( uu ); } ret.restlength = ( 1.0f - uu ) * Sresthair[pid].restlength + Sresthair[pid2].restlength * uu; ret.vid = Dface_start[pid]; ret.killme = 0; } ret.pid = pid; return ( ret ); } BASEHAIR MTgen_hair( 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 >= total_slgfaces[slg] - 1 ) id = total_slgfaces[slg] - 1; pid = id; init_a_hair( &ret ); if( slg != 4 ) { int tva, tvb, tvc; va = facelist[face_start[id]]; vb = facelist[face_start[id] + 1]; vc = facelist[face_start[id] + 2]; vha = &hair[va]; vhb = &hair[vb]; vhc = &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( Gdontinterp == 1 ) { a = .333333333f; b = .333333333f; c = .333333333f; } //ret= memcpy( &ret, &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 < 15; x++ ) { VERT *hva, *hvb, *hvc; hva = &hair[va].hv[x]; hvb = &hair[vb].hv[x]; hvc = &hair[vc].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 = &hair[va].velocity[x]; hvb = &hair[vb].velocity[x]; hvc = &hair[vc].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 = &hair[va].noisev[x]; hvb = &hair[vb].noisev[x]; hvc = &hair[vc].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=&hair[va]; hvb=&hair[vb]; hvc=&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( Gdontinterp == 1 ) { a = .333333333f; b = .333333333f; c = .333333333f; } ret.restlength = a * vha->restlength + b * vhb->restlength + c * vhc->restlength; { VERT *hva, *hvb, *hvc; hva = &hair[va].hv[0]; hvb = &hair[vb].hv[0]; hvc = &hair[vc].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 = &hair[va].noisev[qq]; hvb = &hair[vb].noisev[qq]; hvc = &hair[vc].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 = &hair[va].noisev[qq]; hvb = &hair[vb].noisev[qq]; hvc = &hair[vc].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; if (id>total_splines-1) id=total_splines-1; pid=id; pid2 = pid + 1; if( pid2 > total_splines - 1 ) pid2 = total_splines - 1; MTmix100(gs); uu = ( float ) MTdrand98( gs ); if( Gdontinterp == 1 ) uu = 0.0f; // for (qq=0;qq<(int)(drand98()*(float)100);qq++) // uu=(float)drand98(); ret = interpMT( Shair[pid], Shair[pid2], uu,gs ); ret.norm.x = Shair[pid].hv[1].x - Shair[pid].hv[0].x; ret.norm.y = Shair[pid].hv[1].y - Shair[pid].hv[0].y; ret.norm.z = Shair[pid].hv[1].z - Shair[pid].hv[0].z; ret.norm = Vnorm( ret.norm ); for( x = 0; x < 60; x++ ) { ret.slider[x] = ( 1.0f - uu ) * Sresthair[pid].slider[x] + Sresthair[pid2].slider[x] * ( uu ); } ret.restlength = ( 1.0f - uu ) * Sresthair[pid].restlength + Sresthair[pid2].restlength * uu; ret.vid = Dface_start[pid]; ret.killme = 0; } ret.pid = pid; return ( ret ); } static BASEHAIR gen_resthair( int id, int slg, CURVEINFO * cinfo ) { 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 = GnodeID; cinfo->shaveID = SHAVEID; cinfo->groupID = Gslg; if( id >= total_slgfaces[slg] - 1 ) id = total_slgfaces[slg] - 1; pid = id; if( slg != 4 ) { va = facelist[face_start[id]]; vb = facelist[face_start[id] + 1]; vc = facelist[face_start[id] + 2]; cinfo->pntid[0] = vlink[va]; cinfo->pntid[1] = vlink[vb]; cinfo->pntid[2] = vlink[vc]; } // cinfo->hairID = GhairID; cinfo->nodeID = GnodeID; cinfo->shaveID = SHAVEID; cinfo->groupID = Gslg; if( slg != 4 ) { cinfo->UTpid = D2UTface_link[face_link[id]]; //face_link[id]; } if( slg == 4 ) cinfo->UTpid = id; if( cinfo->UTpid >= DUTtotalfaces - 1 ) cinfo->UTpid = DUTtotalfaces - 1; if( slg != 4 ) { cinfo->Tpid = face_link[id]; //face_link[id]; // cinfo->pntid[0] = va; // cinfo->pntid[1] = vb; // cinfo->pntid[2] = -1; } if( slg == 4 ) { int id1; if (id>total_splines-1) id=total_splines-1; id1 = id + 1; if( id1 > total_splines - 1 ) id1 = total_splines - 1; cinfo->Tpid = id; // cinfo->pntid[0] = Dfacelist[Dface_start[id]]; // this should really point to the Shair // cinfo->pntid[1] = Dfacelist[Dface_start[id1]]; cinfo->pntid[0] = id; // this should really point to the Shair 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 ) { // cinfo->pntid[2] = vc; if( ( hair[va].splitgroup == hair[vb].splitgroup ) && ( hair[vb].splitgroup == hair[vc].splitgroup ) ) breakit = 0; if( hair[va].splitmerge + hair[vb].splitmerge + hair[vc].splitmerge > 0 ) breakit = 0; if( breakit == 0 ) { int qq; // MTmix100(gs); uu = ( float ) drand98( ); // for (qq=0;qq<(int)(drand98()*(float)100);qq++) // uu=(float)drand98(); // MTmix100(gs); vvv = ( float ) drand98( ); // 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( Gdontinterp == 1 ) { a = .333333333f; b = .333333333f; c = .333333333f; } ret.restlength = a * hair[va].restlength + b * hair[vb].restlength + c * hair[vc].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 < 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( Guv_sets[x].totalverts ) { uva = Guv_sets[x].v[Guv_sets[x].facelist[Guv_sets[x].face_start[cinfo->Tpid]]]; uvb = Guv_sets[x].v[Guv_sets[x].facelist[Guv_sets[x].face_start[cinfo->Tpid] + 1]]; uvc = Guv_sets[x].v[Guv_sets[x].facelist[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( 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, &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 = &hair[va]; rvb = &hair[vb]; rvc = &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 = hair[va].resthandle.x * a + hair[vb].resthandle.x * b + hair[vc].resthandle.x * c; ret.resthandle.y = hair[va].resthandle.y * a + hair[vb].resthandle.y * b + hair[vc].resthandle.y * c; ret.resthandle.z = hair[va].resthandle.z * a + hair[vb].resthandle.z * b + hair[vc].resthandle.z * c; ret.resthandle = Vnorm( ret.resthandle ); ret.handle.x = hair[va].handle.x * a + hair[vb].handle.x * b + hair[vc].handle.x * c; ret.handle.y = hair[va].handle.y * a + hair[vb].handle.y * b + hair[vc].handle.y * c; ret.handle.z = hair[va].handle.z * a + hair[vb].handle.z * b + hair[vc].handle.z * c; ret.handle = Vnorm( ret.handle ); for( x = 0; x < 15; x++ ) { VERT *hva, *hvb, *hvc; hva = &hair[va].noisev[x]; hvb = &hair[vb].noisev[x]; hvc = &hair[vc].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 = &hair[va].velocity[x]; hvb = &hair[vb].velocity[x]; hvc = &hair[vc].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 = &hair[va].noisev[x]; hvb = &hair[vb].noisev[x]; hvc = &hair[vc].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 * vn[va].x + b * vn[vb].x + c * vn[vc].x; 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.resthandle.x = hair[va].resthandle.x * a + hair[vb].resthandle.x * b + hair[vc].resthandle.x * c; ret.resthandle.y = hair[va].resthandle.y * a + hair[vb].resthandle.y * b + hair[vc].resthandle.y * c; ret.resthandle.z = hair[va].resthandle.z * a + hair[vb].resthandle.z * b + hair[vc].resthandle.z * c; ret.resthandle = Vnorm( ret.resthandle ); ret.handle.x = hair[va].handle.x * a + hair[vb].handle.x * b + hair[vc].handle.x * c; ret.handle.y = hair[va].handle.y * a + hair[vb].handle.y * b + hair[vc].handle.y * c; ret.handle.z = hair[va].handle.z * a + hair[vb].handle.z * b + hair[vc].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 ) drand98( ); // MTmix100(gs); vvv = ( float ) drand98( ); //*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( Gdontinterp == 1 ) { a = .333333333f; b = .333333333f; c = .333333333f; } ret.restlength = a * hair[va].restlength + b * hair[vb].restlength + c * hair[vc].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 < Guv_totalsets; x++ ) { // if( Guv_link[x] == -1 ) // { // cinfo->UV[x].x = NaN; // cinfo->UV[x].y = NaN; // cinfo->UV[x].z = NaN; // } // if( x != lastuv_link ) // if( x != -1 ) { VERT uu; VERT uva, uvb, uvc; // we need to resolve a uv; if( Guv_sets[x].totalverts ) { uva = Guv_sets[x].v[Guv_sets[x].facelist[Guv_sets[x].face_start[cinfo->Tpid]]]; uvb = Guv_sets[x].v[Guv_sets[x].facelist[Guv_sets[x].face_start[cinfo->Tpid] + 1]]; uvc = Guv_sets[x].v[Guv_sets[x].facelist[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 < 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( Guv_sets[x].totalverts ) { uva = Guv_sets[x].v[Guv_sets[x].facelist[Guv_sets[x].face_start[cinfo->Tpid]]]; uvb = Guv_sets[x].v[Guv_sets[x].facelist[Guv_sets[x].face_start[cinfo->Tpid] + 1]]; uvc = Guv_sets[x].v[Guv_sets[x].facelist[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 = &hair[va].resthv[0]; hvb = &hair[vb].resthv[0]; hvc = &hair[vc].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 ) drand98( ); if( flip < .3 ) { memcpy( &ret, &hair[va], sizeof( BASEHAIR ) ); } if( ( flip >= .3 ) && ( flip < .6 ) ) { memcpy( &ret, &hair[vb], sizeof( BASEHAIR ) ); } if( ( flip >= .6 ) && ( flip <= 1.0f ) ) { memcpy( &ret, &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; pid=id; pid2=pid+1; if (pid2>total_splines-1) pid2=total_splines-1; // MTmix100(gs); uu = ( float ) drand98( ); if( Gdontinterp == 1 ) uu = 0.0f; // for (qq=0;qq<(int)(drand98()*(float)100);qq++) // uu=(float)drand98(); ret = interp( Sresthair[pid], Sresthair[pid2], uu ); ret.vid = Dfacelist[Dface_start[pid]]; ret.pid = pid; ret.uu = ( uu + pid ) / ( float ) ( 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 ) * Sresthair[pid].restlength + Sresthair[pid2].restlength * uu; for( x = 0; x < 60; x++ ) { VERT u1; u1.x = ( uu + pid ) / ( float ) ( total_slgfaces[4] - 1 ); u1.y = 0; u1.z = 0; cinfo->UV[x] = u1; ret.slider[x] = ( 1.0f - uu ) * Sresthair[pid].slider[x] + Sresthair[pid2].slider[x] * ( uu ); } cinfo->killme = 0; ret.killme = 0; } ret.pid = pid; //cinfo->u=ret.uu; //cinfo->v=ret.vv; return ( ret ); } static BASEHAIR gen_resthair_ROOT( int id, int slg, CURVEINFO * cinfo ) { 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, vb, vc; float uu, vvv; VERT zero; init_a_hair( &ret ); va = 0; vb = 0; vc = 0; init_a_hair( &ret ); if( id >= total_slgfaces[slg] - 1 ) id = total_slgfaces[slg] - 1; pid = id; // cinfo->hairID = GhairID; cinfo->nodeID = GnodeID; cinfo->shaveID = SHAVEID; cinfo->groupID = Gslg; if( slg != 4 ) { va = facelist[face_start[id]]; vb = facelist[face_start[id] + 1]; vc = facelist[face_start[id] + 2]; cinfo->pntid[2] = vlink[vc]; // cinfo->pntid[0] = va; // cinfo->pntid[1] = vb; cinfo->pntid[0] = vlink[va]; cinfo->pntid[1] = vlink[vb]; cinfo->pntid[2] = vlink[vc]; // cinfo->pntid[2] = -1; cinfo->UTpid = D2UTface_link[face_link[id]]; //face_link[id]; cinfo->Tpid = face_link[id]; //face_link[id]; } if( slg == 4 ) { // va = Dfacelist[Dface_start[id]]; // vb = Dfacelist[Dface_start[id] + 1]; va = id; if (va>total_splines-1) va=total_splines-1; vb = id+1; if (vb>total_splines-1) vb=total_splines-1; cinfo->pntid[0] = va; cinfo->pntid[1] = vb; cinfo->pntid[2] = -1; cinfo->UTpid = pid; cinfo->Tpid = id; } if( cinfo->UTpid >= DUTtotalfaces ) cinfo->UTpid = DUTtotalfaces - 1; //cinfo->pid=D2UTface_link[face_link[id]]; if( slg != 4 ) { // cinfo->pntid[2] = vc; if( ( hair[va].splitgroup == hair[vb].splitgroup ) && ( hair[vb].splitgroup == hair[vc].splitgroup ) ) breakit = 0; if( hair[va].splitmerge + hair[vb].splitmerge + hair[vc].splitmerge > 0 ) breakit = 0; if( breakit == 0 ) { int qq; // MTmix100(gs); uu = ( float ) drand98( ); // for (qq=0;qq<(int)(drand98()*(float)100);qq++) // uu=(float)drand98(); // MTmix100(gs); vvv = ( float ) drand98( ); // 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( Gdontinterp == 1 ) { a = .333333333f; b = .333333333f; c = .333333333f; } cinfo->wgt[0] = a; cinfo->wgt[1] = b; cinfo->wgt[2] = c; memcpy( &ret, &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 x = 0; // for (x=0;x<1;x++) { ret.uu = a * hair[va].uu + b * hair[vb].uu + c * hair[vc].uu; ret.vv = a * hair[va].vv + b * hair[vb].vv + c * hair[vc].vv; } // interp verts // for (x=0;x<1;x++) { ret.hv[x].x = a * hair[va].hv[x].x + b * hair[vb].hv[x].x + c * hair[vc].hv[x].x; ret.hv[x].y = a * hair[va].hv[x].y + b * hair[vb].hv[x].y + c * hair[vc].hv[x].y; ret.hv[x].z = a * hair[va].hv[x].z + b * hair[vb].hv[x].z + c * hair[vc].hv[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 * vn[va].x + b * vn[vb].x + c * vn[vc].x; 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.resthandle.x = hair[va].resthandle.x * a + hair[vb].resthandle.x * b + hair[vc].resthandle.x * c; ret.resthandle.y = hair[va].resthandle.y * a + hair[vb].resthandle.y * b + hair[vc].resthandle.y * c; ret.resthandle.z = hair[va].resthandle.z * a + hair[vb].resthandle.z * b + hair[vc].resthandle.z * c; ret.resthandle = Vnorm( ret.resthandle ); ret.handle.x = hair[va].handle.x * a + hair[vb].handle.x * b + hair[vc].handle.x * c; ret.handle.y = hair[va].handle.y * a + hair[vb].handle.y * b + hair[vc].handle.y * c; ret.handle.z = hair[va].handle.z * a + hair[vb].handle.z * b + hair[vc].handle.z * c; ret.handle = Vnorm( ret.handle ); 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 ) drand98( ); //for (qq=0;qq<(int)(drand98()*(float)100);qq++) // uu=(float)drand98(); // MTmix100(gs); vvv = ( float ) drand98( ); //*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( Gdontinterp == 1 ) { a = .333333333f; b = .333333333f; c = .333333333f; } { // 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; } cinfo->wgt[0] = a; cinfo->wgt[1] = b; cinfo->wgt[2] = c; { VERT *hva, *hvb, *hvc; hva = &hair[va].hv[0]; hvb = &hair[vb].hv[0]; hvc = &hair[vc].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=resthair[va].hv[0].x*a+ // resthair[vb].hv[0].x*b+ // resthair[vc].hv[0].x*c; //basevert.y=resthair[va].hv[0].y*a+ // resthair[vb].hv[0].y*b+ // resthair[vc].hv[0].y*c; //basevert.z=resthair[va].hv[0].z*a+ // resthair[vb].hv[0].z*b+ // resthair[vc].hv[0].z*c; flip = ( float ) drand98( ); if( flip < .3 ) { memcpy( &ret, &hair[va], sizeof( BASEHAIR ) ); } if( ( flip >= .3 ) && ( flip < .6 ) ) { memcpy( &ret, &hair[vb], sizeof( BASEHAIR ) ); } if( ( flip >= .6 ) && ( flip <= 1.0f ) ) { memcpy( &ret, &hair[vc], sizeof( BASEHAIR ) ); } if( 0 == 1 ) 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; if (id>total_splines-1) id=total_splines-1; pid=id; pid2=id+1; if (pid2>total_splines-1) pid2=total_splines-1; // MTmix100(gs); uu = ( float ) drand98( ); if( Gdontinterp == 1 ) uu = .333333333f; // for (qq=0;qq<(int)(drand98()*(float)100);qq++) // uu=(float)drand98(); ret = interp( Sresthair[pid], Sresthair[pid2], uu ); ret.vid = Dfacelist[Dface_start[pid]]; ret.pid = pid; ret.uu = ( uu + pid ) / ( float ) ( total_slgfaces[4] - 1 ); ret.vv = 0; cinfo->wgt[0] = 1.0f - ret.uu; cinfo->wgt[1] = uu; cinfo->wgt[2] = -1; cinfo->killme = 0; ret.killme = 0; } //cinfo->u=ret.uu; //cinfo->v=ret.vv; // ret.dreadcount = ( float ) ( int ) sliders[25][slg].value; ret.pid = pid; return ( ret ); } static BASEHAIR gen_hair_ROOT( int id, int slg ) { BASEHAIR ret; float a, b, c; float s, t; int x; int pid; int breakit = 1; /* map (s,t) to a point in that sub-triangle */ int va = 0, vb = 0, vc = 0; BASEHAIR *vha = NULL, *vhb = NULL, *vhc = NULL; float uu, vvv; if( id >= total_slgfaces[slg] - 1 ) id = total_slgfaces[slg] - 1; pid = id; if( slg != 4 ) { int tva, tvb, tvc; va = facelist[face_start[id]]; vb = facelist[face_start[id] + 1]; vc = facelist[face_start[id] + 2]; vha = &hair[va]; vhb = &hair[vb]; vhc = &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 ) drand98( ); // for (qq=0;qq<(int)(drand98()*(float)100);qq++) // uu=(float)drand98(); // MTmix100(gs); vvv = ( float ) drand98( ); // 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 ); // come back if( Gdontinterp == 1 ) { a = .333333333f; b = .333333333f; c = .333333333f; } //ret= memcpy( &ret, &hair[va], sizeof( BASEHAIR ) ); // grab the basic characteristics from the first vert; // interp slider //#ifdef SLOW 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 = &hair[va].hv[x]; hvb = &hair[vb].hv[x]; hvc = &hair[vc].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; ret.velocity[x].x = 0.0f; ret.velocity[x].y = 0.0f; ret.velocity[x].z = 0.0f; ret.noisev[x] = ret.hv[x]; // 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=&hair[va]; hvb=&hair[vb]; hvc=&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 ); ret.norm.x = a * vn[va].x + b * vn[vb].x + c * vn[vc].x; 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 ) drand98( ); // MTmix100(gs); //for (qq=0;qq<(int)(drand98()*(float)100);qq++) // uu=(float)drand98(); vvv = ( float ) drand98( ); //*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( Gdontinterp == 1 ) { a = .333333333f; b = .333333333f; c = .333333333f; } { VERT *hva, *hvb, *hvc; hva = &hair[va].hv[0]; hvb = &hair[vb].hv[0]; hvc = &hair[vc].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 ) drand98( ); 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; ret.noisev[qq] = ret.hv[qq]; } qq = 0; hva = &hair[va].noisev[qq]; hvb = &hair[vb].noisev[qq]; hvc = &hair[vc].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; if (id>total_splines-1) id=total_splines-1; pid=id; pid2=pid+1; if (pid2>total_splines-1) pid2=total_splines-1; // MTmix100(gs); uu = ( float ) drand98( ); if( Gdontinterp == 1 ) uu = 0.0f; // for (qq=0;qq<(int)(drand98()*(float)100);qq++) // uu=(float)drand98(); ret = interp( Shair[pid], Shair[pid2], uu ); ret.vid = Dfacelist[Dface_start[pid]]; ret.killme = 0; } ret.pid = pid; return ( ret ); } BASEHAIR MTgen_resthair( 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 = GnodeID; cinfo->shaveID = SHAVEID; cinfo->groupID = Gslg; if( id >= total_slgfaces[slg] - 1 ) id = total_slgfaces[slg] - 1; pid = id; if( slg == 0 ) { va = facelist[face_start[id]]; vb = facelist[face_start[id] + 1]; vc = facelist[face_start[id] + 2]; cinfo->pntid[0] = vlink[va]; cinfo->pntid[1] = vlink[vb]; cinfo->pntid[2] = vlink[vc]; cinfo->UTpid = D2UTface_link[face_link[id]]; //face_link[id]; if( cinfo->UTpid >= DUTtotalfaces - 1 ) cinfo->UTpid = DUTtotalfaces - 1; cinfo->Tpid = face_link[id]; //face_link[id]; } // cinfo->hairID = GhairID; cinfo->nodeID = GnodeID; cinfo->shaveID = SHAVEID; cinfo->groupID = Gslg; if( slg == 4 ) { int id1; if (id > total_splines -1) id=total_splines-1; id1 = id + 1; cinfo->UTpid = id; if( id1 > total_splines - 1 ) id1 = total_splines - 1; cinfo->Tpid = id; cinfo->pntid[0] = id; cinfo->pntid[1] = id1; cinfo->pntid[2] = -1; } if( slg != 4 ) { if( ( hair[va].splitgroup == hair[vb].splitgroup ) && ( hair[vb].splitgroup == hair[vc].splitgroup ) ) breakit = 0; if( hair[va].splitmerge + hair[vb].splitmerge + hair[vc].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( Gdontinterp == 1 ) { a = .333333333f; b = .333333333f; c = .333333333f; } ret.restlength = a * hair[va].restlength + b * hair[vb].restlength + c * hair[vc].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 < 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( Guv_sets[x].totalverts ) { uva = Guv_sets[x].v[Guv_sets[x].facelist[Guv_sets[x].face_start[cinfo->Tpid] + 2]]; uvb = Guv_sets[x].v[Guv_sets[x].facelist[Guv_sets[x].face_start[cinfo->Tpid] + 1]]; uvc = Guv_sets[x].v[Guv_sets[x].facelist[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, &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 = &hair[va]; rvb = &hair[vb]; rvc = &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 = hair[va].resthandle.x * a + hair[vb].resthandle.x * b + hair[vc].resthandle.x * c; ret.resthandle.y = hair[va].resthandle.y * a + hair[vb].resthandle.y * b + hair[vc].resthandle.y * c; ret.resthandle.z = hair[va].resthandle.z * a + hair[vb].resthandle.z * b + hair[vc].resthandle.z * c; ret.resthandle = Vnorm( ret.resthandle ); ret.handle.x = hair[va].handle.x * a + hair[vb].handle.x * b + hair[vc].handle.x * c; ret.handle.y = hair[va].handle.y * a + hair[vb].handle.y * b + hair[vc].handle.y * c; ret.handle.z = hair[va].handle.z * a + hair[vb].handle.z * b + hair[vc].handle.z * c; ret.handle = Vnorm( ret.handle ); for( x = 0; x < 15; x++ ) { VERT *hva, *hvb, *hvc; hva = &hair[va].noisev[x]; hvb = &hair[vb].noisev[x]; hvc = &hair[vc].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 = &hair[va].velocity[x]; hvb = &hair[vb].velocity[x]; hvc = &hair[vc].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 = &hair[va].noisev[x]; hvb = &hair[vb].noisev[x]; hvc = &hair[vc].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 * vn[va].x + b * vn[vb].x + c * vn[vc].x; 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.resthandle.x = hair[va].resthandle.x * a + hair[vb].resthandle.x * b + hair[vc].resthandle.x * c; ret.resthandle.y = hair[va].resthandle.y * a + hair[vb].resthandle.y * b + hair[vc].resthandle.y * c; ret.resthandle.z = hair[va].resthandle.z * a + hair[vb].resthandle.z * b + hair[vc].resthandle.z * c; ret.resthandle = Vnorm( ret.resthandle ); ret.handle.x = hair[va].handle.x * a + hair[vb].handle.x * b + hair[vc].handle.x * c; ret.handle.y = hair[va].handle.y * a + hair[vb].handle.y * b + hair[vc].handle.y * c; ret.handle.z = hair[va].handle.z * a + hair[vb].handle.z * b + hair[vc].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( Gdontinterp == 1 ) { a = .333333333f; b = .333333333f; c = .333333333f; } ret.restlength = a * hair[va].restlength + b * hair[vb].restlength + c * hair[vc].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 < 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( Guv_sets[x].totalverts ) { uva = Guv_sets[x].v[Guv_sets[x].facelist[Guv_sets[x].face_start[cinfo->Tpid]]]; uvb = Guv_sets[x].v[Guv_sets[x].facelist[Guv_sets[x].face_start[cinfo->Tpid] + 1]]; uvc = Guv_sets[x].v[Guv_sets[x].facelist[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 < 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( Guv_sets[x].totalverts ) { uva = Guv_sets[x].v[Guv_sets[x].facelist[Guv_sets[x].face_start[cinfo->Tpid]]]; uvb = Guv_sets[x].v[Guv_sets[x].facelist[Guv_sets[x].face_start[cinfo->Tpid] + 1]]; uvc = Guv_sets[x].v[Guv_sets[x].facelist[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 = &hair[va].resthv[0]; hvb = &hair[vb].resthv[0]; hvc = &hair[vc].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, &hair[va], sizeof( BASEHAIR ) ); } if( ( flip >= .3 ) && ( flip < .6 ) ) { memcpy( &ret, &hair[vb], sizeof( BASEHAIR ) ); } if( ( flip >= .6 ) && ( flip <= 1.0f ) ) { memcpy( &ret, &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; if (id>total_splines-1) id=total_splines-1; pid=id; pid2 = id + 1; if( pid2 > total_splines - 1 ) pid2 = total_splines - 1; MTmix100(gs); uu = ( float ) MTdrand98( gs ); if( Gdontinterp == 1 ) uu = 0.0f; // for (qq=0;qq<(int)(drand98()*(float)100);qq++) // uu=(float)drand98(); ret = interpMT( Sresthair[pid], Sresthair[pid2], uu ,gs); ret.vid = Dfacelist[Dface_start[pid]]; ret.pid = pid; ret.uu = ( uu + pid ) / ( float ) ( 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 ) * Sresthair[pid].restlength + Sresthair[pid2].restlength * uu; for( x = 0; x < 60; x++ ) { VERT u1; u1.x = ( uu + pid ) / ( float ) ( total_slgfaces[4] - 1 ); u1.y = 0; u1.z = 0; cinfo->UV[x] = u1; ret.slider[x] = ( 1.0f - uu ) * Sresthair[pid].slider[x] + Sresthair[pid2].slider[x] * ( uu ); } cinfo->killme = 0; ret.killme = 0; } ret.pid = pid; //cinfo->u=ret.uu; //cinfo->v=ret.vv; return ( ret ); } BASEHAIR MTgen_hair_ROOT( 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 >= total_slgfaces[slg] - 1 ) id = total_slgfaces[slg] - 1; pid = id; init_a_hair( &ret ); if( slg != 4 ) { int tva, tvb, tvc; va = facelist[face_start[id]]; vb = facelist[face_start[id] + 1]; vc = facelist[face_start[id] + 2]; vha = &hair[va]; vhb = &hair[vb]; vhc = &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( Gdontinterp == 1 ) { a = .333333333f; b = .333333333f; c = .333333333f; } //ret= memcpy( &ret, &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 = &hair[va].hv[x]; hvb = &hair[vb].hv[x]; hvc = &hair[vc].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 = &hair[va].velocity[x]; hvb = &hair[vb].velocity[x]; hvc = &hair[vc].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 = &hair[va].noisev[x]; hvb = &hair[vb].noisev[x]; hvc = &hair[vc].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++) { ret.norm.x = a * hair[va].norm.x + b * hair[vb].norm.x + c * hair[vc].norm.x; ret.norm.y = a * hair[va].norm.y + b * hair[vb].norm.y + c * hair[vc].norm.y; ret.norm.z = a * hair[va].norm.z + b * hair[vb].norm.z + c * hair[vc].norm.z; ret.resthandle.x = hair[va].resthandle.x * a + hair[vb].resthandle.x * b + hair[vc].resthandle.x * c; ret.resthandle.y = hair[va].resthandle.y * a + hair[vb].resthandle.y * b + hair[vc].resthandle.y * c; ret.resthandle.z = hair[va].resthandle.z * a + hair[vb].resthandle.z * b + hair[vc].resthandle.z * c; ret.resthandle = Vnorm( ret.resthandle ); ret.handle.x = hair[va].handle.x * a + hair[vb].handle.x * b + hair[vc].handle.x * c; ret.handle.y = hair[va].handle.y * a + hair[vb].handle.y * b + hair[vc].handle.y * c; ret.handle.z = hair[va].handle.z * a + hair[vb].handle.z * b + hair[vc].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( Gdontinterp == 1 ) { a = .333333333f; b = .333333333f; c = .333333333f; } ret.restlength = a * vha->restlength + b * vhb->restlength + c * vhc->restlength; { VERT *hva, *hvb, *hvc; hva = &hair[va].hv[0]; hvb = &hair[vb].hv[0]; hvc = &hair[vc].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 = &hair[va].noisev[qq]; hvb = &hair[vb].noisev[qq]; hvc = &hair[vc].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 = &hair[va].noisev[qq]; hvb = &hair[vb].noisev[qq]; hvc = &hair[vc].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 > total_splines - 1 ) pid2 = total_splines - 1; MTmix100(gs); uu = ( float ) MTdrand98( gs ); if( Gdontinterp == 1 ) uu = 0.0f; // for (qq=0;qq<(int)(drand98()*(float)100);qq++) // uu=(float)drand98(); // ret = interp( Shair[pid], Shair[pid2], uu ); ret = interpMT( Shair[pid], Shair[pid2], uu,gs ); ret.norm.x = Shair[pid].hv[1].x - Shair[pid].hv[0].x; ret.norm.y = Shair[pid].hv[1].y - Shair[pid].hv[0].y; ret.norm.z = Shair[pid].hv[1].z - Shair[pid].hv[0].z; ret.norm = Vnorm( ret.norm ); for( x = 0; x < 60; x++ ) { ret.slider[x] = ( 1.0f - uu ) * Sresthair[pid].slider[x] + Sresthair[pid2].slider[x] * ( uu ); } ret.restlength = ( 1.0f - uu ) * Sresthair[pid].restlength + Sresthair[pid2].restlength * uu; ret.vid = Dface_start[pid]; ret.killme = 0; } ret.pid = pid; return ( ret ); } BASEHAIR MTgen_resthair_ROOT( 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 = GnodeID; cinfo->shaveID = SHAVEID; cinfo->groupID = Gslg; if( id >= total_slgfaces[slg] - 1 ) id = total_slgfaces[slg] - 1; pid = id; if( slg != 4 ) { va = facelist[face_start[id]]; vb = facelist[face_start[id] + 1]; vc = facelist[face_start[id] + 2]; cinfo->pntid[0] = vlink[va]; cinfo->pntid[1] = vlink[vb]; cinfo->pntid[2] = vlink[vc]; cinfo->UTpid = D2UTface_link[face_link[id]]; //face_link[id]; if( cinfo->UTpid >= DUTtotalfaces - 1 ) cinfo->UTpid = DUTtotalfaces - 1; cinfo->Tpid = face_link[id]; //face_link[id]; } cinfo->nodeID = GnodeID; cinfo->shaveID = SHAVEID; cinfo->groupID = Gslg; if( slg == 4 ) { int id1; id1 = id + 1; cinfo->UTpid = id; if( id1 > total_splines - 1 ) id1 = total_splines - 1; cinfo->Tpid = id; cinfo->pntid[0] = id; cinfo->pntid[1] = id1; cinfo->pntid[2] = -1; } if( slg ==0 ) { if( ( hair[va].splitgroup == hair[vb].splitgroup ) && ( hair[vb].splitgroup == hair[vc].splitgroup ) ) breakit = 0; if( hair[va].splitmerge + hair[vb].splitmerge + hair[vc].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( Gdontinterp == 1 ) { a = .333333333f; b = .333333333f; c = .333333333f; } ret.restlength = a * hair[va].restlength + b * hair[vb].restlength + c * hair[vc].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 < 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( Guv_sets[x].totalverts ) { uva = Guv_sets[x].v[Guv_sets[x].facelist[Guv_sets[x].face_start[cinfo->Tpid] + 2]]; uvb = Guv_sets[x].v[Guv_sets[x].facelist[Guv_sets[x].face_start[cinfo->Tpid] + 1]]; uvc = Guv_sets[x].v[Guv_sets[x].facelist[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, &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 = &hair[va]; rvb = &hair[vb]; rvc = &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 ret.resthandle.x = hair[va].resthandle.x * a + hair[vb].resthandle.x * b + hair[vc].resthandle.x * c; ret.resthandle.y = hair[va].resthandle.y * a + hair[vb].resthandle.y * b + hair[vc].resthandle.y * c; ret.resthandle.z = hair[va].resthandle.z * a + hair[vb].resthandle.z * b + hair[vc].resthandle.z * c; ret.resthandle = Vnorm( ret.resthandle ); ret.handle.x = hair[va].handle.x * a + hair[vb].handle.x * b + hair[vc].handle.x * c; ret.handle.y = hair[va].handle.y * a + hair[vb].handle.y * b + hair[vc].handle.y * c; ret.handle.z = hair[va].handle.z * a + hair[vb].handle.z * b + hair[vc].handle.z * c; ret.handle = Vnorm( ret.handle ); for( x = 0; x < 1; x++ ) { VERT *hva, *hvb, *hvc; hva = &hair[va].noisev[x]; hvb = &hair[vb].noisev[x]; hvc = &hair[vc].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 = &hair[va].velocity[x]; hvb = &hair[vb].velocity[x]; hvc = &hair[vc].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 = &hair[va].noisev[x]; hvb = &hair[vb].noisev[x]; hvc = &hair[vc].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 * vn[va].x + b * vn[vb].x + c * vn[vc].x; 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.resthandle.x = hair[va].resthandle.x * a + hair[vb].resthandle.x * b + hair[vc].resthandle.x * c; ret.resthandle.y = hair[va].resthandle.y * a + hair[vb].resthandle.y * b + hair[vc].resthandle.y * c; ret.resthandle.z = hair[va].resthandle.z * a + hair[vb].resthandle.z * b + hair[vc].resthandle.z * c; ret.resthandle = Vnorm( ret.resthandle ); ret.handle.x = hair[va].handle.x * a + hair[vb].handle.x * b + hair[vc].handle.x * c; ret.handle.y = hair[va].handle.y * a + hair[vb].handle.y * b + hair[vc].handle.y * c; ret.handle.z = hair[va].handle.z * a + hair[vb].handle.z * b + hair[vc].handle.z * c; ret.handle = Vnorm( ret.handle ); } ret.cutlength = ret.slider[29]; } } if( slg == 0 ) 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( Gdontinterp == 1 ) { a = .333333333f; b = .333333333f; c = .333333333f; } ret.restlength = a * hair[va].restlength + b * hair[vb].restlength + c * hair[vc].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 < 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( Guv_sets[x].totalverts ) { uva = Guv_sets[x].v[Guv_sets[x].facelist[Guv_sets[x].face_start[cinfo->Tpid]]]; uvb = Guv_sets[x].v[Guv_sets[x].facelist[Guv_sets[x].face_start[cinfo->Tpid] + 1]]; uvc = Guv_sets[x].v[Guv_sets[x].facelist[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 < 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( Guv_sets[x].totalverts ) { uva = Guv_sets[x].v[Guv_sets[x].facelist[Guv_sets[x].face_start[cinfo->Tpid]]]; uvb = Guv_sets[x].v[Guv_sets[x].facelist[Guv_sets[x].face_start[cinfo->Tpid] + 1]]; uvc = Guv_sets[x].v[Guv_sets[x].facelist[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 = &hair[va].resthv[0]; hvb = &hair[vb].resthv[0]; hvc = &hair[vc].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, &hair[va], sizeof( BASEHAIR ) ); } if( ( flip >= .3 ) && ( flip < .6 ) ) { memcpy( &ret, &hair[vb], sizeof( BASEHAIR ) ); } if( ( flip >= .6 ) && ( flip <= 1.0f ) ) { memcpy( &ret, &hair[vc], 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; pid=id; pid2 = pid + 1; if( id > total_splines - 1 ) id = total_splines - 1; if( pid2 > total_splines - 1 ) pid2 = total_splines - 1; MTmix100(gs); uu = ( float ) MTdrand98( gs ); if( Gdontinterp == 1 ) uu = 0.0f; // for (qq=0;qq<(int)(drand98()*(float)100);qq++) // uu=(float)drand98(); ret = interpMT( Sresthair[pid], Sresthair[pid2], uu,gs ); ret.vid = Dfacelist[Dface_start[pid]]; ret.pid = pid; ret.uu = ( uu + pid ) / ( float ) ( 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 ) * Sresthair[pid].restlength + Sresthair[pid2].restlength * uu; ret.killme=0; for( x = 0; x < 60; x++ ) { VERT u1; u1.x = ( uu + pid ) / ( float ) ( total_slgfaces[4] - 1 ); u1.y = 0; u1.z = 0; cinfo->UV[x] = u1; ret.slider[x] = ( 1.0f - uu ) * Sresthair[pid].slider[x] + Sresthair[pid2].slider[x] * ( uu ); } cinfo->killme = 0; ret.killme = 0; } ret.pid = pid; //cinfo->u=ret.uu; //cinfo->v=ret.vv; return ( ret ); }