hobj_t * BuildMeshTileShape( hobj_t *surf_poly, hobj_t *plane, hobj_t *texdef, hpair_t *mat_pair, u_list_t *poly_list ) { hobj_t *shape; hobj_t *tmp; hobj_t *polygon; hobj_t *meshtile; u_list_iter_t iter; polygon_t *p; int poly_num; shape = EasyNewClass( "shape" ); InsertHPair( shape, NewHPair2( "string", "tess_name", "meshtile" ) ); polygon = DeepCopyClass( surf_poly ); EasyNewClsref( polygon, "plane", plane ); InsertClass( shape, polygon ); if ( mat_pair ) { InsertHPair( shape, NewHPair2( "ref", "material", mat_pair->value ) ); } else { InsertHPair( shape, NewHPair2( "ref", "material", "default" ) ); } { hobj_t *texdef0; texdef0 = EasyNewClass( "proj_texdef0" ); InsertClass( shape, texdef0 ); EasyNewClsref( texdef0, "texdef", texdef ); } meshtile = EasyNewClass( "meshtile" ); InsertClass( shape, meshtile ); #if 0 poly_num = 0; U_ListIterInit( &iter, poly_list ); for ( ; ( p = U_ListIterNext( &iter ) ) ; ) { if ( p->pointnum == 3 ) { InsertClass( meshtile, CreateClassFromPolygon( p ) ); poly_num++; } else { int j; polygon_t *tmp; tmp = NewPolygon( 3 ); tmp->pointnum = 3; Vec3dCopy( tmp->p[0], p->p[0] ); for ( j = 1; j < p->pointnum-1; j++ ) { Vec3dCopy( tmp->p[1], p->p[j] ); Vec3dCopy( tmp->p[2], p->p[j+1] ); InsertClass( meshtile, CreateClassFromPolygon( tmp ) ); poly_num++; } FreePolygon( tmp ); } } EasyNewInt( meshtile, "polynum", poly_num ); #endif return shape; }
//重载=运算符 DeepCopyClass& operator=(DeepCopyClass& d1) { std::cout << "= Construct" << std::endl; return DeepCopyClass(d1); }