void plug_warning(t_plug *dst_plug,t_plug *src_plug) { t_context *C=ctx_get(); char msg[40]; char *src_plug_type=data_name_get(src_plug->data_type); char *dst_plug_type=data_name_get(dst_plug->data_type); sprintf(msg,"%d(%s)(%s)-(%s)(%s)",C->app->frame,src_plug->name,src_plug_type,dst_plug->name,dst_plug_type); term_print(C->term,msg); }
void vlst_data_init(t_vlst *vlst, int old_count) { int i,j; int indice; indice = old_count * vlst->length; for(i = old_count; i < vlst->count; i++) { for(j = 0; j < vlst->length; j++) { switch(vlst->type) { case(dt_uint): set_uint(grf_uint(vlst->data, indice),0); break; case(dt_int): set_int(grf_int(vlst->data, indice),0); break; case(dt_float): set_float(grf_float(vlst->data, indice),0); break; default: printf("[vlst_data_init] %s not implemented\n", data_name_get(vlst->type)); break; } indice++; } } }
void cls_block_link(t_block *self,t_node *target) { if(target->type==dt_list) { t_lst *lst=target->data; self->bricks=lst; target->users++; } else printf("[ERROR:cls_block_link] Unknown node type %s",data_name_get(target->type)); }
void image_data_convert( t_image *image, t_data_type type) { t_vlst *vlst = image->vlst; if(vlst) { if( type == dt_uchar && vlst->type == dt_float) { vlst_map( vlst, dt_uchar, 0, 255); } else printf("[Image] data_convert Not implemented for %s\n", data_name_get( type)); } }
void vlst_set_data(t_vlst *vlst, void *data, int indice) { void *ptr = vlst->data; switch(vlst->type) { case(dt_float): srf_float(ptr, data, indice); break; case(dt_uint): srf_uint(ptr, data, indice); break; case(dt_int): srf_int(ptr, data, indice); break; default: printf("[ERR vlst_set_data] Unknown type %s\n",data_name_get(vlst->type)); break; } }
void *vlst_get_pointer(t_vlst *vlst, int indice) { void *ptr = vlst->data; switch(vlst->type) { case(dt_float): return grf_float(ptr, indice); break; case(dt_uint): return grf_uint(ptr, indice); break; default: printf("[ERR vlst_get_pointer] Unknown type %s\n",data_name_get(vlst->type)); return NULL; break; } }
void brick_info( t_term *term, t_brick *brick) { t_plug *plug = &brick->plug_intern; t_data_type type = plug->data_type; term_l( term, "%s", data_name_get( type)); switch(type) { case( dt_vlst): vlst_info( term, ( t_vlst *) plug->data); break; default: break; } }
t_vlst *vlst_make( const char *name, t_data_type type, int length, int count, void *data) { t_context *C=ctx_get(); t_node *node_vlst=scene_add(C->scene,dt_vlst,name); t_vlst *vlst=node_vlst->data; vlst->type = type; vlst->length = length; vlst->count=count; vlst->count_new=vlst->count; if(type == dt_int) vlst->size = sizeof(int); else if(type == dt_uint) vlst->size = sizeof(unsigned int); else if(type == dt_float) vlst->size = sizeof(float); else if(type == dt_uchar) vlst->size = sizeof(unsigned char); else printf("[ERROR vlst_make] Unknown type %s\n",data_name_get(type)); if( !data && length && count) { vlst->data=mem_malloc((vlst->size)*(vlst->length)*(vlst->count)); if(C->scene->store) { scene_add_data_var(C->scene,"vlst_data","v_data",((vlst->size)*(vlst->length)*(vlst->count)),vlst->data); } } else { vlst->data = data; } if(C->ui->add_bricks && C->ui->add_bricks_data) { t_node *node_block=add_block(C,"vlst"); t_block *block=node_block->data; add_part_vlst(C,block,dt_vlst,"vlst",vlst); vlst->ref = block; } return vlst; }
void plug_cls_init(t_plug *plug) { int i; int n = sizeof(plugs)/sizeof(plugs[0]); int found=0; for(i=0;i<n;i++) { if(plug->data_type==plugs[i]->type) { plugs[i]->make(plug); found=1; break; } } if(!found) { char *type=data_name_get(plug->data_type); printf("[ERROR:plug_cls_init] Unknown plug type [%s]\n",type); } }
void vlst_show(t_vlst *vlst) { t_context *C = ctx_get(); if(vlst) { int i; int count=vlst->count; int length=vlst->length; void *dat=vlst->data; if(C->event->debug_terminal) printf("[VLST] type:%s name:%s count:%d length:%d\n", data_name_get(vlst->type), vlst->id.name, count, length); else printf("C->event->debug_terminal must be on !\n"); if(C->event->debug_console) term_log("[VLST] type:%s name:%s count:%d length:%d", data_name_get(vlst->type), vlst->id.name, count, length); if( term) term_l( term, "[VLST] type:%s name:%s count:%d length:%d", data_name_get(vlst->type), vlst->id.name, count, length); if(dat) { if(vlst->type == dt_float) { if(vlst->length == 3) { float *d=(float *)dat; for(i=0;i<count;i++) { if(C->event->debug_terminal) printf("[%d] %f %f %f\n",i,d[0],d[1],d[2]); if(C->event->debug_console) term_log("[%d] %f %f %f",i,d[0],d[1],d[2]); if( term) term_l( term, "[%d] %f %f %f",i,d[0],d[1],d[2]); d+=length; } } else if(vlst->length == 4) { float *d=(float *)dat; for(i=0;i<count;i++) { if(C->event->debug_terminal) printf("[%d] %f %f %f %f\n",i,d[0],d[1],d[2],d[3]); if(C->event->debug_console) term_log("[%d] %f %f %f %f",i,d[0],d[1],d[2],d[3]); if( term) term_l( term, "[%d] %f %f %f %f",i,d[0],d[1],d[2],d[3]); d+=length; } } } else if(vlst->type == dt_uint) { if(vlst->length == 2) { unsigned int *d=(unsigned int *)dat; for(i=0;i<count;i++) { if(C->event->debug_terminal) printf("[%d] %u %u \n",i,d[0],d[1]); if(C->event->debug_console) term_log("[%d] %u %u",i,d[0],d[1]); if( term) term_l( term, "[%d] %u %u",i,d[0],d[1]); d+=length; } } else if(vlst->length == 3) { unsigned int *d=(unsigned int *)dat; for(i=0;i<count;i++) { if(C->event->debug_terminal) printf("[%d] %u %u %u \n",i,d[0],d[1],d[2]); if(C->event->debug_console) term_log("[%d] %u %u %u",i,d[0],d[1],d[2]); if( term) term_l( term, "[%d] %u %u %u",i,d[0],d[1],d[2]); d+=length; } } else if(vlst->length == 4) { unsigned int *d=(unsigned int *)dat; for(i=0;i<count;i++) { if(C->event->debug_terminal) printf("[%d] %u %u %u %u\n",i,d[0],d[1],d[2],d[3]); if(C->event->debug_console) term_log("[%d] %u %u %u %u",i,d[0],d[1],d[2],d[3]); if( term) term_l( term, "[%d] %u %u %u %u",i,d[0],d[1],d[2],d[3]); d+=length; } } } else if(vlst->type == dt_int) { if(vlst->length == 4) { int *d=(int *)dat; for(i=0;i<count;i++) { if(C->event->debug_terminal) printf("[%d] %d %d %d %d\n",i,d[0],d[1],d[2],d[3]); if(C->event->debug_console) term_log("[%d] %d %d %d %d",i,d[0],d[1],d[2],d[3]); if( term) term_l( term, "[%d] %d %d %d %d",i,d[0],d[1],d[2],d[3]); d+=length; } } else if(vlst->length == 2) { int *d=(int *)dat; for(i=0;i<count;i++) { if(C->event->debug_terminal) printf("[%d] %d %d \n",i,d[0],d[1]); if(C->event->debug_console) term_log("[%d] %d %d",i,d[0],d[1]); if( term) term_l( term, "[%d] %d %d",i,d[0],d[1]); d+=length; } } } } else { printf("NO DATA\n"); } } }
void __cls_plug_flow_operator_get(t_plug_mode mode,t_plug *plug,t_plug *plug_src) { t_brick *brick = plug->brick; t_block *block = brick->block; t_brick *brick_indice = block_brick_get(block,"indice"); t_brick *brick_result = block_brick_get(block,"result"); t_plug *plug_result = &brick_result->plug_intern; t_plug *plug_indice = &brick_indice->plug_intern; t_lst *lst; t_vlst *vlst; // IN if(plug_src && mode == mode_in) { switch(plug_src->data_type) { // + LST case (dt_lst): // get lst lst = plug_src->data; // if lst if(lst) { if(!lst->current) { // set first if(lst->first) { lst->current = lst->first; } } else { t_link *link = lst->current; if(link->next) { lst->current = link->next; } else { // } //XXX change type plug_result->data_type=dt_camera; t_camera *camera=link->data; plug_result->data=camera; } } break; // +VLST case(dt_vlst): // get vlst vlst = plug_src->data; if(vlst) { t_plug _plug; _plug.data_type = dt_vector; // change type to vector if(brick_result->plug_intern.data_type != dt_vector) brick_type_change(brick_result,&_plug); // get indice int i = drf_int(plug_indice->data); // if < indice if(i < vlst->count) { t_vector *vector = plug_result->data; // get pointer float *ptr = vlst->data; // do pointer arithmetic vector->data = ptr + (vlst->length * i); } else { t_vector *vector = plug_result->data; set_int(plug_indice->data,vlst->count-1); float *ptr = vlst->data; vector->data = ptr + (vlst->length * (vlst->count-1)); } t_plug *plug_result_out = &brick_result->plug_out; //XXX // open vector if(plug_result_out->is_connected) { t_plug *plug_vector = plug_get_dst(plug_result); if(plug_vector->data_type == dt_vector) { t_brick *brick_vector = plug_vector->brick; t_plug *plug_vector_in = &brick_vector->plug_in; // FLOW IN plug_vector_in->flow_in=1; t_block *block_vector = brick_vector->block; t_brick *brick_x = block_brick_get(block_vector,"x"); t_brick *brick_y = block_brick_get(block_vector,"y"); t_brick *brick_z = block_brick_get(block_vector,"z"); brick_x->state.draw_value=1; brick_y->state.draw_value=1; brick_z->state.draw_value=1; brick_x->action = op_slider; brick_y->action = op_slider; brick_z->action = op_slider; } } } break; default: printf(">> %s\n",data_name_get(plug_src->data_type)); break; } } }