Will be there a pivot?

Mar 23, 2013 at 11:25 PM
Edited Mar 23, 2013 at 11:27 PM
Ive modified the UpdateLocal method to get a pivot point for the entities.

Its not performance optimated.
But I think it is possible to make a hierarchy with nodes to get a pivot too. But this is easier to setup for me in this way.

How is the normal way to have a pivot. Transform the Entity inside an actor?


modification for getting a pivot for an entity.
void UpdateLocal( float fTime )
{
    // Update the controllers that are attached to this entity.
    for ( auto pController : GetParent().m_Controllers )
        pController->Update( fTime );

    // Load the local space matrix with the rotation and translation components.
    if ( m_bCalcLocal )
    {
        /* old
        Matrix4f scale;
        scale.Scale( m_fScale );
        
        this->m_mLocal.MakeIdentity();
        this->m_mLocal.SetRotation( this->m_mRotation );
        this->m_mLocal.SetTranslation( this->m_vTranslation);
        this->m_mLocal = scale * this->m_mLocal;
        */

        Matrix4f rotation;
        rotation.MakeIdentity();
        rotation.SetRotation( this->m_mRotation );

        Matrix4f translation;
        translation.MakeIdentity();
        translation.SetTranslation( this->m_vTranslation);

        Matrix4f scalation;
        scalation.MakeIdentity();
        scalation.Scale( this->m_fScale );

        Matrix4f pivot;
        pivot.MakeIdentity();
        pivot.SetTranslation( this->m_vPivot);

        this->m_mLocal = rotation * pivot * scalation * translation;
    }
}
Coordinator
Mar 23, 2013 at 11:32 PM
Can you clarify what you mean by pivot? I think from your code you mean that you are doing some sort of an offset? In general, the local translation is applied after the rotation, but you have two options to manage this if you want to have another translation:
  1. You can use a customized controller to do the modifications for you.
  2. You can use another node to provide an offset, then attach this entity to that node.
The latter of the two is actually why there is a node and a body (entity) in each Actor class - so that the entity can be moved 'locally' while the node represents the main portion of the actor that is anchored.
Mar 23, 2013 at 11:38 PM
Yes the pivot is an offset.

Ok i will try to make this with nodes. It was easier to handle this like this way. But i know this needs more performance for general purposes.
Coordinator
Mar 23, 2013 at 11:44 PM
You could of course just use a subclass of Entity3D that implements your specialized update local method. Just subclass it and then override the UpdateLocal method! Then you can use whatever customized logic that you want.
Mar 24, 2013 at 1:14 AM
good idea