openscenegraph in ActiveX by ACTIVEQT
[Email protected]
Abstract. Qt ' s ActiveX and COM support allows QT for Windows developers to access and use ActiveX controls and COM objects provided By any ActiveX server in their Qt applications. Make their QT application available as COM servers, with any number of Qt objects and widgets as COM objects and ActiveX c Ontrols. Make OpenSceneGraph to ActiveX controls and then you can use it on other place, like IE.
Key Words. OpenSceneGraph, ActiveX, COM, ACTIVEQT
1.Introduction
ActiveX is an open integration platform that provides developers, users, and web manufacturers with a quick and easy way to create program integration and content across the Internet and intranet. With Acitvex, you can easily insert multimedia effects, interactive objects, and complex programs into your Web pages. The ActiveX controls you write can run on different programs, such as Internet Explorer, Visual Basic, Mfc-and atl-based containters, and so on.
This article attempts to use Qt's ACTIVEQT module to encapsulate OpenSceneGraph as an ActiveX control and to display a three-dimensional model in Internet Explorer.
2.ACTIVEQT
Accustomed to use the QT package of objects, with comfortable. QT's Windows commercial and open source versions all provide the ACTIVEQT framework, which allows us to use ActiveX controls in Qt, and also to develop Qt-based ActiveX controls. The ACTIVEQT contains two components Qaxcontainter and qaxserver:
V Qaxcontainer allows us to use COM objects, like COM objects in Excel, to read and write to Excel;
V Qaxserver can export our written QT control as a COM object or an ActiveX control.
It's much easier to use ACTIVEQT to write ActiveX controls.
3.OpenSceneGraph
OpenSceneGraph is the OpenGL object-oriented encapsulation, using OpenSceneGraph can easily handle three-dimensional scene, can be used for three-dimensional visualization, simulation and other fields. Because it is also pure C + + development, it produces the idea of writing openscenegraph into an ActiveX control so that you can manipulate the three-dimensional scene on the web.
4.Example
First create a ACTIVEQT server project in Visual Studio, as shown in:
Next use the OSGQT module to use OpenSceneGraph in Qt, just add an initialization function, the code looks like this:
void Osgactivex::init () {Osgqt::initqtwindowingsystem (); Myrootnode = new OSG::P ositionattitudetransform (); Myrootnode->addchild (Osgdb::readnodefile ("D:/test.stl")); Myviewer = new Osgviewer::viewer (); Myviewer->addeventhandler (New Osgga::statesetmanipulator (Myviewer->getcamera ()->getOrCreateStateSet ()) ); Myviewer->addeventhandler (New Osgviewer::statshandler ()); Myviewer->setcameramanipulator (New Osgga::trackballmanipulator ()); Myviewer->setscenedata (Myrootnode); Osgqt::setviewer (Myviewer); Myosgwidget = new Osgqt::glwidget (this); Mygraphicscontext = new OSGQT::GRAPHICSWINDOWQT (myosgwidget); Myviewer->getcamera ()->setviewport (0, 0, myosgwidget->width (), Myosgwidget->height ()); Myviewer->getcamera ()->setprojectionmatrixasperspective (30.0f, static_cast<double> (myOsgWidget-> Width ())/static_cast<double> (Myosgwidget->height ()), 1.0f, 10000.0f); Myviewer->getcamera ()->setgraphicscontext(Mygraphicscontext); Setcentralwidget (myosgwidget);}
After compiling an ActiveX control, write an HTML file to test the resulting results, where the main contents of the HTML file are as follows:
<object id= "Osgactivex" classid= "Clsid:450b2b35-9ac6-4fcd-a883-2acf0fa19a16" > [Object Not available! Did you forget to build and register the server?] </object>
Where ClassID is the GUID used to define the registration with the Qaxfactory_default macro. The results of the program run are as follows:
5.Conclusion
Using ACTIVEQT to encapsulate OpenSceneGraph as an ActiveX control, such a control can be used in multiple programs, such as Ie,visual Basic, and so on.
After a good understanding of ACTIVEQT, OSG ActiveX controls can be extended to have a more powerful three-dimensional interactive function.
6.References
1. Qt ' s ActiveX Framework
2. Https://zh.wikipedia.org/wiki/ActiveX
PDF version:openscenegraph in ActiveX by ACTIVEQT
OpenSceneGraph in ActiveX by ACTIVEQT