[osg-users] Matrix xform will scale but not translate

Darick Barnes dbtex352000 at yahoo.com
Sun Nov 15 12:23:08 PST 2009


Hi,

For some reason I cannot translate my hexagon geode made up of a primitiveset of LINE_STRIP 
The scaling works but translation does not.  I am modifying AdapterWidget.cpp --MDI  section of the code so that I can use QT4.  It is from the osgviewerQt example.  I have tried code in Tut07 and other examples but they do not work in this section of AdapterWidget.cpp
	else if (arguments.read("--mdi")) {
		std::cout<<"Using ViewetQT MDI version"<<std::endl;
		/*
		Following problems are found here:
		- miminize causes loaded model to disappear (some problem with Camera matrix? - clampProjectionMatrix is invalid)
		*/
		//Creating the root node
		osg::ref_ptr<osg::Group> root (new osg::Group);
	
		ViewerQT* viewerWindow = new ViewerQT;
		viewerWindow->setCameraManipulator(new     osgGA::TrackballManipulator);
		//viewerWindow->setSceneData(loadedModel.get());
		
		HexTile hex;
		osg::ref_ptr<osg::Geode> workGeode (new osg::Geode());
		int count = 0;
		char buffer[33];
	osg::MatrixTransform* hexScaleTransMAT = new osg::MatrixTransform;

		osg::Matrix hexScaleMatrix;
		osg::Matrix hexTranslateMatrix;
		osg::Matrix transMat;
		hexScaleMatrix = osg::Matrix::scale(0.005f,0.005f,0.05f);
		hexTranslateMatrix= osg::Matrix::translate(110.0f,110.0f,0.0f);
		//hexTranslateMatrix = osg::Matrix::identity();
		transMat = hexTranslateMatrix ;

            //Creates the hexagon node
		workGeode = hex.Draw(50,0.0f,0.0f);
		//itoa (count,buffer,10);
		//workGeode->setName(buffer);

		hexScaleTransMAT->addChild(workGeode.get());
		hexScaleTransMAT->setMatrix(hexScaleMatrix * hexTranslateMatrix);

		root->addChild(hexScaleTransMAT);

		viewerWindow->setSceneData(root);

		//QMainWindow* mw = new QMainWindow();
		QtWindow* mw = new QtWindow();

		QMdiArea* mdiArea = new QMdiArea(mw);
		mw->setCentralWidget(mdiArea);
		mw->setWindowTitle("OpenSceneGraphEditor");
		//FramelessWindowHint creates a borderless window
		QMdiSubWindow *subWindow = mdiArea->addSubWindow(viewerWindow,Qt::FramelessWindowHint);
		//QMdiSubWindow *subWindow = mdiArea->addSubWindow(viewerWindow);
		subWindow->showMaximized();
		subWindow->setWindowTitle("New Window");
		mw->show();
#endif // USE_QT4 

Scaling works but no translation.  In debug, the matrices look good.  I’m sure it is something simple that I am missing 
I am using Osg 2.8.2  Windows XP  SP3 and I am using ViewerQT MDI version in AdapterWidget.cpp
Any help is appreciated 


Cheers,
Darick

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=19672#19672







More information about the osg-users mailing list