Example #1
0
void Noun::setWorldFrame( const Matrix33 & frame )
{
	m_WorldFrame = frame;
	Matrix33 localFrame( frame );

	BaseNode * pBaseNode = parent();
	while( pBaseNode != NULL )
	{
		NodeTransform * pNode = WidgetCast<NodeTransform>( pBaseNode );
		if ( pNode != NULL )
			localFrame = pNode->frame() * localFrame;

		pBaseNode = pBaseNode->parent();
	}

	setFrame( localFrame );
}
Example #2
0
void Noun::setWorldPosition( const Vector3 & position )
{
	// convert the world position into a local position by enumerating all parent nodes
	m_WorldPosition = position;
	Vector3 localPosition( position );

	BaseNode * pBaseNode = parent();
	while( pBaseNode != NULL )
	{
		NodeTransform * pNode = WidgetCast<NodeTransform>( pBaseNode );
		if ( pNode != NULL )
			localPosition = pNode->frame() * (localPosition - pNode->position());

		pBaseNode = pBaseNode->parent();
	}

	setPosition( localPosition );
}
Example #3
0
void Noun::onAttached()
{
	// call the base class
	NodeTransform::onAttached();
	// clear the detach flag, just in case a detached noun is re-attached
	m_bDetach = false;
	// get our zone
	BaseNode * pParent = parent();
	m_pZone = NULL;
	while( pParent != NULL && m_pZone == NULL )
	{
		m_pZone = WidgetCast<NodeZone>( pParent );
		pParent = pParent->parent();
	}

	// inform our zone that we are attached
	if ( m_pZone != NULL )
		m_pZone->onAttachNoun( this );
}
Example #4
0
void CSceneRender::OnCameraZoomextents() 
{
	ScenePort * pDoc = dynamic_cast<ScenePort *>( GetDocument() );
	ASSERT( pDoc );

	m_TargetPosition = Vector3(0,0,0);
	m_TargetDistance = 50.0f;

	if ( pDoc->m_pSelectedNode )
	{
		// find the world position of the selected node
		BaseNode * pBaseNode = pDoc->m_pSelectedNode->getCachedNode();
		if ( pBaseNode )
		{
			// get the hull of the selected node
			BoxHull hull( pBaseNode->hull() );

			Vector3 position( 0.0f );
			while( pBaseNode )
			{
				if ( dynamic_cast< NodeTransform * >( pBaseNode ) )
				{
					NodeTransform * pNode = (NodeTransform *)pBaseNode;
					position = (~pNode->frame() * position) + pNode->position();
				}
				pBaseNode = pBaseNode->parent();
			}

			m_TargetPosition = position;
			m_TargetDistance = hull.radius() * 2.0f;
		}
	}

	// redraw the scene
	OnUpdate(this,true,NULL);
	OnDraw(NULL);
}
Example #5
0
void WindowButton::onButtonUp()
{
	m_ButtonDown = false;
	m_Flags &= ~DEPRESSED;

	// play select sound
	selectSound();
	// post message to listeners
	postMessage( WB_BUTTONUP, StringHash( name() ), 0 );

	// abort any ButtonPopup parents
	BaseNode * pParent = parent();
	while( pParent != NULL )
	{
		ButtonPopup * pPopup = WidgetCast<ButtonPopup>( pParent );
		if ( pPopup != NULL )
		{
			pPopup->onButtonAbort();
			break;
		}
		// next parent object
		pParent = pParent->parent();
	}
}