int model_pose_duplicate(model_type *model,int pose_idx) { int dup_pose_idx; dup_pose_idx=model_pose_add(model); if (dup_pose_idx==-1) return(-1); memmove(&model->poses[dup_pose_idx],&model->poses[pose_idx],sizeof(model_pose_type)); strcat(model->poses[dup_pose_idx].name," copy"); return(dup_pose_idx); }
void model_piece_add_pose(void) { int idx; if (model.nbone==0) { os_dialog_alert("Add Pose","You need to have at least one bone before creating a pose."); return; } idx=model_pose_add(&model); if (idx==-1) { os_dialog_alert("Add Pose","You've reached the pose limit for this model."); return; } state.model.cur_item=item_model_pose; state.model.cur_pose_idx=idx; state.model.cur_pose_bone_move_idx=-1; model_palette_scroll_into_view(item_model_pose,idx); dialog_property_string_run(list_string_value_string,(void*)model.poses[idx].name,name_str_len,0,0); }
bool read_pose_xml(model_type *model) { int n,k,t,npose,pose_idx,cnt, tag,model_head,bone_tag,poses_tag,pose_tag,constraint_bone_idx; char sub_path[1024],path[1024]; model_tag constraint_bone_tag; model_bone_move_type *bone_move; model_pose_type *pose; // load the pose xml sprintf(sub_path,"Models/%s",model->name); file_paths_data(&modelutility_settings.file_path_setup,path,sub_path,"pose","xml"); if (!xml_open_file(path)) return(FALSE); model_head=xml_findrootchild("Model"); if (model_head==-1) return(FALSE); // poses poses_tag=xml_findfirstchild("Poses",model_head); npose=xml_countchildren(poses_tag); pose_tag=xml_findfirstchild("Pose",poses_tag); for (n=0;n!=npose;n++) { // add new pose pose_idx=model_pose_add(model); if (pose_idx==-1) { xml_close_file(); return(FALSE); } pose=&model->poses[pose_idx]; // set pose data xml_get_attribute_text(pose_tag,"name",pose->name,64); bone_move=pose->bone_moves; for (k=0;k!=model->nbone;k++) { bone_move->rot.x=bone_move->rot.z=bone_move->rot.y=0.0f; bone_move->mov.x=bone_move->mov.z=bone_move->mov.y=1.0f; bone_move->acceleration=0; bone_move->skip_blended=FALSE; bone_move->constraint.bone_idx=-1; bone_move->constraint.offset.x=bone_move->constraint.offset.y=bone_move->constraint.offset.z=0; bone_move++; } bone_tag=xml_findfirstchild("Bones",pose_tag); cnt=xml_countchildren(bone_tag); tag=xml_findfirstchild("Bone",bone_tag); for (k=0;k!=cnt;k++) { t=model_find_bone(model,xml_get_attribute_model_tag(tag,"tag")); if (t!=-1) { bone_move=&pose->bone_moves[t]; xml_get_attribute_3_coord_float(tag,"rot",&bone_move->rot.x,&bone_move->rot.y,&bone_move->rot.z); xml_get_attribute_3_coord_float(tag,"move",&bone_move->mov.x,&bone_move->mov.y,&bone_move->mov.z); bone_move->acceleration=xml_get_attribute_float(tag,"acceleration"); bone_move->skip_blended=xml_get_attribute_boolean(tag,"skip_blended"); bone_move->constraint.bone_idx=-1; bone_move->constraint.offset.x=bone_move->constraint.offset.y=bone_move->constraint.offset.z=0; constraint_bone_tag=xml_get_attribute_model_tag(tag,"constraint_bone"); if (constraint_bone_tag!=model_null_tag) { constraint_bone_idx=model_find_bone(model,constraint_bone_tag); if (constraint_bone_idx!=-1) { bone_move->constraint.bone_idx=constraint_bone_idx; xml_get_attribute_3_coord_int(tag,"constraint_offset",&bone_move->constraint.offset.x,&bone_move->constraint.offset.y,&bone_move->constraint.offset.z); } } } tag=xml_findnextchild(tag); } pose_tag=xml_findnextchild(pose_tag); } xml_close_file(); return(TRUE); }