AutoParamDataSource::getWorldMatrix bug? [nope]

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
guts
Gnoblar
Posts: 24
Joined: Thu Oct 28, 2004 3:18 pm

AutoParamDataSource::getWorldMatrix bug? [nope]

Post by guts »

not sure about that, but shouldn't:

Code: Select all

const Matrix4& AutoParamDataSource::getWorldMatrix(void) const
    {
        if (mWorldMatrixDirty)
        {
            mCurrentRenderable->getWorldTransforms(mWorldMatrix);
            mWorldMatrixCount = mCurrentRenderable->getNumWorldTransforms();
            mWorldMatrixDirty = false;
        }
        return mWorldMatrix[0];
    }
be

Code: Select all

const Matrix4& AutoParamDataSource::getWorldMatrix(void) const
    {
        if (mWorldMatrixDirty)
        {
            mCurrentRenderable->getWorldTransforms(mWorldMatrix);
            mWorldMatrixCount = mCurrentRenderable->getNumWorldTransforms();
            mWorldMatrixDirty = false;
        }
        return ((mWorldMatrixCount > 1) ? Matrix4::IDENTITY : mWorldMatrix[0]);
    }
?

User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19265
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post by sinbad »

No, this method always gets you the first world matrix. If there are many, you can still get the first but if you want the many you should be using the multi-version.

guts
Gnoblar
Posts: 24
Joined: Thu Oct 28, 2004 3:18 pm

Post by guts »

but the hardware skinning vertex program uses the world/view/projection matrix to transform bones. and in the case of hardware skinning the first world matrix represents the transformation of the first bone doesn't it? so if the first bone's transform matrix isn't IDENTITY all bones are transformed wrong. they already have there "right" transformation through Entity::CacheBoneMatrices (where the get multiplied with the world matrix of the node they are attached to...)
am I wrong?!

User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19265
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post by sinbad »

In hardware skinning the bone matrices do already include the world matrix, yes. In this case the first world matrix is the first bone, and is populated with it. It almost certainly won't be IDENTITY since even if the entity is untransformed, the first bone may be. You seem to think there's a 2-stage transformation, once of worldmatrices[0] and once by the hardware skinning program using the bones. There isn't - the bones do the complete and only transform. That's why worldmatrices[0] is shared between being the 'normal' world matrix for unanimated entities, and the first bone for animated entities.

Note that for software skinning the Entity forces the return of Matrix4::IDENTITY for world matrix since no hardware transform is done. So the code is correct.

guts
Gnoblar
Posts: 24
Joined: Thu Oct 28, 2004 3:18 pm

Post by guts »

I'm sorry! I just noticed that my auto parameter i populated the vertex program with, wasn't the view/projection matrix, but the model/view/protection matrix ... that's why i got this wrong behaviour ...

Post Reply