In HOOPS Native Platform, interactivity is made available through operators. Operators are special classes which perform a function on the scene graph, usually by manipulating the camera to achieve an effect such as rotation, zoom, or pan. Activating one of the predefined operators is as simple as instantiating it and adding it to the OperatorControl. For this case we’ll activate the orbit and zoom operators:

view.GetOperatorControl().Push(new HPS::OrbitOperator(MouseButtons::ButtonLeft()));
view.GetOperatorControl().Push(new HPS::ZoomOperator(MouseButtons::ButtonMiddle()));

You’ll notice that these functions are called on a View object. Every View has an associated OperatorControl, which is a stack of operators (hence the “Push” function). When an event is received by the HOOPS Visualize event subsystem, that event is handed off the first operator on its stack. If the event is not consumed, it is passed to the next operator on the stack.

We’re using an orbit operator to rotate the model, and a zoom operator to zoom in and out. In this case, the operators are controlled using different mouse buttons, so their order in the stack is not important. To get rid of an operator, simply pop it off the stack using OperatorControl.Pop().

There are many predefined operators which implement the most common 3D graphics operations. You can even create your own operators if you require specialized functionality. To read more about operators, see the HOOPS Visualize Programming Guide articles about standard and custom operators.

On-screen text and key handlers

If you’ve run the program, you will have noticed there’s a message “Press any key to exit”. This requirement exposes one of the limitations of the StandAloneWindow - namely, it’s not designed for an interactive experience. While extremely simple, this type of window has no event loop and lacks other critical functions for a normal application. Therefore, we set up our own loop to capture a keypress to end the program (this step is not necessary when using an ApplicationWindow).

	KeyHandler kh;
	windowKey.GetEventDispatcher().Subscribe(kh, HPS::Object::ClassID<HPS::KeyboardEvent>());

	while (!kh._stopped)

However, getting text on the screen is easy regardless of window type. In our program, you’ll see this code:

	// setup on-screen instructions
	SegmentKey textSegment = modelKey.Subsegment();
	textSegment.InsertText(Point(0.95f, 0.70f, 0), "Left click and drag to rotate model\nDrag middle mouse button to zoom\nPress any key to exit");
	textSegment.GetMaterialMappingControl().SetTextColor(RGBAColor(1, 0, 0));

This code creates a special segment under the model segment using modelKey.Subsegment(). Normally, a child segment will inherit any settings from its parent, and this includes the camera used to view the geometry in that segment. However, in this case, we want to override the parent’s camera with an orthographic projection so that the text does not rotate as the model rotates. This is done by calling SetProjection on the segment’s CameraControl. We also set the text color and the text itself.

Next steps

We hope this short tutorial will familiarize you with the basic concepts behind any HOOPS Native Platform application. There is much more to learn. To read more about how a complete application works, we suggest reading through the Sandbox Walkthrough tutorial. That tutorial explains the MFC Sandbox, which is an MFC application based on an ApplicationWindow.

Once you feel comfortable, read through the Programming Guides in the HPS, HOOPS Exchange, and HOOPS Publish documentation (links are in the sidebar) for in-depth knowledge on the HOOPS APIs.