Version: HPS 2022
Language: C++
Description:
This sample code shows how to apply Zebra Striping using Channel::EnvironmentTexture
with Parameterization::ReflectionVector
void CHPSView::OnUserCode() { HPS::SegmentKey modelKey = GetCanvas().GetFrontView().GetAttachedModel().GetSegmentKey(); ImageKit imageKit; UTF8 file_in = "zebra.jpg"; Image::ImportOptionsKit importOptionsKit; importOptionsKit.SetFormat(Image::Format::Jpeg); imageKit = Image::File::Import(static_cast<const char*>(file_in), importOptionsKit); PortfolioKeyArray portfolios; PortfolioKey pKey; ImageDefinition imageDefinition; TextureOptionsKit textureOptionsKit; modelKey.GetPortfolioControl().Show(portfolios); pKey = portfolios[0]; imageDefinition = pKey.DefineImage("zebra_texture", imageKit); textureOptionsKit.SetParameterizationSource(Material::Texture::Parameterization::ReflectionVector); pKey.DefineTexture("zebra", imageDefinition, textureOptionsKit); HPS::SegmentKey mySegmentKey = modelKey.Subsegment("geometry"); HPS::CylinderKey cylinderKey = mySegmentKey.InsertCylinder( Point(5, 5, 10), Point(-7, -5, -10), 5, HPS::Cylinder::Capping::Both); HPS::SegmentKey segKey = mySegmentKey; segKey.GetMaterialMappingControl() .SetFaceTexture("zebra", Material::Texture::Channel::EnvironmentTexture); GetCanvas().Update(); }