How-to (HPS) : create a stamp/logo in your scene

Following is sample code on how to create a stamp/logo in your View. This code has been tested in our sample hps_mfc_sandbox.

    GetCanvas().GetWindowKey().GetTransparencyControl().SetDepthPeelingLayers(3);

    HPS::SegmentKey mySegmentKey = GetCanvas().GetFrontView().GetAttachedModel().GetSegmentKey();

	//  Insert a cylinder in the main scene/view
    HPS::CylinderKey cylinderKey = mySegmentKey.Subsegment("cylinder").InsertCylinder(Point(0.5f, 0.5f, 1), // first point
        Point(-0.75f, -0.5f, -1), // second point
        0.55f, // radius
        HPS::Cylinder::Capping::Both); // capping enum


	//  Import visualize-logo.hsf to subwindow segment
	//  Note  visualize-logo.hsf contain a transparent texture 

    HPS::SubwindowKit subwindowKit;
    subwindowKit.SetSubwindow(HPS::Rectangle(0.7f, 1.0f, -1.0f, -0.7f), HPS::Subwindow::Type::Lightweight);

    HPS::Stream::ImportNotifier importNotifier;

    try {
        HPS::Stream::ImportOptionsKit importOptionsKit;
        importOptionsKit.SetSegment(mySegmentKey.Subsegment("subwindow")); // set destination segment

        importNotifier = HPS::Stream::File::Import("C:/Users/simon.phung/Desktop/visualize-logo.hsf", importOptionsKit);

        // the notifier can be used to check the load progress
        float percent_complete;
        importNotifier.Status(percent_complete);

        // pauses this thread until the HSF is finished loading
        importNotifier.Wait();
    }
    catch (HPS::IOException ioe) {
        // handle exception
        throw;
    }



    PointArray pointArray(4);
    pointArray[0] = Point(-4, -1, 0);
    pointArray[1] = Point(4, -1, 0);
    pointArray[2] = Point(4, 1, 0);
    pointArray[3] = Point(-4, 1, 0);

    IntArray faceList(5);
    faceList[0] = 4;
    faceList[1] = 0;
    faceList[2] = 1;
    faceList[3] = 2;
    faceList[4] = 3;

    //! [texture_step5]
    // the vertices_map array corresponds to the vertex indices of the shell
    HPS::SizeTArray vertices_map;
    vertices_map.resize(4);
    vertices_map[0] = 0;
    vertices_map[1] = 1;
    vertices_map[2] = 2;
    vertices_map[3] = 3;

    HPS::FloatArray vparams;
    vparams.resize(8); // for UV coordinates on a quad, see texture coordinates discussion
    vparams[0] = 0;
    vparams[1] = 0; // [0, 0]
    vparams[2] = 1;
    vparams[3] = 0; // [1, 0]
    vparams[4] = 1;
    vparams[5] = 1; // [1, 1]
    vparams[6] = 0;
    vparams[7] = 1; // [0, 1]

    HPS::ShellKit shellKit;
    shellKit.SetPoints(pointArray);
    shellKit.SetFacelist(faceList);
    shellKit.SetVertexParametersByList(vertices_map, vparams, 2);

	// Setup subwindow segment and insert a shell (quad)
	// texture quad to ts3d_logo (defined in hsf file)

    mySegmentKey.Subsegment("subwindow").SetSubwindow(subwindowKit);
    mySegmentKey.Subsegment("subwindow").GetVisibilityControl().SetFaces(true);
    mySegmentKey.Subsegment("subwindow").Subsegment("shell").InsertShell(shellKit);
	mySegmentKey.Subsegment("subwindow").GetDrawingAttributeControl().SetDepthRange(0.0f, 0.1f);
    mySegmentKey.Subsegment("subwindow").Subsegment("shell").GetMaterialMappingControl().SetFaceTexture("ts3d_logo"); // alternatively, use a material palette
    //! [texture_step6]

	// setup camera in subwindow 

    mySegmentKey.Subsegment("subwindow").Subsegment("shell").GetCameraControl()
        .SetUpVector(Vector(0, 1, 0))
        .SetPosition(Point(0, 0, 10))
        .SetTarget(Point(0, 0, 0))
        .SetField(5, 5)
        .SetProjection(HPS::Camera::Projection::Perspective);

File: visualize-logo.hsf
visualize-logo.zip (37.1 KB)

Screenshot: You can see cylinder rendered behind subwindow.