示例#1
0
void bitmap_texture_write_xml(texture_type *texture,int frame_count,bool write_scale)
{
	int						k;
	
		// settings
		
	xml_add_attribute_boolean("animate",texture->animate.on);
	xml_add_attribute_boolean("additive",texture->additive);
	xml_add_attribute_boolean("pixelated",texture->pixelated);
	xml_add_attribute_boolean("compress",texture->compress);
	xml_add_attribute_boolean("flip_normal",texture->flip_normal);

	xml_add_attribute_float("shine_factor",texture->shine_factor);
	xml_add_attribute_list("rl_alpha_type",(char*)rtl_alpha_list_str,texture->rl_alpha_type);
	xml_add_attribute_float("rl_refract_factor",texture->rl_refract_factor);
	
	xml_add_attribute_int("glow_rate",texture->glow.rate);
	xml_add_attribute_float("glow_min",texture->glow.min);
	xml_add_attribute_float("glow_max",texture->glow.max);
	
	xml_add_attribute_text("shader",texture->shader_name);
	xml_add_attribute_text("material_name",texture->material_name);
	
	xml_add_tagend(FALSE);

		// scale
		
	if (write_scale) {
		xml_add_tagstart("Scale");
		xml_add_attribute_float("x",texture->scale.uv_size.x);
		xml_add_attribute_float("y",texture->scale.uv_size.y);
		xml_add_attribute_float("x_off",texture->scale.uv_offset.x);
		xml_add_attribute_float("y_off",texture->scale.uv_offset.y);
		xml_add_tagend(TRUE);
	}
	
		// images
		
	xml_add_tagstart("Images");
	xml_add_tagend(FALSE);
		
	for (k=0;k!=frame_count;k++) {
		xml_add_tagstart("Image");
		if (texture->animate.wait[k]!=0) xml_add_attribute_int("wait",texture->animate.wait[k]);
		if (texture->frames[k].name[0]!=0x0) xml_add_attribute_text("bitmap",texture->frames[k].name);
		xml_add_tagend(TRUE);
	}
	
	xml_add_tagclose("Images");
}
示例#2
0
void encode_mesh_v2_xml(model_type *model)
{
	int						i,n,k,j,frame_count;
	char					tag_name[32];
	model_hit_box_type		*hit_box;
	model_mesh_type			*mesh;
    model_vertex_type		*vertex;
	model_material_type		*material;
    model_bone_type			*bone;
    model_trig_type			*trig;
    texture_type			*texture;
    
        // model info
    
    xml_add_tagstart("Creator");
    xml_add_attribute_text("name","dim3 Animator");
    xml_add_attribute_text("version","1.0");
    xml_add_tagend(TRUE);
	
        // options
    
    xml_add_tagstart("Options");
	xml_add_attribute_list("deform",(char*)deform_mode_str,model->deform_mode);
    xml_add_tagend(TRUE);
 	
        // center
	
    xml_add_tagstart("Center");
    xml_add_attribute_3_coord_int("offset",model->center.x,model->center.y,model->center.z);
    xml_add_tagend(TRUE);
    
        // boxes
    
    xml_add_tagstart("View_Box");
    xml_add_attribute_3_coord_int("size",model->view_box.size.x,model->view_box.size.y,model->view_box.size.z);
    xml_add_attribute_3_coord_int("offset",model->view_box.offset.x,model->view_box.offset.y,model->view_box.offset.z);
    xml_add_tagend(TRUE);
	
		// light
	
    xml_add_tagstart("Light");

	for (k=0;k!=max_model_light;k++) {
		if (k==0) {
			strcpy(tag_name,"light_bone");
		}
		else {
			sprintf(tag_name,"light_bone_%d",k);
		}
		xml_add_attribute_model_tag(tag_name,model->tags.light_bone_tag[k]);
	}

	for (k=0;k!=max_model_halo;k++) {
		if (k==0) {
			strcpy(tag_name,"halo_bone");
		}
		else {
			sprintf(tag_name,"halo_bone_%d",k);
		}
 		xml_add_attribute_model_tag(tag_name,model->tags.halo_bone_tag[k]);
	}

 	xml_add_attribute_model_tag("name_bone",model->tags.name_bone_tag);

	xml_add_tagend(TRUE);
	
		// hit boxes
		
    xml_add_tagstart("Hit_Boxes");
    xml_add_tagend(FALSE);
    
    hit_box=model->hit_boxes;
    
    for (i=0;i!=model->nhit_box;i++) {
		xml_add_tagstart("Hit_Box");
		xml_add_attribute_text("name",hit_box->name);
		xml_add_attribute_3_coord_int("size",hit_box->box.size.x,hit_box->box.size.y,hit_box->box.size.z);
		xml_add_attribute_3_coord_int("offset",hit_box->box.offset.x,hit_box->box.offset.y,hit_box->box.offset.z);
		xml_add_tagend(TRUE);
		
		hit_box++;
	}
	
    xml_add_tagclose("Hit_Boxes");
    
        // bones
        
    xml_add_tagstart("Bones");
    xml_add_tagend(FALSE);
    
    bone=model->bones;
    
    for (i=0;i!=model->nbone;i++) {
    
        xml_add_tagstart("Bone");
        
        xml_add_attribute_model_tag("tag",bone->tag);
		xml_add_attribute_text("name",bone->name);
		
        xml_add_attribute_3_coord_int("c3",bone->pnt.x,bone->pnt.y,bone->pnt.z);
		
        if (bone->parent_idx!=-1) xml_add_attribute_model_tag("parent",model->bones[bone->parent_idx].tag);
        
        xml_add_tagend(TRUE);
    
        bone++;
    }

    xml_add_tagclose("Bones");
	
        // meshes
        
    xml_add_tagstart("Meshes");
    xml_add_tagend(FALSE);
	
	for (j=0;j!=model->nmesh;j++) {
	
		mesh=&model->meshes[j];
	
		xml_add_tagstart("Mesh");
		xml_add_attribute_text("name",mesh->name);
		xml_add_attribute_boolean("no_lighting",mesh->no_lighting);
		xml_add_attribute_boolean("additive",mesh->blend_add);
		xml_add_attribute_boolean("tintable",mesh->tintable);
		xml_add_tagend(FALSE);
	   
			// vertexes
			
		xml_add_tagstart("Vertexes");
		xml_add_tagend(FALSE);
		
		vertex=mesh->vertexes;
		
		for (i=0;i!=mesh->nvertex;i++) {
		
			xml_add_tagstart("v");
			
			xml_add_attribute_3_coord_int("c3",vertex->pnt.x,vertex->pnt.y,vertex->pnt.z);
			xml_add_attribute_3_coord_float("n3",vertex->normal.x,vertex->normal.y,vertex->normal.z);

			if (vertex->major_bone_idx!=-1) {
				xml_add_attribute_model_tag("major",model->bones[vertex->major_bone_idx].tag);
			}
			if (vertex->minor_bone_idx!=-1) {
				xml_add_attribute_model_tag("minor",model->bones[vertex->minor_bone_idx].tag);
				xml_add_attribute_float("factor",vertex->bone_factor);
			}
			
			xml_add_tagend(TRUE);
		
			vertex++;
		}
						
		xml_add_tagclose("Vertexes");
		
			// materials
			
		xml_add_tagstart("Materials");
		xml_add_tagend(FALSE);
		
		texture=model->textures;
		material=mesh->materials;
		
		for (n=0;n!=max_model_texture;n++) {
		
			if (texture->frames[0].name[0]==0x0) {
				texture++;
				material++;
				continue;
			}
			
			xml_add_tagstart("Material");
			xml_add_tagend(FALSE);

				// triangles
				
			xml_add_tagstart("Triangles");
			xml_add_tagend(FALSE);
		
			trig=&mesh->trigs[material->trig_start];
		
			for (i=0;i!=material->trig_count;i++) {
		
				for (k=0;k!=3;k++) {
					xml_add_tagstart("v");
					
					xml_add_attribute_int("id",trig->v[k]);
					xml_add_attribute_2_coord_float("uv",trig->gx[k],trig->gy[k]);
					
					xml_add_tagend(TRUE);
				}
				
				trig++;
			}
			
			xml_add_tagclose("Triangles");
			xml_add_tagclose("Material");
			
			texture++;
			material++;
		}
		
		xml_add_tagclose("Materials");
		
		xml_add_tagclose("Mesh");
	}
	
	xml_add_tagclose("Meshes");
   
         // fills
         
    xml_add_tagstart("Fills");
    xml_add_tagend(FALSE);
    
    texture=model->textures;
    
    for (n=0;n!=max_model_texture;n++) {
    
        if (texture->frames[0].name[0]==0x0) {
            texture++;
            continue;
        }

		frame_count=model_count_texture_frames(model,n);
        
        xml_add_tagstart("Fill");
		bitmap_texture_write_xml(texture,frame_count,FALSE);
        xml_add_tagclose("Fill");
        
		texture++;
    }
    
    xml_add_tagclose("Fills");
}