How to: Apply texture to each face of a shell (HPS)

Following sample code apply texture to separate faces of a shell.
You can copy/paste sample to hps_mfc_sandbox.

Screenshot:

Sample Code:

    SegmentKey modelKey = GetCanvas().GetFrontView().GetAttachedModel().GetSegmentKey();
	PortfolioKey portfolio = GetCanvas().GetFrontView().GetPortfolioKey();

    //  Import Jpeg file and setup texture

    HPS::Image::ImportOptionsKit iok;
    iok.SetFormat(HPS::Image::Format::Jpeg);

    //! [image_glyphs]
    // import the image into the database
	UTF8 filename = "D:/hmf_master/wood.jpg";
    HPS::ImageKit myImageKit = HPS::Image::File::Import(filename, iok);

    // define the image in a portfolio
    HPS::ImageDefinition patternImageDef = portfolio.DefineImage("wood_pattern", myImageKit);


    // Define texture
	TextureOptionsKit texture_options; //    = TextureOptionsKit::GetDefault();
	texture_options.SetModulation(true).SetInterpolationFilter(Material::Texture::Interpolation::None);
	portfolio.DefineTexture("my_texture", patternImageDef, texture_options);


    
    // Insert shell with 3 faces	

    
    Point points[8] = { Point(0, 0, 0),
				   Point(2, 0, 0),
				   Point(2, 2, 0),
				   Point(0, 2, 0),
					Point(4, 2, 0),
				   Point(4, 0, 0),
				   Point(6, 2, 0),
				   Point(6, 0, 0) };

    int faceList[15] = { 4, 0, 1, 2, 3, 
                         4, 1, 5, 4, 2,
                         4, 5, 7, 6, 4};
	HPS::ShellKey myShellKey = modelKey.InsertShell(8, points, 15, faceList);





    // Setup texture settings 
	MaterialKitArray materialKitArray(3);
    //face1
	materialKitArray[0].SetDiffuseColor(RGBColor::White());
	materialKitArray[0].SetDiffuseTexture("my_texture"); // this material is now a texture
    //face2
	materialKitArray[1].SetDiffuseColor(HPS::RGBAColor(1, 0, 0, 1));
    //face3
	materialKitArray[2].SetDiffuseColor(RGBColor::White());
	materialKitArray[2].SetDiffuseTexture("my_texture"); // this material is now a texture

	HPS::MaterialPaletteDefinition mpd = portfolio.DefineMaterialPalette("ManualHighlight", materialKitArray);


    modelKey.SetMaterialPalette("ManualHighlight");


    // Apply texture to specific face
    // 
	//! [subentity_materials]
	HPS::SizeTArray faceIndices(3);
	faceIndices[0] = 0;
	faceIndices[1] = 1;
	faceIndices[2] = 2;

	HPS::FloatArray materialIndices(3);
	materialIndices[0] = 0;
	materialIndices[1] = 1;
	materialIndices[2] = 2;

	myShellKey.SetFaceIndexColorsByList(faceIndices, materialIndices);

    GetCanvas().UpdateWithNotifier().Wait();