void Renderer::dummyPhongShader()
	{
		CM_TRACE_FUNC("Renderer::dummyPhongShader()");

		_s("//----------------phong_shader_for_test begin---");
		_S( ei_shader("phong_shader_for_test") );
		_S( ei_shader_param_string("desc", "plastic") );
		_S( ei_shader_param_vector("Cs", 1.0f, 0.2f, 0.3f) );
		_S( ei_shader_param_vector("Kd", 0.7f, 1.0f, 1.0f) );
		_S( ei_shader_param_scalar("Ks", 1.0f) );
		_S( ei_shader_param_scalar("roughness", 0.2f) );
		_S( ei_end_shader() );

		_S( ei_shader("opaque_shadow_for_test") );
		_S( ei_shader_param_string("desc", "opaque") );
		_S( ei_end_shader() );

		_S( ei_material("phong_mtl_for_test") );
		_S( ei_add_surface("phong_shader_for_test") );
		_S( ei_add_shadow("opaque_shadow_for_test") );
		_S( ei_end_material() );
		_s("//----------------phong_shader_for_test end ---");
	}
void ei_dof_unittest()
{
    char	cur_dir[ EI_MAX_FILE_NAME_LEN ];
    char	output_filename[ EI_MAX_FILE_NAME_LEN ];

    ei_get_current_directory(cur_dir);

    ei_context(ei_create_context());

    ei_verbose(EI_VERBOSE_ALL);
    ei_link("eiIMG");
    ei_link("eiSHADER");

    ei_options("opt");
    ei_samples(0, 2);
    ei_contrast(0.05f, 0.05f, 0.05f, 0.05f);
    ei_filter(EI_FILTER_GAUSSIAN, 3.0f);
    ei_end_options();

    ei_shader("dof_shader");
    ei_shader_param_string("desc", "simple_dof");
    ei_shader_param_scalar("fplane", 0.1f);
    ei_end_shader();

    ei_camera("cam1");
    ei_append_filename(output_filename, cur_dir, "frame_dof01.bmp");
    ei_output(output_filename, "bmp", EI_IMG_DATA_RGB);
    ei_output_variable("color", EI_DATA_TYPE_VECTOR);
    ei_end_output();
    ei_focal(100.0f);
    ei_aperture(144.724029f);
    ei_aspect(800.0f / 600.0f);
    ei_resolution(800, 600);
    ei_clip(0.1,1000);
    ei_add_lens("dof_shader");
    ei_end_camera();

    ei_instance("caminst1");
    ei_element("cam1");
    ei_end_instance();

    ei_shader("point_light_shader");
    ei_shader_param_string("desc", "pointlight");
    ei_shader_param_scalar("intensity", 1.0f);
    ei_shader_param_vector("lightcolor", 1.0f, 1.0f, 1.0f);
    ei_end_shader();

    ei_light("light1");
    ei_add_light("point_light_shader");
    ei_origin(141.375732f, 83.116005f, 35.619434f);
    ei_end_light();

    ei_instance("lightinst1");
    ei_element("light1");
    ei_end_instance();

    ei_shader("phong_shader");
    ei_shader_param_string("desc", "plastic");
    ei_shader_param_vector("Cs", 1.0f, 0.2f, 0.3f);
    ei_shader_param_vector("Kd", 0.7f, 1.0f, 1.0f);
    ei_shader_param_scalar("Ks", 1.0f);
    ei_shader_param_scalar("roughness", 0.2f);
    ei_end_shader();

    ei_shader("opaque_shadow");
    ei_shader_param_string("desc", "opaque");
    ei_end_shader();

    ei_material("mtl");
    ei_add_surface("phong_shader");
    ei_add_shadow("opaque_shadow");
    ei_end_material();

    ei_object("obj1", "poly");
    ei_pos_list(ei_tab(EI_DATA_TYPE_VECTOR, 1024));
    ei_tab_add_vector(-7.068787f, -4.155799f, -22.885710f);
    ei_tab_add_vector(-0.179573f, -7.973234f, -16.724060f);
    ei_tab_add_vector(-7.068787f, 4.344949f, -17.619093f);
    ei_tab_add_vector(-0.179573f, 0.527515f, -11.457443f);
    ei_tab_add_vector(0.179573f, -0.527514f, -28.742058f);
    ei_tab_add_vector(7.068787f, -4.344948f, -22.580408f);
    ei_tab_add_vector(0.179573f, 7.973235f, -23.475441f);
    ei_tab_add_vector(7.068787f, 4.155800f, -17.313791f);
    ei_end_tab();
    ei_triangle_list(ei_tab(EI_DATA_TYPE_INDEX, 1024));
    ei_tab_add_index(0);
    ei_tab_add_index(1);
    ei_tab_add_index(3);
    ei_tab_add_index(0);
    ei_tab_add_index(3);
    ei_tab_add_index(2);
    ei_tab_add_index(1);
    ei_tab_add_index(5);
    ei_tab_add_index(7);
    ei_tab_add_index(1);
    ei_tab_add_index(7);
    ei_tab_add_index(3);
    ei_tab_add_index(5);
    ei_tab_add_index(4);
    ei_tab_add_index(6);
    ei_tab_add_index(5);
    ei_tab_add_index(6);
    ei_tab_add_index(7);
    ei_tab_add_index(4);
    ei_tab_add_index(0);
    ei_tab_add_index(2);
    ei_tab_add_index(4);
    ei_tab_add_index(2);
    ei_tab_add_index(6);
    ei_tab_add_index(4);
    ei_tab_add_index(5);
    ei_tab_add_index(1);
    ei_tab_add_index(4);
    ei_tab_add_index(1);
    ei_tab_add_index(0);
    ei_tab_add_index(2);
    ei_tab_add_index(3);
    ei_tab_add_index(7);
    ei_tab_add_index(2);
    ei_tab_add_index(7);
    ei_tab_add_index(6);
    ei_end_tab();
    ei_end_object();

    ei_instance("inst1");
    ei_add_material("mtl");
    ei_element("obj1");
    ei_end_instance();

    ei_instgroup("world");
    ei_add_instance("caminst1");
    ei_add_instance("lightinst1");
    ei_add_instance("inst1");
    ei_end_instgroup();

    // render frame 01
    ei_render("world", "caminst1", "opt");

    ei_delete_context(ei_context(NULL));
}
void spotlight_test2()
{
	//    Generated by Liquid v2.3.5 (buildtime=22:30:18.85)
	//    Scene : E:/MyDocuments/maya/projects/default/er_spotlight_one
	//    User  : yaoyansi
	//    Time  : Mon Feb 27 22:46:59 2012

	//### SCENE BEGIN ###
	eiContext *CONTEXT = ei_create_context();
	ei_context(CONTEXT);
	//ei_set_connection( &(MayaConnection::getInstance()->connection.base );
	ei_verbose( 6 );
	ei_link( "eiIMG" );
	ei_link( "eiSHADER" );
// 	ei_link( "eiSHADER_maya" );
// 	//----------------phong_shader_for_test begin---
// 	ei_shader("phong_shader_for_test");
// 	ei_shader_param_string("desc","plastic");
// 	ei_shader_param_vector("Cs",1,0.2,0.3);
// 	ei_shader_param_vector("Kd",0.7,1,1);
// 	ei_shader_param_scalar("Ks",1);
// 	ei_shader_param_scalar("roughness",0.2);
// 	ei_end_shader();
// 	ei_shader("opaque_shadow_for_test");
// 	ei_shader_param_string("desc","opaque");
// 	ei_end_shader();
// 	ei_material("phong_mtl_for_test");
// 	ei_add_surface("phong_shader_for_test");
// 	ei_add_shadow("opaque_shadow_for_test");
// 	ei_end_material();
// 	//----------------phong_shader_for_test end ---

	//############################### option #
	ei_options("perspShape_option");
	ei_contrast(0.05,0.05,0.05,0.05);
	ei_samples(0,2);
#ifdef UAE_ESS_DADA
#else
	ei_filter(4,3);
	//transform motion=0, deform motion=0
	ei_motion(0);
	ei_trace_depth(4,4,4);
	ei_displace(1);
	ei_max_displace(1);
	ei_face(3);
#endif
	ei_end_options();
	// maya settings: focal=35, aperture = 36, aspect=1.33333
	//Depth of Field on camera "|persp|perspShape" is turned off in Maya

	//############################### camera #
	ei_camera("|persp|perspShape_object");
	ei_output("E:/MyDocuments/maya/projects/default/rmanpix/er_spotlight_one.perspShape.1.elvishray-2.bmp","bmp",1);
	ei_output_variable("color",10);
	ei_end_output();
#ifdef UAE_ESS_DADA
	ei_focal(1.000000);
	ei_aperture(0.828427);
	ei_aspect(1.33333);
	ei_resolution(640,480);
	//ei_clip(0.1,1000);
#else
	ei_focal(35);
	ei_aperture(36);
	ei_aspect(1.33333);
	ei_resolution(768,576);
	ei_clip(0.1,1000);
#endif
	ei_end_camera();
	//----------------------------------
	ei_instance("|persp|perspShape");
	ei_element("|persp|perspShape_object");
#ifdef UAE_ESS_DADA
	ei_transform(
		0.965926,-0.258819,-0.000000,0.000000,
		0.117501,0.438521,0.891007, 0.000000,
		-0.230609, -0.860646, 0.453990, 0.000000,
		-73.653915, -319.819275, 185.246506, 1.000000
	);
#else
	ei_transform(0.736097,1.38778e-017,0.676876,0,   0.185872,0.961558,-0.202134,0,   -0.650855,0.274603,0.7078,0,   -7.39524,3.14342,5.02456,1);
#endif	
	ei_end_instance();
	//
	// shader(plastic,, ...)
	ei_shader("liquidSurface1");
	ei_shader_param_string( "desc","plastic");
	ei_shader_param_vector("Cs",1,0,0);
	ei_shader_param_vector("Kd",1,1,1);
	ei_shader_param_scalar("Ks",0.5);
	ei_shader_param_scalar("roughness",0.1);
	ei_shader_param_vector("specularcolor",1,1,1);
	ei_end_shader();
	// shader(opaque,, ...)
	ei_shader("liquidSurface2");
	ei_shader_param_string( "desc","opaque");
	ei_end_shader();
	// shader(plastic,, ...)
	ei_shader("liquidSurface3");
	ei_shader_param_string( "desc","plastic");
	ei_shader_param_vector("Cs",0,0,1);
	ei_shader_param_vector("Kd",1,1,1);
	ei_shader_param_scalar("Ks",0.5);
	ei_shader_param_scalar("roughness",0.1);
	ei_shader_param_vector("specularcolor",1,1,1);
	ei_end_shader();

	ei_material("liquidSurface3SG");
	ei_add_surface("liquidSurface3");
	ei_end_material();
	ei_material("liquidSurface1SG");
	ei_add_surface("liquidSurface1");
	ei_add_shadow("liquidSurface2");
	ei_end_material();

	// Renderer::exportLight("_spotLight2_spotLightShape2");

	// Renderer::exportSpotLight()
	ei_shader("|spotLight2|spotLightShape2_shader");
#ifdef UAE_ESS_DADA
	ei_shader_param_string("desc","spotlight");
	ei_shader_param_vector("lightcolor",1,1,1);
	ei_shader_param_scalar("intensity",1);
	ei_shader_param_scalar("deltaangle",0.114319);
	ei_shader_param_vector("direction",0,0,-1);
	ei_shader_param_scalar("spread",0.489565);
#else
	ei_shader_param_string("desc","spotlight");
	ei_shader_param_vector("lightcolor",1,1,1);
	ei_shader_param_scalar("intensity",1);
	ei_shader_param_scalar("deltaangle",0.00152309);
	ei_shader_param_vector("direction",0,0,-1);
	ei_shader_param_scalar("spread",0.0190323);
#endif
	ei_end_shader();
	ei_light("|spotLight2|spotLightShape2_object");
	ei_add_light("|spotLight2|spotLightShape2_shader" );
#ifdef UAE_ESS_DADA
	ei_origin( 0.000000, 0.000000, 0.000000);
#else
	ei_transform(1,0,0,0,   0,1,0,0,   0,0,1,0,   0,0,0,1);
#endif
	ei_end_light();
	ei_instance("|spotLight2|spotLightShape2");
	ei_element("|spotLight2|spotLightShape2_object");
#ifdef UAE_ESS_DADA
	ei_transform(
		1.000000,0.000000,0.000000,0.000000,
		0.000000,1.000000,0.000000,0.000000,
		0.000000,0.000000,1.000000,0.000000,
		4.059041,1.106999,271.584686,1.000000
		);
#else

#endif
	ei_end_instance();

	// Renderer::exportOneGeometry_Mesh(|pCube1|pCubeShape1,0,0)

	//############################### mesh #
	ei_object("pCubeShape1_object","poly");
	{
		eiTag tag;
		//### vertex positions, fnMesh.numVertices()=8
		tag = ei_tab(EI_DATA_TYPE_VECTOR, 1024);
		//tag=220
		ei_pos_list(tag);
		ei_tab_add_vector(-0.5,-0.5,0.5);
		ei_tab_add_vector(0.5,-0.5,0.5);
		ei_tab_add_vector(-0.5,0.5,0.5);
		ei_tab_add_vector(0.5,0.5,0.5);
		ei_tab_add_vector(-0.5,0.5,-0.5);
		ei_tab_add_vector(0.5,0.5,-0.5);
		ei_tab_add_vector(-0.5,-0.5,-0.5);
		ei_tab_add_vector(0.5,-0.5,-0.5);
		ei_end_tab();
		//### UV, size=14
		tag = eiNULL_TAG;
		ei_declare("u",2,5, &tag);
		tag = ei_tab(EI_DATA_TYPE_SCALAR, 1024);
		//tag=224
		ei_variable("u", &tag);
		ei_tab_add_scalar(0.375);
		ei_tab_add_scalar(0.625);
		ei_tab_add_scalar(0.375);
		ei_tab_add_scalar(0.625);
		ei_tab_add_scalar(0.375);
		ei_tab_add_scalar(0.625);
		ei_tab_add_scalar(0.375);
		ei_tab_add_scalar(0.625);
		ei_tab_add_scalar(0.375);
		ei_tab_add_scalar(0.625);
		ei_tab_add_scalar(0.875);
		ei_tab_add_scalar(0.875);
		ei_tab_add_scalar(0.125);
		ei_tab_add_scalar(0.125);
		ei_end_tab();
		tag = eiNULL_TAG;
		ei_declare("v",2,5, &tag);
		tag = ei_tab(EI_DATA_TYPE_SCALAR, 1024);
		//tag=226
		ei_variable("v", &tag);
		ei_tab_add_scalar(0);
		ei_tab_add_scalar(0);
		ei_tab_add_scalar(0.25);
		ei_tab_add_scalar(0.25);
		ei_tab_add_scalar(0.5);
		ei_tab_add_scalar(0.5);
		ei_tab_add_scalar(0.75);
		ei_tab_add_scalar(0.75);
		ei_tab_add_scalar(1);
		ei_tab_add_scalar(1);
		ei_tab_add_scalar(0);
		ei_tab_add_scalar(0.25);
		ei_tab_add_scalar(0);
		ei_tab_add_scalar(0.25);
		ei_end_tab();
		//### triangles, size=[2, 2, 2, 2, 2, 2]
		tag = ei_tab(EI_DATA_TYPE_INDEX, 1024);
		//tag=228
		ei_triangle_list(tag);
		ei_tab_add_index(0);
		ei_tab_add_index(1);
		ei_tab_add_index(2);
		ei_tab_add_index(2);
		ei_tab_add_index(1);
		ei_tab_add_index(3);
		ei_tab_add_index(2);
		ei_tab_add_index(3);
		ei_tab_add_index(4);
		ei_tab_add_index(4);
		ei_tab_add_index(3);
		ei_tab_add_index(5);
		ei_tab_add_index(4);
		ei_tab_add_index(5);
		ei_tab_add_index(6);
		ei_tab_add_index(6);
		ei_tab_add_index(5);
		ei_tab_add_index(7);
		ei_tab_add_index(6);
		ei_tab_add_index(7);
		ei_tab_add_index(0);
		ei_tab_add_index(0);
		ei_tab_add_index(7);
		ei_tab_add_index(1);
		ei_tab_add_index(1);
		ei_tab_add_index(7);
		ei_tab_add_index(3);
		ei_tab_add_index(3);
		ei_tab_add_index(7);
		ei_tab_add_index(5);
		ei_tab_add_index(6);
		ei_tab_add_index(0);
		ei_tab_add_index(4);
		ei_tab_add_index(4);
		ei_tab_add_index(0);
		ei_tab_add_index(2);
		ei_end_tab();
	}//pCubeShape1_object
	ei_end_object();
	//--------------------------
	ei_instance("pCubeShape1");
	ei_add_material("liquidSurface1SG");
	ei_element("pCubeShape1_object");
	ei_transform(0.767864,0,-0.502506,0,   0,0.917675,0,0,   0.502506,0,0.767864,0,   0.0691485,0.091951,-2.25972,1);
	//ribNode->doDef=205, ribNode->doMotion=205
	ei_motion(1);
	ei_end_instance();
	//

	// Renderer::exportOneGeometry_Mesh(|pPlane1|pPlaneShape1,0,0)

	//############################### mesh #
	ei_object("pPlaneShape1_object","poly");
	{
		eiTag tag;
		//### vertex positions, fnMesh.numVertices()=4
		tag = ei_tab(EI_DATA_TYPE_VECTOR, 1024);
		//tag=233
		ei_pos_list(tag);
#ifdef UAE_ESS_DADA
ei_tab_add_vector(-122.330475,-116.084732,0.000000);
ei_tab_add_vector(-61.165237,-116.084732,0.000000);
ei_tab_add_vector(0.000000,-116.084732,0.000000);
ei_tab_add_vector(61.165237,-116.084732,0.000000);
ei_tab_add_vector(122.330475,-116.084732,0.000000);
ei_tab_add_vector(-122.330475,-58.042366,0.000000);
ei_tab_add_vector(-61.165237,-58.042366,0.000000);
ei_tab_add_vector(0.000000,-58.042366,0.000000);
ei_tab_add_vector(61.165237,-58.042366,0.000000);
ei_tab_add_vector(122.330475,-58.042366,0.000000);
ei_tab_add_vector(-122.330475,0.000000,0.000000);
ei_tab_add_vector(-61.165237,0.000000,0.000000);
ei_tab_add_vector(0.000000,0.000000,0.000000);
ei_tab_add_vector(61.165237,0.000000,0.000000);
ei_tab_add_vector(122.330475,0.000000,0.000000);
ei_tab_add_vector(-122.330475,58.042366,0.000000);
ei_tab_add_vector(-61.165237,58.042366,0.000000);
ei_tab_add_vector(0.000000,58.042366,0.000000);
ei_tab_add_vector(61.165237,58.042366,0.000000);
ei_tab_add_vector(122.330475,58.042366,0.000000);
ei_tab_add_vector(-122.330475,116.084732,0.000000);
ei_tab_add_vector(-61.165237,116.084732,0.000000);
ei_tab_add_vector(0.000000,116.084732,0.000000);
ei_tab_add_vector(61.165237,116.084732,0.000000);
ei_tab_add_vector(122.330475,116.084732,0.000000);
#else
		ei_tab_add_vector(-4.76676,-1.12863e-015,5.08292);
		ei_tab_add_vector(4.76676,-1.12863e-015,5.08292);
		ei_tab_add_vector(-4.76676,1.12863e-015,-5.08292);
		ei_tab_add_vector(4.76676,1.12863e-015,-5.08292);
#endif
		ei_end_tab();
		//### N
		tag = eiNULL_TAG;
		ei_declare("N",2,5, &tag);
		tag = ei_tab(EI_DATA_TYPE_VECTOR, 1024);
		//tag=235
		ei_variable("N", &tag);
#ifdef UAE_ESS_DADA
		ei_tab_add_vector(0.000000, 0.000000, 1.000000);
		ei_tab_add_vector(0.000000, 0.000000, 1.000000);
		ei_tab_add_vector(0.000000, 0.000000, 1.000000);
		ei_tab_add_vector(0.000000, 0.000000, 1.000000);
		ei_tab_add_vector(0.000000, 0.000000, 1.000000);
		ei_tab_add_vector(0.000000, 0.000000, 1.000000);
		ei_tab_add_vector(0.000000, 0.000000, 1.000000);
		ei_tab_add_vector(0.000000, 0.000000, 1.000000);
		ei_tab_add_vector(0.000000, 0.000000, 1.000000);
		ei_tab_add_vector(0.000000, 0.000000, 1.000000);
		ei_tab_add_vector(0.000000, 0.000000, 1.000000);
		ei_tab_add_vector(0.000000, 0.000000, 1.000000);
		ei_tab_add_vector(0.000000, 0.000000, 1.000000);
		ei_tab_add_vector(0.000000, 0.000000, 1.000000);
		ei_tab_add_vector(0.000000, 0.000000, 1.000000);
		ei_tab_add_vector(0.000000, 0.000000, 1.000000);
		ei_tab_add_vector(0.000000, 0.000000, 1.000000);
		ei_tab_add_vector(0.000000, 0.000000, 1.000000);
		ei_tab_add_vector(0.000000, 0.000000, 1.000000);
		ei_tab_add_vector(0.000000, 0.000000, 1.000000);
		ei_tab_add_vector(0.000000, 0.000000, 1.000000);
		ei_tab_add_vector(0.000000, 0.000000, 1.000000);
		ei_tab_add_vector(0.000000, 0.000000, 1.000000);
		ei_tab_add_vector(0.000000, 0.000000, 1.000000);
		ei_tab_add_vector(0.000000, 0.000000, 1.000000);
#else
		ei_tab_add_vector(0,1,2.22045e-016);
		ei_tab_add_vector(0,1,2.22045e-016);
		ei_tab_add_vector(0,1,2.22045e-016);
		ei_tab_add_vector(0,1,2.22045e-016);
#endif
		ei_end_tab();

#ifdef UAE_ESS_DADA

#else		//### UV, size=4
		tag = eiNULL_TAG;
		ei_declare("u",2,5, &tag);
		tag = ei_tab(EI_DATA_TYPE_SCALAR, 1024);
		//tag=237
		ei_variable("u", &tag);
		ei_tab_add_scalar(0);
		ei_tab_add_scalar(0.937799);
		ei_tab_add_scalar(0);
		ei_tab_add_scalar(0.937799);
		ei_end_tab();
		tag = eiNULL_TAG;
		ei_declare("v",2,5, &tag);
		tag = ei_tab(EI_DATA_TYPE_SCALAR, 1024);
		//tag=239
		ei_variable("v", &tag);
		ei_tab_add_scalar(0);
		ei_tab_add_scalar(0);
		ei_tab_add_scalar(1);
		ei_tab_add_scalar(1);
		ei_end_tab();
#endif
		//### triangles, size=[2]
		tag = ei_tab(EI_DATA_TYPE_INDEX, 1024);
		//tag=241
		ei_triangle_list(tag);
#ifdef UAE_ESS_DADA
			ei_tab_add_index(5);ei_tab_add_index(0);ei_tab_add_index(6);
			ei_tab_add_index(1);ei_tab_add_index(6);ei_tab_add_index(0);
			ei_tab_add_index(6);ei_tab_add_index(1);ei_tab_add_index(7);
			ei_tab_add_index(2);ei_tab_add_index(7);ei_tab_add_index(1);
			ei_tab_add_index(7);ei_tab_add_index(2);ei_tab_add_index(8);
			ei_tab_add_index(3);ei_tab_add_index(8);ei_tab_add_index(2);
			ei_tab_add_index(8);ei_tab_add_index(3);ei_tab_add_index(9);
			ei_tab_add_index(4);ei_tab_add_index(9);ei_tab_add_index(3);
			ei_tab_add_index(10);ei_tab_add_index(5);ei_tab_add_index(11);
			ei_tab_add_index(6);ei_tab_add_index(11);ei_tab_add_index(5);
			ei_tab_add_index(11);ei_tab_add_index(6);ei_tab_add_index(12);
			ei_tab_add_index(7);ei_tab_add_index(12);ei_tab_add_index(6);
			ei_tab_add_index(12);ei_tab_add_index(7);ei_tab_add_index(13);
			ei_tab_add_index(8);ei_tab_add_index(13);ei_tab_add_index(7);
			ei_tab_add_index(13);ei_tab_add_index(8);ei_tab_add_index(14);
			ei_tab_add_index(9);ei_tab_add_index(14);ei_tab_add_index(8);
			ei_tab_add_index(15);ei_tab_add_index(10);ei_tab_add_index(16);
			ei_tab_add_index(11);ei_tab_add_index(16);ei_tab_add_index(10);
			ei_tab_add_index(16);ei_tab_add_index(11);ei_tab_add_index(17);
			ei_tab_add_index(12);ei_tab_add_index(17);ei_tab_add_index(11);
			ei_tab_add_index(17);ei_tab_add_index(12);ei_tab_add_index(18);
			ei_tab_add_index(13);ei_tab_add_index(18);ei_tab_add_index(12);
			ei_tab_add_index(18);ei_tab_add_index(13);ei_tab_add_index(19);
			ei_tab_add_index(14);ei_tab_add_index(19);ei_tab_add_index(13);
			ei_tab_add_index(20);ei_tab_add_index(15);ei_tab_add_index(21);
			ei_tab_add_index(16);ei_tab_add_index(21);ei_tab_add_index(15);
			ei_tab_add_index(21);ei_tab_add_index(16);ei_tab_add_index(22);
			ei_tab_add_index(17);ei_tab_add_index(22);ei_tab_add_index(16);
			ei_tab_add_index(22);ei_tab_add_index(17);ei_tab_add_index(23);
			ei_tab_add_index(18);ei_tab_add_index(23);ei_tab_add_index(17);
			ei_tab_add_index(23);ei_tab_add_index(18);ei_tab_add_index(24);
			ei_tab_add_index(19);ei_tab_add_index(24);ei_tab_add_index(18);
#else	
		ei_tab_add_index(0);
		ei_tab_add_index(1);
		ei_tab_add_index(2);
		ei_tab_add_index(2);
		ei_tab_add_index(1);
		ei_tab_add_index(3);
#endif
		ei_end_tab();
	}//pPlaneShape1_object
	ei_end_object();
	//--------------------------
	ei_instance("pPlaneShape1");
	ei_add_material("liquidSurface3SG");
	ei_element("pPlaneShape1_object");
#ifdef UAE_ESS_DADA
	ei_transform(
		1.000000,0.000000,0.000000,0.000000,
		0.000000,1.000000,0.000000,0.000000,
		0.000000,0.000000,1.000000,0.000000,
		5.742889,6.604416,0.000000,1.000000
	);
#else	
	ei_transform(1,0,0,0,   0,1,0,0,   0,0,1,0,   0.747431,-0.565344,-3.9602,1);
#endif
	//ribNode->doDef=205, ribNode->doMotion=205
	ei_motion(1);
	ei_end_instance();
	//

	//Renderer::worldEpilogue()
	ei_instgroup("perspShape");
	//camera
	ei_add_instance("|persp|perspShape");
	//lightlinks and meshes
	ei_add_instance("|spotLight2|spotLightShape2");
	//ei_add_instance("pCubeShape1");
	//lightlinks and meshes
	//ei_add_instance("|spotLight2|spotLightShape2");
	ei_add_instance("pPlaneShape1");
	ei_end_instgroup( );
	ei_render("perspShape", "|persp|perspShape", "perspShape_option");
	ei_delete_context(CONTEXT);

}
	void Renderer::_UserDefinedShader(
		const liqShader &shader,
		const std::vector<liqTokenPointer> &tokenPointerArray
	)
	{	
		CM_TRACE_FUNC("Renderer::_UserDefinedShader("<<shader.getName()<<", tokenPointerArray)");

		std::string const& liquidShaderName=shader.getName();
		std::string const& rmSloFilePath=shader.getShaderFileName();
		std::string const& mayaShaderName=rmSloFilePath.substr(rmSloFilePath.find_last_of('/')+1);
		_s( "// shader("<<mayaShaderName<<","<<", ...)" );//Renderman slo file name, e.g."your_shader_dir/test_type2"
		//_s( "// shader("<<liquidShaderName<<","<<", ...)" );//e.g."lambert1", or "liquidSurface1", NOTE: it is liquidShader, not maya shader.

		_S( ei_shader(liquidShaderName.c_str()) );

		_s("ei_shader_param_string( \"desc\",\""<<mayaShaderName<<"\");");
		ei_shader_param_string("desc", mayaShaderName.c_str()); // //"opaque"

		//tokenPointerArray only store parameters of user-defined shader
		size_t parameterNum =  tokenPointerArray.size() - 1;
		for(size_t i=0; i<parameterNum; ++i)
		{
 			//_s("//- "
 			//	<<const_cast<liqTokenPointer*>(&tokenPointerArray[i])->getDetailedTokenName()<<","//uniform float intensity
 			//	<<tokenPointerArray[i].getDetailType()<<","
 			//	<<"//tokenPointerArray[i].getTokenFloatArray()"<<","
 			//	<<"//[error]tokenPointerArray[i].getTokenString()"<<","
 			//	<<tokenPointerArray[i].getTokenName()<<","//intensity,
 			//	<<tokenPointerArray[i].getParameterType()<<","//rFloat,
 			//	<<tokenPointerArray[i].getRiDeclare()<<","//uniform float,
 			//	);
// 			_s("// "<<tokenPointerArray[i].getTokenName());

			liqTokenPointer* vp = const_cast< liqTokenPointer* >( &tokenPointerArray[i] );
			switch( tokenPointerArray[i].getParameterType() )
			{
			case rFloat:
				{
					const liqFloat *v = vp->getTokenFloatArray();
					_s("ei_shader_param_scalar(\""<<vp->getTokenName()<<"\"," <<v[0]<<");");
					ei_shader_param_scalar( vp->getTokenName().c_str(), v[0] );
				}
				break;
			case rPoint: case rVector: case rNormal: case rColor:
				{
					const liqFloat *v = vp->getTokenFloatArray();
					_s("ei_shader_param_vector(\""<<vp->getTokenName()<<"\"," <<v[0]<<","<<v[1]<<","<<v[2]<<");");
					ei_shader_param_vector( vp->getTokenName().c_str(), v[0] ,v[1], v[2] );
				}
				break;
			case rString: case rShader:
				{
					const std::string &v = vp->getTokenString();
					_s("ei_shader_param_string(\""<<vp->getTokenName()<<"\"," <<v<<");");
					ei_shader_param_string( vp->getTokenName().c_str(), v.c_str() );
				}
				break; 
			case rHpoint:
				{
					const liqFloat *v = vp->getTokenFloatArray();
					_s("ei_shader_param_vector4(\""<<vp->getTokenName()<<"\"," <<v[0]<<","<<v[1]<<","<<v[2]<<","<<v[3]<<");");
					ei_shader_param_vector4( vp->getTokenName().c_str(), v[0] ,v[1], v[2], v[3] );
				}
				break;
			case rMatrix:
				{
					const liqFloat *v = vp->getTokenFloatArray();
					_s("//matrix:"
						<<v[0]<<","<<v[1]<<","<<v[2]<<","<<v[3]
						<<v[4]<<","<<v[5]<<","<<v[6]<<","<<v[7]
						<<v[8]<<","<<v[9]<<","<<v[10]<<","<<v[11]
						<<v[12]<<","<<v[13]<<","<<v[14]<<","<<v[15]
					);
				}
				;break;
			default :
				assert(0);
			}

		}//for
		_S( ei_end_shader() );


	}
