Beispiel #1
0
static void create_subd_mesh(Mesh *mesh, BL::Mesh b_mesh, PointerRNA *cmesh, const vector<uint>& used_shaders)
{
	/* create subd mesh */
	SubdMesh sdmesh;

	/* create vertices */
	BL::Mesh::vertices_iterator v;

	for(b_mesh.vertices.begin(v); v != b_mesh.vertices.end(); ++v)
		sdmesh.add_vert(get_float3(v->co()));

	/* create faces */
	BL::Mesh::faces_iterator f;

	for(b_mesh.faces.begin(f); f != b_mesh.faces.end(); ++f) {
		int4 vi = get_int4(f->vertices_raw());
		int n= (vi[3] == 0)? 3: 4;
		//int shader = used_shaders[f->material_index()];

		if(n == 4)
			sdmesh.add_face(vi[0], vi[1], vi[2], vi[3]);
		/*else
			sdmesh.add_face(vi[0], vi[1], vi[2]);*/
	}

	/* finalize subd mesh */
	sdmesh.link_boundary();

	/* subdivide */
	DiagSplit dsplit;
	dsplit.camera = NULL;
	dsplit.dicing_rate = RNA_float_get(cmesh, "dicing_rate");

	sdmesh.tesselate(&dsplit, false, mesh, used_shaders[0], true);
}
Beispiel #2
0
static void create_subd_mesh(Scene *scene,
                             Mesh *mesh,
                             BL::Mesh& b_mesh,
                             PointerRNA *cmesh,
                             const vector<uint>& used_shaders)
{
	/* create subd mesh */
	SubdMesh sdmesh;

	/* create vertices */
	BL::Mesh::vertices_iterator v;

	for(b_mesh.vertices.begin(v); v != b_mesh.vertices.end(); ++v)
		sdmesh.add_vert(get_float3(v->co()));

	/* create faces */
	BL::Mesh::tessfaces_iterator f;

	for(b_mesh.tessfaces.begin(f); f != b_mesh.tessfaces.end(); ++f) {
		int4 vi = get_int4(f->vertices_raw());
		int n = (vi[3] == 0) ? 3: 4;
		//int shader = used_shaders[f->material_index()];

		if(n == 4)
			sdmesh.add_face(vi[0], vi[1], vi[2], vi[3]);
		else
			sdmesh.add_face(vi[0], vi[1], vi[2]);
	}

	/* finalize subd mesh */
	sdmesh.finish();

	/* parameters */
	bool need_ptex = mesh->need_attribute(scene, ATTR_STD_PTEX_FACE_ID) ||
	                 mesh->need_attribute(scene, ATTR_STD_PTEX_UV);

	SubdParams sdparams(mesh, used_shaders[0], true, need_ptex);
	sdparams.dicing_rate = RNA_float_get(cmesh, "dicing_rate");
	//scene->camera->update();
	//sdparams.camera = scene->camera;

	/* tesselate */
	DiagSplit dsplit(sdparams);
	sdmesh.tessellate(&dsplit);
}