Page 1 of 1

Attitude indicator & Magnometer help?

Posted: Fri Apr 27, 2007 11:11 am
by mooreaa
Hello, I am trying to make an attitude indicator and a magnometer visualization and I'm reallly stuck.

I was orignally gonna just build a magnometer by drawing 2d polys and rotating it, but I can't get the 2d stuff to rotate at all. I'm using m_pVideoDriver->setTransform(irr::video::ETS_WORLD, m_pNode->getRelativeTransformation());
m_pNode->setRotation(rot);
m_pVideoDriver->draw2DPolygon(m_position,45.4f,video::SColor(255,220,220,220),18);

but it must be compeltely wrong because I don't know/have a way to associate the polygon with the node.

I dunno if anyone has any ideas on how to make the visualizations.

Posted: Fri Apr 27, 2007 1:12 pm
by Luben
You'll have to do this

Node->setRotation(...);
Node->updateAbsoluteTransformation();
Driver->setTransform(ETS_WORLD, Node->getAbsoluteTransformation());
Driver->draw();

Posted: Fri Apr 27, 2007 4:21 pm
by vitek
A few things...
  • Aaron, is that you?
  • When you set the world transform, you almost always want the nodes absolute transformation [the one that converts from object space coordinates to world space coordinates]. You can get that with getAbsoluteTransformation().
  • Setting the world transform only applies when rendering 3d objects. When you call draw2DPolygon it sets the driver up for rendering 2d primitives, and it wipes out whatever transforms you may have set.
I posted some code a while back for doing a compass gui element. You might have a look at that code here.

Travis