void er_maketexture(const std::string &source_image_dir, 
					const std::string &source_image_name, 
					const std::string &source_image_ext)
{
	char	tmp[ EI_MAX_FILE_NAME_LEN ];
	ei_get_current_directory(tmp);
	std::string cur_dir(tmp);
	cur_dir = boost::replace_all_copy( cur_dir, "\\", "/" );

	char	output_filename[ EI_MAX_FILE_NAME_LEN ];



	ei_context();
	ei_verbose( 6 );
	ei_link( "eiIMG" );
	ei_link( "eiSHADER" );
	ei_link( "eiSHADER_maya" );

	//############################### option #;
	ei_options("perspShape_option");
	ei_contrast(0.05);
	ei_samples(0,2);
	ei_filter(4,3);
	//transform motion=0, deform motion=0;
	ei_motion(0);
	ei_trace_depth(4,4,4,4,4,4);
	ei_displace(0);
	ei_face(3);
	ei_end_options();
	// maya settings: focal=35, aperture = 46.8, aspect=1.33333;
	//Depth of Field on camera "|persp|perspShape" is turned off in Maya;

	//############################### camera #;
	ei_camera("|persp|perspShape_object");
	//beauty channel;
	ei_output( (cur_dir+"/er_maketexture_output.bmp").c_str(), "bmp",1);
	printf("rendering result:%s\n",(cur_dir+"/er_maketexture_output.bmp").c_str());
	//mode=rgb;
	ei_output_variable("color",11);
	ei_end_output();
	// AOV;
	// AOV end;
	ei_focal(35);
	ei_aperture(36);
	ei_aspect(1.33333);
	ei_resolution(800,600);
	ei_clip(0.1,10000);
	ei_end_camera();
	//----------------------------------;
	ei_instance("|persp|perspShape");
	ei_element("|persp|perspShape_object");
	ei_transform(0.999945,0,-0.0104718,0,   -0.0104706,0.015038,-0.999832,0,   0.000157475,0.999887,0.0150372,0,   -2.6803,10.6466,-0.386112,1);
	ei_end_instance();
	//;
	ei_shader("maya_place2dTexture", "place2dTexture1");
	ei_shader_param_int("liq_UserDefinedU",0);
	ei_shader_param_int("liq_UserDefinedV",0);
	ei_shader_param_vector("i_uvCoord",0,0,0);
	ei_shader_param_scalar("i_coverageU", 1);
	ei_shader_param_scalar("i_coverageV", 1);
	ei_shader_param_bool("i_mirrorU", 0);
	ei_shader_param_bool("i_mirrorV", 0);
	ei_shader_param_scalar("i_noiseU", 0);
	ei_shader_param_scalar("i_noiseV", 0);
	ei_shader_param_scalar("i_offsetU", 0);
	ei_shader_param_scalar("i_offsetV", 0);
	ei_shader_param_scalar("i_repeatU", 1);
	ei_shader_param_scalar("i_repeatV", 1);
	ei_shader_param_scalar("i_rotateFrame", 0);
	ei_shader_param_scalar("i_rotateUV", 0);
	ei_shader_param_bool("i_stagger", 0);
	ei_shader_param_scalar("i_translateFrameU", 0);
	ei_shader_param_scalar("i_translateFrameV", 0);
	ei_shader_param_bool("i_wrapU", 1);
	ei_shader_param_bool("i_wrapV", 1);
	ei_shader_param_vector("o_outUV", 0, 0, 0);
	ei_end_shader();

	//make texture
	const std::string src_image_fullpath(source_image_dir+"/"+source_image_name);
	std::string des_image_fullpath(cur_dir+"/"+source_image_name);

	if(source_image_ext != "tex")
	{
		des_image_fullpath += ".tex";
		ei_make_texture( 
			src_image_fullpath.c_str(),
			des_image_fullpath.c_str(),
			EI_TEX_WRAP_CLAMP, EI_TEX_WRAP_CLAMP, EI_FILTER_BOX, 1.0f, 1.0f);
	}
	printf("des image:%s\n", des_image_fullpath.c_str());

	ei_texture( src_image_fullpath.c_str() );
	ei_file_texture( des_image_fullpath.c_str(), eiFALSE);
	ei_end_texture();


	ei_shader("maya_file", "file1");
	ei_shader_param_scalar("i_alphaGain", 1);
	ei_shader_param_bool("i_alphaIsLuminance", 0);
	ei_shader_param_scalar("i_alphaOffset", 0);
	ei_shader_param_vector("i_colorGain", 1, 1, 1);
	ei_shader_param_vector("i_colorOffset", 0, 0, 0);
	ei_shader_param_vector("i_defaultColor", 0.5, 0.5, 0.5);
	ei_shader_link_param("i_uvCoord", "place2dTexture1", "o_outUV");
	ei_shader_param_texture("i_fileTextureName", src_image_fullpath.c_str() );
	ei_shader_param_index("i_filterType", 3);
	ei_shader_param_scalar("i_filter", 1);
	ei_shader_param_scalar("i_filterOffset", 0);
	ei_shader_param_bool("i_invert", 0);
	ei_shader_param_bool("i_fileHasAlpha", 0);
	ei_shader_param_scalar("o_outAlpha", 1);
	ei_shader_param_vector("o_outColor", 0, 0, 0);
	ei_shader_param_vector("o_outTransparency", 0, 0, 0);
	ei_end_shader();

	ei_shader("maya_phong", "phong1");
	ei_shader_param_vector("i_ambientColor", 0, 0, 0);
	ei_shader_link_param("i_color", "file1", "o_outColor");
	ei_shader_param_vector("i_transparency", 0, 0, 0);
	ei_shader_param_vector("i_incandescence", 0, 0, 0);
	ei_shader_param_int("liq_UserDefinedNormal", 0);
	ei_shader_param_vector("i_normalCamera", 1, 1, 1);
	ei_shader_param_scalar("i_diffuse", 0.8);
	ei_shader_param_scalar("i_translucence", 0);
	ei_shader_param_scalar("i_translucenceDepth", 0.5);
	ei_shader_param_scalar("i_translucenceFocus", 0.5);
	ei_shader_param_scalar("i_cosinePower", 20);
	ei_shader_param_vector("i_specularColor", 0.5, 0.5, 0.5);
	ei_shader_param_scalar("i_reflectivity", 0.5);
	ei_shader_param_vector("i_reflectedColor", 0, 0, 0);
	ei_shader_param_index("i_matteOpacityMode", 2);
	ei_shader_param_scalar("i_matteOpacity", 1);
	ei_shader_param_index("i_reflectionLimit", 1);
	ei_shader_param_vector("o_outColor", 0, 0, 0);
	ei_shader_param_vector("o_outTransparency", 0, 0, 0);
	ei_end_shader();

	ei_material("phong1SG");
	ei_surface_shader("phong1");
	ei_end_material();

	//worldPrologue;

	// Renderer::exportLight("_pointLight1_pointLightShape1");;

	// Renderer::exportPointLight();
	ei_shader("pointlight", "|pointLight1|pointLightShape1_shader");
	ei_shader_param_vector("lightcolor",1,1,1);
	ei_shader_param_scalar("intensity",1);
	ei_end_shader();
	ei_light("|pointLight1|pointLightShape1_object");
	ei_light_shader("|pointLight1|pointLightShape1_shader" );
	ei_origin(0,0,0);
	ei_end_light();
	ei_instance("|pointLight1|pointLightShape1");
	ei_element("|pointLight1|pointLightShape1_object");
	ei_transform(1,0,0,0,   0,1,0,0,   0,0,1,0,   0,5.23026,0,1);
	{;
	eiInt tag = 0;
	ei_declare("|pPlane2_lightgroup",0,4, &tag);
	};
	ei_end_instance();

	// Renderer::exportLight("_pointLight2_pointLightShape2");;

	// Renderer::exportPointLight();
	ei_shader("pointlight", "|pointLight2|pointLightShape2_shader");
	ei_shader_param_vector("lightcolor",1,1,1);
	ei_shader_param_scalar("intensity",1);
	ei_end_shader();
	ei_light("|pointLight2|pointLightShape2_object");
	ei_light_shader("|pointLight2|pointLightShape2_shader" );
	ei_origin(0,0,0);
	ei_end_light();
	ei_instance("|pointLight2|pointLightShape2");
	ei_element("|pointLight2|pointLightShape2_object");
	ei_transform(1,0,0,0,   0,1,0,0,   0,0,1,0,   -5.18346,1.22941,0,1);
	{;
	eiInt tag = 0;
	ei_declare("|pPlane2_lightgroup",0,4, &tag);
	};
	ei_end_instance();

	// Renderer::exportOneGeometry_Mesh(|pPlane2|pPlaneShape11,0,0);

	//############################### mesh #;
	//shape full path name=|pPlane2|pPlaneShape11;
	ei_object("poly","|pPlane2|pPlaneShape11");
	{;
	eiTag tag;
	//### vertex positions, fnMesh.numVertices()=9;
	tag = ei_tab(EI_TYPE_VECTOR, 1, 1024);
	ei_pos_list(tag);
	ei_tab_add_vector(-0.5,-1.11022e-016,0.5);
	ei_tab_add_vector(0,-1.11022e-016,0.5);
	ei_tab_add_vector(0.5,-1.11022e-016,0.5);
	ei_tab_add_vector(-0.5,0,0);
	ei_tab_add_vector(0,0,0);
	ei_tab_add_vector(0.5,0,0);
	ei_tab_add_vector(-0.5,1.11022e-016,-0.5);
	ei_tab_add_vector(0,1.11022e-016,-0.5);
	ei_tab_add_vector(0.5,1.11022e-016,-0.5);
	ei_end_tab();
	//### N ###;
	tag = eiNULL_TAG;
	ei_declare("N",2,6, &tag);
	tag = ei_tab(EI_TYPE_VECTOR, 1, 1024);
	ei_variable("N", &tag);
	ei_tab_add_vector(0,1,2.22045e-016);
	ei_tab_add_vector(0,1,2.22045e-016);
	ei_tab_add_vector(0,1,2.22045e-016);
	ei_tab_add_vector(0,1,2.22045e-016);
	ei_tab_add_vector(0,1,2.22045e-016);
	ei_tab_add_vector(0,1,2.22045e-016);
	ei_tab_add_vector(0,1,2.22045e-016);
	ei_tab_add_vector(0,1,2.22045e-016);
	ei_tab_add_vector(0,1,2.22045e-016);
	ei_end_tab();
	//### N ### end;
	//### UV(map1), size=9;
	tag = eiNULL_TAG;
	ei_declare("uv",2,6, &tag);
	tag = ei_tab(EI_TYPE_VECTOR2, 1, 1024);
	ei_variable("uv", &tag);
	ei_tab_add_vector2(0,0);
	ei_tab_add_vector2(0.5,0);
	ei_tab_add_vector2(1,0);
	ei_tab_add_vector2(0,0.5);
	ei_tab_add_vector2(0.5,0.5);
	ei_tab_add_vector2(1,0.5);
	ei_tab_add_vector2(0,1);
	ei_tab_add_vector2(0.5,1);
	ei_tab_add_vector2(1,1);
	ei_end_tab();
	//### triangles, size=4;
	tag = ei_tab(EI_TYPE_INDEX, 1, 1024);
	ei_triangle_list(tag);
	ei_tab_add_index(0);
	ei_tab_add_index(1);
	ei_tab_add_index(3);
	ei_tab_add_index(3);
	ei_tab_add_index(1);
	ei_tab_add_index(4);
	ei_tab_add_index(1);
	ei_tab_add_index(2);
	ei_tab_add_index(4);
	ei_tab_add_index(4);
	ei_tab_add_index(2);
	ei_tab_add_index(5);
	ei_tab_add_index(3);
	ei_tab_add_index(4);
	ei_tab_add_index(6);
	ei_tab_add_index(6);
	ei_tab_add_index(4);
	ei_tab_add_index(7);
	ei_tab_add_index(4);
	ei_tab_add_index(5);
	ei_tab_add_index(7);
	ei_tab_add_index(7);
	ei_tab_add_index(5);
	ei_tab_add_index(8);
	ei_end_tab();
	}//|pPlane2|pPlaneShape11;
	ei_end_object();
	//--------------------------;
	//ribNode->name=|pPlane2|pPlaneShape11;
	//ribNode's transform node=|pPlane2;
	//ribNode->object(0)->getDataPtr()->getFullPathName()=|pPlane2|pPlaneShape11;
	ei_instance("|pPlane2");
	ei_mtl("phong1SG");
	//shape name=|pPlane2|pPlaneShape11;
	//shape full path name=|pPlane2|pPlaneShape11;
	ei_element("|pPlane2|pPlaneShape11");
	ei_transform(9.6133,0,0,0,   0,1,0,0,   0,0,8.02763,0,   -2.76716,0,-0.566055,1);
	//ribNode->doDef=205, ribNode->doMotion=205;
	ei_motion(1);
	{//light group(light-link group);
	const char *tag = NULL;
	ei_declare("lightgroup",0,1, &tag);
	tag = ei_token("|pPlane2_lightgroup");;
	ei_variable("lightgroup", &tag);
	};
	ei_end_instance();
	//;

	//Renderer::worldEpilogue();
	ei_instgroup("perspShape");
	//camera;
	ei_add_instance("|persp|perspShape");
	//light(s);
	ei_add_instance("|pointLight1|pointLightShape1");
	ei_add_instance("|pointLight2|pointLightShape2");
	//mesh(s);
	ei_add_instance("|pPlane2");
	ei_end_instgroup( );
	//ei_set_connection( &(MayaConnection::getInstance()->connection.base );
	ei_render("perspShape", "|persp|perspShape", "perspShape_option");
	ei_end_context();

}