About Store Forum Documentation Contact



Post Reply 
Messed up with matrices
Author Message
kulesz Offline
Member

Post: #1
Messed up with matrices
Hi,

It's a bit late and my head isn't working too well.
I try to draw a particle, which is attached to specific object bone (in example, torch - point is placed in the end of the stick).
I'm calculating the position with:
Code:
// matrix is the hand matrix (the hand position)
void drawParticles(Particles &particles, Matrix & matrix)
{
    SkelPoint* lightPoint;
    if (lightPoint = mesh->skeleton()->findPoint("lightPoint"))
    {
        Matrix a(*lightPoint);
        particles.matrix = a + matrix.pos;
        particles.draw();
    }
}

But the effect looks like on a screen (like the position isn't rotated by the item orientation).
Where did I messed up the matrices? ;-)


Attached File(s) Image(s)
   
(This post was last modified: 11-07-2011 12:18 AM by kulesz.)
11-07-2011 12:17 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #2
RE: Messed up with matrices
Try using:

Code:
if (lightPoint = Players[0].cskel.findPoint("lightPoint"))
{
    particles.matrix = lightPoint->pos;
    particles.draw();
}

The cskel should already be rotated since it's animating with your character. Using mesh()->skeleton() will give you the non-transformed version (i.e. what you see in Model Editor).
(This post was last modified: 11-07-2011 08:22 AM by Driklyn.)
11-07-2011 08:22 AM
Find all posts by this user Quote this message in a reply
kulesz Offline
Member

Post: #3
RE: Messed up with matrices
But the lightPoint is the point in item skeleton, not the player skeleton.
11-07-2011 09:53 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #4
RE: Messed up with matrices
Yeah, good point, didn't think about that..

Here's a code snippet from an old project of mine. This was used to find the barrel direction and position of the gun the player is currently holding.

Code:
if (SkelPoint *point = skeleton->findPoint("barrel")) {
    barrel_dir = point->dir * matrix();
    barrel_pos = point->pos * matrixScaled();
}

skeleton, matrix(), and matrixScaled() belong to the gun (Game::Item). I believe this will help you out..
11-07-2011 08:56 PM
Find all posts by this user Quote this message in a reply
Post Reply